public int GetTimeToWait(long chatId) { var tempIndex = QueueList.IndexOf(QueueList.FirstOrDefault(x => x.ChatId == chatId)); int resultMinutes = 0; for (int i = tempIndex - 1; i >= 0; i--) { resultMinutes += QueueList[i].TimeMinutes; } return(resultMinutes); }
public void AddMoreTime(long chatId, int timeMinutes) { var tempIndex = QueueList.IndexOf(QueueList.FirstOrDefault(x => x.ChatId == chatId)); if (tempIndex == 0) { QueueList[tempIndex].TimeMinutes += timeMinutes; } else { QueueList[tempIndex].TimeMinutes += timeMinutes; } var senderIndex = QueueList.IndexOf(QueueList.First(item => item.ChatId == chatId)); AlertSubscribers(NotificationEventType.TimeChange, senderIndex); }
public async void SkipOrDequeue(long chatId) { var tempIndex = QueueList.IndexOf(QueueList.FirstOrDefault(x => x.ChatId == chatId)); _LogHelper.Log("FDS9FDJ23J423K", $"About to decide (SkipOrDequeue) for index {tempIndex} and chatId {chatId}", LogLevel.Trace, true); if (QueueList.Last().ChatId == chatId || QueueList[tempIndex].FailedAttempts == 1) { _LogHelper.Log("LKN5LK43N543V5CX", "Will dequeue", chatId, LogLevel.Trace); string notificationText = _localizationHelper.GetLocalizedString(StringToLocalize.InactivityDequeueAlert); AlertSubscriber(chatId, notificationText); await _menuLoader.LoadStateMenu(chatId, UserState.InMainMenu); DequeueId(chatId); } else { _LogHelper.Log("43hjh432j4h2klk", $"Will skip. tempindex = {tempIndex}", chatId, LogLevel.Trace); ++QueueList[tempIndex].FailedAttempts; var temp = QueueList[tempIndex]; QueueList[tempIndex] = QueueList[tempIndex + 1]; QueueList[tempIndex + 1] = temp; if (tempIndex == 0) { ProcessUserInBetweenQueueAndRoom(); string notificationText = _localizationHelper.GetLocalizedString(StringToLocalize.SkipFirstAlert) .Replace("[QUEUEPOS]", (tempIndex + 1).ToString()) .Replace("[WAITTIME]", GetTimeToWait(QueueList[tempIndex + 1].ChatId).ToString()); AlertSubscriber(QueueList[tempIndex + 1].ChatId, notificationText); _menuLoader.LoadStateMenu(chatId, UserState.InQueue); } else { string notificationText = _localizationHelper.GetLocalizedString(StringToLocalize.SkipOtherAlert) .Replace("[QUEUEPOS]", tempIndex.ToString()) .Replace("[WAITTIME]", GetTimeToWait(QueueList[tempIndex].ChatId).ToString()); AlertSubscriber(QueueList[tempIndex].ChatId, notificationText); //_menuLoader.LoadStateMenu(chatId, UserState.InQueue); } } }
public int GetPlace(long chatId) { return(QueueList.IndexOf(QueueList.FirstOrDefault(x => x.ChatId == chatId))); }