lcl 2 tháng trước cách đây
mục cha
commit
f4c5ff180c
3 tập tin đã thay đổi với 62 bổ sung3 xóa
  1. 5 2
      Controllers/HomeController.cs
  2. 2 1
      Startup.cs
  3. 55 0
      Util/TestHelper.cs

+ 5 - 2
Controllers/HomeController.cs

@@ -215,11 +215,14 @@ namespace MySystem.Controllers
 
         public string push2()
         {
-            List<string> list = new List<string>();
+            // List<string> list = new List<string>();
+            string[] list = function.ReadInstance("9.txt").Split('\n');
             string result = ",";
             foreach(string sub in list)
             {
-                result += function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/push?n=QUEUE_KXS_HAODA_PRIZE_CONFIG_DIVISION&m=" + sub) + ",";
+                function.WriteLog(sub);
+                string[] data = sub.Split('|');
+                result += function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=" + data[1] + "&m=" + data[0] + "&ids=" + data[2]) + ",";
             }
             return result;
         }

+ 2 - 1
Startup.cs

@@ -102,7 +102,8 @@ namespace MySystem
                     pattern: "{controller=Home}/{action=Index}/{Id?}");
             });
 
-            StartHelper.Instance.Start(); //开启线程
+            // StartHelper.Instance.Start(); //开启线程
+            TestHelper.Instance.Start();
         }
         
     }

+ 55 - 0
Util/TestHelper.cs

@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using Library;
+using LitJson;
+using MySystem;
+
+public class TestHelper
+{
+    public readonly static TestHelper Instance = new TestHelper();
+    private TestHelper()
+    { }
+
+    public void Start()
+    {
+        Thread th = new Thread(DoQueue);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    public void DoWorks()
+    {
+        while (true)
+        {
+            string content = RedisDbconn.Instance.RPop<string>("LogQueue");
+            if (!string.IsNullOrEmpty(content))
+            {
+                try
+                {
+                }
+                catch (Exception ex)
+                {
+                    LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + content + "\n" + ex, "SLS日志异常");
+                }
+            }
+            else
+            {
+                Thread.Sleep(5000);
+            }
+        }
+    }
+
+    public void DoQueue()
+    { 
+        string[] list = function.ReadInstance("9.txt").Split('\n');
+        string result = ",";
+        foreach(string sub in list)
+        {
+            function.WriteLog(sub);
+            string[] data = sub.Split('|');
+            result += function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=" + data[1] + "&m=" + data[0] + "&ids=" + data[2]) + ",";
+        }
+    }
+}