|
@@ -49,27 +49,27 @@ namespace MySystem
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void StartTest()//启动
|
|
|
+ public void StartSaveToDb()//启动
|
|
|
{
|
|
|
- Thread thread = new Thread(threadStartTest);
|
|
|
+ Thread thread = new Thread(threadStartSaveToDb);
|
|
|
thread.IsBackground = true;
|
|
|
thread.Start();
|
|
|
}
|
|
|
|
|
|
- private void threadStartTest()
|
|
|
+ private void threadStartSaveToDb()
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
- string content = RedisDbconnTest.Instance.RPop<string>("KxsPosDataQueue");
|
|
|
+ string content = RedisDbconn.Instance.RPop<string>("KxsPosDataSaveToDbQueue");
|
|
|
if (!string.IsNullOrEmpty(content))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- DoSomeThing(content);
|
|
|
+ DoSomeThing2(content);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + content + "\n" + ex, "推送机具数据异常");
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + content + "\n" + ex, "保存推送结果");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -101,6 +101,16 @@ namespace MySystem
|
|
|
function.WriteLog("encryptContent:" + encryptContent, "统一推送日志");
|
|
|
string res = PostWebRequest(url, encryptContent, new Dictionary<string, string>());
|
|
|
function.WriteLog("res:" + res + "\n\n\n", "统一推送日志");
|
|
|
+ RedisDbconn.Instance.AddList("KxsPosDataSaveToDbQueue", dataContent + "#cut#" + encryptContent + "#cut#" + dataType + "#cut#" + res);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void DoSomeThing2(string content)
|
|
|
+ {
|
|
|
+ string[] data = content.Split(new string[]{ "#cut#" }, StringSplitOptions.None);
|
|
|
+ string dataContent = data[0];
|
|
|
+ string encryptContent = data[1];
|
|
|
+ string dataType = data[2];
|
|
|
+ string res = data[3];
|
|
|
if(!res.Contains("\"status\""))
|
|
|
{
|
|
|
SaveToDb(dataContent, encryptContent, dataType, res);
|