OperateAmountRecordService.cs 948 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Threading;
  2. using MySystem;
  3. using MySystem.OpModels;
  4. public class OperateAmountRecordService
  5. {
  6. public readonly static OperateAmountRecordService Instance = new OperateAmountRecordService();
  7. private OperateAmountRecordService()
  8. {
  9. }
  10. public void Start()
  11. {
  12. Thread th = new Thread(DoWorks);
  13. th.IsBackground = true;
  14. th.Start();
  15. }
  16. private void DoWorks()
  17. {
  18. while (true)
  19. {
  20. string content = RedisDbconn.Instance.RPop<string>("OperateAmountRecordServiceQueue");
  21. if (!string.IsNullOrEmpty(content))
  22. {
  23. WebCMSEntities db = new WebCMSEntities();
  24. Utils.Instance.OperateAmountChange(db,Newtonsoft.Json.JsonConvert.DeserializeObject<OpAmountItem>(content));
  25. db.Dispose();
  26. }
  27. else
  28. {
  29. Thread.Sleep(5000);
  30. }
  31. }
  32. }
  33. }