초기 커밋.

This commit is contained in:
2026-04-01 20:16:50 +09:00
parent f78d79089f
commit 93394e54ac
59 changed files with 3440 additions and 0 deletions

View File

@@ -0,0 +1,517 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace ssgrestserver
{
abstract class ARequestObject
{
protected string TAG = "DB Connection Abstarct Class";
//private const string SSG_REST_SERVER_REAL = "http://inf.shinsegaetvshopping.com/";
private const string SSG_REST_SERVER_REAL = "http://202.3.21.200/";
private const string SSG_REST_SERVER_REAL_New = "https://m.shinsegaetvshopping.com/";
private const string SSG_REST_SERVER_TEST = "http://sinf-dev.shinsegaetvshopping.com/";
protected List<string> mNeedKeyList = new List<string>();
protected Dictionary<string, JObject> mAccessableDictionary = null;
internal ARequestObject()
{
mRequestParameterKVPairList = new Dictionary<string, string>();
}
/// <summary>
/// 접근할 테이블명
/// </summary>
protected string TABLE_NAME = "";
protected bool mIsSendTypeGet = false;
protected Dictionary<string, string> mRequestParameterKVPairList = null;
protected DataCenter mDataCenter = DataCenter.getInstance();
protected string m채널이름 = "";
protected readonly string[] = { "상품", "경품", "텍스트", "채팅", "상품평", "QNA", "공지", "채팅판", "동영상", "콜데이터", "매진" };
/// <summary>
/// 테스트중
/// </summary>
public bool mIsRealURL = true;
internal static string create(string receiveValue)
{
string returnValue = "";
try
{
//인스턴스에서 쓸 값 초기화.
ARequestObject bufInstance = null;
///요청종류/씬포멧명/적용범위 ?Key=Value&Key=Value...
///방송용/코스피지수?Key=Value&Key=Value... 1타입
//////방송용/9?적용범위=코스피지수&종류=당일 2타입
//URL에서 Request부분(?)과 address부분을 분리
string[] bufURLSplit = receiveValue.Split('?');
//리퀘스트타입은 Get으로 넘어오는 Address데이터의 마지막부분 -> /RequestType
string[] bufRequestArray = bufURLSplit[0].Split('/');
string = bufRequestArray[2];
string = bufRequestArray[3];
///씬에따라 구분.
///사용처는 나중에 User Key로 사용할예정 현재는 그냥 쓰자. 테스트용임
switch ()
{
#region "방송용데이터"
case "새데이터조회":
switch ()
{
case "상품수량":
bufInstance = new ();
break;
case "경품프로모션":
bufInstance = new ();
break;
case "채팅리스트":
bufInstance = new ();
break;
case "채팅답변등록":
bufInstance = new ();
break;
case "방송채택":
bufInstance = new ();
break;
case "방송편성":
bufInstance = new ();
break;
case "상품평조회":
bufInstance = new ();
break;
case "상품QnA":
bufInstance = new QnA();
break;
case "공지CRUD":
bufInstance = new CRUD();
break;
case "콜데이터조회":
bufInstance = new ();
break;
case "방송VVIP":
bufInstance = new VVIP();
break;
case "매진조회":
bufInstance = new ();
break;
default:
returnValue = "알수없는 분류 - " + + "----" + ;
break;
}
break;
#endregion
case "데이터입력":
switch ()
{
case "상품수량":
bufInstance = new ();
break;
case "경품프로모션":
bufInstance = new ();
break;
default:
returnValue = "알수없는 분류 - " + + "----" + ;
break;
}
break;
case "입력데이터조회":
switch ()
{
case "상품수량":
bufInstance = new ();
break;
case "경품프로모션":
bufInstance = new ();
break;
default:
returnValue = "알수없는 분류 - " + + "----" + ;
break;
}
break;
case "자막상황":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
default:
returnValue = "알수없는 분류 - " + + "----" + ;
break;
}
break;
default:
break;
case "텍스트":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "씬이름":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "QNA":
switch ()
{
case "조회":
bufInstance = new QNA();
break;
case "입력":
bufInstance = new QNA();
break;
}
break;
case "공지":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "상품평":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "채팅":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "채팅판":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "동영상":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "콜데이터":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "매진":
switch ()
{
case "조회":
bufInstance = new ();
break;
case "입력":
bufInstance = new ();
break;
}
break;
case "test":
switch ()
{
case "test":
bufInstance = new ();
break;
}
break;
}
bufInstance.mNeedKeyList = new List<string>();
if (bufRequestArray[1].Trim() == "")
{
throw new Exception("잘못된 채널정보");
}
bufInstance.m채널이름 = bufRequestArray[1];
if (bufInstance != null)
{
//URL이 충분히 왔을때만 작업
if (bufURLSplit.Length > 1)
{
bufInstance.mRequestParameterKVPairList = bufInstance.parseParameter(bufURLSplit[1]);
}
//필수키가 있는 리퀘스트에 한해서 체크한다.
string checkString = "";
if (bufInstance is INeedKeyRequest)
{
((INeedKeyRequest)bufInstance).setNeedKeys();
checkString = bufInstance.checkNeedUpdateKey();
}
if (checkString == "")
{
returnValue = bufInstance.startUpdateWork();
}
else
{
returnValue = checkString;
}
}
return returnValue;
}
catch (DuplicateNameException dne)
{
return "같은 종목을 여러번 요청하였습니다. " + dne.ToString();
}
}
protected Dictionary<string, string> parseParameter(string recvParametersInURL)
{
Dictionary<string, string> rtnValue = new Dictionary<string, string>();
string[] bufGetDataArray = recvParametersInURL.Split('&');
foreach (string item in bufGetDataArray)
{
string[] bufKVDataArray = item.Split('=');
rtnValue.Add(bufKVDataArray[0], bufKVDataArray[1]);
}
return rtnValue;
}
protected abstract string startUpdateWork();
protected string httpRequest(string requestURL)
{
string rtnValue = "";
try
{
bool isMasterGoodsInfo = requestURL.Contains("masterGoodsInfo");
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create((mIsRealURL ? SSG_REST_SERVER_REAL : SSG_REST_SERVER_TEST) + requestURL);
if (isMasterGoodsInfo)
{
httpWebRequest = (HttpWebRequest)WebRequest.Create((SSG_REST_SERVER_REAL_New) + requestURL);
}
;
// 인코딩 UTF-8
byte[] sendData = UTF8Encoding.UTF8.GetBytes("");
if (mIsSendTypeGet || isMasterGoodsInfo)
{
httpWebRequest.Method = "GET";
}
else
{
httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = sendData.Length;
Stream requestStream = httpWebRequest.GetRequestStream();
requestStream.Write(sendData, 0, sendData.Length);
requestStream.Close();
}
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("UTF-8"));
rtnValue = streamReader.ReadToEnd();
streamReader.Close();
httpWebResponse.Close();
return rtnValue;
}
catch (Exception ex)
{
return ex.ToString();
}
}
private string checkNeedUpdateKey()
{
foreach (string item in mNeedKeyList)
{
if (!mRequestParameterKVPairList.ContainsKey(item))
{
return "필수키가 없음 - " + item;
}
}
return "";
}
protected void ()
{
Dictionary<string, JObject> bufTargetDictionary = DataCenter.getInstance().getData(DataCenter..);
if (mRequestParameterKVPairList.ContainsKey("보낸사람"))
{
if (mRequestParameterKVPairList["보낸사람"] == "코더")
{
bufTargetDictionary[m채널이름]["코더조회시간"] = DateTime.Now;
}
}
TimeSpan = DateTime.Now - Convert.ToDateTime(bufTargetDictionary[m채널이름]["코더조회시간"]);
if (.TotalSeconds > 3)
{
bufTargetDictionary[m채널이름]["코더"] = "N";
}
else
{
bufTargetDictionary[m채널이름]["코더"] = "Y";
}
bufTargetDictionary[m채널이름]["현재서버시간"] = DateTime.Now;
}
protected void ()
{
if (!DataCenter.getInstance().getData(DataCenter..).ContainsKey(m채널이름))
{
JObject buf코더상태 = new JObject();
foreach (string item in )
{
buf코더상태.Add(item, "N");
}
buf코더상태.Add("코더", "N");
buf코더상태.Add("코더조회시간", new DateTime(1990, 1, 1));
buf코더상태.Add("현재서버시간", DateTime.Now);
DataCenter.getInstance().getData(DataCenter..).Add(m채널이름, buf코더상태);
}
}
}
}