214 lines
6.7 KiB
C#
214 lines
6.7 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static ssgrestserver.DataCenter;
|
|
|
|
namespace ssgrestserver
|
|
{
|
|
class DataCenter
|
|
{
|
|
|
|
#region Singleton
|
|
|
|
private volatile static DataCenter mInstance = null;
|
|
|
|
private static object mSingletonLocker = new object();
|
|
|
|
internal enum 관리중인데이터들배열
|
|
{
|
|
최근받은경품정보,
|
|
최근받은상품수량,
|
|
최근코더상태,
|
|
최근받은텍스트,
|
|
씬이름,
|
|
코더상태,
|
|
CRUD데이터,
|
|
상품평,
|
|
채팅,
|
|
QNA,
|
|
공지,
|
|
채팅판,
|
|
동영상,
|
|
콜데이터,
|
|
매진,
|
|
VVIP
|
|
}
|
|
|
|
private readonly Dictionary<관리중인데이터들배열, Dictionary<string, JObject>> m관리중인데이터들 = null;
|
|
|
|
private DataCenter()
|
|
{
|
|
|
|
m관리중인데이터들 = new Dictionary<관리중인데이터들배열, Dictionary<string, JObject>>();
|
|
|
|
foreach (관리중인데이터들배열 item in Enum.GetValues(typeof(관리중인데이터들배열)).Cast<관리중인데이터들배열>().ToArray())
|
|
{
|
|
m관리중인데이터들.Add(item, new Dictionary<string, JObject>());
|
|
}
|
|
}
|
|
|
|
public static DataCenter getInstance()
|
|
{
|
|
lock (mSingletonLocker)
|
|
{
|
|
if (mInstance == null)
|
|
{
|
|
mInstance = new DataCenter();
|
|
}
|
|
}
|
|
|
|
return mInstance;
|
|
}
|
|
#endregion
|
|
|
|
internal int mServerPort = 60001;
|
|
|
|
internal Dictionary<string, JObject> getData(관리중인데이터들배열 recvDataType)
|
|
{
|
|
lock (mSingletonLocker)
|
|
{
|
|
return m관리중인데이터들[recvDataType];
|
|
}
|
|
}
|
|
|
|
public List<Tuple<string, string>> PareURLTupleList = null;
|
|
|
|
public string interpritURL(string recvURL, bool isReverse = false)
|
|
//public string interpritURL(string recvURL)
|
|
{
|
|
|
|
|
|
string rtnValue = "";
|
|
|
|
|
|
if (PareURLTupleList == null)
|
|
{
|
|
/*
|
|
Replace("!", "뚫꽵1").
|
|
Replace("*", "뚫꽵2").
|
|
Replace("'", "뚫꽵3").
|
|
replace("(", "뚫꽵4").
|
|
replace(")", "뚫꽵5").
|
|
Replace(";", "뚫꽵6").
|
|
Replace(":", "뚫꽵7").
|
|
Replace("@", "뚫꽵8").
|
|
Replace("&", "뚫꽵9").
|
|
Replace("=", "뚫꽵10").
|
|
Replace("+", "뚫꽵11").
|
|
Replace("$", "뚫꽵12").
|
|
Replace("/", "뚫꽵13").
|
|
Replace("?", "뚫꽵14").
|
|
Replace("#", "뚫꽵15").
|
|
Replace("[", "뚫꽵16").
|
|
Replace("]", "뚫꽵17") + @"&";
|
|
*/
|
|
|
|
PareURLTupleList = new List<Tuple<string, string>>();
|
|
PareURLTupleList.Add(new Tuple<string, string>("!", "뚫꽵1"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("*", "뚫꽵2"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("'", "뚫꽵3"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("(", "뚫꽵4"));
|
|
PareURLTupleList.Add(new Tuple<string, string>(")", "뚫꽵5"));
|
|
PareURLTupleList.Add(new Tuple<string, string>(";", "뚫꽵6"));
|
|
PareURLTupleList.Add(new Tuple<string, string>(":", "뚫꽵7"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("@", "뚫꽵8"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("&", "뚫꽵9"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("=", "뚫꽵10"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("+", "뚫꽵11"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("$", "뚫꽵12"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("/", "뚫꽵13"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("?", "뚫꽵14"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("#", "뚫꽵15"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("[", "뚫꽵16"));
|
|
PareURLTupleList.Add(new Tuple<string, string>("]", "뚫꽵17"));
|
|
|
|
PareURLTupleList.Reverse();
|
|
}
|
|
|
|
//rtnValue = isReverse ? WebUtility.UrlDecode(recvURL) : recvURL;
|
|
rtnValue = recvURL;
|
|
|
|
foreach (Tuple<string,string> item in PareURLTupleList)
|
|
{
|
|
//if (isReverse)
|
|
//{
|
|
// rtnValue = rtnValue.Replace(item.Item1, item.Item2);
|
|
//}
|
|
//else
|
|
//{
|
|
rtnValue = rtnValue.Replace(item.Item2, item.Item1);
|
|
////}
|
|
|
|
}
|
|
if (isReverse)
|
|
{
|
|
return rtnValue;
|
|
}
|
|
else
|
|
{
|
|
return WebUtility.UrlEncode(rtnValue);
|
|
}
|
|
|
|
}
|
|
|
|
internal enum FILE_STATUS_CODE
|
|
{
|
|
UPLOADING = 0,
|
|
UPDATE_COMPLETED = 1,
|
|
NOTFOUND = 2
|
|
}
|
|
|
|
private object fileManagerLocker = new object();
|
|
|
|
|
|
private Dictionary<string, FileStatus> mFileUpdateManager = new Dictionary<string, FileStatus>();
|
|
|
|
internal void setFileStatus(string fileName, FILE_STATUS_CODE status)
|
|
{
|
|
lock (fileManagerLocker)
|
|
{
|
|
if (!mFileUpdateManager.ContainsKey(fileName))
|
|
{
|
|
FileStatus bufStats = new FileStatus();
|
|
bufStats.fileName = fileName;
|
|
bufStats.status = status;
|
|
bufStats.changedTime = DateTime.Now;
|
|
|
|
mFileUpdateManager.Add(fileName, bufStats);
|
|
}
|
|
else
|
|
{
|
|
mFileUpdateManager[fileName].status = status;
|
|
mFileUpdateManager[fileName].changedTime = DateTime.Now;
|
|
}
|
|
}
|
|
}
|
|
|
|
internal FileStatus getFileStatus(string filename)
|
|
{
|
|
lock (fileManagerLocker)
|
|
{
|
|
if (mFileUpdateManager.ContainsKey(filename))
|
|
{
|
|
return mFileUpdateManager[filename];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
internal class FileStatus
|
|
{
|
|
internal string fileName;
|
|
internal FILE_STATUS_CODE status;
|
|
internal DateTime changedTime;
|
|
}
|
|
}
|