1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Threading;
- using Library;
- using LitJson;
- using MySystem;
- using MySystem.Models;
- public class SourceDataToDb
- {
- public readonly static SourceDataToDb Instance = new SourceDataToDb();
- private SourceDataToDb()
- { }
- public void Start()
- {
- Thread th = new Thread(DoWorks);
- th.IsBackground = true;
- th.Start();
- }
- public void DoWorks()
- {
- while (true)
- {
- string content = RedisDbconn.Instance.RPop<string>("DataToDbQueue");
- if (!string.IsNullOrEmpty(content))
- {
- try
- {
- string[] data = content.Split('|');
- string jsonString = data[2];
- int BrandId = int.Parse(data[1]);
- int Kind = int.Parse(data[0]);
- WebCMSEntities db = new WebCMSEntities();
- string key = "kxs_" + Kind + "_list_" + BrandId;
- JobMqMsg obj = RedisDbconn.Instance.GetList<JobMqMsg>("GetSpData", 1, 1000).FirstOrDefault(m => m.OrderString.Contains(key));
- if(obj != null)
- {
- PublicImportDataService.Instance.InsertData(key, content, obj, BrandId);
- }
- db.Dispose();
- }
- catch(Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "接收云长WIFI设备绑定异常");
- }
- }
- else
- {
- Thread.Sleep(5000);
- }
- }
- }
-
- }
|