초기 커밋.

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

118
ssgrestserver/Form1.cs Normal file
View File

@@ -0,0 +1,118 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ssgrestserver
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
mLogPath = Application.StartupPath + @"\Log";
mImgPath = Application.StartupPath + @"\Image";
DirectoryInfo di = new DirectoryInfo(mLogPath);
DirectoryInfo di2 = new DirectoryInfo(mImgPath);
if (!di.Exists) di.Create();
if (!di2.Exists) di2.Create();
}
private void Form1_Load(object sender, EventArgs e)
{
button1_Click(null, null);
}
internal string mLogPath = "";
internal string mImgPath = "";
NetManager mNetManager = new NetManager();
public void recvLog(string TAG, string comment)
{
try
{
this.Invoke(new MethodInvoker(() => { updateLog(TAG + "___" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "____" + comment); }));
}
catch (Exception)
{
}
}
int OldFileChecker = 0;
void updateLog(string recvlog)
{
if (lstBoxLog.Items.Count == 50)
{
lstBoxLog.Items.Clear();
}
lstBoxLog.Items.Add(recvlog);
File.AppendAllText(mLogPath + @"\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", recvlog);
if (recvlog.Contains("{\"보낸사람\":\"web\",\"채팅\""))
{
string chatText = recvlog.Substring(recvlog.IndexOf("{"));
chatText = chatText.Substring(0, chatText.Length - 1);
JObject jObject = JObject.Parse(chatText);
jObject.Remove("보낸사람");
jObject.Remove("status");
File.AppendAllText(mLogPath + @"\" + DateTime.Now.ToString("채팅기록_yyyy-MM-dd") + ".txt", jObject.ToString());
}
//날짜가 지난 파일 삭제
OldFileChecker++;
if (OldFileChecker > 100)
{
DirectoryInfo directory = new DirectoryInfo(mLogPath);
DateTime now = DateTime.Now;
foreach (FileInfo file in directory.GetFiles())
{
TimeSpan timeDiff = now - file.LastWriteTime;
if (timeDiff.TotalHours > 170) file.Delete();
}
OldFileChecker = 0;
directory = new DirectoryInfo(mImgPath);
foreach (FileInfo file in directory.GetFiles())
{
TimeSpan timeDiff = now - file.LastWriteTime;
if (timeDiff.TotalHours > 170) file.Delete();
}
}
}
private void button1_Click(object sender, EventArgs e)
{
mNetManager = new NetManager();
mNetManager.start();
}
public string getStartupPath()
{
return Application.StartupPath;
}
}
}