Example #1
0
        public CalculatorViewModel(
            IAlertsService alertsService,
            IClipboardService clipboardService,
            ICommandFactoryService commandFactoryService,
            INavigationService navigationService,
            IPlatformInformationService platformInformationService)
        {
            _alertsService              = alertsService;
            _clipboardService           = clipboardService;
            _commandFactoryService      = commandFactoryService;
            _navigationService          = navigationService;
            _platformInformationService = platformInformationService;

            AllClearCommand             = _commandFactoryService.Create(AllClear);
            ClearCommand                = _commandFactoryService.Create(Clear);
            DeleteCommand               = _commandFactoryService.Create(async() => await Delete());
            BinaryOperatorCommand       = _commandFactoryService.Create <string>(async(symbol) => await BinaryOperator(symbol));
            UnaryOperatorCommand        = _commandFactoryService.Create <string>(async(symbol) => await UnaryOperator(symbol));
            ParenthesisCommand          = _commandFactoryService.Create <string>(async(parenthesis) => await Parenthesis(parenthesis));
            VariableStorageCommand      = _commandFactoryService.Create <string>(async(symbol) => await VariableStorage(symbol));
            NumberCommand               = _commandFactoryService.Create <string>(async(number) => await Number(number));
            DecimalCommand              = _commandFactoryService.Create(async() => await Decimal());
            CalculateCommand            = _commandFactoryService.Create(async() => await Calculate());
            CopyCommand                 = _commandFactoryService.Create(async() => await Copy());
            PasteCommand                = _commandFactoryService.Create(async() => await Paste());
            SelectInputSectionCommand   = _commandFactoryService.Create <InputSectionViewModel>(async(inputSectionViewModel) => await SelectInputSection(inputSectionViewModel));
            ManageInputCharacterCommand = _commandFactoryService.Create <string>(async(character) => await ManageInputCharacter(character));
            ShowHistoryCommand          = _commandFactoryService.Create(async() => await ShowHistory());
            NavigateToSettingsCommand   = _commandFactoryService.Create(async() => await NavigateToSettings());
            NavigateToAboutCommand      = _commandFactoryService.Create(async() => await NavigateToAbout());

            Input.CollectionChanged += Input_CollectionChanged;
        }
 public ItemViewModel(IItemsService itemsService, IAlertsService alertsService, IHttpContextAccessor httpContextAccessor)
 {
     this.itemsService        = itemsService;
     this.alertsService       = alertsService;
     this.httpContextAccessor = httpContextAccessor;
     this.itemDetailsSubject  = new Subject <FullDetailItem>();
     this.alertsSubject       = new Subject <Alert[]>();
 }
Example #3
0
 public TeamCommands(IAlertsService alertService, IUserSubscriptionsService userSubsService,
                     ITeamService teamService, IUserService userService)
 {
     _alertService    = alertService;
     _userSubsService = userSubsService;
     _teamService     = teamService;
     _userService     = userService;
 }
 public AlertsController(
     IAlertsService alertService,
     IQuotesService quotesService,
     AlertsHub alertsHub
     )
 {
     this.alertsService = alertService;
     this.quotesService = quotesService;
     this.alertsHub     = alertsHub;
 }
 public CreateAlertViewModel(
     IItemsService itemsService,
     IAlertsService alertsService,
     IHttpContextAccessor httpContextAccessor,
     NavigationManager uriHelper)
 {
     this.itemsService        = itemsService;
     this.alertsService       = alertsService;
     this.httpContextAccessor = httpContextAccessor;
     this.uriHelper           = uriHelper;
     this.itemDetailsSubject  = new Subject <FullDetailItem>();
 }
Example #6
0
        public async Task RemoveExpired(DiscordClient client, IAlertsService alertService)
        {
            var alerts = await alertService.GetByType(AlertType.Adventure);

            foreach (var item in alerts)
            {
                if (DateTime.Now - item.SendedAt > completionTime)
                {
                    await alertService.Remove(item);
                }
            }
        }
Example #7
0
        public async Task Alert(DiscordClient client, IAlertsService alertService)
        {
            var alerts = await alertService.GetByType(AlertType.Adventure);

            foreach (var item in alerts)
            {
                if ((DateTime.Now - item.SendedAt) > completionTime)
                {
                    await alertService.Remove(item);

                    await client.GetGuildAsync(item.GuildId)
                    .Result.GetChannel(item.ChannelId)
                    .SendMessageAsync($"{ client.GetUserAsync(item.UserId).Result.Mention}, you are ready for a new **adventure**!");
                }
            }
        }
        public async Task Alert(DiscordClient client, IAlertsService alertService)
        {
            var alerts = await alertService.GetByType(AlertType.GuildRaid);

            foreach (var item in alerts)
            {
                if ((DateTime.Now - item.SendedAt) > completionTime)
                {
                    await alertService.Remove(item);

                    await client.GetGuildAsync(item.GuildId)
                    .Result.GetChannel(item.ChannelId)
                    .SendMessageAsync($"The team { client.GetGuildAsync(item.GuildId).Result.GetRole(815401607382171698).Mention} is ready to **raid**!");
                }
            }
        }
        public static async Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo timer, ILogger log, [Inject] IElasticService elasticService, [Inject] IAlertsService alertsService)
        {
            log.LogInformation($"{nameof(ServiceBusMonitorTimerFunction)} function executed at: {DateTime.UtcNow:yyyy-MM-dd HH::mm:ss}");

            try
            {
                alertsService.Logger = log;
                var elasticIndex     = Environment.GetEnvironmentVariable("ElasticIndex");
                var managementClient = new ManagementClient(Environment.GetEnvironmentVariable("ServiceBusConnection"));
                var queues           = await managementClient.GetQueuesAsync();

                var alertList = new List <Alert>();

                foreach (var queueDescription in queues)
                {
                    log.LogInformation($"Investigating queue '{queueDescription.Path}'");
                    var queue = await managementClient.GetQueueRuntimeInfoAsync(queueDescription.Path);

                    var activeMessageCount     = queue.MessageCountDetails.ActiveMessageCount;
                    var deadLetterMessageCount = queue.MessageCountDetails.DeadLetterMessageCount;
                    log.LogInformation($"Active messages: {activeMessageCount}");
                    log.LogInformation($"Dead letter messages: {deadLetterMessageCount}");

                    var list = await elasticService.ElasticQueueDetailsRepository.GetListAsync(queueDescription.Path);

                    var single = list.FirstOrDefault();

                    if (single == null)
                    {
                        var queueDetails = new ElasticQueueDetails(queueDescription.Path)
                        {
                            ActiveMessagesCount     = activeMessageCount,
                            DeadletterMessagesCount = deadLetterMessageCount,
                            TransferMessagesCount   = queue.MessageCountDetails.TransferMessageCount
                        };
                        await elasticService.PostAsync(elasticIndex, queueDetails);
                    }
                    else
                    {
                        var alert = await alertsService.AuditAsync(single, new ElasticQueueDetails(queueDescription.Path)
                        {
                            ActiveMessagesCount     = activeMessageCount,
                            DeadletterMessagesCount = deadLetterMessageCount,
                            TransferMessagesCount   = queue.MessageCountDetails.TransferMessageCount
                        });

                        if (alert != null)
                        {
                            log.LogInformation($"Found alert and added for dispatch," +
                                               $"{Environment.NewLine}" +
                                               $"{Enum.GetName(typeof(Severity), alert.Severity)}" +
                                               $"{Environment.NewLine}" +
                                               $"Details: '{alert.Message}', {queueDescription.Path}" +
                                               $"{Environment.NewLine}");

                            alertList.Add(alert);
                        }

                        single.ActiveMessagesCount     = activeMessageCount;
                        single.DeadletterMessagesCount = deadLetterMessageCount;
                        single.TransferMessagesCount   = queue.MessageCountDetails.TransferMessageCount;
                        single.Updated = DateTime.UtcNow;
                        await elasticService.PutAsync(elasticIndex, single);
                    }
                }

                if (alertList.Count > 0)
                {
                    var correlations = await alertsService.ProcessAlertsAsync(alertList);

                    foreach (var correlationId in correlations)
                    {
                        log.LogInformation($"Mail message '{correlationId}' was added to queue");
                    }
                }
            }
            catch (Exception exception)
            {
                log.LogError($"Error in {nameof(ServiceBusMonitorTimerFunction)}, details: {exception.Message}");
                throw;
            }
        }
Example #10
0
 public TimerCommands(IAlertsService alertService, IUserSubscriptionsService userSubsService)
 {
     _alertService    = alertService;
     _userSubsService = userSubsService;
 }
Example #11
0
 public AlertsController(IAlertsService alertService)
 {
     _alertService = alertService;
 }