GetConfigFilePathFromCurrentContext() public static méthode

public static GetConfigFilePathFromCurrentContext ( ) : string
Résultat string
Exemple #1
0
        protected void HomePage_Load(object sender, System.EventArgs e)
        {
            if (SiteConfig.EnableStartPageCaching && Request.QueryString != null && Request.QueryString["page"] != "admin")
            {
                hideAdminTools = true;
                double seconds = 86400;                 //max 86400 seconds = 24 hours
                // only the default site without any querys will have an expiration
                // time in seconds to the end of day, with query the site will expire
                // after 24 hours
                if (Request.QueryString != null && Request.QueryString.Count == 0)
                {
                    DateTime time        = DateTime.Now;
                    DateTime timeEnd     = new DateTime(time.Year, time.Month, time.Day, 23, 59, 59);
                    TimeSpan endTimeSpan = new TimeSpan(timeEnd.Ticks - time.Ticks);
                    seconds = endTimeSpan.Hours * 60 + endTimeSpan.Minutes * 60 + endTimeSpan.Seconds;
                }
                Response.Cache.SetExpires(DateTime.Now.AddSeconds(seconds));
                Response.Cache.VaryByParams["*"] = true;
                Response.Cache.VaryByHeaders["Accept-Language"] = true;
                Response.Cache.SetCacheability(HttpCacheability.Public);
                Response.Cache.SetValidUntilExpires(true);

                // insert something into the cache so that we can invalidate it when a new entry or comment is made
                this.DataCache.Insert("BlogCoreData", "BlogCoreData", System.Web.Caching.CacheItemPriority.NotRemovable);

                Response.AddCacheItemDependency("BlogCoreData");
                Response.AddFileDependency(SiteConfig.GetConfigFilePathFromCurrentContext());
            }
        }
        private void LoadFilters()
        {
            SiteConfig siteConfig = SiteConfig.GetSiteConfig(SiteConfig.GetConfigFilePathFromCurrentContext());

            contentFilters          = new ContentFilterCollection(siteConfig.ContentFilters);
            checkFilterHtml.Checked = siteConfig.ApplyContentFiltersToWeb;
            checkFilterRSS.Checked  = siteConfig.ApplyContentFiltersToRSS;
        }
        private void SaveSites( )
        {
            SiteConfig siteConfig = SiteConfig.GetSiteConfig(SiteConfig.GetConfigFilePathFromCurrentContext());

            siteConfig.CrosspostSites.Clear();
            siteConfig.CrosspostSites.AddRange(crosspostSites);
            XmlSerializer ser = new XmlSerializer(typeof(SiteConfig));

            using (StreamWriter writer = new StreamWriter(SiteConfig.GetConfigFilePathFromCurrentContext()))
            {
                ser.Serialize(writer, siteConfig);
            }
        }
Exemple #4
0
        public static void Save(SiteConfig siteConfig)
        {
            System.Security.Principal.WindowsImpersonationContext wi = Impersonation.Impersonate();

            XmlSerializer ser = new XmlSerializer(typeof(SiteConfig));

            using (StreamWriter writer = new StreamWriter(SiteConfig.GetConfigFilePathFromCurrentContext()))
            {
                ser.Serialize(writer, siteConfig);
            }

            wi.Undo();
        }
        private void SaveFilters()
        {
            SiteConfig siteConfig = SiteConfig.GetSiteConfig(SiteConfig.GetConfigFilePathFromCurrentContext());

            siteConfig.ApplyContentFiltersToWeb = checkFilterHtml.Checked;
            siteConfig.ApplyContentFiltersToRSS = checkFilterRSS.Checked;
            siteConfig.ContentFilters.Clear();
            siteConfig.ContentFilters.AddRange(contentFilters);
            XmlSerializer ser = new XmlSerializer(typeof(SiteConfig));

            using (StreamWriter writer = new StreamWriter(SiteConfig.GetConfigFilePathFromCurrentContext()))
            {
                ser.Serialize(writer, siteConfig);
            }
        }
        private void LoadSites( )
        {
            SiteConfig siteConfig = SiteConfig.GetSiteConfig(SiteConfig.GetConfigFilePathFromCurrentContext());

            crosspostSites = new CrosspostSiteCollection(siteConfig.CrosspostSites);

            // [email protected] 24-MAR-04
            // ensure that each allBlogNames property has at
            // least one entry, namely the blog name
            foreach (CrosspostSite site in crosspostSites)
            {
                if (site.AllBlogNames == null || site.AllBlogNames.Length == 0)
                {
                    site.AllBlogNames = new string[] { site.BlogName }
                }
                ;
            }
        }
        protected void Application_Start(Object sender, EventArgs e)
        {
            //We clear out the Cache on App Restart...
            CacheFactory.GetCache().Clear();

            ILoggingDataService loggingService = null;

            loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
            loggingService.AddEvent(new EventDataItem(EventCodes.ApplicationStartup, "", ""));

            SiteConfig siteConfig = SiteConfig.GetSiteConfig(SiteConfig.GetConfigFilePathFromCurrentContext());

            //if (siteConfig.EnableReportMailer)
            {
                reportMailer = new ReportMailer(
                    SiteConfig.GetConfigFilePathFromCurrentContext(),
                    SiteConfig.GetContentPathFromCurrentContext(),
                    SiteConfig.GetLogPathFromCurrentContext()
                    );

                reportMailerThread              = new Thread(new ThreadStart(reportMailer.Run));
                reportMailerThread.Name         = "ReportMailer";
                reportMailerThread.IsBackground = true;
                reportMailerThread.Start();
            }

            if (siteConfig.EnablePop3)
            {
                mailToWeblog = new MailToWeblog(
                    SiteConfig.GetConfigFilePathFromCurrentContext(),
                    SiteConfig.GetContentPathFromCurrentContext(),
                    SiteConfig.GetBinariesPathFromCurrentContext(),
                    SiteConfig.GetLogPathFromCurrentContext(),
                    new Uri(new Uri(SiteConfig.GetSiteConfig().Root), SiteConfig.GetSiteConfig().BinariesDirRelative)
                    );

                mailToWeblogThread              = new Thread(new ThreadStart(mailToWeblog.Run));
                mailToWeblogThread.Name         = "MailToWeblog";
                mailToWeblogThread.IsBackground = true;
                mailToWeblogThread.Start();
            }

            if (siteConfig.EnableXSSUpstream)
            {
                xssUpstreamer = new XSSUpstreamer(
                    SiteConfig.GetConfigFilePathFromCurrentContext(),
                    SiteConfig.GetContentPathFromCurrentContext(),
                    SiteConfig.GetLogPathFromCurrentContext()
                    );

                xssUpstreamerThread              = new Thread(new ThreadStart(xssUpstreamer.Run));
                xssUpstreamerThread.Name         = "XSSUpstreamer";
                xssUpstreamerThread.IsBackground = true;
                xssUpstreamerThread.Start();
            }

            /*
             * if (siteConfig.EnableMovableTypeBlackList)
             * {
             *      ReferralBlackListFactory.AddBlacklist(new MovableTypeBlacklist(), Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), "blacklist.txt"));
             * }
             */

            if (siteConfig.EnableReferralUrlBlackList && siteConfig.ReferralUrlBlackList.Length != 0)
            {
                ReferralBlackListFactory.AddBlacklist(new ReferralUrlBlacklist(), siteConfig.ReferralUrlBlackList);
            }
        }