12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- using System.Threading;
- using Common;
- using Infrastructure;
- using Model;
- using Services;
- public class HaoDaHelper
- {
- public readonly static HaoDaHelper Instance = new HaoDaHelper();
- private HaoDaHelper()
- { }
- public void Start()
- {
- Thread th = new Thread(DoWorks);
- th.IsBackground = true;
- th.Start();
- }
- public void DoWorks()
- {
- while (true)
- {
- string content = RedisServer.Cache.RPop<string>("hd:notice:order");
- if(!string.IsNullOrEmpty(content))
- {
- DoQueue(content);
- }
- else
- {
- Thread.Sleep(5000);
- }
- }
- }
- public void DoQueue(string content)
- {
- try
- {
- var item = Newtonsoft.Json.JsonConvert.DeserializeObject<HdTradeRecord>(content);
- var tradeService = App.GetService<IHdTradeRecordService>();
- tradeService.Add(item);
-
- }
- catch (Exception ex)
- {
- Function.WriteLog(DateTime.Now.ToString() + "\n" + ex, "好哒订单入库异常");
- }
- }
- }
|