private void CheckVersion(string versionNumber, string versionFile) { var versionText = versionFile; var strings = versionText.Split(new[] { "||" }, StringSplitOptions.None); _history = strings[1]; VersionNumber = strings[0]; if (versionNumber != VersionNumber) { _gameProvider.UsingDb( context => { TelemetryStatic.TelemetryClient = new TelemetryClient(); var parentId = TelemetryStatic.TelemetryClient.Context.Operation.Id; var subscribedChats = context.ChatInTelegrams.Where(chat => chat.Subscribed).ToArray(); Parallel.ForEach(subscribedChats, chat => { TelemetryStatic.TelemetryClient = new TelemetryClient(); var operationContext = TelemetryStatic.TelemetryClient.Context.Operation; operationContext.ParentId = parentId; operationContext.Name = "Update notification"; TelemetryStatic.TelemetryClient.Context.Properties[TelemetryStatic.ChatKey] = chat.Id.ToString(); LocalizedStrings.Language = chat.LanguageIndex; var chatId = chat.Id; var apiChat = new ApiChat(_api, new BotFlow.Persistance.Chat(chatId, ""), _limiter); try { apiChat.Echo(LocalizedStrings.GameUpdatedMessage, 0, null); } catch (ApiChatException exception) { var apiRequestException = exception.InnerException as ApiRequestException; if (apiRequestException != null && apiRequestException.ErrorCode != 400) { throw; //это кейс что Chat was deactivated } } //todo: should return it context.Delete(chat); }); //context.SaveChanges(); }); } }
public IGameStateBanner CreateBanner(string message) { var echo = _apiChat.Echo(message, 0, null); return(new GameStateBanner(echo)); }