Exemplo n.º 1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                PublishmentSystemInfo.Additional.IsTracker = TranslateUtils.ToBool(IsTracker.SelectedValue);

                PublishmentSystemInfo.Additional.TrackerDays          = int.Parse(TrackerDays.Text);
                PublishmentSystemInfo.Additional.TrackerPageView      = int.Parse(TrackerPageView.Text);
                PublishmentSystemInfo.Additional.TrackerUniqueVisitor = int.Parse(TrackerUniqueVisitor.Text);
                PublishmentSystemInfo.Additional.TrackerCurrentMinute = int.Parse(TrackerCurrentMinute.Text);
                PublishmentSystemInfo.Additional.TrackerStyle         = ETrackerStyleUtils.GetEnumType(TrackerStyle.SelectedValue);

                try
                {
                    DataProvider.PublishmentSystemDao.Update(PublishmentSystemInfo);
                    Body.AddSiteLog(PublishmentSystemId, "修改统计设置");
                    SuccessMessage("统计设置修改成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "统计设置修改失败!");
                }
            }
        }
Exemplo n.º 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdFunction, AppManager.Cms.LeftMenu.Function.IdTracking, "修改统计设置", AppManager.Cms.Permission.WebSite.Tracking);

                EBooleanUtils.AddListItems(IsTracker, "统计", "不统计");
                ControlUtils.SelectListItemsIgnoreCase(IsTracker, PublishmentSystemInfo.Additional.IsTracker.ToString());

                TrackerDays.Text          = PublishmentSystemInfo.Additional.TrackerDays.ToString();
                TrackerPageView.Text      = PublishmentSystemInfo.Additional.TrackerPageView.ToString();
                TrackerUniqueVisitor.Text = PublishmentSystemInfo.Additional.TrackerUniqueVisitor.ToString();
                TrackerCurrentMinute.Text = PublishmentSystemInfo.Additional.TrackerCurrentMinute.ToString();
                ETrackerStyleUtils.AddListItems(TrackerStyle);
                ControlUtils.SelectListItems(TrackerStyle, ETrackerStyleUtils.GetValue(PublishmentSystemInfo.Additional.TrackerStyle));
            }
        }
Exemplo n.º 3
0
        public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo)
        {
            string parsedContent;

            try
            {
                var ie = node.Attributes?.GetEnumerator();

                var isGetUrlFromAttribute = false;
                var channelIndex          = string.Empty;
                var channelName           = string.Empty;

                var type      = TypePageView;
                var scope     = ScopePage;
                var isAverage = false;
                var style     = string.Empty;
                var addNum    = 0;
                var since     = string.Empty;
                var isDynamic = false;

                if (ie != null)
                {
                    while (ie.MoveNext())
                    {
                        var attr          = (XmlAttribute)ie.Current;
                        var attributeName = attr.Name.ToLower();
                        if (attributeName.Equals(AttributeChannelIndex))
                        {
                            channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                            if (!string.IsNullOrEmpty(channelIndex))
                            {
                                isGetUrlFromAttribute = true;
                            }
                        }
                        else if (attributeName.Equals(AttributeChannelName))
                        {
                            channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                            if (!string.IsNullOrEmpty(channelName))
                            {
                                isGetUrlFromAttribute = true;
                            }
                        }
                        else if (attributeName.Equals(AttributeType))
                        {
                            type = attr.Value;
                        }
                        else if (attributeName.Equals(AttributeScope))
                        {
                            scope = attr.Value;
                        }
                        else if (attributeName.Equals(AttributeIsAverage))
                        {
                            isAverage = TranslateUtils.ToBool(attr.Value, false);
                        }
                        else if (attributeName.Equals(AttributeStyle))
                        {
                            style = ETrackerStyleUtils.GetValue(ETrackerStyleUtils.GetEnumType(attr.Value));
                        }
                        else if (attributeName.Equals(AttributeAddNum))
                        {
                            addNum = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (attributeName.Equals(AttributeSince))
                        {
                            since = attr.Value;
                        }
                        else if (attributeName.Equals(AttributeIsDynamic))
                        {
                            isDynamic = TranslateUtils.ToBool(attr.Value);
                        }
                    }
                }

                parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(pageInfo, contextInfo, isGetUrlFromAttribute, channelIndex, channelName, type, scope, isAverage, style, addNum, since);
            }
            catch (Exception ex)
            {
                parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex);
            }

            return(parsedContent);
        }
Exemplo n.º 4
0
        private static string GetAnalysisValue(PageInfo pageInfo, int channelId, int contentId, string templateType, string type, string scope, bool isAverage, string style, int addNum, string since, string referrer)
        {
            var publishmentSystemInfo = pageInfo.PublishmentSystemInfo;

            if (publishmentSystemInfo == null)
            {
                return(string.Empty);
            }

            var html = string.Empty;

            var eStyle = publishmentSystemInfo.Additional.TrackerStyle;

            if (!string.IsNullOrEmpty(style))
            {
                eStyle = ETrackerStyleUtils.GetEnumType(style);
            }
            if (string.IsNullOrEmpty(scope) || !StringUtils.EqualsIgnoreCase(scope, ScopeSite))
            {
                scope = ScopePage;
            }
            var eTemplateType = ETemplateTypeUtils.GetEnumType(templateType);

            var accessNum = 0;
            var sinceDate = DateUtils.SqlMinValue;

            if (!string.IsNullOrEmpty(since))
            {
                sinceDate = DateTime.Now.AddHours(-DateUtils.GetSinceHours(since));
            }

            if (StringUtils.EqualsIgnoreCase(type, TypePageView))
            {
                if (StringUtils.EqualsIgnoreCase(scope, ScopePage))
                {
                    if (eTemplateType != ETemplateType.FileTemplate)
                    {
                        accessNum = DataProvider.TrackingDao.GetTotalAccessNumByPageInfo(pageInfo.PublishmentSystemId, channelId, contentId, sinceDate);
                    }
                    else
                    {
                        accessNum = DataProvider.TrackingDao.GetTotalAccessNumByPageUrl(pageInfo.PublishmentSystemId, referrer, sinceDate);
                    }
                }
                else
                {
                    accessNum = DataProvider.TrackingDao.GetTotalAccessNum(pageInfo.PublishmentSystemId, sinceDate);
                    accessNum = accessNum + publishmentSystemInfo.Additional.TrackerPageView;
                }
                if (isAverage)
                {
                    var nodeInfo = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, pageInfo.PublishmentSystemId);
                    var timeSpan = new TimeSpan(DateTime.Now.Ticks - nodeInfo.AddDate.Ticks);
                    if (!string.IsNullOrEmpty(since))
                    {
                        timeSpan = new TimeSpan(DateTime.Now.Ticks - sinceDate.Ticks);
                    }
                    var trackerDays = (timeSpan.Days == 0) ? 1 : timeSpan.Days;//总统计天数
                    trackerDays = trackerDays + publishmentSystemInfo.Additional.TrackerDays;
                    accessNum   = Convert.ToInt32(Math.Round(Convert.ToDouble(accessNum / trackerDays)));
                }
            }
            else if (StringUtils.EqualsIgnoreCase(type, TypeUniqueVisitor))
            {
                if (StringUtils.EqualsIgnoreCase(scope, ScopePage))
                {
                    if (eTemplateType != ETemplateType.FileTemplate)
                    {
                        accessNum = DataProvider.TrackingDao.GetTotalUniqueAccessNumByPageInfo(pageInfo.PublishmentSystemId, channelId, contentId, sinceDate);
                    }
                    else
                    {
                        accessNum = DataProvider.TrackingDao.GetTotalUniqueAccessNumByPageUrl(pageInfo.PublishmentSystemId, referrer, sinceDate);
                    }
                }
                else
                {
                    accessNum = DataProvider.TrackingDao.GetTotalUniqueAccessNum(pageInfo.PublishmentSystemId, sinceDate);
                    accessNum = accessNum + publishmentSystemInfo.Additional.TrackerUniqueVisitor;
                }
                if (isAverage)
                {
                    var nodeInfo    = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, pageInfo.PublishmentSystemId);
                    var timeSpan    = new TimeSpan(DateTime.Now.Ticks - nodeInfo.AddDate.Ticks);
                    var trackerDays = (timeSpan.Days == 0) ? 1 : timeSpan.Days;//总统计天数
                    trackerDays = trackerDays + publishmentSystemInfo.Additional.TrackerDays;
                    accessNum   = Convert.ToInt32(Math.Round(Convert.ToDouble(accessNum / trackerDays)));
                }
            }
            else if (StringUtils.EqualsIgnoreCase(type, TypeCurrentVisitor))
            {
                accessNum = DataProvider.TrackingDao.GetCurrentVisitorNum(pageInfo.PublishmentSystemId, publishmentSystemInfo.Additional.TrackerCurrentMinute);
            }

            accessNum = accessNum + addNum;
            if (accessNum == 0)
            {
                accessNum = 1;
            }

            if (eStyle != ETrackerStyle.None)
            {
                if (eStyle == ETrackerStyle.Number)
                {
                    html = accessNum.ToString();
                }
                else
                {
                    var    numString   = accessNum.ToString();
                    var    htmlBuilder = new StringBuilder();
                    string imgFolder   = $"{SiteFilesAssets.GetUrl(pageInfo.ApiUrl, SiteFilesAssets.Tracker.DirectoryName)}/{ETrackerStyleUtils.GetValue(eStyle)}";
                    foreach (var t in numString)
                    {
                        string imgHtml = $"<img src='{imgFolder}/{t}.gif' align=absmiddle border=0>";
                        htmlBuilder.Append(imgHtml);
                    }
                    html = htmlBuilder.ToString();
                }
            }

            return(html);
        }