You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.6 KiB

1 month ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using Operation;
using Sog;
using LitJson;
using SimpleHttpServer;
using MySql.Data.MySqlClient;
using System.IO;
using System.Text;
namespace Operation
{
public class UploadClientError
{
private static int m_seqNum;
public void DoUploadClientError(HttpResponse rsp, HttpRequest request, HttpQueryParams query)
{
TraceLog.Trace("UploadClientError.DoUploadClientError Url {0},param count {1}", request.Url,query.Count);
string content = query.GetValue("content");
TraceLog.Trace("UploadClientError.DoUploadClientError content {0}", content);
//客户端启动上报,记录一下log(Error)就可以了
if(content.Contains("101AppStartReport") == true)
{
TraceLog.Error("UploadClientError.DoUploadClientError 101AppStartReport |{0}", content);
return;
}
string filename = GetFileName();
TraceLog.Trace("UploadClientError.DoUploadClientError filename = {0}", filename);
//string content1 = content.Substring(0, 12);
string path = @"../log/clienterrorlog/";
string path1 = @"../log/clienterrorlogLua/";
if (content.IndexOf("LuaException") == -1)
{
if (Directory.Exists(path)) //确定给定路径是否引用磁盘上现有目录。
{
File.WriteAllText(Path.Combine(path, filename), content);
}
else
{
Directory.CreateDirectory(path); //在指定路径中创建所有目录,除非它们已经存在。
File.WriteAllText(Path.Combine(path, filename), content);
}
// FileStream errorlog = new FileStream(@"E:x_proj/x_proj_svr/log/clienterrorlog/" + filename, FileMode.Create);
// File.WriteAllText(path + filename, content);//把content放到log下clienterrorlog文件夹下的filename文件中
}
else
{
if (Directory.Exists(path1)) //确定给定路径是否引用磁盘上现有目录。
{
File.WriteAllText(Path.Combine(path1, filename), content);
}
else
{
Directory.CreateDirectory(path1); //在指定路径中创建所有目录,除非它们已经存在。
File.WriteAllText(Path.Combine(path1, filename), content);
}
// FileStream errorlog = new FileStream(@"E:x_proj/x_proj_svr/log/clienterrorlog/" + filename, FileMode.Create);
// File.WriteAllText(path + filename, content);//把content放到log下clienterrorlog文件夹下的filename文件中
}
}
public void ProccessRequest(HttpResponse rsp, HttpRequest request, HttpQueryParams query)
{
try
{
DoUploadClientError(rsp,request,query);
}
catch(Exception e)
{
throw e;
}
}
private string GetFileName()
{
m_seqNum++;
string nowtime = DateTime.Now.ToString("u").Replace(' ','_').Replace(':','_');
string filename = nowtime + "_" + m_seqNum.ToString() + ".err";
return filename;
}
}
}