Beispiel #1
0
        private void UpdateActiveAlerts()
        {
            var customers        = new List <Customer>();
            var alertDefinitions = new AlertDefinitionRepository(_monilyzerContext).GetAlertDefinitions(DateTime.UtcNow);
            var activeAlerts     = new List <ActiveAlert>();

            foreach (var alertDefinition in alertDefinitions)
            {
                if (alertDefinition.AlertObjectType == MonilyzerObjectType.Customer)
                {
                    if (customers.Count == 0)
                    {
                        customers = new CustomerRepository(_monilyzerContext).GetCustomers().ToList();
                    }

                    foreach (var customer in customers)
                    {
                        activeAlerts.AddRange(AlertService.EvaluateCustomerAlerts(customer, alertDefinitions));
                    }
                }
            }

            new ActiveAlertRepository(_monilyzerContext).InsertUpdateActiveAlerts(activeAlerts);
        }
Beispiel #2
0
        public async Task <YoutubeDataItem> GetFromHistory(string id)
        {
            YoutubeDataItem ret = null;

            try
            {
                LoggingService.LogInformation("GetFromHistory'", "YouTubeService.GetFromHistory");

                var found = AppDatabase.Current.RetrieveYoutubeHistoryItemByID(id);
                if (found != null && found.Count > 0)
                {
                    var item = found.First();

                    var ytdi = new YoutubeDataItem(item.Uid, item.Title, item.Subtitle, item.ImagePath, item.Description, item.VideoId, null);
                    ret = ytdi;
                }
            }
            catch (Exception ex)
            {
                AlertService.LogAlertMessage("Error retrieving History from Cache", ex.Message);
            }

            return(ret);
        }
 public HomeController(AlertService alertService)
 {
     _alertService = alertService;
 }
 public VideoGameController(IConfiguration configuration, AlertService alertService)
 {
     config            = configuration;
     this.alertService = alertService;
 }
Beispiel #5
0
 public void AlertAcknowledge(string alertCode)
 {
     AlertService.Delete(alertCode);
     Console.WriteLine("Button was clicked!");
 }
Beispiel #6
0
 public DeviceController(WebSocketHandler websocketHandler, DeviceService deviceService, HeartbeatService heartbeatService, AlertService alertService)
 {
     _deviceService    = deviceService;
     _heartbeatService = heartbeatService;
     _alertService     = alertService;
     _websocketHandler = websocketHandler;
 }
Beispiel #7
0
 public AlertForm(AlertService alertService)
 {
     _alertService = alertService;
 }
 public ServerSettingsViewModel(INavigationService n, StudioServicesApi a, AlertService al, KeyValueService k) : base(n, a, al, k)
 {
 }
Beispiel #9
0
 public RaportController(IKompaniaRepository _kompaniaRepository, IPunetoriRepository _punetoriRepository, IPagaRepository _pagaRepository,
                         IGradaRepository _gradaRepository, IBankRepository _bankRepository, IRaportRepository _raportRepository, IHttpContextAccessor _httpContextAccessor, IWebHostEnvironment _webHostEnvironment,
                         RoleManager <IdentityRole> _roleManager, UserManager <ApplicationUser> _userManager, AlertService _alertService)
     : base(_roleManager, _userManager)
 {
     kompaniaRepository  = _kompaniaRepository;
     punetoriRepository  = _punetoriRepository;
     pagaRepository      = _pagaRepository;
     gradaRepository     = _gradaRepository;
     bankRepository      = _bankRepository;
     raportRepository    = _raportRepository;
     httpContextAccessor = _httpContextAccessor;
     session             = httpContextAccessor.HttpContext.Session;
     webHostEnvironment  = _webHostEnvironment;
     System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
 }
Beispiel #10
0
 public OrderController(AlertService alertService)
 {
     this.alertService = alertService;
 }
        /// <summary>
        /// Detects the anomalies and generate alert.
        /// </summary>
        /// <param name="timerInfo">The timer information.</param>
        /// <returns>
        /// A <see cref="Task" /> representing the asynchronous operation.
        /// </returns>
        public static async Task ProcessAnomalyDetection([TimerTrigger("0 0 0 * * *")] TimerInfo timerInfo)
        {
            try
            {
                var alertService = new AlertService();
                var meterService = new MeterService();
                var requestModel = new AnomalyServiceRequest();

                using (SqlConnection sqlConnection = new SqlConnection(ConfigurationSettings.DbConnectionString))
                {
                    sqlConnection.Open();

                    var piServers = meterService.GetPiServerList(sqlConnection);

                    foreach (var piServer in piServers)
                    {
                        try
                        {
                            DateTime anomalyDetectionStartTime = piServer.PiServerCurrentDateTime.AddDays(-1).Date;
                            DateTime anomalyDetectionEndTime   = anomalyDetectionStartTime.AddHours(24).AddSeconds(-1);

                            using (SqlTransaction sqlTransaction = sqlConnection.BeginTransaction())
                            {
                                var query = "SELECT PowerScout, Temperature, Timestamp, Visibility, kW_System, days, Breaker_details FROM LiveData WHERE Timestamp > @startTime AND Timestamp <= @endTime and PiServerName = @PiServerName  ORDER BY Timestamp";

                                requestModel.GlobalParameters = new GlobalParameter();
                                Inputs inputs = new Inputs();
                                Input1 input  = new Input1()
                                {
                                    ColumnNames = new List <string> {
                                        "PowerScout", "Temperature", "Timestamp", "Visibility", "kW_System", "days", "Breaker_details"
                                    }
                                };
                                List <List <string> > values = new List <List <string> >();

                                using (SqlCommand selectDataCommand = new SqlCommand(query, sqlConnection, sqlTransaction))
                                {
                                    selectDataCommand.Parameters.AddWithValue("@startTime", anomalyDetectionStartTime.ToString(Constants.DATE_TIME_FORMAT));
                                    selectDataCommand.Parameters.AddWithValue("@endTime", anomalyDetectionEndTime.ToString(Constants.DATE_TIME_FORMAT));
                                    selectDataCommand.Parameters.AddWithValue("@PiServerName", piServer.PiServerName);

                                    using (SqlDataReader result = selectDataCommand.ExecuteReader())
                                    {
                                        List <string> rowValues = null;

                                        while (result.Read())
                                        {
                                            rowValues = new List <string>();

                                            rowValues.Add(SqlTypeConverter.ToString(result["PowerScout"]));
                                            rowValues.Add(SqlTypeConverter.ToString(result["Temperature"]));
                                            rowValues.Add(SqlTypeConverter.ToDateTime(result["Timestamp"]).ToString(Constants.DATE_TIME_FORMAT));
                                            rowValues.Add(SqlTypeConverter.ToString(result["Visibility"]));
                                            rowValues.Add(SqlTypeConverter.ToString(result["kW_System"]));
                                            rowValues.Add(SqlTypeConverter.ToString(result["days"]));
                                            rowValues.Add(SqlTypeConverter.ToString(result["Breaker_details"]));
                                            values.Add(rowValues);
                                        }

                                        result.Close();
                                    }
                                }

                                if (values.Count > 0)
                                {
                                    input.Values        = values;
                                    inputs.input1       = input;
                                    requestModel.Inputs = inputs;
                                    var azureMLConfigurationService = new AzureMLConfigurationService();
                                    var anomalyConfig = azureMLConfigurationService.GetAnomalyConfigData(sqlConnection, sqlTransaction);
                                    var responseModel = await AzureMLClient.CallAzureMLAsync(requestModel, anomalyConfig.AzureMlAnomalyDetectionApiUrl, anomalyConfig.AzureMlAnomalyDetectionApiKey);

                                    if (responseModel != null)
                                    {
                                        AddAnomalyToDatabase(sqlConnection, sqlTransaction, responseModel, piServer.PiServerName, anomalyDetectionStartTime, anomalyDetectionEndTime, alertService);
                                    }
                                }

                                sqlTransaction.Commit();
                            }
                        }
                        catch (Exception e)
                        {
                            var errorMsg = string.Format("AnomalyDetectionJob Error : Anomaly detection failed for pi server - {0}", piServer.PiServerName);

                            Console.WriteLine(errorMsg);
                            Console.WriteLine("Error Message - {0}", e.Message);
                            Console.WriteLine("StackTrace - {0}", e.StackTrace);

                            ApplicationInsightsLogger.LogException(e, new Dictionary <string, string> {
                                { "Job Error Message", errorMsg }
                            });
                        }
                    }

                    sqlConnection.Close();
                }
            }
            catch (Exception e)
            {
                ApplicationInsightsLogger.LogException(e);

                throw;
            }
        }
        private static void AddAnomalyToDatabase(SqlConnection sqlConnection, SqlTransaction sqlTransaction, AnomalyServiceResponse anomalyServiceResponseModel, string piServerName, DateTime anomalyDetectionStartTime, DateTime anomalyDetectionEndTime, AlertService alertService)
        {
            List <List <string> > filteredAnomalies = anomalyServiceResponseModel.Results.Output1.Value.Values.Where(x => Convert.ToDouble(x.ElementAt(8)) < ConfigurationSettings.AnomalyThreshold).ToList();

            string anomalyoutputInsertQuery = "INSERT INTO AnomalyOutput(PowerScout, Temperature,Timestamp,Visibility,days,Breaker_details,kW_System,ScoredLabels,ScoredProbabilities, PiServername) VALUES (@PowerScout,@Temperature,@Timestamp,@Visibility,@days,@Breaker_details,@kW_System,@ScoredLabels,@ScoredProbabilities, @PiServerName)";

            foreach (var rowData in filteredAnomalies)
            {
                using (SqlCommand cmd = new SqlCommand(anomalyoutputInsertQuery, sqlConnection, sqlTransaction))
                {
                    cmd.Parameters.AddWithValue("@PowerScout", rowData.ElementAt(0).ToString());
                    cmd.Parameters.AddWithValue("@Temperature", Convert.ToDouble(rowData.ElementAt(1)));
                    cmd.Parameters.AddWithValue("@Timestamp", Convert.ToDateTime(rowData.ElementAt(2), CultureInfo.InvariantCulture).ToString(Constants.DATE_TIME_FORMAT));
                    cmd.Parameters.AddWithValue("@Visibility", Convert.ToDouble(rowData.ElementAt(3)));
                    cmd.Parameters.AddWithValue("@days", rowData.ElementAt(4).ToString());
                    cmd.Parameters.AddWithValue("@Breaker_details", rowData.ElementAt(5).ToString());
                    cmd.Parameters.AddWithValue("@kW_System", Convert.ToDouble(rowData.ElementAt(6)));
                    cmd.Parameters.AddWithValue("@ScoredLabels", Convert.ToDouble(rowData.ElementAt(7)));
                    cmd.Parameters.AddWithValue("@ScoredProbabilities", Convert.ToDouble(rowData.ElementAt(8)));
                    cmd.Parameters.AddWithValue("@PiServerName", piServerName);

                    cmd.ExecuteNonQuery();
                }
            }

            if (filteredAnomalies.Count > 0)
            {
                string anomalyAlertMessage = string.Format(Constants.ANOMALY_ALERT_MESSAGE, filteredAnomalies.Count, anomalyDetectionStartTime, anomalyDetectionEndTime);

                var alert = new Alert
                {
                    AlertType    = Constants.ALERT_TYPE_ANOMALY,
                    Description  = anomalyAlertMessage,
                    TimeStamp    = anomalyDetectionStartTime,
                    PiServerName = piServerName
                };
                alertService.AddNewAlert(sqlConnection, sqlTransaction, alert);
            }

            Console.WriteLine("AnomalyDetectionJob RowInserted : Created alert and anomaly for PiServer - {0}.", piServerName);
        }
 public DepartamentiController(IDepartamentiRepository _departamentiRepository, IKompaniaRepository _kompaniaRepository, RoleManager <IdentityRole> _roleManager, UserManager <ApplicationUser> _userManager, AlertService _alertService)
     : base(_roleManager, _userManager)
 {
     alertService           = _alertService;
     userManager            = _userManager;
     roleManager            = _roleManager;
     departamentiRepository = _departamentiRepository;
     kompaniaRepository     = _kompaniaRepository;
 }
 public AlertController()
 {
     db           = new MyDBcontext();
     alertService = new AlertService();
 }
 public AddInvoiceProductPopupViewModel(INavigationService n, StudioServicesApi a, AlertService al, KeyValueService k) : base(n, a, al, k)
 {
 }
Beispiel #16
0
 private void OnAlertDangerAddClick()
 {
     AlertService.Add($"Error at: {DateTime.Now}", BBComponents.Enums.BootstrapColors.Danger);
 }
Beispiel #17
0
 private void OnAlertNonDismissableClick()
 {
     AlertService.Add($"Non dismissable info at: {DateTime.Now}", BBComponents.Enums.BootstrapColors.Info, 0);
 }
Beispiel #18
0
 public InvoiceCreationDetailsViewModel(INavigationService n, StudioServicesApi a, AlertService al, KeyValueService k) : base(n, a, al, k)
 {
 }
Beispiel #19
0
 public WarehouseInvoiceListViewModel(INavigationService n, StudioServicesApi a, AlertService al, KeyValueService k) : base(n, a, al, k)
 {
     // Costruttore
 }
        public AlohaService()
        {
            LogHelper.Configure();
            log = LogHelper.GetLogger();
            if (!MapperInited)
            {
                try
                {
                    Mapper.Initialize(cfg =>
                    {
                        //cfg.CreateMap<ServiceDataContracts.Dish, Entities.Dish>().ReverseMap();
                        cfg.CreateMap <ServiceDataContracts.Dish, Entities.Dish>().ReverseMap();
                        cfg.CreateMap <ServiceDataContracts.DishPackageToGoOrder, Entities.DishPackageToGoOrder>()
                        .ForMember(m => m.Dish, opt => opt.Ignore())
                        .ForMember(m => m.OrderToGo, opt => opt.Ignore());

                        cfg.CreateMap <Entities.DishPackageToGoOrder, ServiceDataContracts.DishPackageToGoOrder>()
                        .ForMember(m => m.Dish, opt => opt.Ignore())
                        .ForMember(m => m.OrderToGo, opt => opt.Ignore());


                        cfg.CreateMap <ServiceDataContracts.DishPackageFlightOrder, Entities.DishPackageFlightOrder>()
                        .ForMember(m => m.Dish, opt => opt.Ignore())
                        .ForMember(m => m.OrderFlight, opt => opt.Ignore())
                        .ReverseMap();

                        cfg.CreateMap <ServiceDataContracts.User, Entities.User>()
                        .ForMember(m => m.UserRole, opt => opt.Ignore())
                        //.ForMember(m => m.OrderFlight, opt => opt.Ignore())
                        .ReverseMap();

                        /*
                         * cfg.CreateMap<ServiceDataContracts.OrderToGo, Entities.OrderToGo>()
                         * //.ForMember(m => m., opt => opt.Ignore())
                         * //.ForMember(m => m.OrderFlight, opt => opt.Ignore())
                         * .ReverseMap();
                         */
                        cfg.CreateMap <ServiceDataContracts.Driver, Entities.Driver>()
                        .ReverseMap();


                        cfg.CreateMap <ServiceDataContracts.OrderFlight, Entities.OrderFlight>()
                        .ForMember(m => m.AirCompany, opt => opt.Ignore())
                        .ForMember(m => m.ContactPerson, opt => opt.Ignore())
                        .ForMember(m => m.CreatedBy, opt => opt.Ignore())
                        .ForMember(m => m.DeliveryPlace, opt => opt.Ignore())
                        .ForMember(m => m.PaymentType, opt => opt.Ignore())
                        .ForMember(m => m.SendBy, opt => opt.Ignore())
                        .ForMember(m => m.WhoDeliveredPersonPerson, opt => opt.Ignore())
                        .ReverseMap();

                        cfg.CreateMap <ServiceDataContracts.OrderToGo, Entities.OrderToGo>()
                        .ForMember(m => m.DishPackages, opt => opt.MapFrom(a => a.DishPackages.ToList()))

                        //.ForMember(m => m.DishPackages, a=> a.MapFrom<List<Entities.DishPackageToGoOrder>, List<ServiceDataContracts.DishPackageToGoOrder>>(a.))
                        .ReverseMap();


                        cfg.CreateMap <ServiceDataContracts.OrderCustomer, Entities.OrderCustomer>()
                        .ReverseMap();
                        cfg.CreateMap <ServiceDataContracts.OrderCustomerPhone, Entities.OrderCustomerPhone>()
                        .ReverseMap();
                        cfg.CreateMap <ServiceDataContracts.OrderCustomerAddress, Entities.OrderCustomerAddress>()
                        .ReverseMap();
                        cfg.CreateMap <ServiceDataContracts.OrderCustomerInfo, Entities.OrderCustomerInfo>()
                        .ReverseMap();
                    });

                    //Mapper.Initialize(cfg => cfg.CreateMap<ServiceDataContracts.DishPackageFlightOrder, Entities.DishPackageFlightOrder>().ReverseMap());
                    //Mapper.Initialize(cfg => cfg.CreateMap<ServiceDataContracts.DishPackageToGoOrder, Entities.DishPackageToGoOrder>().ReverseMap());

                    //Mapper.Initialize(cfg => cfg.CreateMap<ServiceDataContracts.Dish, Entities.Dish>().ReverseMap());
                    //Mapper.Initialize(cfg => cfg.CreateMap<Entities.Dish, ServiceDataContracts.Dish>());

                    MapperInited = true;
                    log.Debug("Mapper.Initialize ok");
                }
                catch (Exception e)
                {
                    log.Error("Mapper.Initialize error " + e.Message);
                }
            }
            userService          = new UserService(new AlohaDb());
            orderService         = new OrderService(new AlohaDb());
            airCompanyService    = new AirCompanyService(new AlohaDb());
            userGroupService     = new UserGroupService(new AlohaDb());
            contactPersonService = new ContactPersonService(new AlohaDb());

            curierService                 = new CurierService(new AlohaDb());
            deliveryPersonService         = new DeliveryPersonService(new AlohaDb());
            deliveryPlaceService          = new DeliveryPlaceService(new AlohaDb());
            marketingChannelService       = new MarketingChannelService(new AlohaDb());
            dishPackageFlightOrderService = new DishPackageFlightOrderService(new AlohaDb());
            dishPackageToGoOrderService   = new DishPackageToGoOrderService(new AlohaDb());
            dishService                 = new DishService(new AlohaDb());
            driverService               = new DriverService(new AlohaDb());
            itemLabelInfoService        = new ItemLabelInfoService(new AlohaDb());
            orderCustomerService        = new OrderCustomerService(new AlohaDb());
            orderFlightService          = new OrderFlightService(new AlohaDb());
            orderToGoService            = new OrderToGoService(new AlohaDb());
            discountService             = new DiscountService(new AlohaDb());
            alertService                = new AlertService(new AlohaDb());
            paymentService              = new PaymentService(new AlohaDb());
            paymentGroupService         = new PaymentGroupService(new AlohaDb());
            dishLogicGroupService       = new DishLogicGroupService(new AlohaDb());
            dishKitchenGroupService     = new DishKitchenGroupService(new AlohaDb());
            logItemService              = new LogItemService(new AlohaDb());
            orderCustomerAddressService = new OrderCustomerAddressService(new AlohaDb());
            orderCustomerPhoneService   = new OrderCustomerPhoneService(new AlohaDb());
            updaterService              = new UpdaterService(new AlohaDb());
        }
 public HomeController(ILogger <HomeController> logger, AlertService alertService)
 {
     _logger           = logger;
     this.alertService = alertService;
 }
Beispiel #22
0
 public AlertServiceTests()
 {
     Alerts = new AlertService(null, null, null);
 }
Beispiel #23
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Get the AlertService.
            AlertService alertService = (AlertService)user.GetService(
                AdWordsService.v201402.AlertService);

            // Create the selector.
            AlertSelector selector = new AlertSelector();

            // Create the alert query.
            AlertQuery query = new AlertQuery();

            query.filterSpec      = FilterSpec.ALL;
            query.clientSpec      = ClientSpec.ALL;
            query.triggerTimeSpec = TriggerTimeSpec.ALL_TIME;
            query.severities      = new AlertSeverity[] { AlertSeverity.GREEN, AlertSeverity.YELLOW,
                                                          AlertSeverity.RED };

            // Enter all possible values of AlertType to get all alerts. If you are
            // interested only in specific alert types, then you may also do it as
            // follows:
            // query.types = new AlertType[] {AlertType.CAMPAIGN_ENDING,
            //     AlertType.CAMPAIGN_ENDED};
            query.types    = (AlertType[])Enum.GetValues(typeof(AlertType));
            selector.query = query;

            // Set paging for selector.
            selector.paging = new Paging();

            int offset   = 0;
            int pageSize = 500;

            AlertPage page = new AlertPage();

            try {
                do
                {
                    // Get account alerts.
                    selector.paging.startIndex    = offset;
                    selector.paging.numberResults = pageSize;

                    page = alertService.get(selector);

                    // Display the results.
                    if (page != null && page.entries != null)
                    {
                        int i = offset;
                        foreach (Alert alert in page.entries)
                        {
                            Console.WriteLine("{0}) Customer Id is {1:###-###-####}, Alert type is '{2}', " +
                                              "Severity is {3}", i + 1, alert.clientCustomerId, alert.alertType,
                                              alert.alertSeverity);
                            for (int j = 0; j < alert.details.Length; j++)
                            {
                                Console.WriteLine("  - Triggered at {0}", alert.details[j].triggerTime);
                            }
                            i++;
                        }
                    }
                    offset += pageSize;
                } while (offset < page.totalNumEntries);
                Console.WriteLine("Number of alerts found: {0}", page.totalNumEntries);
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to retrieve alerts.", ex);
            }
        }
Beispiel #24
0
 public ManagerController(IConfiguration configuration, AlertService alertService)
 {
     config            = configuration;
     this.alertService = alertService;
 }
 public ViewUserProfileContactsViewModel(INavigationService n, StudioServicesApi a, AlertService al, KeyValueService k) : base(n, a, al, k)
 {
 }
Beispiel #26
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            //Frame rootFrame = Window.Current.Content as Frame;

            //// Do not repeat app initialization when the Window already has content,
            //// just ensure that the window is active
            //if (rootFrame == null)
            //{
            //    // Create a Frame to act as the navigation context and navigate to the first page
            //    rootFrame = new Frame();

            //    // Set the default language
            //    rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

            //    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            //    {
            //        //TODO: Load state from previously suspended application
            //    }

            //    // Place the frame in the current Window
            //    Window.Current.Content = rootFrame;
            //}

            //if (rootFrame.Content == null)
            //{
            //    // When the navigation stack isn't restored navigate to the first page,
            //    // configuring the new page by passing required information as a navigation
            //    // parameter

            //    //if (!rootFrame.Navigate(typeof(SplashScreen), e.Arguments))
            //    if (!rootFrame.Navigate(typeof(ModernCSApp2.MasterPage), e.Arguments))
            //    {
            //        throw new Exception("Failed to create initial page");
            //    }
            //}



            LoggingService.Init(AppDatabase.Current);
            LoggingService.Start();
            LoggingService.LogInformation("launching app...", "App.OnLaunched");

            AlertService.Init(AppDatabase.Current);
            AlertService.Start();
            LoggingService.LogInformation("initialized alerts...", "App.OnLaunched");

            GestureService.Init();
            LoggingService.LogInformation("initialized gensture manager...", "App.OnLaunched");

            AppDatabase.Current.LoadInstances();
            LoggingService.LogInformation("loaded appstate ...", "App.OnLaunched");

            AppService.Init();
            AppService.Start();
            LoggingService.LogInformation("initialized app services ...", "App.OnLaunched");

            WindowLayoutService.Init();
            LoggingService.LogInformation("initialized window layout services ...", "App.OnLaunched");



            var mp = new ModernCSApp.MasterPage(false);
            Window.Current.Content = mp;

            // Ensure the current window is active
            Window.Current.Activate();
        }
 public AddCompanyProductViewModel(INavigationService n, StudioServicesApi a, AlertService al, KeyValueService k) : base(n, a, al, k)
 {
 }
Beispiel #28
0
        public static IHostBuilder CreateLinuxHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .UseSerilog()
        .UseSystemd()
        .ConfigureServices((hostContext, sc) =>
        {
            sc.AddSingleton <IConfiguration>(_conf);
            sc.AddSingleton <IContextService>(_instance);
            sc.AddSingleton <ILogger>(_logger);
            sc.AddSingleton <IMapper>(_mapper);
            sc.AddTransient <IUnitOfWork, UnitOfWork>(_ =>
            {
                return(new UnitOfWork(_conf["Databases:AuroraEntities"], _instance));
            });
            sc.AddTransient <IAlertService, AlertService>(_ =>
            {
                var alert   = new AlertService(_conf);
                alert.Grant = new ResourceOwnerGrantV2(_conf);

                return(alert);
            });
            sc.AddTransient <IAdminService, AdminService>(_ =>
            {
                var admin   = new AdminService(_conf);
                admin.Grant = new ResourceOwnerGrantV2(_conf);

                return(admin);
            });
            sc.AddTransient <IStsService, StsService>(_ =>
            {
                var sts   = new StsService(_conf);
                sts.Grant = new ResourceOwnerGrantV2(_conf);

                return(sts);
            });
            sc.AddSingleton <IHostedService, Daemon>();
            sc.AddQuartz(jobs =>
            {
                jobs.SchedulerId = Guid.NewGuid().ToString();

                jobs.UseMicrosoftDependencyInjectionJobFactory(options =>
                {
                    options.AllowDefaultConstructor = false;
                });

                jobs.UseSimpleTypeLoader();
                jobs.UseInMemoryStore();
                jobs.UseDefaultThreadPool();

                if (bool.Parse(_conf["Jobs:MOTDDownloadJob:Enable"]))
                {
                    var motdPullJobKey = new JobKey(JobType.MOTDDownloadJob.ToString(), GroupType.Daemons.ToString());
                    jobs.AddJob <MOTDDownloadJob>(opt => opt
                                                  .StoreDurably()
                                                  .WithIdentity(motdPullJobKey)
                                                  );

                    foreach (var cron in _conf.GetSection("Jobs:MOTDDownloadJob:Schedules").GetChildren()
                             .Select(x => x.Value).ToList())
                    {
                        jobs.AddTrigger(opt => opt
                                        .ForJob(motdPullJobKey)
                                        .StartNow()
                                        .WithCronSchedule(cron)
                                        );
                    }
                }
                if (bool.Parse(_conf["Jobs:MOTDUploadJob:Enable"]))
                {
                    var motdPushJobKey = new JobKey(JobType.MOTDUploadJob.ToString(), GroupType.Daemons.ToString());
                    jobs.AddJob <MOTDUploadJob>(opt => opt
                                                .StoreDurably()
                                                .WithIdentity(motdPushJobKey)
                                                );

                    foreach (var cron in _conf.GetSection("Jobs:MOTDUploadJob:Schedules").GetChildren()
                             .Select(x => x.Value).ToList())
                    {
                        jobs.AddTrigger(opt => opt
                                        .ForJob(motdPushJobKey)
                                        .StartNow()
                                        .WithCronSchedule(cron)
                                        );
                    }
                }
            });
            sc.AddQuartzServer(opt =>
            {
                opt.WaitForJobsToComplete = true;
            });
        });
Beispiel #29
0
 private void BindData()
 {
     RadScheduler1.DataSource = AlertService.GetAlerts();
 }
Beispiel #30
0
 private void OnAlertSuccessAddClick()
 {
     AlertService.Add($"Success message at: {DateTime.Now}", BBComponents.Enums.BootstrapColors.Success);
 }