Esempio n. 1
0
        public static void Configure()
        {
            DbRegistry.Configure();

            PrepareRedisSessionProvider();

            if (HttpContext.Current != null && HttpContext.Current.Request != null)
            {
                var url = HttpContext.Current.Request.GetUrlRewriter();
                CommonLinkUtility.Initialize(new UriBuilder(url.Scheme, url.Host, url.Port).Uri.ToString());
            }

            ConfigureWebApi();

            if (DBResourceManager.ResourcesFromDataBase)
            {
                DBResourceManager.WhiteLableEnabled = true;
                DBResourceManager.PatchAssemblies();
            }

            AjaxSecurityChecker.Instance.CheckMethodPermissions += AjaxCheckMethodPermissions;
            AppDomain.CurrentDomain.AssemblyResolve             += CurrentDomainOnAssemblyResolve;

            //try
            //{
            //    AmiPublicDnsSyncService.Synchronize();
            //}
            //catch { }

            NotifyConfiguration.Configure();

            WebItemManager.Instance.LoadItems();

            SearchHandlerManager.Registry(new StudioSearchHandler());

            StorageFactory.InitializeHttpHandlers();

            BundleConfig.Configure();

            WhiteLabelHelper.ApplyPartnerWhiteLableSettings();

            LdapNotifyHelper.RegisterAll();

            try
            {
                new S3UploadGuard().DeleteExpiredUploadsAsync(TimeSpan.FromDays(1));//todo:
            }
            catch (Exception)
            {
            }

            try
            {
                Core.WarmUp.Instance.Start();
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("ASC").Error("Start Warmup", ex);
            }
        }
        public void SetLdapCronSettings(string cron)
        {
            CheckLdapPermissions();

            if (!string.IsNullOrEmpty(cron))
            {
                new CronExpression(cron); // validate

                if (!LdapSettings.Load().EnableLdapAuthentication)
                {
                    throw new Exception(Resource.LdapSettingsErrorCantSaveLdapSettings);
                }
            }

            var settings = LdapCronSettings.Load();

            if (settings == null)
            {
                settings = new LdapCronSettings();
            }

            settings.Cron = cron;
            settings.Save();

            var t = CoreContext.TenantManager.GetCurrentTenant();

            if (!string.IsNullOrEmpty(cron))
            {
                LdapNotifyHelper.UnregisterAutoSync(t);
                LdapNotifyHelper.RegisterAutoSync(t, cron);
            }
            else
            {
                LdapNotifyHelper.UnregisterAutoSync(t);
            }
        }