/// <summary> /// 请求提示 /// </summary> /// <param name="text">提示文本</param> /// <param name="type">提示窗口类型</param> /// <param name="onOK">按确认/重试键时回调</param> /// <param name="onCancel">按取消键时回调(默认关闭弹窗)</param> /// <param name="duration">自动消失时长</param> /// <remarks>用于呼出提示窗口(弹窗)</remarks> /// <example>例 1:显示一个提示: /// <code> /// var gameSys = GameSystem.get(); /// gameSys.requestAlert("提示!"); /// </code> /// </example> /// <example>例 2:显示一个带确认按钮的提示,确认时执行 onOK 函数,否则关闭弹窗: /// <code> /// var gameSys = GameSystem.get(); /// gameSys.requestAlert("确认?", AlertWindow.Type.YesOrNo, onOK); /// </code> /// </example> public void requestAlert(string text, AlertWindow.Type type = AlertWindow.Type.Notice, UnityAction onOK = null, UnityAction onCancel = null, float duration = AlertWindow.DefaultDuration) { alertRequest = new AlertRequest(text, type, onOK, onCancel, duration); }
public async Task SendAlertAsync([FromBody] AlertRequest request) { foreach (var phone in request?.Receivers) { //发送短信,忽略发送结果 await _sms.SendMessageAsync(phone, request.Message).ConfigureAwait(false); } }
/// <summary> /// Send an Event Based Alerts request. /// </summary> /// <param name="request">Event Based Alerts request</param> /// <param name="customValues">Any custom parameters you need for template.</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> /// <returns></returns> public static SMS.SMSResponse RequestAlert(AlertRequest request, Dictionary <string, string> customValues, Credentials creds = null) { var sb = ApiRequest.GetQueryStringBuilderFor(request, creds); foreach (var key in customValues.Keys) { sb.AppendFormat("{0}={1}&", System.Net.WebUtility.UrlEncode(key), System.Net.WebUtility.UrlEncode(customValues[key])); } var json = ApiRequest.DoRequest(ApiRequest.GetBaseUriFor(typeof(ShortCode), "/sc/us/alert/json?" + sb), creds); return(JsonConvert.DeserializeObject <SMS.SMSResponse>(json)); }
/// <summary> /// Send an Event Based Alerts request. /// </summary> /// <param name="request">Event Based Alerts request</param> /// <param name="customValues">Any custom parameters you need for template.</param> /// <param name="creds">(Optional) Overridden credentials for only this request</param> /// <returns></returns> public static SMS.SMSResponse RequestAlert(AlertRequest request, Dictionary <string, string> customValues, Credentials creds = null) { var parameters = ApiRequest.GetParameters(request); foreach (var key in customValues.Keys) { parameters.Add(key, customValues[key]); } var response = ApiRequest.DoGetRequestWithQueryParameters <SMS.SMSResponse>(ApiRequest.GetBaseUriFor(typeof(ShortCode), "/sc/us/alert/json"), ApiRequest.AuthType.Query, parameters, creds); SMS.ValidateSmsResponse(response); return(response); }
private void OnDialog(AlertRequest request) { var dialog = new AlertDialog.Builder(this); dialog.SetTitle(request.Title); if (request.Msg != null) { dialog.SetMessage(request.Msg); } dialog.SetPositiveButton( string.IsNullOrEmpty(request.OkActionText) ? AppRes["DialogYes"] : request.OkActionText, (sender, args) => { request.OkAction?.Invoke(); }); if (request.Type == AlertRequest.AlertType.OkCancel) { dialog.SetNegativeButton( string.IsNullOrEmpty(request.CancelActionText) ? AppRes["DialogNo"] : request.CancelActionText, (sender, args) => { request.CancelAction?.Invoke(); }); } dialog.Show(); }
private void model_ErrorOccurredAtChatCollectServiceCreation(Model.ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, string errorText) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"コメント元、\"{serviceEntry.Name}\"を有効にしようとしたとき以下のエラーが発生し、有効化できませんでした。\n\n{errorText}" }); }
private void model_ErrorOccurredInChatPosting(Model.ChatCollectService.IChatCollectService service, Model.ChatCollectService.BasicChatPostObject postObject, string errorText) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"\"{service.Name}\"にコメントを投稿するとき以下のエラーが発生しました。\n\n{errorText}" }); }
private void model_ErrorOccurredInChatCollecting(Model.ChatCollectService.IChatCollectService service, string errorText) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"\"{service.Name}\"で以下のエラーが発生しました。このコメント元を無効化します。\n\n{errorText}" }); }
private async Task initializeInternal() { if (initialized) { return; } initialized = true; // モデルの初期化 try { await model.Initialize(); await BasicSettingControlViewModel.Initialize(); //await ChatPostControlViewModel.Initialize(); } catch (Exception e) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"初期化で予期しないエラーが発生しました\n{e.ToString()}" }); CloseApplication(); return; } if (model.State != Model.TVTCommentState.Working) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = "Viewer側(TVTestプラグイン側)と接続できませんでした" }); CloseApplication(); return; } // 表示関係の設定復元 Model.Serialization.WindowPositionEntity rect = model.Settings.View.MainWindowPosition; this.WindowPosition.X = rect.X; this.WindowPosition.Y = rect.Y; this.WindowPosition.Width = rect.Width; this.WindowPosition.Height = rect.Height; ChatListColumnInfos = model.Settings.View.ChatListViewColumns?.Select( x => new Views.AttachedProperties.GridViewColumnSettingsBinder.ColumnInfo(x.Id, x.Width) ).ToArray(); this.SelectedTab.Value = model.Settings.View.MainWindowTab; // ウィンドウの位置を復元したら最小化を解除 Window window = Application.Current.MainWindow; window.WindowState = WindowState.Normal; // モデルのイベントハンドラを登録 model.ChatCollectServiceModule.ErrorOccurredInChatCollecting += model_ErrorOccurredInChatCollecting; model.ChatCollectServiceModule.ErrorOccurredInChatPosting += model_ErrorOccurredInChatPosting; model.ChatCollectServiceModule.ErrorOccurredInServiceCreation += model_ErrorOccurredAtChatCollectServiceCreation; // モデルのプロパティを結びつける CurrentPlayTime = model.ChannelInformationModule.CurrentTime; CurrentChannel = model.ChannelInformationModule.CurrentChannel; CurrentEvent = model.ChannelInformationModule.CurrentEvent; disposables.Add(CurrentPlayTime.Subscribe(_ => updateWindowTitle())); disposables.Add(CurrentChannel.Subscribe(_ => updateWindowTitle())); disposables.Add(CurrentEvent.Subscribe(_ => updateWindowTitle())); // 旧ニコニコ実況が廃止されたので現状常にnull // 今後対応するときのためにとって置いてる forceValueData = new ReadOnlyObservableValue <Model.IForceValueData>(Observable.Return <Model.IForceValueData>(null)); UseDefaultChatCollectService = model.DefaultChatCollectServiceModule.IsEnabled; model.CommandModule.ShowWindowCommandInvoked += commandModule_ShowWindowCommandInvoked; // コマンド生成 ChangeChannelCommand = new DelegateCommand <Model.ChannelInfo>(channel => { if (channel != null) { model.ChannelInformationModule.SetCurrentChannel(channel); } }); AddChatCollectServiceCommand = new DelegateCommand <ShellContents.ChatCollectServiceAddListItemViewModel>( async x => { if (x != null) { await addChatCollectService(x); } }, _ => !UseDefaultChatCollectService.Value ); RemoveChatCollectServiceCommand = new DelegateCommand <Model.ChatCollectService.IChatCollectService>( service => { if (service != null) { model.ChatCollectServiceModule.RemoveService(service); } }, _ => !UseDefaultChatCollectService.Value ); UseDefaultChatCollectService.Subscribe(x => { AddChatCollectServiceCommand.RaiseCanExecuteChanged(); RemoveChatCollectServiceCommand.RaiseCanExecuteChanged(); }); ClearChatsCommand = new DelegateCommand(() => model.ChatModule.ClearChats()); AddWordNgCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } model.ChatModule.AddChatModRule(new Model.ChatModRules.WordNgChatModRule(model.ChatServices.SelectMany(x => x.ChatCollectServiceEntries), chat.Text)); }); AddUserNgCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } model.ChatModule.AddChatModRule(new Model.ChatModRules.UserNgChatModRule(chat.SourceService.Owner.ChatCollectServiceEntries, chat.UserId)); }); CopyCommentCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } Clipboard.SetText(chat.Text); }); CopyUserCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } Clipboard.SetText(chat.UserId); }); OnPropertyChanged(null); }
public SettingsWindowViewModel(Model.TVTComment model) { DefaultChatCollectServices = new ShellContents.DefaultChatCollectServicesViewModel(model); niconico = model.ChatServices.OfType <Model.ChatService.NiconicoChatService>().Single(); nichan = model.ChatServices.OfType <Model.ChatService.NichanChatService>().Single(); ChatCollectServiceCreationPresetSettingControlViewModel = new SettingsWindowContents.ChatCollectServiceCreationPresetSettingControlViewModel(model); LoginNiconicoCommand = new DelegateCommand(async() => { if (string.IsNullOrWhiteSpace(NiconicoUserId.Value) || string.IsNullOrWhiteSpace(NiconicoPassword.Value)) { return; } try { await niconico.SetUser(NiconicoUserId.Value, NiconicoPassword.Value, NiconicoSid.Value, NiconicoSession.Value, NiconicoSecure.Value); syncNiconicoUserStatus(); } catch (Model.NiconicoUtils.NiconicoLoginSessionException) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = "ニコニコへのログインに失敗しました" }); } }); ApplyNichanSettingsCommand = new DelegateCommand(() => { if (string.IsNullOrWhiteSpace(NichanResCollectInterval.Value) || string.IsNullOrWhiteSpace(NichanThreadSearchInterval.Value)) { return; } try { nichan.SetIntervalValues( TimeSpan.FromSeconds(uint.Parse(NichanResCollectInterval.Value)), TimeSpan.FromSeconds(uint.Parse(NichanThreadSearchInterval.Value))); nichan.SetApiParams( NichanApiHmKey.Value, NichanApiAppKey.Value, nichan.GochanApiUserId, nichan.GochanApiPassword, NichanApiAuthUserAgent.Value, NichanApiAuthX2chUA.Value, NichanApiUserAgent.Value ); nichan.SetPastCollectServiceBackTime(TimeSpan.FromMinutes(double.Parse(NichanPastCollectServiceBackTime.Value))); syncNichanSettings(); } catch (Exception e) when(e is FormatException || e is OverflowException) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = "2ch設定の値が不正です" }); } }); ChatPreserveCount = model.ChatModule.ChatPreserveCount; syncNiconicoUserStatus(); syncNichanSettings(); }
public async Task <IActionResult> AlertAsync([FromServices] INocService nocService, AlertRequest request) { await nocService.AlertAsync(request.Ic, request.Type, request.PopId); return(Ok()); }
internal void ConnectIndication(ConnectIndication indication) { Connection connection = Connections.GetConnectionByPLCI(indication.Identifier.PLCI); if (connection == null) { connection = new Connection(_application, this, indication.Identifier.PLCI, indication.CalledPartyNumber, indication.CallingPartyNumber); Connections.InternalAdd(connection); } AlertRequest request = new AlertRequest(); request.Identifier.Value = indication.Identifier.Value; _application.SendMessage(request); // Notify user application.... connection.Status = ConnectionStatus.D_ConnectPending; connection.ConnectIndication(indication); IncomingPhysicalConnectionEventArgs args = new IncomingPhysicalConnectionEventArgs(connection); _application.OnIncomingPhysicalConnection(args); }
private void TmrAlert_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { List <AlertRequest> nonCompletedRequests = AlertRequest.GetNonCompletedAlarms(); if (nonCompletedRequests.Count > 0) { foreach (var item in nonCompletedRequests) { if (!skype.Client.IsRunning) { skype.Client.Start(true, true); } if (item.AlarmType == "CallAlarm") { try { if (skype.ActiveCalls.Count == 0) { Call call = skype.PlaceCall(item.AlarmNumber); AlertRequest.Update(item.AlarmRequestId); } string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string filepath = System.IO.Path.Combine(path, "tmp.wav"); //Speak.SetOutputToWaveFile(filepath); //Speak.Speak("Hello world"); //Speak.SetOutputToDefaultAudioDevice(); } catch (Exception ex) { } } else if (item.AlarmType == "SmsAlarm") { try { var smsType = SKYPE4COMLib.TSmsMessageType.smsMessageTypeOutgoing; var message = skype.CreateSms(smsType, item.AlarmNumber); message.Body = "Acil Durum:Evimde birileri var"; message.Send(); AlertRequest.Update(item.AlarmRequestId); } catch (Exception ex) { } } else if (item.AlarmType == "PanicSms") { try { var smsType = SKYPE4COMLib.TSmsMessageType.smsMessageTypeOutgoing; var message = skype.CreateSms(smsType, item.AlarmNumber); message.Body = "Acil Durum! Güvende olmadığımı hissediyorum.Konum:" + item.AlarmParameter; message.Send(); AlertRequest.Update(item.AlarmRequestId); } catch (Exception ex) { } } } } }
//gelen resmi model ile kıyasla private void RecognisePicture(MemoryStream memoryStream) { Image <Gray, byte> img = new Image <Gray, byte>(new Bitmap(Image.FromStream((Stream)memoryStream))); HaarCascade haaryuz = new HaarCascade("haarcascade_frontalface_alt2.xml"); MCvAvgComp[][] Yuzler = img.DetectHaarCascade(haaryuz, 1.2, 5, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(15, 15)); foreach (MCvAvgComp item in Yuzler[0]) { List <Classes.User> customerUsers = Classes.User.GetObjects().Where(x => x.CustomerId == GlobalSetting.CustomerId).ToList(); var yuz = img.Copy(item.rect).Convert <Gray, byte>().Resize(100, 100, INTER.CV_INTER_CUBIC); string name = train.Recognise(yuz); if (string.IsNullOrEmpty(name) || name == "Tanımsız" || customerUsers.FirstOrDefault(x => x.Username == name) == null) { AlarmSetting alarm = AlarmSetting.GetObjects().FirstOrDefault(x => x.AlarmSettingId == GlobalSetting.UserAlarmSettingId); if (alarm.IsActive) { if (alarm.IsCallAlarmActive) { if (!string.IsNullOrEmpty(alarm.FirstPersonNumber)) { if (alarm.FirstPersonNumber.Length == 10) { alarm.FirstPersonNumber = "+90" + alarm.FirstPersonNumber; } else if (alarm.FirstPersonNumber.Length == 11) { alarm.FirstPersonNumber = "+9" + alarm.FirstPersonNumber; } AlertRequest request = new AlertRequest(); request.AlarmNumber = alarm.FirstPersonNumber; request.AlarmParameter = string.Empty; request.AlarmType = "CallAlarm"; request.IsAlerted = false; request.Insert(); } if (!string.IsNullOrEmpty(alarm.SecondPersonNumber)) { if (alarm.SecondPersonNumber.Length == 10) { alarm.SecondPersonNumber = "+90" + alarm.SecondPersonNumber; } else if (alarm.SecondPersonNumber.Length == 11) { alarm.SecondPersonNumber = "+9" + alarm.SecondPersonNumber; } AlertRequest request = new AlertRequest(); request.AlarmNumber = alarm.SecondPersonNumber; request.AlarmParameter = string.Empty; request.AlarmType = "CallAlarm"; request.IsAlerted = false; request.Insert(); } } else if (alarm.IsPoliceAlarmActive) { if (alarm.SecondPersonNumber.Length == 10) { alarm.SecondPersonNumber = "+90" + alarm.SecondPersonNumber; } else if (alarm.SecondPersonNumber.Length == 11) { alarm.SecondPersonNumber = "+9" + alarm.SecondPersonNumber; } AlertRequest request = new AlertRequest(); request.AlarmNumber = "911"; request.AlarmParameter = string.Empty; request.AlarmType = "CallAlarm"; request.IsAlerted = false; request.Insert(); } else if (alarm.IsSmsAlarmActive) { if (alarm.SecondPersonNumber.Length == 10) { alarm.SecondPersonNumber = "+90" + alarm.SecondPersonNumber; } else if (alarm.SecondPersonNumber.Length == 11) { alarm.SecondPersonNumber = "+9" + alarm.SecondPersonNumber; } AlertRequest request = new AlertRequest(); request.AlarmNumber = alarm.SecondPersonNumber; request.AlarmParameter = string.Empty; request.AlarmType = "SmsAlarm"; request.IsAlerted = false; request.Insert(); } } } } }
public object CreateAlert(AlertRequest alertRequest) { throw new System.NotImplementedException(); }
/// <summary> /// 清空提示请求 /// </summary> /// <remarks>清空当前的提示请求(并不等于关闭提示窗口,只是用于清除前一个操作的请求)</remarks> public void clearRequestAlert() { alertRequest = null; }