private static async Task RunProgramRunExample() { try { NameValueCollection props = new NameValueCollection { { "quartz.serializer.type", "binary" } }; StdSchedulerFactory factory = new StdSchedulerFactory(props); IScheduler scheduler = await factory.GetScheduler(); await scheduler.Start(); foreach (var tjob in JobsConfiguration.Jobs()) { await scheduler.ScheduleJob(tjob.Job, tjob.Trigger); } await Task.Delay(-1); await scheduler.Shutdown(); } catch (SchedulerException se) { Console.WriteLine(se); } }
public Functions(IIntegrationEventLogService eventLogService, EdcConfiguration edcConfiguration, IEdcPublishService edcPublishService, JobsConfiguration jobsConfiguration, IEmailService emailService, ILogger logger, ILoggerHelper loggerHelper, IEmailTemplateProvider emailTemplateProvider) { Ensure.That(eventLogService).IsNotNull(); Ensure.That(edcConfiguration).IsNotNull(); Ensure.That(edcPublishService).IsNotNull(); Ensure.That(jobsConfiguration).IsNotNull(); Ensure.That(emailService).IsNotNull(); Ensure.That(logger).IsNotNull(); Ensure.That(loggerHelper).IsNotNull(); Ensure.That(emailTemplateProvider).IsNotNull(); _eventLogService = eventLogService; _edcConfiguration = edcConfiguration; _edcPublishService = edcPublishService; _jobsConfiguration = jobsConfiguration; _emailService = emailService; _logger = logger; _loggerHelper = loggerHelper; _emailTemplateProvider = emailTemplateProvider; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddLogging(builder => { builder.AddSeq(); }); services.AddOptions(); services.Configure <DbConfiguration>(Configuration.GetSection("DbConfig")); services.Configure <ADConfiguration>(Configuration.GetSection("ADConfig")); services.Configure <EmailGeneratorConfiguration>(Configuration.GetSection("EmailGenerator")); // Auto Mapper Configurations var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new CoreMappingProfile()); mc.AddProfile(new VstsMappingProfile()); }); services.AddSingleton(mappingConfig.CreateMapper()); services.AddResponseCompression(); services.AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryApiResources(Config.GetApiResources()) .AddInMemoryClients(Config.GetClients()); services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = Configuration.GetValue <string>("Authority"); options.RequireHttpsMetadata = false; options.ApiName = "api"; }); services.AddTransient <IResourceOwnerPasswordValidator, ADPasswordValidator>(); services.AddTransient <IProfileService, ProfileServiceWithCustomClaims>(); services.AddCors(); services.AddMvc(o => { o.Conventions.Add(new NotFoundOnNullResultFilterConvention()); }) .AddNewtonsoftJson() .SetCompatibilityVersion(CompatibilityVersion.Latest) .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <IdentityViewModelValidator>()); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Ether API", Version = "v1" }); }); services.AddEmailGeneratorClient(); services.AddReporter <GeneratePullRequestsReport, PullRequestsReport, PullRequestReportViewModel>(Constants.PullRequestsReportType, Constants.PullRequestsReportName); services.AddReporter <GenerateAggregatedWorkitemsETAReport, AggregatedWorkitemsETAReport, AggregatedWorkitemsETAReportViewModel>(Constants.ETAReportType, Constants.ETAReportName); services.AddReporter <GenerateWorkItemsReport, WorkItemsReport, WorkItemsReportViewModel>(Constants.WorkitemsReportType, Constants.WorkitemsReporterName); services.AddReporter <GenerateReOpenedWorkItemsReport, ReOpenedWorkItemsReport, ReOpenedWorkItemsReportViewModel>(Constants.ReOpenedWorkitemsReportType, Constants.ReOpenedWorkitemsReporterName); var jobsConfig = new JobsConfiguration(); Configuration.GetSection("Jobs").Bind(jobsConfig); services.AddJobs(cfg => { cfg.RecurrentJob <PullRequestsSyncJob>(TimeSpan.FromMinutes(jobsConfig.PullRequestJobRecurrence)); cfg.RecurrentJob <WorkItemsSyncJob>(TimeSpan.FromMinutes(jobsConfig.WorkItemsJobRecurrence)); cfg.RecurrentJob <RetentionJob>(TimeSpan.FromMinutes(jobsConfig.RetentionJobRecurrence)); }); }