Esempio n. 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            XmlConfigurator.ConfigureAndWatch(new FileInfo(Server.MapPath("~/log4net.config")));
            ContainerConfiguration.Register(Server.MapPath("~/bin"));

            if (string.IsNullOrWhiteSpace(WitsmlSettings.OverrideServerVersion))
            {
                WitsmlSettings.OverrideServerVersion = typeof(EtpController).GetAssemblyVersion();
            }

            var container        = (IContainer)System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IContainer));
            var databaseProvider = container.Resolve <IDatabaseProvider>();

            // pre-init IWitsmlStore dependencies
            var store = container.Resolve <IWitsmlStore>();

            store.WMLS_GetCap(new WMLS_GetCapRequest(OptionsIn.DataVersion.Version141));

            Task.Run(async() =>
            {
                // Wait before initializing Hangfire to give server time to warm up
                await Task.Delay(WitsmlSettings.ChangeDetectionPeriod * 1000);

                // Configure and register Hangfire jobs
                Hangfire.GlobalConfiguration.Configuration.UseMongoStorage(databaseProvider.ConnectionString, databaseProvider.DatabaseName);
                HangfireConfig.Register(container);
            });
        }
        public static void ConfigureScheduledJobs(HangfireConfig hangFireConfig)
        {
            var jobsConfig = hangFireConfig.Jobs;
            var ValidateKeysOnDatabaseConfig = jobsConfig.ValidateKeysOnDatabase;

            RecurringJob.AddOrUpdate <CleanupDatabaseJob>(recurringJobId: ValidateKeysOnDatabaseConfig.Name, methodCall: job => job.ValidateKeysOnDatabase(ValidateKeysOnDatabaseConfig.BatchSize), ValidateKeysOnDatabaseConfig.CronExpression);

            var updateZipConfig = jobsConfig.UpdateZipFiles;

            RecurringJob.AddOrUpdate <UpdateZipFilesJob>(recurringJobId: updateZipConfig.Name, methodCall: job => job.GenerateZipFiles(), updateZipConfig.CronExpression);

            var uploadConfig = jobsConfig.UploadKeysToTheGateway;

            RecurringJob.AddOrUpdate <UploadTemporaryExposureKeysEuGatewayJob>(recurringJobId: uploadConfig.Name, methodCall: job => job.Invoke(), uploadConfig.CronExpression);

            var downloadConfig = jobsConfig.DownloadKeysFromTheGateway;

            RecurringJob.AddOrUpdate <DownloadTemporaryExposureKeysEuGatewayJob>(recurringJobId: downloadConfig.Name, methodCall: job => job.Invoke(), downloadConfig.CronExpression);

            var removeOldZipFilesConfig = jobsConfig.RemoveOldZipFiles;

            RecurringJob.AddOrUpdate <RemoveOldZipFilesJob>(recurringJobId: removeOldZipFilesConfig.Name, methodCall: job => job.RemoveOldZipFiles(hangFireConfig), removeOldZipFilesConfig.CronExpression);

            var getCovidStatisticsConfig = jobsConfig.GetCovidStatistics;

            RecurringJob.AddOrUpdate <GetCovidStatisticsJob>(recurringJobId: getCovidStatisticsConfig.Name, methodCall: job => job.ObtainCovidStatistics(), getCovidStatisticsConfig.CronExpression);

            // This job entry should be removed after the problem with rolingStart, that is causing keys to be rejected by Google Exposure Notifcation, have been resolved.
            RecurringJob.AddOrUpdate <CleanupDatabaseJob>(recurringJobId: "maintenance-rollingStart-check-on-datbase-keys", methodCall: job => job.ValidateRollingStartOnDatabaseKeys(1000), Cron.Never);
        }
Esempio n. 3
0
 public void RemoveOldZipFiles(HangfireConfig hangfireConfig)
 {
     _daysToInvalidateZipFile = hangfireConfig.DaysToInvalidateZipFile;
     foreach (var zipFilesFolder in hangfireConfig.ZipFilesFolders)
     {
         RemoveOldZipFilesFromFolder(zipFilesFolder);
     }
 }
Esempio n. 4
0
 public ZipFileService(HangfireConfig hangfireConfig, IPackageBuilderService packageBuilder,
                       IZipFileInfoService zipFileInfoService, IFileSystem fileSystem)
 {
     _fileSystem          = fileSystem;
     _rootZipFilesFolders = hangfireConfig.ZipFilesFolders;
     _originCountryCode   = hangfireConfig.OriginCountryCode;
     _packageBuilder      = packageBuilder;
     _zipFileInfoService  = zipFileInfoService;
 }
Esempio n. 5
0
 public void Init()
 {
     _hangfireConfig = new HangfireConfig()
     {
         OriginCountryCode = "NO"
     };
     _hangfireConfig.DaysToInvalidateZipFile = 1;
     _fileSystem  = new FileSystemMockFactory().GetMock();
     _zipFileInfo = new ZipFileInfoServiceMockFactory().GetMock();
 }
        public void RemoveOldZipFiles(HangfireConfig hangfireConfig)
        {
            var daysToInvalidateZipFile = hangfireConfig.DaysToInvalidateZipFile;
            var originCountyCode        = hangfireConfig.OriginCountryCode;

            foreach (var zipFilesFolder in hangfireConfig.ZipFilesFolders)
            {
                RemoveOldZipFilesFromFolder(zipFilesFolder, originCountyCode, daysToInvalidateZipFile);
            }
        }
Esempio n. 7
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            var connectionString = ConfigurationManager.ConnectionStrings["HangfireDbConnection"].ConnectionString;

            GlobalConfiguration.Configuration.UseSqlServerStorage(connectionString);
            //GlobalConfiguration.Configuration.UseSqlServerStorage(@"Data Source=10.4.1.190\SQLExpress1;User Id=SilUtilSqlUser;Password=Pa55w0rd");
            app.UseHangfireDashboard();
            app.UseHangfireServer();
            HangfireConfig.StartBackgroundScheduling();
        }
 public JobActionFilter(
     IDbContextFactory <JobActionDbContext> dbContextFactory,
     IRecurringJobManagerFactory recurringJobManagerFactory,
     HangfireConfig hangfireConfig,
     JobStorageFactory jobStorageFactory)
 {
     this.dbContextFactory           = dbContextFactory;
     this.recurringJobManagerFactory = recurringJobManagerFactory;
     this.hangfireConfig             = hangfireConfig;
     this.jobStorageFactory          = jobStorageFactory;
 }
Esempio n. 9
0
 public void Init()
 {
     _hangfireConfig = new HangfireConfig();
     _hangfireConfig.ZipFilesFolders = new List <string>()
     {
         ""
     };
     _hangfireConfig.DaysToInvalidateZipFile = 1;
     _fileSystem  = new FileSystemMockFactory().GetMock();
     _zipFileInfo = new ZipFileInfoServiceMockFactory().GetMock();
 }
Esempio n. 10
0
 /// <summary>
 /// Storage service constructor
 /// </summary>
 /// <param name="optionsCommonConfig"></param>
 /// <param name="optionsEventLogConfig"></param>
 /// <param name="hangfireConfig"></param>
 /// <param name="botClient"></param>
 /// <param name="queryService"></param>
 public StorageService(
     IOptionsSnapshot <CommonConfig> optionsCommonConfig,
     IOptionsSnapshot <EventLogConfig> optionsEventLogConfig,
     IOptionsSnapshot <HangfireConfig> hangfireConfig,
     ITelegramBotClient botClient,
     QueryService queryService
     )
 {
     _commonConfig   = optionsCommonConfig.Value;
     _eventLogConfig = optionsEventLogConfig.Value;
     _hangfireConfig = hangfireConfig.Value;
     _botClient      = botClient;
     _queryService   = queryService;
 }
        public static void ConfigureScheduledJobs(HangfireConfig hangfireConfig)
        {
            var jobsConfig = hangfireConfig.Jobs;
            var ValidateKeysOnDatabaseConfig = jobsConfig.ValidateKeysOnDatabase;

            RecurringJob.AddOrUpdate <CleanupDatabaseJob>(recurringJobId: ValidateKeysOnDatabaseConfig.Name, methodCall: job => job.ValidateKeysOnDatabase(ValidateKeysOnDatabaseConfig.BatchSize), ValidateKeysOnDatabaseConfig.CronExpression);

            var updateZipConfig = jobsConfig.UpdateZipFiles;

            RecurringJob.AddOrUpdate <UpdateZipFilesJob>(recurringJobId: updateZipConfig.Name, methodCall: job => job.GenerateZipFiles(), updateZipConfig.CronExpression);

            var removeOldZipFilesConfig = jobsConfig.RemoveOldZipFiles;

            RecurringJob.AddOrUpdate <RemoveOldZipFilesJob>(recurringJobId: removeOldZipFilesConfig.Name, methodCall: job => job.RemoveOldZipFiles(hangfireConfig), removeOldZipFilesConfig.CronExpression);
        }
        public void RemoveOldZipFiles(HangfireConfig hangfireConfig)
        {
            var daysToInvalidateZipFile = hangfireConfig.DaysToInvalidateZipFile;
            var originCountyCode        = hangfireConfig.OriginCountryCode;

            foreach (var zipFilesFolder in hangfireConfig.ZipFilesFolders)
            {
                if (string.IsNullOrEmpty(zipFilesFolder))
                {
                    continue;
                }

                RemoveOldZipFilesFromFolder(zipFilesFolder, originCountyCode, daysToInvalidateZipFile);
            }
        }
Esempio n. 13
0
        public void Configuration(IAppBuilder app)
        {
            //Database.SetInitializer(new MigrateDatabaseToLatestVersion<ApplicationDbContext, Migrations.Configuration>());
            //Database.SetInitializer(new MigrateDatabaseToLatestVersion<BusinessDbContext, Model.Migrations.Configuration>());

            app.MapSignalR();

            AuthStartup.Register(app);

            HangfireConfig.RegisterHangfire(app);

            LoggerConfig.Register();

            //BusinessModelSeedDataManager.RunSeed();
            SecurityModelSeedDataManager.RunSeed();
            BusinessModelSeedDataManager.FillTenantSubscription();
            BusinessModelSeedDataManager.CreateFiscalYear(BusinessDbContext.Create());
        }
Esempio n. 14
0
        protected override void OnStart(string[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
            string appdatadir = Environment.GetEnvironmentVariable("LOCALAPPDATA");
#endif
            try
            {
                string serviceHost     = ConfigurationManager.AppSettings["HeyServiceHost"] ?? "localhost";
                string servicePort     = ConfigurationManager.AppSettings["HeyServicePort"] ?? "60400";
                string serviceProtocol = ConfigurationManager.AppSettings["HeyServiceProtocol"] ?? "http";

                var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                XmlConfigurator.Configure(new FileInfo(Path.Combine(assemblyFolder, "log.config")));
                _log = LogManager.GetLogger(GetType());
                _backgroundJobServer = HangfireConfig.StartHangfire("HeyDb");
                _disposable          = WebApp.Start <Startup>(url: $"{serviceProtocol}://{serviceHost}:{servicePort}/");
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                Stop();
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, HangfireConfig hangfireConfig)
        {
            loggerFactory.AddFile(hangfireConfig.LogsPath);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseHangfireDashboard();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseHangfireServer(options: new BackgroundJobServerOptions {
                WorkerCount = 1
            });

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            ScheduledJobsConfiguration.ConfigureScheduledJobs(hangfireConfig);
        }
Esempio n. 16
0
 protected void Application_End(object sender, EventArgs e)
 {
     HangfireConfig.Unregister();
 }
Esempio n. 17
0
        public void SetUp()
        {
            _backgroundJobServer = HangfireConfig.StartHangfire("TestHeyDb");
            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute {
                Attempts = 0
            });
            _repository = new HangfireJobRepository();
            var heyService = new HeyService(_repository);

            _heyController = new HeyController(heyService);

            _scheduledId          = "1";
            _scheduledHeyRemember = new HeyRememberDto()
            {
                Domain             = "Hey.Api.Rest.Tests",
                Name               = "GetTests",
                Id                 = _scheduledId,
                DomainSpecificData = "[]",
                When               = new[] { DateTime.Now + TimeSpan.FromMinutes(60) }
            };

            _processingId          = "2";
            _processingHeyRemember = new HeyRememberDto()
            {
                Domain             = "Hey.Api.Rest.Tests",
                Name               = "GetTests",
                Id                 = _processingId,
                DomainSpecificData = "[]",
                When               = new[] { DateTime.Now }
            };

            _succededId          = "3";
            _succededHeyRemember = new HeyRememberDto()
            {
                Domain             = "Hey.Api.Rest.Tests",
                Name               = "GetSuccessTests",
                Id                 = _succededId,
                DomainSpecificData = "[]",
                When               = new[] { DateTime.Now }
            };

            _failedId          = "3";
            _failedHeyRemember = new HeyRememberDto()
            {
                Domain             = "Hey.Api.Rest.Tests",
                Name               = "FailTests",
                Id                 = _failedId,
                DomainSpecificData = "[]",
                When               = new[] { DateTime.Now }
            };

            _recurringId          = "4";
            _recurringHeyRemember = new HeyRememberDto()
            {
                Domain             = "Hey.Api.Rest.Tests",
                Name               = "RecurringTests",
                Id                 = _recurringId,
                DomainSpecificData = "[]",
                When               = new[] { DateTime.Today },
                CronExpression     = "* * * * *",
            };
        }
Esempio n. 18
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddHangfire(configuration => HangfireConfig.GetServiceConfiguration(configuration));
     services.AddHangfireServer();
     HangfireConfig.RegisterManagerJobServer();
 }
Esempio n. 19
0
 public JobActionDbContext(HangfireConfig hangfireConfig)
 {
     this.hangfireConfig = hangfireConfig;
 }
Esempio n. 20
0
 public void Configuration(IAppBuilder app)
 {
     HangfireConfig.Configure(app);
 }