private void OnNotifyEvent(Agent agent, NotifyEvents notify, string msg1, string msg2) { if (this.quitPressed) { return; } this.SafeInvoke(() => { this.statusStrip.Items[0].Text = this.GetConnetionString(); if (NotifyEvents.Connecting == notify) { ConnetionRecord cr = new ConnetionRecord(); this.connectionHistory.Add(cr); } else if (NotifyEvents.Connected == notify) { int count = this.connectionHistory.Count; ConnetionRecord cr = this.connectionHistory[count - 1]; cr.ConnectedTime = DateTime.Now; } else if (NotifyEvents.Disconnect == notify) { int count = this.connectionHistory.Count; ConnetionRecord cr = this.connectionHistory[count - 1]; cr.DisconnectedTime = DateTime.Now; } else if (NotifyEvents.HandleEvent == notify) { string line = string.Format("{0}: {1} {2}", DateTime.Now, msg1, msg2); this.AddListItem(line); } else if (NotifyEvents.HistoryDataSent == notify) { string deviceKey = msg1.ToLower(); string line = string.Format("HD: {0}", msg2); Log.GetLogFile(deviceKey).Log(line); this.UpdateSendDataRecord(deviceKey, true); } /// 国家数据中心相关 else if (NotifyEvents.ConnectToCountryCenter == notify) { /// 国家数据中心相关 this.StartConnectCountryCenter(); this.AddListItem(msg1); } else if (NotifyEvents.DisconnectToCountryCenter == notify) { /// 国家数据中心相关 this.StopConnectCountryCenter(); this.AddListItem(msg1); } }); }
private void OnNotifyEvent(Agent agent, NotifyEvents notify, string msg1, string msg2) { if (this.quitPressed) return; this.SafeInvoke(() => { this.statusStrip.Items[0].Text = this.GetConnetionString(); if (NotifyEvents.Connecting == notify) { ConnetionRecord cr = new ConnetionRecord(); this.connectionHistory.Add(cr); } else if (NotifyEvents.Connected == notify) { int count = this.connectionHistory.Count; ConnetionRecord cr = this.connectionHistory[count - 1]; cr.ConnectedTime = DateTime.Now; } else if (NotifyEvents.Disconnect == notify) { int count = this.connectionHistory.Count; ConnetionRecord cr = this.connectionHistory[count - 1]; cr.DisconnectedTime = DateTime.Now; } else if (NotifyEvents.HandleEvent == notify) { string line = string.Format("{0}: {1} {2}", DateTime.Now, msg1, msg2); this.AddListItem(line); } else if (NotifyEvents.HistoryDataSent == notify) { string deviceKey = msg1.ToLower(); string line = string.Format("HD: {0}", msg2); Log.GetLogFile(deviceKey).Log(line); this.UpdateSendDataRecord(deviceKey, true); } /// 国家数据中心相关 else if (NotifyEvents.ConnectToCountryCenter == notify) { /// 国家数据中心相关 this.StartConnectCountryCenter(); this.AddListItem(msg1); } else if (NotifyEvents.DisconnectToCountryCenter == notify) { /// 国家数据中心相关 this.StopConnectCountryCenter(); this.AddListItem(msg1); } }); }
private void OnNotifyEvent(Agent agent, NotifyEvents notify, string msg1, string msg2) { if (this.quitPressed) { return; } this.SafeInvoke(() => { //this.statusStrip.Items[0].Text = this.GetConnetionString(); if (NotifyEvents.Connecting == notify) { ConnetionRecord cr = new ConnetionRecord(); this.connectionHistory.Add(cr); } else if (NotifyEvents.Connected == notify) { int count = this.connectionHistory.Count; ConnetionRecord cr = this.connectionHistory[count - 1]; cr.ConnectedTime = DateTime.Now; this.MainConnStatusLabel.ForeColor = Color.Black; this.MainConnStatusLabel.Text = "省中心连接状态: 上传中"; this.StopConnectCountryCenter(); this.countryCenterAgent.DoLog(ScadaDataClient, "正在断开国家数据中心连接..."); } else if (NotifyEvents.ConnectedCountry == notify) { this.SubConnStatusLabel.ForeColor = Color.Black; this.SubConnStatusLabel.Text = "国家中心连接状态: 上传中"; this.countryCenterAgent.DoLog(ScadaDataClient, "已经连接到国家数据中心!"); } else if (NotifyEvents.Disconnect == notify) { int count = this.connectionHistory.Count; ConnetionRecord cr = this.connectionHistory[count - 1]; cr.DisconnectedTime = DateTime.Now; this.retryCount++; if (this.retryCount % 3 == 0) { this.StartConnectCountryCenter(); } this.MainConnStatusLabel.ForeColor = Color.Red; this.MainConnStatusLabel.Text = "省中心连接状态: 未连接"; } else if (NotifyEvents.DisconnectCountry == notify) { this.SubConnStatusLabel.ForeColor = Color.Red; this.SubConnStatusLabel.Text = "国家中心连接状态: 未连接"; } else if (NotifyEvents.HandleEvent == notify) { string line = string.Format("{0}: {1} {2}", DateTime.Now, msg1, msg2); this.AddListItem(line); } else if (NotifyEvents.HistoryDataSent == notify) { string deviceKey = msg1.ToLower(); string line = string.Format("HD: {0}", msg2); Log.GetLogFile(deviceKey).Log(line); this.UpdateSendDataRecord(deviceKey, true); } }); }