private void UnRegisterChip(TimerView timerView) { foreach (EventView eventView in list.FindAll(t => t.ChipId == timerView.ChipId)) { eventView.Timer = null; } }
public void OnTimerDisconnect(INetworkSocket socket, AllEventViews allEventViews) { TimerView timerView = FindTimerViewByIpaddress(socket.IPInfo.IPAddress); timerView.UnBindToEventView(); this.list.Remove(timerView);//去掉Timer列表里的项目 }
private void RegisterChip(TimerView timerView) { foreach (EventView eventView in list.FindAll(t => t.ChipId == timerView.ChipId)) { eventView.Timer = timerView; timerView.EventName += eventView.Name + ";"; } }
public void OnDisconnect(INetworkSocket socket) { m_socketList.Remove(socket); TimerView timerView = FindTimerViaSocket(socket); timerView.UnBindToEventView(); TimerViews.Remove(timerView);//去掉Timer列表里的项目 }
private void UnBindChip(TimerView timerView) { foreach (EventView eventView in EventViews.FindAll(t => t.ChipId == timerView.ChipId)) { eventView.Timer = null; eventView.ChipId = 0; } }
private void BindChip(TimerView timerView) { EventView eventView = EventViews.First(t => t.ChipId == timerView.ChipId); eventView.Timer = timerView; timerView.EventName = eventView.Name; SendMessageToSocket("setdata,eventname," + eventView.Name, timerView.Socket); SendMessageToSocket("setdata,timelimit," + eventView.Time_limit.GetValueOrDefault().TotalSeconds, timerView.Socket); }
public void OnReceived(INetworkSocket socket, Packet receivedPacket) { //ListTimerViews.OnreceivedTimerMessage(socket, receivedPacket, ListEventViews); TimerView timerView = FindTimerViaSocket(socket); //timerView.DealWithPacket(receivedPacket, EventViews); try { string cmd = StringFromByteArr(receivedPacket.PacketRaw); string[] s = cmd.Split(','); if (s.Count() >= 2 && timerView != null) { switch (s[0]) { case "chipid": timerView.ChipId = Convert.ToInt32(s[1]); BindChip(timerView); break; case "timerstatus": if (timerView.ChipId != null) { timerView.Status = (TimerView.TimerStatus)Convert.ToInt32(s[1]); timerView.Time_used = new TimeSpan(Convert.ToInt64(s[3]) / 1000 * 10000000); } break; default: break; } } } catch (Exception e) { SetTipMessage(e.Message); } }
private void ChangeEventRegister(int chipid, int item_id) { TimerView timer = TimerViews.First(t => t.ChipId == chipid); //查找对应的timer对象 //timer.ChangeEventRegister(eventid, ListEventViews); UnBindChip(timer);//先取消与此timer有关的eventView注册 EventView eventView = EventViews.Find(t => t.Id == item_id); //查找对应的eventView对象 eventView.ChipId = chipid; //设置内存里EventView里的chipid BindChip(timer); //注册修改后的timer对象到eventView中 try { Chip chip = dbContext.Chips.Where(c => c.Serial == chipid).FirstOrDefault(); if (chip != null) { chip.EventId = eventView.EventId; } else { dbContext.Chips.Add(new Chip() { EventId = eventView.EventId, Serial = chipid }); } dbContext.SaveChanges(); } catch (Exception e) { MessageBox.Show(e.Message); } // dbContext.Events.First(t => t.Id == eventid).ChipId = chipid;//修改数据库里的event的chipid }
public void BindTimerView(TimerView timerView) { this.Timer = timerView; timerView.EventView = this; }
public void OnreceivedTimerMessage(INetworkSocket socket, Packet receivedPacket, AllEventViews allEventViews) { TimerView timerView = FindTimerViewByIpaddress(socket.IPInfo.IPAddress); timerView.DealWithPacket(receivedPacket, allEventViews); }