private void OnNotify(DataAgent agent, NotifyEvents notifyEvent, Notify p) { this.SafeInvoke(() => { this.OnNotifyAtUIThread(agent, notifyEvent, p); }); }
/// <summary> /// /// </summary> /// <param name="agent"></param> /// <param name="notifyEvent"></param> /// <param name="msg"></param> private void OnNotifyAtUIThread(DataAgent agent, NotifyEvents ne, Notify p) { string msg = string.Format("{0}: {1}", DateTime.Now, p.Message); if (ne == NotifyEvents.UploadFileOK) { fileUploadInfoListBox.Items.Add(msg); } else if (ne == NotifyEvents.UploadFileFailed) { fileUploadInfoListBox.Items.Add(msg); } else if (ne == NotifyEvents.DebugMessage) { this.debugConsole.Text += string.Format("{0}\n", p.Message); } else if (ne == NotifyEvents.EventMessage) { mainListBox.Items.Add(msg); } else if (ne == NotifyEvents.SendDataOK) { this.UpdateSendDataRecord(p.DeviceKey, false); } else if (ne == NotifyEvents.SendDataFailed) { //this.UpdateSendDataRecord(p.DeviceKey, false); } else if (ne == NotifyEvents.HistoryData) { this.HandleHistoryData(p.Payload); } }
private void PlaySound(NotifyEvents notifyEvent) { // Do not play sounds when busy and suspend sounds on busy is selected. if (!bPlaySounds || (localStatus == "Busy" && bSuspendSoundsOnBusy) || (localStatus == "DoNotDisturb" && bSuspendSoundsOnDND)) { return; } try { Stream waveStream = null; switch (notifyEvent) { case NotifyEvents.Online: waveStream = LANChat.Resources.Properties.Resources.ResourceManager.GetStream("online"); break; case NotifyEvents.NewMessage: waveStream = LANChat.Resources.Properties.Resources.ResourceManager.GetStream("newmessage"); break; case NotifyEvents.NewFile: waveStream = LANChat.Resources.Properties.Resources.ResourceManager.GetStream("newalert"); break; case NotifyEvents.FileComplete: waveStream = LANChat.Resources.Properties.Resources.ResourceManager.GetStream("done"); break; } SoundPlayer.PlaySound(waveStream); } catch { } }
internal void Append( Context context, Kind kind, NotifyEvents notifyEvents, string contentFormat, params object[] args) { var previousContent = this.ContentText?.Length > 0 ? this.ContentText + Environment.NewLine : string.Empty; this.Update(context, kind, notifyEvents, previousContent + contentFormat, args); }
internal void Update( Context context, Kind kind, NotifyEvents notifyEvents, string contentFormat, params object[] args) { // Sometimes exception messages contain curly braces, which confuses string.Format this.ContentText = args.Length > 0 ? string.Format(CurrentCulture, contentFormat, args) : contentFormat; var showPopup = (int)kind >= (int)notifyEvents; if (showPopup) { #pragma warning disable CS0618 // Type or member is obsolete using (var builder = new Android.App.Notification.Builder(context)) #pragma warning restore CS0618 // Type or member is obsolete using (var intent = new Intent(context, this.activityType)) using (var style = new Android.App.Notification.BigTextStyle()) { // This is necessary so that the intent object is going to be interpreted as a new intent rather than // an update to an existing intent. intent.SetAction(this.id.ToString()); this.addArguments(intent); builder .SetSmallIcon(Resource.Drawable.ic_stat_name) .SetContentTitle(this.title) .SetContentText(this.ContentText) .SetContentIntent(PendingIntent.GetActivity(context, 0, intent, 0)) .SetStyle(style.BigText(this.ContentText)) .SetAutoCancel(true); SetLights(builder, kind); this.manager.Notify(this.id, builder.Build()); } } Info("Notification{0}: {1}", showPopup ? " (shown in popup)" : string.Empty, this.ContentText); }
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); } }); }
internal Data( string firstCurrency, string secondCurrency, int customerId, string apiKey, string apiSecret, bool buy, float tradePeriod, TransferToMainAccount transferToMainAccount, NotifyEvents notifyEvents) { this.FirstCurrency = firstCurrency; this.SecondCurrency = secondCurrency; this.CustomerId = customerId; this.ApiKey = apiKey; this.ApiSecret = apiSecret; this.Buy = buy; this.TradePeriod = tradePeriod; this.TransferToMainAccount = transferToMainAccount; this.NotifyEvents = notifyEvents; }
internal void Append( Context context, Kind kind, NotifyEvents notifyEvents, int contentFormatId, params object[] args) => this.Append(context, kind, notifyEvents, context.Resources.GetString(contentFormatId), args);
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); } }); }