TestHelper.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Threading;
  5. using Library;
  6. using LitJson;
  7. using MySystem;
  8. public class TestHelper
  9. {
  10. public readonly static TestHelper Instance = new TestHelper();
  11. private TestHelper()
  12. { }
  13. public void Start()
  14. {
  15. Thread th = new Thread(DoQueue);
  16. th.IsBackground = true;
  17. th.Start();
  18. }
  19. public void DoWorks()
  20. {
  21. while (true)
  22. {
  23. string content = RedisDbconn.Instance.RPop<string>("LogQueue");
  24. if (!string.IsNullOrEmpty(content))
  25. {
  26. try
  27. {
  28. }
  29. catch (Exception ex)
  30. {
  31. LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + content + "\n" + ex, "SLS日志异常");
  32. }
  33. }
  34. else
  35. {
  36. Thread.Sleep(5000);
  37. }
  38. }
  39. }
  40. public void DoQueue()
  41. {
  42. string check = function.ReadInstance("/chk.txt");
  43. if(!string.IsNullOrEmpty(check))
  44. {
  45. return;
  46. }
  47. function.WritePage("/", "chk.txt", DateTime.Now.ToString());
  48. string[] list = function.ReadInstance("9.txt").Split('\n');
  49. foreach(string sub in list)
  50. {
  51. function.WriteLog(sub);
  52. function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_MACHINE_PRIZE_CONFIG_DIVISION&m=" + sub + "&ids=3");
  53. }
  54. // list = function.ReadInstance("10.txt").Split('\n');
  55. // foreach(string sub in list)
  56. // {
  57. // function.WriteLog(sub);
  58. // // function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=" + data[1] + "&m=" + data[0] + "&ids=60,");
  59. // function.GetWebRequest("https://logic-executor-api.kexiaoshuang.com/noauth/prize/push?n=QUEUE_KXS_MACHINE_PRIZE_CONFIG_DIVISION&m=" + sub);
  60. // }
  61. }
  62. }