예제 #1
0
 public IndexViewModel(DirectLinkOptions directLinkOptions, Db data, string dbHash, QPublishingOptions options)
 {
     Data               = data;
     DbHash             = dbHash;
     _directLinkOptions = directLinkOptions;
     _options           = options;
 }
예제 #2
0
 public HomeController(JsLanguageHelper languageHelper, JsConstantsHelper constantsHelper, QPublishingOptions options, QuartzService quartzService)
 {
     _languageHelper  = languageHelper;
     _constantsHelper = constantsHelper;
     _options         = options;
     _quartzService   = quartzService;
 }
예제 #3
0
 protected AuthQpController(IArticleService dbArticleService, QPublishingOptions options)
     : base(dbArticleService, options)
 {
 }
예제 #4
0
 protected QPController(IArticleService dbArticleService, QPublishingOptions options)
     : this()
 {
     DbArticleService = dbArticleService;
     Options          = options;
 }
예제 #5
0
 public ArticleSchedulerProperties(QPublishingOptions options)
 {
     XmlConfigPath      = options.QpConfigPath;
     ConfigServiceUrl   = options.QpConfigUrl;
     ConfigServiceToken = options.QpConfigToken;
 }
예제 #6
0
 public FieldController(IArticleService dbArticleService, QPublishingOptions options)
     : base(dbArticleService, options)
 {
 }
예제 #7
0
 public UserController(IUserService service, IArticleService dbArticleService, QPublishingOptions options)
     : base(dbArticleService, options)
 {
     _service = service;
 }
예제 #8
0
 public AuthenticationHelper(IHttpContextAccessor httpContextAccessor, QPublishingOptions options)
 {
     _httpContext = httpContextAccessor.HttpContext;
     _options     = options;
 }
예제 #9
0
 public ArticleController(IArticleService dbArticleService, ArticleFullTextSearchQueryParser parser, QPublishingOptions options)
     : base(dbArticleService, options)
 {
     _parser = parser;
 }
예제 #10
0
파일: Startup.cs 프로젝트: QuantumArt/QP
        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);
        }