public mainVeiwModel(MainWindow main, MainControl control) { mainWindow = main; this.control = control; thread = new Thread(new ThreadStart(() => { while (true) { if (PublicData.PublicData.state != "未连接服务器") { GetArchivesAccessList getArchivesAccessList = new GetArchivesAccessList(); GetArchivesListByList(getArchivesAccessList.GetNewestMessage()); ////报警记录 GetNewestAlarmList getNewestAlarmList = new GetNewestAlarmList(); GetAlarmListByList(getNewestAlarmList.GetNewestMessage()); break; //////可借出列 } Thread.Sleep(500); } })); thread1 = new Thread(new ThreadStart(() => { while (true) { NowDate = DateTime.Now.ToString("yyyy/MM/dd"); NowTime = DateTime.Now.ToString("HH:mm:ss"); WeekNow = GetWeek(DateTime.Now.DayOfWeek.ToString()); state = PublicData.PublicData.state; Color = PublicData.PublicData.color; PIC = PublicData.PublicData.pic; Thread.Sleep(50); } })); thread.IsBackground = true; thread.Start(); thread1.IsBackground = true; thread1.Start(); InNum = PublicData.PublicData.IntoNum.ToInt() + "人"; OutNum = PublicData.PublicData.OutNum.ToInt() + "人"; }
public void DealRF100(byte[] data, MainControl control) { lock (this) { if (PublicData.PublicData.TJDate == Convert.ToDateTime("2018-1-1")) { PublicData.PublicData.TJDate = DateTime.Now; } else { if ((DateTime.Now - PublicData.PublicData.TJDate).TotalSeconds > 5) { PublicData.PublicData.TempEPCList.Clear(); } } int start = 0; if (data.Length < 2) { return; } List <string> j = byteToHexStr(data, data.Length); bool result = false; foreach (string strEPC in j) { lock (strEPC) { if (PublicData.PublicData.TempEPCList.Contains(strEPC)) { // return; } else { PublicData.PublicData.TJDate = DateTime.Now; PublicData.PublicData.TempEPCList.Add(strEPC); PublicData.PublicData.EPC.Enqueue(strEPC); SelectDAL select = new SelectDAL(); ReturnInfo returnInfo = select.Select(strEPC); BookMessage message = new BookMessage() { EPC = strEPC }; ///添加档案进出记录 if (returnInfo.stateCode != "202") { result = true; AddArchivesInOrOutList addArchivesIn = new AddArchivesInOrOutList(message); addArchivesIn.GetArchivesInOrOut(); } ///报警记录判断 if (returnInfo.stateCode == "201") { ///添加报警记录 AddAlarmList addAlarmList = new AddAlarmList(message); addAlarmList.AddAlarm(); } } } } if (result) { Task.Run(() => { GetArchivesAccessList getArchivesAccessList = new GetArchivesAccessList(); List <Archives> list = GetArchivesListByList(getArchivesAccessList.GetNewestMessage()); ////报警记录 GetNewestAlarmList getNewestAlarmList = new GetNewestAlarmList(); List <Alarm> alarms = GetAlarmListByList(getNewestAlarmList.GetNewestMessage()); control.Dispatcher.Invoke(() => { control.message.ItemsSource = list; control.AlarmList.ItemsSource = alarms; }); }); } } }