コード例 #1
0
        public void Execute(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);

            _aerisJob = new AerisJob();

            Log.Information("Starting WNRdngData01RegressionJob...\n");

            _aerisJob.ExecuteZipHistoryCheckOnlyForRegression(context);

            _aerisJob = null;

            ////_weatherRepository.ClearWthNormalParams();

            PopulateWthNormalParams();

            _aerisJob = new AerisJob();

            _aerisJob.PopulateWthExpUsageTableAfterRegression(context);

            _aerisJob = null;

            Log.Information("\nFinished WNRdngData01RegressionJob. \n");
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: ndrwwlf/WeatherRegression
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          //.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          //.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            if (env.IsDevelopment() || env.IsProduction())
            {
                builder.AddUserSecrets <Startup>();
            }

            Configuration = builder.Build();


            AerisJobParams aerisJobParams = new AerisJobParams();

            aerisJobParams.AerisClientId               = Configuration.GetSection("AerisJobParams:AerisClientID").Value;
            aerisJobParams.AerisClientSecret           = Configuration.GetSection("AerisJobParams:AerisClientSecret").Value;
            aerisJobParams.MyConnectionString          = Configuration.GetSection("AerisJobParams:MyConnectionString").Value;
            aerisJobParams.JitWebData3ConnectionString = Configuration.GetSection("AerisJobParams:JitWebData3ConnectionString").Value;
            aerisJobParams.RealJitWeatherConnection    = Configuration.GetSection("AerisJobParams:RealJitWeatherConnection").Value;

            SchedulerJob.RunAsync(aerisJobParams).GetAwaiter().GetResult();
        }
コード例 #3
0
        public void PopulateWthExpUsageTableAfterRegression(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);

            PopulateWthExpUsageTable();
        }
コード例 #4
0
        public void Start()
        {
            string userDir = "C:\\Users\\workweek";

            //string userDir = "C:\\Users\\andy";

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                         .MinimumLevel.Override("System", LogEventLevel.Information)
                         .MinimumLevel.Override("Quartz", LogEventLevel.Error)
                         .Enrich.FromLogContext()
                         //to outsite of project
                         .WriteTo.File(userDir + "/Logs/MasterLog.log", restrictedToMinimumLevel: LogEventLevel.Information, fileSizeLimitBytes: 500000,
                                       rollOnFileSizeLimit: true, retainedFileCountLimit: 2, shared: true)
                         .WriteTo.RollingFile(userDir + "/Logs/Daily/log-{Date}.log", retainedFileCountLimit: 60, shared: true)
                         .WriteTo.File(userDir + "/Logs/ErrorLog.log", restrictedToMinimumLevel: LogEventLevel.Warning, shared: true)
                         .WriteTo.Console()
                         .CreateLogger();

            AerisJobParams aerisJobParams = new AerisJobParams();

            IScheduler scheduler;
            var        schedulerFactory = new StdSchedulerFactory();

            scheduler = schedulerFactory.GetScheduler();
            scheduler.Context.Put("aerisJobParams", aerisJobParams);
            scheduler.Start();

            IJobDetail aerisJob = JobBuilder.Create <AerisJob>().Build();

            ITrigger aerisTrigger = TriggerBuilder.Create()
                                    .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(07, 11))
                                    //.StartNow()
                                    .Build();

            scheduler.ScheduleJob(aerisJob, aerisTrigger);

            IJobDetail regressionJob = JobBuilder.Create <WNRdngData01RegressionJob>()
                                       .WithIdentity(new JobKey("regKey"))
                                       .StoreDurably()
                                       .Build();

            scheduler.AddJob(regressionJob, true);

            /* ***executes regressionJob on start of service *** */
            scheduler.TriggerJob(regressionJob.Key);

            ITrigger regressionTrigger = TriggerBuilder.Create()
                                         .ForJob(regressionJob)
                                         .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(19, 30))
                                         //.StartNow()
                                         .Build();

            scheduler.ScheduleJob(regressionTrigger);
        }
コード例 #5
0
        public void ExecuteZipHistoryCheckOnlyForRegression(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);


            Log.Information("Checking if Historical WeatherData is needed...");

            try
            {
                _allZips = _weatherRepository.GetDistinctZipCodes();

                GatherHistoricalWeatherData(_allZips);

                //int difZip = 0;
                //List<WthNormalParams> allParams = _weatherRepository.GetAllParams();
                //foreach (WthNormalParams param in allParams)
                //{
                //    string bZip = _weatherRepository.GetBZip(param.AccID, 0, 0);

                //    if (bZip.Length > 0)
                //    {
                //        if (!bZip.Equals(param.ZipW))
                //        {
                //            difZip++;
                //            Log.Information("Different Zip. bZip: {0}, wnpZip: {1}", bZip, param.ZipW);
                //        }
                //    }
                //}
                //Log.Information("Different zips: {0}", difZip);

                if (newZipsDailyGatherNeededForRegression)
                {
                    GatherDailyWeatherData(-3, _allZips);

                    _actualZipDateEntriesTotal = _weatherRepository.GetZipDateRowCount();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message + " " + ex.StackTrace);
            }

            if (newZipsDailyGatherNeededForRegression)
            {
                Log.Information($"Finished GatherWeatherData(). " +
                                $"Expected Total ZipDates Entries: {_expectedZipDateEntriesTotal}.. Actual: {_actualZipDateEntriesTotal}.\n");
            }

            _expectedZipDateEntriesTotal = 0;
            _actualZipDateEntriesTotal   = 0;
        }
コード例 #6
0
        public void Execute(IJobExecutionContext context)
        {
            _aerisJobParams    = AerisJobParamsValueOf(context);
            _weatherRepository = _weatherRepositoryValueOf(_aerisJobParams);

            Log.Information("WeatherData and ExpUsage job starting...\n");

            GatherWeatherData();

            PopulateWthExpUsageTable();

            Log.Information($"\nWeatherData and ExpUsage job finished. " +
                            $"WeatherData was gathered and ExpUsage was calculated for Readings going back to MoID: {_MoID}.");
        }
コード例 #7
0
        protected override void OnStart(string[] args)
        {
            string userDir = "C:\\Users\\workweek";

            //string userDir = "C:\\Users\\User";

            //Log.Logger = new LoggerConfiguration()
            //.MinimumLevel.Information()
            //.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
            //.MinimumLevel.Override("System", LogEventLevel.Information)
            //.Enrich.FromLogContext()
            ////to outsite of project
            //.WriteTo.RollingFile(userDir + "/Logs/log-{Date}.log", retainedFileCountLimit: null)
            //.CreateLogger();

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                         .MinimumLevel.Override("System", LogEventLevel.Information)
                         .MinimumLevel.Override("Quartz", LogEventLevel.Error)
                         .Enrich.FromLogContext()
                         //to outsite of project
                         .WriteTo.File(userDir + "/Logs/MasterLogJIT.txt", restrictedToMinimumLevel: LogEventLevel.Information, rollOnFileSizeLimit: true)
                         .WriteTo.RollingFile(userDir + "/Logs/log-{Date}.txt", retainedFileCountLimit: null)
                         .WriteTo.Console()
                         .CreateLogger();

            AerisJobParams aerisJobParams = new AerisJobParams();

            IScheduler scheduler;
            var        schedulerFactory = new StdSchedulerFactory();

            scheduler = schedulerFactory.GetScheduler();
            scheduler.Context.Put("aerisJobParams", aerisJobParams);
            scheduler.Start();

            IJobDetail job = JobBuilder.Create <AerisJob>().Build();

            ITrigger trigger = TriggerBuilder.Create()
                               .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(7, 11))
                               //.WithSimpleSchedule(a => a.WithIntervalInMinutes(15).RepeatForever())
                               .Build();

            scheduler.ScheduleJob(job, trigger);
        }
コード例 #8
0
ファイル: Startup.cs プロジェクト: ndrwwlf/WeatherRegression
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var aerisJobParams = new AerisJobParams();

            Configuration.Bind("AerisJobParams", aerisJobParams);
            services.AddSingleton(aerisJobParams);
            services.AddSingleton <IWeatherRepository>(c => new WeatherRepository(aerisJobParams));
            //services.AddSingleton<AerisJob>(c => new AerisJob(aerisJobParams, Configuration.Get<IWeatherRepository>()));

            services.AddMvc(o =>
            {
                o.ModelMetadataDetailsProviders.Add(new RequiredBindingMetadataProvider());
            });

            //services.AddSwaggerGen(c =>
            //{
            //    c.SwaggerDoc("v1", new Info { Title = "Weather Service API", Version = "v1" });
            //});
        }
コード例 #9
0
 public WeatherRepository(AerisJobParams aerisJobParams)
 {
     _jitWeatherConnectionString  = aerisJobParams.JitWeatherConnectionString;
     _jitWebData3ConnectionString = aerisJobParams.JitWebData3ConnectionString;
 }
コード例 #10
0
 public WeatherRepository(AerisJobParams aerisJobParams)
 {
     _myConnectionString          = aerisJobParams.MyConnectionString;
     _jitWebData3ConnectionString = aerisJobParams.JitWebData3ConnectionString;
     _realJitWeatherConnection    = aerisJobParams.RealJitWeatherConnection;
 }
コード例 #11
0
 private IWeatherRepository _weatherRepositoryValueOf(AerisJobParams aerisJobParams)
 {
     return(new WeatherRepository(aerisJobParams));
 }