void server_CashpointConnected(object sender, CashpointMsgReceivedEventArgs e) { Cashpoint c = (from cp in cashpoints where cp.IpAddress == e.IpAddress select cp).FirstOrDefault(); if (c == null) Task.Factory.StartNew(() => { Cashpoint cp = new Cashpoint() { IpAddress = e.IpAddress, ConnectedDateTime = DateTime.Now, IsOnline = true }; cp.PropertyChanged += (s, evt) => { if (evt.PropertyName == "PrinterStatus") if ((cp.PrinterStatus & PrintDeviceStatus.PaperNearOut) == PrintDeviceStatus.PaperNearOut || (cp.PrinterStatus & PrintDeviceStatus.PaperOut) == PrintDeviceStatus.PaperOut) printerSoundTimer.Change(0, SOUND_INTERVAL_SECONDS * 1000); else printerSoundTimer.Change(Timeout.Infinite, Timeout.Infinite); }; cashpoints.Add(cp); }); }
protected virtual void OnCashpointMsgReceived(CashpointMsgReceivedEventArgs e) { if (!servers.ContainsKey(e.IpAddress)) servers.Add(e.IpAddress, DateTime.Now); if (CashpointMsgReceived != null && e.MessageType == CashpointMessageType.Update) CashpointMsgReceived(this, e); }
protected virtual void OnCashpointDisconnected(CashpointMsgReceivedEventArgs e) { servers.Remove(e.IpAddress); if (CashpointDisconnected != null) CashpointDisconnected(this, e); }
protected virtual void OnCashpointConnected(CashpointMsgReceivedEventArgs e) { if (!servers.ContainsKey(e.IpAddress)) servers.Add(e.IpAddress, DateTime.Now); if (CashpointConnected != null) CashpointConnected(this, e); }
void server_CashpointDisconnected(object sender, CashpointMsgReceivedEventArgs e) { Cashpoint c = (from cp in cashpoints where cp.IpAddress == e.IpAddress select cp).FirstOrDefault(); c.IsOnline = false; c.LastUpdate = DateTime.Now; c.Status = CashpointState.Offline; c.CurrentUser = null; }
void server_CashpointMsgReceived(object sender, CashpointMsgReceivedEventArgs e) { Cashpoint c = (from cp in cashpoints where cp.IpAddress == e.IpAddress select cp).FirstOrDefault(); if (c.CurrentUser == null && e.Message.User != "") c.Logins++; c.IsOnline = true; c.Name = e.Message.Name; c.CurrentActionCode = e.Message.Action; c.CurrentUser = e.Message.User == "" ? null : e.Message.User; c.LastUpdate = DateTime.Now; c.PrinterStatus = e.Message.PrinterStatus; }