1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using Library;
- using LitJson;
- using System.Linq;
- using System.Threading;
- using MySystem.PxcModels;
- using System.Data;
- namespace MySystem
- {
- public class PrizeFlowRecordService
- {
- public readonly static PrizeFlowRecordService Instance = new PrizeFlowRecordService();
- private PrizeFlowRecordService()
- { }
- public void Start()
- {
- Thread th = new Thread(StartDo);
- th.IsBackground = true;
- th.Start();
- }
- public void StartDo()
- {
- while(true)
- {
- try
- {
- string content = RedisDbconn.Instance.RPop<string>("PrizeFlowQueue");
- if (!string.IsNullOrEmpty(content))
- {
- DoSomething(content);
- }
- else
- {
- Thread.Sleep(2000);
- }
- }
- catch(Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "奖励返现流程入库异常");
- Thread.Sleep(600000);
- }
- }
- }
- public void DoSomething(string content)
- {
- PrizeFlowRecord item = Newtonsoft.Json.JsonConvert.DeserializeObject<PrizeFlowRecord>(content);
- WebCMSEntities db = new WebCMSEntities();
- db.PrizeFlowRecord.Add(item);
- db.SaveChanges();
- db.Dispose();
- }
- }
- }
|