newtelligence.DasBlog.Web.SiteConfig.GetConfiguredTimeZone C# (CSharp) Метод

GetConfiguredTimeZone() публичный Метод

public GetConfiguredTimeZone ( ) : WindowsTimeZone
Результат newtelligence.DasBlog.Util.WindowsTimeZone
        public WindowsTimeZone GetConfiguredTimeZone()
        {
            if (windowsTimeZone == null)
            {
                windowsTimeZone = WindowsTimeZone.TimeZones.GetByZoneIndex(displayTimeZoneIndex) as WindowsTimeZone;
            }
            return windowsTimeZone;
        }

Usage Example

Пример #1
0
        private void ClickThroughsBox_PreRender(object sender, EventArgs e)
        {
            Control root = contentPlaceHolder;

            SiteConfig          siteConfig  = SiteConfig.GetSiteConfig();
            ILoggingDataService logService  = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
            IBlogDataService    dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService);

            Dictionary <string, int> clickThroughUrls = new Dictionary <string, int>();
            Dictionary <string, int> userAgents       = new Dictionary <string, int>();
            Dictionary <string, int> userDomains      = new Dictionary <string, int>();

            // get the user's local time
            DateTime utcTime   = DateTime.UtcNow;
            DateTime localTime = siteConfig.GetConfiguredTimeZone().ToLocalTime(utcTime);

            if (Request.QueryString["date"] != null)
            {
                try
                {
                    DateTime popUpTime = DateTime.ParseExact(Request.QueryString["date"], "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    utcTime   = new DateTime(popUpTime.Year, popUpTime.Month, popUpTime.Day, utcTime.Hour, utcTime.Minute, utcTime.Second);
                    localTime = new DateTime(popUpTime.Year, popUpTime.Month, popUpTime.Day, localTime.Hour, localTime.Minute, localTime.Second);
                }
                catch (FormatException ex)
                {
                    ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, ex);
                }
            }

            LogDataItemCollection logItems = new LogDataItemCollection();

            logItems.AddRange(logService.GetClickThroughsForDay(localTime));

            if (siteConfig.AdjustDisplayTimeZone)
            {
                newtelligence.DasBlog.Util.WindowsTimeZone tz = siteConfig.GetConfiguredTimeZone();
                TimeSpan ts     = tz.GetUtcOffset(DateTime.UtcNow);
                int      offset = ts.Hours;

                if (offset < 0)
                {
                    logItems.AddRange(logService.GetClickThroughsForDay(localTime.AddDays(1)));
                }
                else
                {
                    logItems.AddRange(logService.GetClickThroughsForDay(localTime.AddDays(-1)));
                }
            }

            foreach (LogDataItem log in logItems)
            {
                bool exclude = false;

                if (siteConfig.AdjustDisplayTimeZone)
                {
                    if (siteConfig.GetConfiguredTimeZone().ToLocalTime(log.RequestedUtc).Date != localTime.Date)
                    {
                        exclude = true;
                    }
                }

                if (!exclude)
                {
                    string key = log.UrlRequested + "°" + log.UrlReferrer;
                    if (!clickThroughUrls.ContainsKey(key))
                    {
                        clickThroughUrls[key] = 0;
                    }
                    clickThroughUrls[key] = clickThroughUrls[key] + 1;

                    if (!userAgents.ContainsKey(log.UserAgent))
                    {
                        userAgents[log.UserAgent] = 0;
                    }
                    userAgents[log.UserAgent] = userAgents[log.UserAgent] + 1;

                    if (!userDomains.ContainsKey(log.UserDomain))
                    {
                        userDomains[log.UserDomain] = 0;
                    }
                    userDomains[log.UserDomain] = userDomains[log.UserDomain] + 1;
                }
            }

            root.Controls.Add(BuildStatisticsTable(GenerateSortedItemList(clickThroughUrls), resmgr.GetString("text_activity_click_throughs"), resmgr.GetString("text_activity_clicks"), new StatisticsBuilderCallback(this.BuildClickThroughsRow), dataService));
            root.Controls.Add(BuildStatisticsTable(GenerateSortedItemList(userDomains), resmgr.GetString("text_activity_user_domains"), resmgr.GetString("text_activity_hits"), new StatisticsBuilderCallback(this.BuildUserDomainRow), dataService));
            root.Controls.Add(BuildStatisticsTable(GenerateSortedItemList(userAgents), resmgr.GetString("text_activity_user_agent"), resmgr.GetString("text_activity_hits"), new StatisticsBuilderCallback(this.BuildAgentsRow), dataService));

            DataBind();
        }
All Usage Examples Of newtelligence.DasBlog.Web.SiteConfig::GetConfiguredTimeZone