public static void Add(this StatusMessages statusMessages, int statusCode) { statusMessages.Add(new StatusMessage() { StatusCode = statusCode }); }
/// <summary> /// Set status message with red font color. /// </summary> /// <param name="message"></param> public void SetStatusMessageWarning(string message, Exception ex = null) { StatusColor = Red; StatusMessages.Add(new StatusMessage { MessageText = message, Data = ex }); StatusText = message; }
/// <summary> /// Set status message in any color /// </summary> /// <param name="message"></param> /// <param name="color"></param> public void SetStatusMessage(string message, Brush color) { StatusColor = color; StatusMessages.Add(new StatusMessage { MessageText = message }); StatusText = message; }
/// <summary> /// Set status message with black color /// </summary> /// <param name="message"></param> public void SetStatusMessage(string message) { StatusColor = Black; StatusMessages.Add(new StatusMessage { MessageText = message }); StatusText = message; }
/// <summary> /// Adds a status message /// </summary> /// <param name="statusMessageText">The text of the status message</param> /// <param name="phoneNumber">The phone number associated with the SMS that this status message describes</param> /// <remarks> /// For example, if the server receives a message from phone number 555-454-3455 updating contact C-0830 to 'seen /// and healthy' then we would assume the status message collection would eventually contain a message stating that, /// so that anyone reading those status messages could see that such an action had taken place. /// </remarks> private void AddStatusMessage(string statusMessageText, string phoneNumber) { SmsStatusMessage message = new SmsStatusMessage(); message.StatusMessage = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " + phoneNumber + " : " + statusMessageText; lock (_statusMessagesLock) { StatusMessages.Add(message); Epi.Logger.Log(message.StatusMessage); } }
private void AddStatusMessage(string message, bool isError = false) { StatusMessage = message; var statusMessageViewModel = new StatusMessageViewModel() { Timestamp = DateTimeOffset.Now, Message = message, IsError = isError }; StatusMessages.Add(statusMessageViewModel); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var phoneNumber = Helpers.SanitizePhone(Input.PhoneNumber); if (await userService.PhoneNumberInUseAsync(phoneNumber)) { StatusMessages.Add(GlobalConstants.PhoneAlreadyUsedError(phoneNumber)); return(Page()); } var user = new UserGE { UserName = Input.UserName, PhoneNumber = phoneNumber }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { var adminRoleName = GlobalConstants.AdministratorRole; await EnsureRoleExists(adminRoleName); await AssignRoleToFirstNUsers(GlobalConstants.AdminsCount, user, adminRoleName); _logger.LogInformation("User created a new account with password."); cache.Remove(GlobalConstants.StatisticsCasheName); StatusMessages.Add("Successfull Registration!"); Thread.Sleep(1000); await _signInManager.SignInAsync(user, isPersistent : true); return(LocalRedirect(returnUrl)); } StatusMessages = result.Errors.Select(x => "Error: " + x.Description).ToList(); } return(Page()); }
private void WriteOutput(string text, OutputMessageLevel level, bool removeLastItem = false) { var messageColor = Colors.Gray; switch (level) { case OutputMessageLevel.Normal: messageColor = Colors.Black; break; case OutputMessageLevel.Informational: messageColor = Colors.Gray; break; case OutputMessageLevel.Success: messageColor = Colors.Green; break; case OutputMessageLevel.Warning: messageColor = Colors.Goldenrod; break; case OutputMessageLevel.Error: messageColor = Colors.Red; break; } if (this.Dispatcher.CheckAccess()) { if (removeLastItem && StatusMessages.Count > 0) { StatusMessages.Remove(StatusMessages.LastOrDefault()); } var message = new OutputMessage { Message = text, MessageColor = messageColor }; StatusMessages.Add(message); StatusListBox.ScrollIntoView(message); } else { this.Dispatcher.Invoke(() => { if (removeLastItem && StatusMessages.Count > 0) { StatusMessages.Remove(StatusMessages.LastOrDefault()); } var message = new OutputMessage { Message = text, MessageColor = messageColor }; StatusMessages.Add(message); StatusListBox.ScrollIntoView(message); }); } }
void backgroundWorkerNewsFeed_ProgressChanged(object sender, ProgressChangedEventArgs e) { FacebookItem item = (FacebookItem)e.UserState; if (item == null) { return; } string notificationClassName = "Facebook " + FullName + " "; if (item.HasUpdatedLikes || item.HasUpdatedComments) { FacebookItem ExistingItem = null; try { switch (item.MessageType) { case FacebookItem.MessageTypes.Link: ExistingItem = Links.Where(oldItem => oldItem.fullId == item.fullId).First(); break; case FacebookItem.MessageTypes.Video: ExistingItem = Videos.Where(oldItem => oldItem.fullId == item.fullId).First(); break; case FacebookItem.MessageTypes.Photo: ExistingItem = Photos.Where(oldItem => oldItem.fullId == item.fullId).First(); break; case FacebookItem.MessageTypes.Note: ExistingItem = Notes.Where(oldItem => oldItem.fullId == item.fullId).First(); break; case FacebookItem.MessageTypes.Event: ExistingItem = Events.Where(oldItem => oldItem.fullId == item.fullId).First(); break; case FacebookItem.MessageTypes.CheckIn: ExistingItem = CheckIns.Where(oldItem => oldItem.fullId == item.fullId).First(); break; default: ExistingItem = StatusMessages.Where(oldItem => oldItem.fullId == item.fullId).First(); break; } if (item.HasUpdatedLikes) { string notificationText = ""; if (!string.IsNullOrWhiteSpace(item.Text)) { notificationText += item.Text.Substring(0, Math.Min(20, item.Text.Length - 1)) + "... "; } else { notificationText += "Facebook item... "; } notificationText += "has new likes"; if (item.isLiked) { AppController.Current.sendNotification(notificationClassName + "Like", notificationText, "The item has " + (item.LikesCount - ExistingItem.LikesCount).ToString() + " new likes", item.User.Avatar, null); } else { AppController.Current.sendNotification(notificationClassName + "Like (on message you didn't comment or like yourself)", notificationText, "The item has " + (item.LikesCount - ExistingItem.LikesCount).ToString() + " new likes", item.User.Avatar, null); } ExistingItem.UpdatedAt = item.UpdatedAt; ExistingItem.LikesCount = item.LikesCount; } if (item.HasUpdatedComments) { foreach (FacebookComment newComment in item.Comments) { if (item.isCommented) { AppController.Current.sendNotification(notificationClassName + "Comment", "New comment on entry of " + ExistingItem.User.FullName, newComment.Text + "\r\nby " + newComment.User.FullName, newComment.User.Avatar, null); } else { AppController.Current.sendNotification(notificationClassName + "Comment (on message you didn't comment or like yourself)", "New comment on entry of " + ExistingItem.User.FullName, newComment.Text + "\r\nby " + newComment.User.FullName, newComment.User.Avatar, null); } ExistingItem.Comments.Add(newComment); ExistingItem.UpdatedAt = item.UpdatedAt; } } } catch (Exception exp) { AppController.Current.Logger.writeToLogfile(exp); } } else { switch (item.MessageType) { case FacebookItem.MessageTypes.Link: Links.Add(item); if (InitialUpdateDoneForLinks) { notificationClassName += "Link"; } break; case FacebookItem.MessageTypes.Video: Videos.Add(item); if (InitialUpdateDoneForVideos) { notificationClassName += "Video"; } break; case FacebookItem.MessageTypes.Photo: Photos.Add(item); if (InitialUpdateDoneForPhotos) { notificationClassName += "Photo"; } break; case FacebookItem.MessageTypes.Note: Notes.Add(item); if (InitialUpdateDoneForNotes) { notificationClassName += "Note"; } break; case FacebookItem.MessageTypes.Event: Events.Add(item); if (InitialUpdateDoneForEvents) { notificationClassName += "Event"; } break; case FacebookItem.MessageTypes.CheckIn: CheckIns.Add(item); if (InitialUpdateDoneForCheckIns) { notificationClassName += "CheckIn"; } break; default: StatusMessages.Add(item); if (InitialUpdateDoneForStatusMessages) { notificationClassName += "Status message"; } break; } if (notificationClassName != "Facebook " + FullName + " ") { AppController.Current.sendNotification(notificationClassName, item.User.FullName, item.Text, item.Avatar, item); } } }