/// <summary> /// Deserializes the data. /// </summary> private void DeserializeData() { if (File.Exists(this.CurrentNotificationSettingsPath + @"\" + _notificationSettingsFileName)) { this.NotificationData = this._xmlSerializer.Desirialize(this.CurrentNotificationSettingsPath + @"\" + _notificationSettingsFileName); } }
internal static AndroidNotificationData SetPushNotificationContentForAndroid(NotificationData data, DeviceDetails deviceDatails) { AndroidNotificationData androidNotificationData = new AndroidNotificationData(); androidNotificationData.To = deviceDatails.TokenID; androidNotificationData.Data = SetNotificationData(data); return(androidNotificationData); }
public bool HasWaitingNotification() { if (!HasProcessingNotification()) { NotificationData notif = packetHandler.GetCurrentNotification(); return(notif != null && notif.status == NotificationData.Status.WAITING); } return(false); }
private bool RunLocalFilters(NotificationData data) { if (FilterFuncs.Any()) { return(FilterFuncs.TrueForAll(f => f.Invoke(ResourceValueChange.Map(data)))); } return(true); }
public void QueueUpdatedQuestNotifier(string questName) { NotificationData newQuestNotifier = new NotificationData("Updated quest", questName, NotificationData.NotificationType.newQuest); if (!notificationDataList.Contains(newQuestNotifier)) { notificationDataList.Enqueue(newQuestNotifier); } }
private static NotificationData CreateNotificationData() { var notificationData = new NotificationData { ["TestValue"] = 42 }; return(notificationData); }
/// <summary> /// 发送通知 /// </summary> /// <param name="notificationName">订阅名称</param> /// <param name="data">推送的数据对象(自定义对象需要继承 NotificationData)</param> /// <param name="entityIdentifier">实体通知对象(new EntityIdentifier(typeof(对象类型), 对象id))</param> /// <param name="severity">通知类型枚举</param> /// <param name="userIds">接收通知的用户id集合 (如果未null将发送到所有人)</param> /// <param name="excludedUserIds">不接收通知的用户id集合</param> /// <returns></returns> public virtual async Task PublishAsync(string notificationName, NotificationData data = null, EntityIdentifier entityIdentifier = null, NotificationSeverity severity = NotificationSeverity.Info, UserIdentifier[] userIds = null, UserIdentifier[] excludedUserIds = null) { if (userIds != null) { //获取订阅了该通知的用户 userIds = userIds.Where(w => _notificationSubscriptionManager.IsSubscribed(w, notificationName)).ToArray(); } await _notificationPublisher.PublishAsync(notificationName, data, entityIdentifier, severity, userIds, excludedUserIds); }
// Update is called once per frame void Update() { if (currentState == State.Open) { if (currentNotification != null && (notificationTimer > currentNotification.displayTime || (currentNotification.cancelable && notificationQueue.Count > 0))) { Close(); } notificationTimer += Time.deltaTime; } else { notificationTimer = 0; } float transitionDistance = dropdownDistance / dropdownTime * Time.deltaTime; if (currentState == State.Closed && notificationQueue.Count > 0) { currentNotification = PopNotification(); Open(currentNotification); } else if (currentState == State.Opening) { Vector3 position = rectTransform.localPosition; position.y -= transitionDistance; float finalPosition = originalPosition - dropdownDistance; if (position.y <= finalPosition) { position.y = finalPosition; currentState = State.Open; } rectTransform.localPosition = position; } else if (currentState == State.Closing) { Vector3 position = rectTransform.localPosition; position.y += transitionDistance; if (position.y >= originalPosition) { position.y = originalPosition; currentState = State.Closed; // Disable if (notificationQueue.Count <= 0) { gameObject.SetActive(false); } } rectTransform.localPosition = position; } }
void Open(NotificationData notificationData) { notificationText.text = notificationData.message; if (currentState == State.Closed) { currentState = State.Opening; } }
/// <summary> /// Maps the specified data. /// </summary> /// <param name="data">The data.</param> /// <returns>ResourceValueChange</returns> public static ResourceValueChange Map(NotificationData data) { return(new ResourceValueChange { DeviceId = data.DeviceId, Path = data.Path, Payload = data.Payload, }); }
public static void SendPushNotification(NotificationData notificationData) { NontificationSetting NontificationSetting = GetNontificationSetting(); string serverKey = NontificationSetting.ServerKey; /*"AAAAkz00EBc:APA91bGCQCoykat89T4nRrz9F0Hfek8k9aHPm64CRErPOt_Xp6qxNRA8td1kse4CtNRscS604qXFczg_tCqglc-YTTEN-fnLgETdM0RB050tAqHHlNhwBINrp_VbiLJMmSz9V1ax2BTL"; // Something very long*/ string senderId = NontificationSetting.SenderId; /*"632387014679";*/ string deviceId = notificationData.NotificationToken; WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send"); tRequest.Method = "post"; tRequest.ContentType = "application/json"; var jsondata = new { to = deviceId, //{ "PDFURL", notificationData.PDFURL }, data = new Dictionary <string, string>() { { "Language", notificationData.Language }, { "SId", notificationData.SId }, { "Title", notificationData.Title }, { "Message", notificationData.Message }, { "Type", notificationData.Type }, { "BN", notificationData.BookingNumber }, { "ConfirmationStatus", notificationData.ConfirmationStatus } }, notification = new { body = notificationData.Message, title = notificationData.Title, sound = "Enabled", }, }; if (string.IsNullOrEmpty(notificationData.PDFURL)) { notificationData.PDFURL = ""; } jsondata.data.Add("PDFURL", notificationData.PDFURL); var json = JsonConvert.SerializeObject(jsondata); Byte[] byteArray = Encoding.UTF8.GetBytes(json); tRequest.Headers.Add(string.Format("Authorization: key={0}", serverKey)); tRequest.Headers.Add(string.Format("Sender: id={0}", senderId)); tRequest.ContentLength = byteArray.Length; using (Stream dataStream = tRequest.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); using (WebResponse tResponse = tRequest.GetResponse()) { using (Stream dataStreamResponse = tResponse.GetResponseStream()) { using (StreamReader tReader = new StreamReader(dataStreamResponse)) { String sResponseFromServer = tReader.ReadToEnd(); var response = sResponseFromServer; } } } } }
/// <summary> /// Method for instant processing of notification events. Events that will fail here will be picked up by a background job for retrial. /// </summary> public async Task <bool> ProcessNotificationAsync(HttpClient client, NotificationData notification, int requestTimeout, CancellationToken stoppingToken) { logger.LogDebug($"Processing notification '{notification.NotificationType}' for transaction '{new uint256(notification.TxExternalId)}' for host '{client.BaseAddress}'"); try { switch (notification.NotificationType) { case CallbackReason.DoubleSpend: notification.Payload = await txRepository.GetDoublespendTxPayloadAsync(notification.NotificationType, notification.TxInternalId); break; case CallbackReason.DoubleSpendAttempt: notification.Payload = await txRepository.GetDoublespendTxPayloadAsync(notification.NotificationType, notification.TxInternalId); break; case CallbackReason.MerkleProof: if (notification.MerkleFormat == MerkleFormat.TSC) { notification.MerkleProof2 = await rpcMultiClient.GetMerkleProof2Async(new uint256(notification.BlockHash).ToString(), new uint256(notification.TxExternalId).ToString()); } else { notification.MerkleProof = await rpcMultiClient.GetMerkleProofAsync(new uint256(notification.TxExternalId).ToString(), new uint256(notification.BlockHash).ToString()); } break; default: throw new InvalidOperationException($"Invalid notification type {notification.NotificationType}"); } } catch (Exception ex) { logger.LogError($"Unable to prepare notification for {new uint256(notification.TxExternalId)}. Error: {ex.GetBaseException().Message}"); await txRepository.SetNotificationErrorAsync(notification.TxExternalId, notification.NotificationType, ex.GetBaseException().Message, ++notification.ErrorCount); return(false); } var errMessage = await SendNotificationAsync(client, notification, requestTimeout, stoppingToken); if (errMessage == null) { await txRepository.SetNotificationSendDateAsync(notification.NotificationType, notification.TxInternalId, notification.BlockInternalId, notification.DoubleSpendTxId, clock.UtcNow()); return(true); } else { await txRepository.SetNotificationErrorAsync(notification.TxExternalId, notification.NotificationType, errMessage, ++notification.ErrorCount); return(false); } }
protected void Page_Load(object sender, EventArgs e) { string emailParam = Request.QueryString["email"]; string codeParam = Request.QueryString["code"]; NotificationData notificationData = new NotificationData(); if (String.IsNullOrWhiteSpace(emailParam) || String.IsNullOrWhiteSpace(codeParam)) { notificationData.Body = $"<strong>Malformed url:</strong> The url parameters could be wrong."; notificationData.Level = AlertLevel.Danger; } else if (!Int32.TryParse(codeParam, out int code)) { notificationData.Body = $"<strong>Invalid code:</strong> The code is not of the correct type."; notificationData.Level = AlertLevel.Danger; } else { string queryUser = "******"; string queryUpdate = "UPDATE Usuarios SET confirmado = 1, numconfir = -1 WHERE email = @email AND numconfir = @numconfir"; Dictionary <string, object> parameters = new Dictionary <string, object> { { "@email", emailParam }, { "@numConfir", code.ToString() } }; QueryResult queryResult = DataAccess.Query(queryUser, parameters); if (queryResult.Rows.Count != 1 || DataAccess.NonQuery(queryUpdate, parameters) != 1) { notificationData.Title = "Could Not Verify Account"; notificationData.Body = $"The email could not be validated. Please try again."; notificationData.Level = AlertLevel.Danger; } else { Session["IsLogged"] = true; string email = Convert.ToString(queryResult.Rows[0]["email"]); Session["Email"] = email; Session["Name"] = queryResult.Rows[0]["nombre"]; Session["LastName"] = queryResult.Rows[0]["apellidos"]; string tipo = Convert.ToString(queryResult.Rows[0]["tipo"]); Session["UserType"] = GetUserType(email, tipo); FormsAuthentication.SetAuthCookie(Session["UserType"].ToString(), true); notificationData.Title = "Account Confirmed"; notificationData.Body = $"Thank you! Email successfully validated."; notificationData.Level = AlertLevel.Success; } } Session["NotificationData"] = notificationData; Response.RedirectToRoute("WebNotification"); }
private static void SendUpdatableToastWithProgressForTranscode(StorageFile SourceFile, StorageFile DestinationFile) { string Tag = "TranscodeNotification"; ToastContent content = new ToastContent() { Launch = "Transcode", Scenario = ToastScenario.Reminder, Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = $"{Globalization.GetString("Transcode_Toast_Title")} {SourceFile.Name}" }, new AdaptiveProgressBar() { Title = SourceFile.FileType.Substring(1).ToUpper() + " ⋙⋙⋙⋙ " + DestinationFile.FileType.Substring(1).ToUpper(), Value = new BindableProgressBarValue("ProgressValue"), ValueStringOverride = new BindableString("ProgressValueString"), Status = new BindableString("ProgressStatus") } } } } }; NotificationData Data = new NotificationData { SequenceNumber = 0 }; Data.Values["ProgressValue"] = "0"; Data.Values["ProgressValueString"] = "0%"; Data.Values["ProgressStatus"] = Globalization.GetString("Toast_ClickToCancel_Text"); ToastNotification Toast = new ToastNotification(content.GetXml()) { Tag = Tag, Data = Data }; Toast.Activated += (s, e) => { if (s.Tag == "TranscodeNotification") { AVTranscodeCancellation.Cancel(); } }; ToastNotificationManager.CreateToastNotifier().Show(Toast); }
/// <summary> /// Executes the initial setup of this notification. /// </summary> public void Initialize() { if (notificationContainer == null) { return; } notificationName = gameObject.name + " (" + gameObject.GetInstanceID() + ")";//generate a unique name for this notification UIElement (need it to be able to hide it when we press one of its buttons) notificationContainer.elementCategory = DUI.DEFAULT_CATEGORY_NAME; notificationContainer.elementName = notificationName; notificationContainer.linkedToNotification = true; notificationContainer.autoRegister = false; //register this element to the registry with the auto generated name (notifiacationName) notificationContainer.animateAtStart = false; //stop show animation if (overlay != null) { overlay.elementCategory = DUI.DEFAULT_CATEGORY_NAME; overlay.elementName = notificationName; //use the same elementName so it will get hidden along with the main UIElement overlay.linkedToNotification = true; overlay.autoRegister = false; //register this element to the registry with the auto generated name (notifiacationName) overlay.animateAtStart = false; } if (specialElements != null && specialElements.Length > 0) { for (int i = 0; i < specialElements.Length; i++) { if (specialElements[i] == null) { continue; } specialElements[i].elementCategory = DUI.DEFAULT_CATEGORY_NAME; specialElements[i].elementName = notificationName; //use the same elementName so it will get hidden along with the main UIElement specialElements[i].linkedToNotification = true; specialElements[i].autoRegister = false; //register this element to the registry with the auto generated name (notifiacationName) specialElements[i].animateAtStart = false; //stop show animation } } if (effects != null && effects.Length > 0) { for (int i = 0; i < effects.Length; i++) { if (effects[i] == null) { continue; } if (effects[i].targetUIElement == null) { continue; } effects[i].targetUIElement.elementCategory = DUI.DEFAULT_CATEGORY_NAME; effects[i].targetUIElement.elementName = notificationName; //use the same elementName so it will get hidden along with the main UIElement effects[i].targetUIElement.linkedToNotification = true; effects[i].autoRegister = false; //register this element to the registry with the auto generated name (notifiacationName) effects[i].playOnAwake = false; //stop show animation } } data = new NotificationData(); }
/// <summary> /// Notifies the specified data. /// </summary> /// <param name="data">The data.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task NotifyAsync(NotificationData data) { if (!ResourceValueSubscriptions.Any() || ResourceValueSubscriptions.FirstOrDefault(p => p.Equals(data)) != null) { if (RunLocalFilters(data)) { await base.NotifyAsync(ResourceValueChange.Map(data)); } } }
public void SendRequest(NotificationData nd, Action onConfirm) { if (_isListening) //to prevent confirm event for listeners with another notification { return; } _notification = nd; _onConfirm += onConfirm; SendRequest(); }
protected string GetOrDefault(NotificationData data, string key, string defaultValue) { if (data.Properties.TryGetValue(key, out object value)) { // 取得了数据就删除对应键值 // data.Properties.Remove(key); return(value.ToString()); } return(defaultValue); }
private NotificationData BuildNotificationData(Notification notification, NotificationDataStorage notificationsData) { var data = new NotificationData(); if (notification is AbstractCommentNotification commentNotification) { data.Comment = BuildNotificationCommentInfo(notificationsData.CommentsByIds.GetOrDefault(commentNotification.CommentId)); } return(data); }
public NotificationData GetNotificationData(string key = "", string message = "", float time = -1.0f, string resourceIcon = "") { var nd = new NotificationData(); nd.Key = key; nd.Message = message; nd.Time = GetTime(time); nd.ResourceIcon = resourceIcon; return(nd); }
private void CheckAndProcessQueue() { if (_currentNotification == null && _requestsQueue.Count > 0) { _currentNotification = _requestsQueue[0]; _requestsQueue.RemoveAt(0); ChangeBlockState(true); _notification.Notify(_currentNotification); } }
public void Start(NotificationData notificationData) { var activity = (MainActivity)Forms.Context; PeriodicService.Title = notificationData.Title; PeriodicService.StartDateTime = notificationData.StartDateTime; var intent = new Intent(activity, typeof(PeriodicService)); activity.StartService(intent); }
public async Task <IList <Model.Notification> > GetNotificationByClass(string AdmissionNo) { NotificationData obj = new NotificationData(csName); StudentData std = new StudentData(csName); string ClassId = std.Get(AdmissionNo).Class; List <Data.Notification> Result = obj.GetNotificationByClass(ClassId); var NotificationList = Mapper.Map <IList <Data.Notification>, IList <Model.Notification> >(Result); return(NotificationList); }
private void validateCommon(NotificationData d, NotificationView v) { Assert.AreEqual(v.ID, d.ID); Assert.AreEqual(v.ValidFrom, d.ValidFrom); Assert.AreEqual(v.ValidTo, d.ValidTo); Assert.AreEqual(v.ReceiverAccountId, d.ReceiverId); Assert.AreEqual(v.SenderAccountId, d.SenderId); Assert.AreEqual(v.Message, d.Message); Assert.AreEqual(v.IsSeen, d.IsSeen); }
private void CheckConfirmation(NotificationData nd) { if (nd == _notification) { _onConfirm(); _onConfirm = delegate {}; _confirmed.Invoke(); TurnOffListening(); } }
public static void ToHud(string message) { if (Locator.GetPlayerBody() == null) { return; } var data = new NotificationData(NotificationTarget.Player, message.ToUpper()); NotificationManager.SharedInstance.PostNotification(data); }
public bool Warning_Template(IDictionary <string, string> requestData) { if (ValidateData(requestData)) { NotificationData data = CreateWarning(requestData); Notify(data); return(true); } return(false); }
private void UpdateProgress(ToastNotification toast, BindableString title, string value) { NotificationData data = new NotificationData { SequenceNumber = 0 }; data.Values[title.BindingName] = value; ToastNotificationManager.CreateToastNotifier().Update(data, toast.Tag); }
private void NotificationConfirmed(NotificationData nd) { _currentNotification = null; CheckAndProcessQueue(); if (_currentNotification == null) { // _closingChannel.RaiseEvent(nd); _notification.Close(); } }
/// <summary> /// Remove specified notification /// </summary> public static void NotificationDone(NotificationCodes code) { lock (MainLocker) { int CurrID = -1; if (CurrentNotification != -1) { CurrID = ((NotificationData)Notifications[CurrentNotification]).ID; } NotificationData data = new NotificationData(); data.ID = -1; bool ok = false; for (int i = 0; i < Notifications.Count; i++) { data = (NotificationData)Notifications[i]; if (data.Code == code) { ok = true; Notifications.RemoveAt(i); break; } } if (!ok) { return; } string command = "DELETE FROM MainFormNotifications WHERE id = '" + data.ID.ToString() + "';"; int result; ClamWinDatabase.ExecCommand(command, out result); CurrentNotification = -1; for (int i = 0; i < Notifications.Count; i++) { data = (NotificationData)Notifications[i]; if (data.ID == CurrID) { CurrentNotification = i; break; } } if (CurrentNotification == -1 && Notifications.Count != 0) { CurrentNotification = Notifications.Count - 1; } PostCurrentChanged(); } }
/// <summary> /// NotifyOfVideoRequest /// Notifies user of an incoming video request /// </summary> private void NotifyOfVideoRequest(Conversation conversation) { // close the current notification before adding another if(currentNotification != null) { Logger.Debug("Current notification != null"); currentNotification.Close(); currentNotification = null; currentPeerID = 0; } lock(notifyLock) { Person peer = PersonManager.GetPerson(conversation.PeerUser); if(peer == null) return; peer.VideoNotifyCount++; String messageTitle = Catalog.GetString("Incoming Video Chat"); String messageBody = String.Format(Catalog.GetString("{0} is requesting a video chat"), peer.DisplayName); Message[] messages = conversation.GetReceivedMessages(); Notification notification; if(peer.Photo != null) { Gdk.Pixbuf sizedPhoto = peer.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear); notification = new Notification(messageTitle, messageBody, sizedPhoto); } else { Gdk.Pixbuf banterIcon = Application.GetIcon ("banter-44", 44); notification = new Notification(messageTitle, messageBody, banterIcon); } NotificationData data = new NotificationData(conversation, ChatType.Video, peer); pendingData[conversation.PeerUser.ID] = data; notification.AddAction("Accept", Catalog.GetString("Accept"), AcceptNotificationHandler); notification.AddAction("Decline", Catalog.GetString("Decline"), DeclineNotificationHandler); notification.Closed += ClosedNotificationHandler; notification.Timeout = 120000; currentNotification = notification; currentPeerID = conversation.PeerUser.ID; Banter.Application.ShowAppNotification(notification); Gnome.Sound.Play(Path.Combine(Banter.Defines.SoundDir, "notify.wav")); } }
public ChangeCardNotification() { Data = new NotificationData(); }
/// <summary> /// NotifyOfTextMessage /// Notifies user of an incoming text message /// </summary> private void NotifyOfTextMessage(Conversation conversation) { // close the current notification before adding another if(currentNotification != null) { Logger.Debug("Current notification != null"); currentNotification.Close(); currentNotification = null; currentPeerID = 0; } lock(notifyLock) { Person peer = PersonManager.GetPerson(conversation.PeerUser); if(peer == null) return; peer.TextNotifyCount++; String messageTitle = String.Format(Catalog.GetString("Message from {0}"), peer.DisplayName); Message[] messages = conversation.GetReceivedMessages(); String messageBody; if(messages.Length > 0) { messageBody = messages[messages.Length - 1].Text; } else messageBody = ""; // Limit the size of the message that is sent if(messageBody.Length > 200) { messageBody = messageBody.Substring(0, 200); messageBody = messageBody + " ..."; } Notification notification; if(peer.Photo != null) { Gdk.Pixbuf sizedPhoto = peer.Photo.ScaleSimple(48, 48, Gdk.InterpType.Bilinear); notification = new Notification(messageTitle, messageBody, sizedPhoto); } else { Gdk.Pixbuf banterIcon = Application.GetIcon ("banter-44", 44); notification = new Notification(messageTitle, messageBody, banterIcon); } NotificationData data = new NotificationData(conversation, ChatType.Text, peer); pendingData[conversation.PeerUser.ID] = data; notification.AddAction("Accept", Catalog.GetString("Accept"), AcceptNotificationHandler); notification.AddAction("Decline", Catalog.GetString("Decline"), DeclineNotificationHandler); notification.Closed += ClosedNotificationHandler; currentNotification = notification; currentPeerID = conversation.PeerUser.ID; Banter.Application.ShowAppNotification(notification); Gnome.Sound.Play(Path.Combine(Banter.Defines.SoundDir, "notify.wav")); } }
public CardMovedNotification() { Data = new NotificationData(); }