OperateAmountRecordService.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. function.WriteLog(content, "运营中心额度变更测试");
  29. Utils.Instance.OperateAmountChange(db,Newtonsoft.Json.JsonConvert.DeserializeObject<OpAmountItem>(content));
  30. db.Dispose();
  31. }
  32. else
  33. {
  34. Thread.Sleep(5000);
  35. }
  36. }
  37. catch(Exception ex)
  38. {
  39. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "运营中心额度变更队列异常");
  40. Thread.Sleep(30000);
  41. }
  42. }
  43. }
  44. }