SycnActiveRewardService.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.PxcModels;
  5. using Library;
  6. using LitJson;
  7. namespace MySystem
  8. {
  9. public class SycnActiveRewardService
  10. {
  11. public readonly static SycnActiveRewardService Instance = new SycnActiveRewardService();
  12. private SycnActiveRewardService()
  13. { }
  14. public void Start(JobMqMsg jobInfo)
  15. {
  16. string content = "";
  17. try
  18. {
  19. string OrderString = jobInfo.OrderString;
  20. if (OrderString.StartsWith("Sp:") && OrderString.EndsWith(":Sycn"))
  21. {
  22. string TableName = OrderString.Split(':')[1];
  23. string Msg = "";
  24. bool op = true;
  25. while (op)
  26. {
  27. string data = RedisDbconn.Instance.RPop<string>(TableName);
  28. if(!string.IsNullOrEmpty(data))
  29. {
  30. Dictionary<string, string> dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
  31. // ProfitHelper.Instance.StartListenActiveDo(dic);
  32. }
  33. else
  34. {
  35. op = false;
  36. }
  37. }
  38. jobInfo.Status = Msg == "success" ? 1 : 0;
  39. jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
  40. RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "SycnTableDataBack");
  41. }
  42. }
  43. catch (Exception ex)
  44. {
  45. if (!string.IsNullOrEmpty(content))
  46. {
  47. Dictionary<string, string> data = new Dictionary<string, string>();
  48. data.Add("ErrTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  49. data.Add("ErrMsg", ex.ToString());
  50. function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(data), "public_err");
  51. }
  52. else
  53. {
  54. function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "public_service");
  55. }
  56. }
  57. }
  58. }
  59. }