ReceiveTaskService.cs 2.2 KB

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