Beispiel #1
0
 public QuartzService(
     ILogger <QuartzService> logger,
     ISchedulerFactory factory,
     CommonSchedulerProperties quartzServiceSettings)
 {
     Logger            = logger;
     _factory          = factory;
     AllSchedulersTask = factory.GetAllSchedulers();
     SchedulerName     = quartzServiceSettings.Name;
 }
Beispiel #2
0
 public UserSynchronizationService(IOptions <CommonSchedulerProperties> options)
 {
     _languageId      = options.Value.DefaultLanguageId;
     _activeDirectory = new ActiveDirectoryRepository();
     settings         = options.Value;
 }
Beispiel #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            var qpOptions = new QPublishingOptions();

            Configuration.Bind("Properties", qpOptions);
            services.AddSingleton(qpOptions);
            QPConfiguration.Options = qpOptions;

            var formOptions = new FormOptions();

            Configuration.Bind("Form", formOptions);
            services.AddSingleton(formOptions);

            if (qpOptions.EnableArticleScheduler)
            {
                var schedulerOptions = new ArticleSchedulerProperties(qpOptions);
                Configuration.Bind("ArticleScheduler", schedulerOptions);
                services.AddSingleton(schedulerOptions);

                services.AddHostedService <S.ArticleService>();
            }

            var commonSchedulerProperties = new CommonSchedulerProperties();

            if (qpOptions.EnableCommonScheduler)
            {
                Configuration.Bind("CommonScheduler", commonSchedulerProperties);
                services.AddTransient <IUserSynchronizationService, UserSynchronizationService>();
            }
            services.AddSingleton(commonSchedulerProperties);
            services.AddQuartzService(commonSchedulerProperties.Name, Configuration.GetSection("CommonScheduler"));

            // used by Session middleware
            services.AddDistributedMemoryCache();
            services.Configure <ForwardedHeadersOptions>(options =>
            {
                options.ForwardedProtoHeaderName = "X-FORWARDED-PROTO";
                options.ForwardedHeaders         =
                    ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
                // Only loopback proxies are allowed by default.
                // Clear that restriction because forwarders are enabled by explicit
                // configuration.
                options.KnownNetworks.Clear();
                options.KnownProxies.Clear();
            });

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.Cookie.HttpOnly   = true;
                options.ExpireTimeSpan    = TimeSpan.FromMinutes(qpOptions.CookieTimeout);
                options.LoginPath         = new PathString("/Logon");
                options.LogoutPath        = new PathString("/Logon/Logout");
                options.AccessDeniedPath  = new PathString("/Logon");
                options.SlidingExpiration = true;
            });

            services.AddOptions();
            services.AddHttpContextAccessor();
            services.AddHttpClient();

            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();
            services.AddScoped <IUrlHelper>(x => {
                var actionContext = x.GetRequiredService <IActionContextAccessor>().ActionContext;
                var factory       = x.GetRequiredService <IUrlHelperFactory>();
                return(factory.GetUrlHelper(actionContext));
            });

            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromSeconds(qpOptions.SessionTimeout);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
            });

            services
            .AddMvc(options =>
            {
                options.ModelBinderProviders.Insert(0, new QpModelBinderProvider());
                options.EnableEndpointRouting = false;
            })
            .AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                options.SerializerSettings.ContractResolver      = new DefaultContractResolver();
            });

            services.AddAuthorization(options =>
            {
                options.AddPolicy("CustomerCodeSelected", policy => policy.RequireClaim("CustomerCode"));
            });

            // servicesn
            services
            .AddTransient <AuthenticationHelper>()
            .AddTransient <JsLanguageHelper>()
            .AddTransient <JsConstantsHelper>()
            .AddSingleton <ISearchGrammarParser, IronySearchGrammarParser>()
            .AddTransient <IStopWordList, StopWordList>()
            .AddTransient <IArticleSearchRepository, ArticleSearchRepository>()
            .AddTransient <ISearchInArticlesRepository, SearchInArticlesRepository>()
            .AddTransient <ISearchInArticlesService, SearchInArticlesService>()
            .AddTransient <IBackendActionLogRepository, AuditRepository>()
            .AddTransient <IBackendActionLogPagesRepository, AuditRepository>()
            .AddTransient <IButtonTracePagesRepository, AuditRepository>()
            .AddTransient <IRemovedEntitiesPagesRepository, AuditRepository>()
            .AddTransient <ISessionLogRepository, AuditRepository>()
            .AddTransient <IApplicationInfoRepository, ApplicationInfoRepository>()
            .AddTransient <IArticleRepository, ArticleRepository>()
            .AddTransient <IContentRepository, ContentRepository>()
            .AddTransient <IArticleSearchService, ArticleSearchService>()
            .AddTransient <IBackendActionLogService, BackendActionLogService>()
            .AddTransient <IButtonTraceService, ButtonTraceService>()
            .AddTransient <IRemovedEntitiesService, RemovedEntitiesService>()
            .AddTransient <ISessionLogService, SessionLogService>()
            .AddTransient <ICustomActionService, CustomActionService>()
            .AddTransient <IFieldDefaultValueService, FieldDefaultValueService>()
            .AddTransient <IRecreateDynamicImagesService, RecreateDynamicImagesService>()
            .AddTransient <IUserService, UserService>()
            .AddTransient <IUserGroupService, UserGroupService>()
            .AddTransient <IXmlDbUpdateLogRepository, XmlDbUpdateLogRepository>()
            .AddTransient <IXmlDbUpdateActionsLogRepository, XmlDbUpdateActionsLogRepository>()
            .AddTransient <IXmlDbUpdateLogService, XmlDbUpdateLogService>()
            .AddTransient <IArticleService, A.ArticleService>()
            .AddTransient <IContentService, ContentService>()
            .AddTransient <IXmlDbUpdateHttpContextProcessor, XmlDbUpdateHttpContextProcessor>()
            .AddTransient <IXmlDbUpdateActionCorrecterService, XmlDbUpdateActionCorrecterService>()
            .AddTransient <INotificationService, NotificationService>()
            .AddTransient <IActionPermissionTreeService, ActionPermissionTreeService>()
            .AddTransient <ISecurityService, SecurityService>()
            .AddTransient <IVisualEditorService, VisualEditorService>()
            .AddTransient <IQpPluginService, QpPluginService>()
            .AddTransient <IWorkflowService, WorkflowService>()
            .AddTransient <IStatusTypeService, StatusTypeService>()
            .AddTransient <IPageTemplateService, PageTemplateService>()
            .AddTransient <IPageService, PageService>()
            .AddTransient <IObjectService, ObjectService>()
            .AddTransient <IFormatService, FormatService>()
            .AddTransient <ProcessRemoteValidationIf>() //preload XAML validation
            .AddTransient <ResourceDictionary>()        // preload QA.Configuration
            .AddTransient <QuartzService>()
            ;

            services
            .AddTransient <WorkflowPermissionService>()
            .AddTransient <SitePermissionService>()
            .AddTransient <SiteFolderPermissionService>()
            .AddTransient <ContentPermissionService>()
            .AddTransient <ChildContentPermissionService>()
            .AddTransient <ArticlePermissionService>()
            .AddTransient <ChildArticlePermissionService>()
            .AddTransient <EntityTypePermissionService>()
            .AddTransient <EntityTypePermissionChangeService>()
            .AddTransient <ActionPermissionService>()
            .AddTransient <ActionPermissionChangeService>()
            ;

            services
            .AddTransient <ISearchGrammarParser, IronySearchGrammarParser>()
            .AddTransient <ArticleFullTextSearchQueryParser>()
            ;

            services
            .AddTransient <IInterfaceNotificationProvider, InterfaceNotificationProvider>()
            .AddTransient <IExternalInterfaceNotificationService, ExternalInterfaceNotificationService>()
            .AddTransient <IExternalSystemNotificationService, ExternalSystemNotificationService>()
            .AddTransient <ISchedulerCustomerCollection, SchedulerCustomerCollection>()
            .AddTransient <ICommonUserService, CommonUserService>()
            .AddTransient <ElasticCdcImportService>()
            .AddTransient <TarantoolCdcImportService>()
            .AddTransient <IDbService, DbService>()
            ;

            RegisterMultistepActionServices(services);
        }