OperateAmountRecordService.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Threading;
  3. using Library;
  4. using MySystem;
  5. using MySystem.OpModels;
  6. public class OperateAmountRecordService
  7. {
  8. public readonly static OperateAmountRecordService Instance = new OperateAmountRecordService();
  9. private OperateAmountRecordService()
  10. {
  11. }
  12. public void Start()
  13. {
  14. Thread th = new Thread(DoWorks);
  15. th.IsBackground = true;
  16. th.Start();
  17. }
  18. private void DoWorks()
  19. {
  20. while (true)
  21. {
  22. try
  23. {
  24. string content = RedisDbconn.Instance.RPop<string>("OperateAmountRecordServiceQueue");
  25. if (!string.IsNullOrEmpty(content))
  26. {
  27. WebCMSEntities db = new WebCMSEntities();
  28. Utils.Instance.OperateAmountChange(db,Newtonsoft.Json.JsonConvert.DeserializeObject<OpAmountItem>(content));
  29. db.Dispose();
  30. }
  31. else
  32. {
  33. Thread.Sleep(5000);
  34. }
  35. }
  36. catch(Exception ex)
  37. {
  38. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "运营中心额度变更队列异常");
  39. Thread.Sleep(30000);
  40. }
  41. }
  42. }
  43. }