protected void UserStatusDropDownList_SelectedIndexChanged(object sender, EventArgs e) { var userStatusDropDownList = (DropDownList)sender; var applicationRow = Utility.FindParentControl <GridDataItem>(userStatusDropDownList); var userId = (int)applicationRow.GetDataKeyValue("UserId"); int statusId; int?statusIdValue = null; if (int.TryParse(userStatusDropDownList.SelectedValue, NumberStyles.Integer, CultureInfo.InvariantCulture, out statusId)) { statusIdValue = statusId; } else if (Utility.HasValue(userStatusDropDownList.SelectedValue)) { Exceptions.LogException(new InvalidOperationException("During update of application status, StatusId could not be parsed.")); } UserStatusInfo.UpdateUserStatus(this.PortalSettings, userId, statusIdValue); // collapse all other application grids, so that the user's status isn't out of sync foreach (GridDataItem item in this.JobsGrid.MasterTableView.Items.Cast <GridDataItem>() .Where(item => item.Expanded && item != applicationRow.OwnerTableView.ParentItem)) { item.Expanded = false; } }
public void UpdateStatusView(UserStatusInfo userStatusInfo) { hpText.text = userStatusInfo.hp.ToString(); battlePowerText.text = userStatusInfo.battlePower.ToString(); movingPowerText.text = userStatusInfo.movingPower.ToString(); attackRangeText.text = userStatusInfo.attackRange.ToString(); hitRateText.text = userStatusInfo.hitRate.ToString(); }
public ClientInfo( ) { SdkRevision = new SdkRevision(); Status = new UserStatus(); StatusInfo = new UserStatusInfo(); CreatedTime = DateTime.Now; LoginPhase = LoginStatus.Connected; }
/// <summary> /// Read status from Facebook and separate them into list /// </summary> public void ReadStatus(UserStatusInfo Data) { int dataCount = Data.Feed.Data.Count(); for (int i = 0; i < dataCount; i++) { string statusMessage = Data.Feed.Data[i].Message; if (statusMessage != null) { try { if (statusMessage.Contains("#fb5")) StatusMessage(i, Data, VeryHappyList); else if (statusMessage.Contains("#fb4")) StatusMessage(i, Data, HappyList); else if (statusMessage.Contains("#fb3")) StatusMessage(i, Data, OkList); else if (statusMessage.Contains("#fb2")) StatusMessage(i, Data, SadList); else if (statusMessage.Contains("#fb1")) StatusMessage(i, Data, VerySadList); else StatusMessage(i, Data, NoCategoryList); } catch(Exception) { } } } /// <summary> /// Save all types of list in Isolated Storage /// </summary> SessionStorage.SaveStatus(VeryHappyList, AppConstants.VeryHappyStatusListName); SessionStorage.SaveStatus(HappyList, AppConstants.HappyStatusListName); SessionStorage.SaveStatus(OkList, AppConstants.OkStatusListName); SessionStorage.SaveStatus(SadList, AppConstants.SadStatusListName); SessionStorage.SaveStatus(VerySadList, AppConstants.VerySadStatusListName); SessionStorage.SaveStatus(NoCategoryList, AppConstants.NoCateogryStatusListName); /// <summary> /// Load saved list from Isolated Storage /// </summary> var s = SessionStorage.LoadStatus(VeryHappyList, AppConstants.VeryHappyStatusListName); }
/// <summary> /// Status Handling Function, adds particular feed in particular list /// </summary> public List<Datum> StatusMessage(int i, UserStatusInfo Data, List<Datum> list) { var result = Data.Feed.Data[i]; list.Add(new Datum() { Caption = result.Caption, Message = result.Message, FullPicture = result.FullPicture, Privacy = result.Privacy, Description = result.Description, Id = result.Id, CreatedTime = result.CreatedTime, Likes = result.Likes, Comments = result.Comments }); return list; }
/// <summary> /// Gets the name of the user's status. /// </summary> /// <param name="userId">The user ID, or <c>null</c> for an anonymous user.</param> /// <returns>The name of the status, or <c>null</c> for an anonymous user or user without a status</returns> protected string GetUserStatusName(int?userId) { try { if (userId.HasValue) { var statusId = UserStatusInfo.LoadUserStatus(this.PortalSettings, userId.Value); if (statusId.HasValue) { return(UserStatus.LoadStatus(statusId.Value).Status); } } } catch (NullReferenceException) { // thrown from LoadUserStatus if user doesn't exist (has been deleted after applying). BD } return(null); }
/// <summary> /// Gets the user status for the given user. /// </summary> /// <param name="userId">The ID of the user, or <c>null</c> for an anonymous user.</param> /// <returns>The ID of the user's status</returns> protected string GetUserStatus(int?userId) { try { if (userId.HasValue) { var statusId = UserStatusInfo.LoadUserStatus(this.PortalSettings, userId.Value); if (statusId.HasValue) { return(statusId.Value.ToString(CultureInfo.InvariantCulture)); } } } catch (NullReferenceException) { // thrown from LoadUserStatus if user doesn't exist (has been deleted after applying). BD } return(string.Empty); }
private async Task Client_GuildMemberUpdated(SocketGuildUser arg1, SocketGuildUser arg2) { await Log(new LogMessage(LogSeverity.Info, "UserUpdate", $"{arg2.Username} updated")); if (arg1.Status != arg2.Status || arg1.Activity?.Name != arg2.Activity?.Name) { DateTimeOffset currentTime = DateTimeOffset.Now; if (Statuses.Statuses.ContainsKey(arg2.Id)) { var previousStatus = Statuses.Statuses[arg2.Id]; if (arg1.Status != arg2.Status) { previousStatus.StatusLastChanged = currentTime; if (arg1.Status == UserStatus.Online) { previousStatus.LastOnline = currentTime; } } if (arg1.Activity?.Name != arg2.Activity?.Name) { previousStatus.Game = arg2.Activity?.Name; previousStatus.StartedPlaying = DateTimeOffset.Now; } } else { UserStatusInfo status = new UserStatusInfo { StatusLastChanged = currentTime, LastOnline = arg1.Status == UserStatus.Online ? currentTime : DateTimeOffset.MinValue, Game = null, StartedPlaying = null, LastMessageSent = DateTimeOffset.MinValue }; Statuses.Statuses.Add(arg2.Id, status); } } }
private async Task Client_Ready() { try { DateTimeOffset currentTime = DateTimeOffset.Now; UserStatusInfo status = new UserStatusInfo { StatusLastChanged = currentTime, LastOnline = currentTime, Game = null, StartedPlaying = null }; Statuses.Statuses.Remove(Client.CurrentUser.Id); Statuses.Statuses.Add(Client.CurrentUser.Id, status); if (Settings.OwnerId != null) { if (Settings.AnnounceStartup.HasValue && Settings.AnnounceStartup.Value) { #if !DEBUG await Client.GetUser(Settings.OwnerId.Value).SendMessageAsync($"[{TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset.Now, DefaultTimeZone)}] Now online!"); #else await Client.GetUser(Settings.OwnerId.Value).SendMessageAsync($"[DEBUG] [{TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset.Now, DefaultTimeZone)}] Now online!"); #endif } if (File.Exists(ExceptionFilePath)) { string message = "***The bot has restarted due to an error***:\n\n" + File.ReadAllText(ExceptionFilePath); foreach (string m in Enumerable.Range(0, message.Length / 1500 + 1).Select(i => message.Substring(i * 1500, message.Length - i * 1500 > 1500 ? 1500 : message.Length - i * 1500))) { await Client.GetUser(Settings.OwnerId.Value).SendMessageAsync(m); } File.Delete(ExceptionFilePath); } } if (Settings.StartupReplyChannel.HasValue) { await((ITextChannel)Client.GetChannel(Settings.StartupReplyChannel.Value)).SendMessageAsync("I return! You can never escape me!"); Settings.StartupReplyChannel = null; Settings.SaveConfig(); } if (Settings.Game != null) { await Client.SetGameAsync(Settings.Game); } Reminders.Reminders = Reminders.Reminders ?? new List <ReminderInfo>(); ulong tick = 0; while (true) { if (tick % 60 == 0) { MinuteTimer(tick / 60); } SecondTimer(tick++); await Task.Delay(1000); } } catch (Exception ex) { if (Settings.OwnerId.HasValue) { await Client.GetUser(Settings.OwnerId.Value).SendMessageAsync($"[ERROR] [{TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTimeOffset.Now, DefaultTimeZone)}] {ex}"); } } }