Пример #1
0
        public void Update(PublishmentSystemInfo publishmentSystemInfo, TemplateInfo templateInfo, string templateContent, string administratorName)
        {
            if (templateInfo.IsDefault)
            {
                SetAllTemplateDefaultToFalse(publishmentSystemInfo.PublishmentSystemId, templateInfo.TemplateType);
            }

            var updateParms = new IDataParameter[]
            {
                GetParameter(ParmTemplateName, EDataType.NVarChar, 50, templateInfo.TemplateName),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateInfo.TemplateType)),
                GetParameter(ParmRelatedFileName, EDataType.NVarChar, 50, templateInfo.RelatedFileName),
                GetParameter(ParmCreatedFileFullName, EDataType.NVarChar, 50, templateInfo.CreatedFileFullName),
                GetParameter(ParmCreatedFileExtName, EDataType.VarChar, 50, templateInfo.CreatedFileExtName),
                GetParameter(ParmCharset, EDataType.VarChar, 50, ECharsetUtils.GetValue(templateInfo.Charset)),
                GetParameter(ParmIsDefault, EDataType.VarChar, 18, templateInfo.IsDefault.ToString()),
                GetParameter(ParmTemplateId, EDataType.Integer, templateInfo.TemplateId)
            };

            ExecuteNonQuery(SqlUpdateTemplate, updateParms);

            TemplateManager.WriteContentToTemplateFile(publishmentSystemInfo, templateInfo, templateContent, administratorName);

            TemplateManager.RemoveCache(templateInfo.PublishmentSystemId);
        }
Пример #2
0
        public string GetLoadingTemplates(int publishmentSystemId, string templateType)
        {
            var arraylist = new ArrayList();

            var eTemplateType = ETemplateTypeUtils.GetEnumType(templateType);

            var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListByType(publishmentSystemId, eTemplateType);

            foreach (var templateInfo in templateInfoList)
            {
                var templateAddUrl = PageTemplateAdd.GetRedirectUrl(publishmentSystemId, templateInfo.TemplateId, eTemplateType);
                arraylist.Add($@"
<tr treeitemlevel=""3"">
	<td align=""left"" nowrap="""">
		<img align=""absmiddle"" src=""../assets/icons/tree/empty.gif""><img align=""absmiddle"" src=""../assets/icons/tree/empty.gif""><img align=""absmiddle"" src=""../assets/icons/menu/template.gif"">&nbsp;<a href=""{templateAddUrl}"" onclick=""fontWeightLink(this)"" target=""management"">{templateInfo.TemplateName}</a>
	</td>
</tr>
");
            }

            var builder = new StringBuilder();

            foreach (string html in arraylist)
            {
                builder.Append(html);
            }
            return(builder.ToString());
        }
Пример #3
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, bool isGetUrlFromAttribute, string channelIndex, string channelName, string type, string scope, bool isAverage, string style, int addNum, string since)
        {
            var channelId = StlCacheManager.NodeId.GetNodeIdByChannelIdOrChannelIndexOrChannelName(pageInfo.PublishmentSystemId, contextInfo.ChannelID, channelIndex, channelName);

            var contentId = 0;

            //判断是否链接地址由标签属性获得
            if (isGetUrlFromAttribute == false)
            {
                contentId = contextInfo.ContentID;
            }

            var templateType = pageInfo.TemplateInfo.TemplateType;

            if (contextInfo.ChannelID != 0)
            {
                templateType = ETemplateType.ChannelTemplate;
                if (contentId != 0)
                {
                    templateType = ETemplateType.ContentTemplate;
                }
            }

            return(GetAnalysisValue(pageInfo, channelId, contentId, ETemplateTypeUtils.GetValue(templateType), type, scope, isAverage, style, addNum, since, string.Empty));
        }
Пример #4
0
        public IEnumerable GetDataSource(int publishmentSystemId, string searchText, string templateTypeString)
        {
            if (string.IsNullOrEmpty(searchText) && string.IsNullOrEmpty(templateTypeString))
            {
                var parms = new IDataParameter[]
                {
                    GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId)
                };

                var enumerable = (IEnumerable)ExecuteReader(SqlSelectAllTemplateByPublishmentSystemId, parms);
                return(enumerable);
            }
            else if (!string.IsNullOrEmpty(searchText))
            {
                var whereString = (string.IsNullOrEmpty(templateTypeString)) ? string.Empty :
                                  $"AND TemplateType = '{templateTypeString}' ";
                searchText   = PageUtils.FilterSql(searchText);
                whereString +=
                    $"AND (TemplateName LIKE '%{searchText}%' OR RelatedFileName LIKE '%{searchText}%' OR CreatedFileFullName LIKE '%{searchText}%' OR CreatedFileExtName LIKE '%{searchText}%')";
                string sqlString =
                    $"SELECT TemplateID, PublishmentSystemID, TemplateName, TemplateType, RelatedFileName, CreatedFileFullName, CreatedFileExtName, Charset, IsDefault FROM siteserver_Template WHERE PublishmentSystemID = {publishmentSystemId} {whereString} ORDER BY TemplateType, RelatedFileName";

                var enumerable = (IEnumerable)ExecuteReader(sqlString);
                return(enumerable);
            }
            else
            {
                return(GetDataSourceByType(publishmentSystemId, ETemplateTypeUtils.GetEnumType(templateTypeString)));
            }
        }
Пример #5
0
 public static string GetRedirectUrl(int publishmentSystemId, int templateId, ETemplateType templateType)
 {
     return(PageUtils.GetCmsUrl(nameof(PageTemplateAdd), new NameValueCollection
     {
         { "PublishmentSystemID", publishmentSystemId.ToString() },
         { "TemplateID", templateId.ToString() },
         { "TemplateType", ETemplateTypeUtils.GetValue(templateType) }
     }));
 }
Пример #6
0
 public static string GetDeleteAllPageUrl(int publishmentSystemId, ETemplateType templateType)
 {
     return(PageUtils.GetCmsUrl(nameof(PageProgressBar), new NameValueCollection
     {
         { "PublishmentSystemID", publishmentSystemId.ToString() },
         { "TemplateType", ETemplateTypeUtils.GetValue(templateType) },
         { "DeleteAllPage", true.ToString() }
     }));
 }
Пример #7
0
 /// <summary>
 /// 初始化首页模板
 /// </summary>
 /// <param name="appId"></param>
 public void InitDefaultContentTemplate(long appId)
 {
     this.Title     = ContentDefaultTitle;
     this.Name      = ContentDefaultName;
     this.Type      = ETemplateTypeUtils.GetValue(ETemplateType.ContentTemplate);
     this.AppId     = appId;
     this.Extension = DefaultExtension;
     this.IsDefault = true;
 }
Пример #8
0
        private void DeleteAllPage()
        {
            var templateType = ETemplateTypeUtils.GetEnumType(Body.GetQueryString("TemplateType"));

            if (templateType == ETemplateType.ChannelTemplate)
            {
                LtlTitle.Text = "删除已生成的栏目页文件";
            }
            else if (templateType == ETemplateType.ContentTemplate)
            {
                LtlTitle.Text = "删除所有已生成的内容页文件";
            }
            else if (templateType == ETemplateType.FileTemplate)
            {
                LtlTitle.Text = "删除所有已生成的文件页";
            }

            try
            {
                if (templateType == ETemplateType.ChannelTemplate)
                {
                    var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(PublishmentSystemId);
                    DirectoryUtility.DeleteChannelsByPage(PublishmentSystemInfo, nodeIdList);
                }
                else if (templateType == ETemplateType.ContentTemplate)
                {
                    var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(PublishmentSystemId);
                    DirectoryUtility.DeleteContentsByPage(PublishmentSystemInfo, nodeIdList);
                }
                else if (templateType == ETemplateType.FileTemplate)
                {
                    DirectoryUtility.DeleteFiles(PublishmentSystemInfo, DataProvider.TemplateDao.GetTemplateIdListByType(PublishmentSystemId, ETemplateType.FileTemplate));
                }

                Body.AddSiteLog(PublishmentSystemId, LtlTitle.Text);

                LtlRegisterScripts.Text = @"
<script>
$(document).ready(function(){
    writeResult('任务执行成功。', '');
})
</script>
";
            }
            catch (Exception ex)
            {
                LtlRegisterScripts.Text = $@"
<script>
$(document).ready(function(){{
    writeResult('', '{ex.Message}');
}})
</script>
";
            }
        }
Пример #9
0
 public static string GetUrl(string apiUrl, int publishmentSystemId, int uniqueId, string area, int channelId, int fileTemplateId, ETemplateType templateType)
 {
     apiUrl = PageUtils.Combine(apiUrl, Route);
     apiUrl = apiUrl.Replace("{publishmentSystemId}", publishmentSystemId.ToString());
     apiUrl = apiUrl.Replace("{uniqueId}", uniqueId.ToString());
     apiUrl = apiUrl.Replace("{area}", area);
     apiUrl = apiUrl.Replace("{channelId}", channelId.ToString());
     apiUrl = apiUrl.Replace("{fileTemplateId}", fileTemplateId.ToString());
     apiUrl = apiUrl.Replace("{templateType}", ETemplateTypeUtils.GetValue(templateType));
     return(apiUrl);
 }
Пример #10
0
        public IEnumerable GetDataSourceByType(int publishmentSystemId, ETemplateType type)
        {
            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type))
            };

            var enumerable = (IEnumerable)ExecuteReader(SqlSelectAllTemplateByType, parms);

            return(enumerable);
        }
Пример #11
0
        private void SetAllTemplateDefaultToFalse(int publishmentSystemId, ETemplateType templateType)
        {
            var sqlString = "UPDATE siteserver_Template SET IsDefault = @IsDefault WHERE PublishmentSystemID = @PublishmentSystemID AND TemplateType = @TemplateType";

            var updateParms = new IDataParameter[]
            {
                GetParameter(ParmIsDefault, EDataType.VarChar, 18, false.ToString()),
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateType))
            };

            ExecuteNonQuery(sqlString, updateParms);
        }
Пример #12
0
        public int Insert(TemplateInfo templateInfo, string templateContent, string administratorName)
        {
            int templateId;

            if (templateInfo.IsDefault)
            {
                SetAllTemplateDefaultToFalse(templateInfo.PublishmentSystemId, templateInfo.TemplateType);
            }

            var sqlInsertTemplate = "INSERT INTO siteserver_Template (PublishmentSystemID, TemplateName, TemplateType, RelatedFileName, CreatedFileFullName, CreatedFileExtName, Charset, IsDefault) VALUES (@PublishmentSystemID, @TemplateName, @TemplateType, @RelatedFileName, @CreatedFileFullName, @CreatedFileExtName, @Charset, @IsDefault)";

            var insertParms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, templateInfo.PublishmentSystemId),
                GetParameter(ParmTemplateName, EDataType.NVarChar, 50, templateInfo.TemplateName),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateInfo.TemplateType)),
                GetParameter(ParmRelatedFileName, EDataType.NVarChar, 50, templateInfo.RelatedFileName),
                GetParameter(ParmCreatedFileFullName, EDataType.NVarChar, 50, templateInfo.CreatedFileFullName),
                GetParameter(ParmCreatedFileExtName, EDataType.VarChar, 50, templateInfo.CreatedFileExtName),
                GetParameter(ParmCharset, EDataType.VarChar, 50, ECharsetUtils.GetValue(templateInfo.Charset)),
                GetParameter(ParmIsDefault, EDataType.VarChar, 18, templateInfo.IsDefault.ToString())
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        templateId = ExecuteNonQueryAndReturnId(trans, sqlInsertTemplate, insertParms);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(templateInfo.PublishmentSystemId);

            TemplateManager.WriteContentToTemplateFile(publishmentSystemInfo, templateInfo, templateContent, administratorName);

            TemplateManager.RemoveCache(templateInfo.PublishmentSystemId);

            return(templateId);
        }
Пример #13
0
        public async Task Should_Create()
        {
            //default app
            var deraultApp = await _appManager.FindDefaultAsync();

            //Act
            var t = new Templates.Template(deraultApp.Id, "test", "T_test", ETemplateTypeUtils.GetValue(ETemplateType.FileTemplate), Templates.Template.DefaultExtension, false);

            t.TemplateContent = "123123";
            await _templateManager.CreateAsync(t);

            //Assert
            var root1 = GetTemplateOrNull("test");

            root1.ShouldNotBeNull();
        }
Пример #14
0
 /// <summary>
 /// 获取模板文件路径
 /// </summary>
 /// <param name="template"></param>
 /// <returns></returns>
 public string GetTemplateFilePath(Template template)
 {
     if (template.Type == ETemplateTypeUtils.GetValue(ETemplateType.IndexTemplate))
     {
         return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.IndexTemplateDirName, template.Name + template.Extension));
     }
     else if (template.Type == ETemplateTypeUtils.GetValue(ETemplateType.ChannelTemplate))
     {
         return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.ChannelTemplateDirName, template.Name + template.Extension));
     }
     else if (template.Type == ETemplateTypeUtils.GetValue(ETemplateType.ContentTemplate))
     {
         return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.ContentTemplateDirName, template.Name + template.Extension));
     }
     else
     {
         return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.FileTemplateDirName, template.Name + template.Extension));
     }
 }
Пример #15
0
        public int GetCount(string templateType)
        {
            var count = 0;

            if (string.IsNullOrEmpty(templateType))
            {
                foreach (var value in _dictionary)
                {
                    count += value.Value;
                }
            }
            else
            {
                var eTemplateType = ETemplateTypeUtils.GetEnumType(templateType);
                if (_dictionary.ContainsKey(eTemplateType))
                {
                    count = _dictionary[eTemplateType];
                }
            }
            return(count);
        }
Пример #16
0
        public List <int> GetTemplateIdListByType(int publishmentSystemId, ETemplateType type)
        {
            var list = new List <int>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type))
            };

            using (var rdr = ExecuteReader(SqlSelectAllTemplateIdByType, parms))
            {
                while (rdr.Read())
                {
                    var templateId = GetInt(rdr, 0);
                    list.Add(templateId);
                }
                rdr.Close();
            }
            return(list);
        }
Пример #17
0
        public ArrayList GetTemplateNameArrayList(int publishmentSystemId, ETemplateType templateType)
        {
            var list = new ArrayList();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateType))
            };

            using (var rdr = ExecuteReader(SqlSelectTemplateNames, parms))
            {
                while (rdr.Read())
                {
                    list.Add(GetString(rdr, 0));
                }
                rdr.Close();
            }

            return(list);
        }
Пример #18
0
        public TemplateInfo GetTemplateByTemplateId(int publishmentSystemId, ETemplateType type, string tId)
        {
            TemplateInfo info  = null;
            var          parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type)),
                GetParameter(ParmTemplateId, EDataType.Integer, tId)
            };

            using (var rdr = ExecuteReader(SqlSelectTemplateByTemplateid, parms))
            {
                if (rdr.Read())
                {
                    var i = 0;
                    info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ETemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i));
                }
                rdr.Close();
            }
            return(info);
        }
Пример #19
0
        public List <string> GetLowerRelatedFileNameList(int publishmentSystemId, ETemplateType templateType)
        {
            var list = new List <string>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateType))
            };

            using (var rdr = ExecuteReader(SqlSelectRelatedFileNameByTemplateType, parms))
            {
                while (rdr.Read())
                {
                    list.Add(GetString(rdr, 0).ToLower());
                }
                rdr.Close();
            }

            return(list);
        }
Пример #20
0
        private AtomEntry ExportTemplateInfo(TemplateInfo templateInfo)
        {
            var entry = AtomUtility.GetEmptyEntry();

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(_publishmentSystemId);

            AtomUtility.AddDcElement(entry.AdditionalElements, "TemplateID", templateInfo.TemplateId.ToString());
            AtomUtility.AddDcElement(entry.AdditionalElements, "PublishmentSystemID", templateInfo.PublishmentSystemId.ToString());
            AtomUtility.AddDcElement(entry.AdditionalElements, "TemplateName", templateInfo.TemplateName);
            AtomUtility.AddDcElement(entry.AdditionalElements, "TemplateType", ETemplateTypeUtils.GetValue(templateInfo.TemplateType));
            AtomUtility.AddDcElement(entry.AdditionalElements, "RelatedFileName", templateInfo.RelatedFileName);
            AtomUtility.AddDcElement(entry.AdditionalElements, "CreatedFileFullName", templateInfo.CreatedFileFullName);
            AtomUtility.AddDcElement(entry.AdditionalElements, "CreatedFileExtName", templateInfo.CreatedFileExtName);
            AtomUtility.AddDcElement(entry.AdditionalElements, "Charset", ECharsetUtils.GetValue(templateInfo.Charset));
            AtomUtility.AddDcElement(entry.AdditionalElements, "IsDefault", templateInfo.IsDefault.ToString());

            var templateContent = StlCacheManager.FileContent.GetTemplateContent(publishmentSystemInfo, templateInfo);

            AtomUtility.AddDcElement(entry.AdditionalElements, "Content", AtomUtility.Encrypt(templateContent));

            return(entry);
        }
Пример #21
0
        public List <TemplateInfo> GetTemplateInfoListByType(int publishmentSystemId, ETemplateType type)
        {
            var list = new List <TemplateInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type))
            };

            using (var rdr = ExecuteReader(SqlSelectAllTemplateByType, parms))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ETemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }
            return(list);
        }
Пример #22
0
        public Dictionary <ETemplateType, int> GetCountDictionary(int publishmentSystemId)
        {
            var dictionary = new Dictionary <ETemplateType, int>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId)
            };

            using (var rdr = ExecuteReader(SqlSelectTemplateCount, parms))
            {
                while (rdr.Read())
                {
                    var templateType = ETemplateTypeUtils.GetEnumType(GetString(rdr, 0));
                    var count        = GetInt(rdr, 1);

                    dictionary.Add(templateType, count);
                }
                rdr.Close();
            }

            return(dictionary);
        }
Пример #23
0
        public static void ParseStl(PublishmentSystemInfo publishmentSystemInfo, PageInfo pageInfo, ContextInfo contextInfo, StringBuilder contentBuilder, string filePath, bool isDynamic)
        {
            if (contentBuilder.Length > 0)
            {
                StlParserManager.ParseTemplateContent(contentBuilder, pageInfo, contextInfo);
            }

            if (EFileSystemTypeUtils.IsHtml(PathUtils.GetExtension(filePath)))
            {
                if (pageInfo.TemplateInfo.TemplateType != ETemplateType.FileTemplate)
                {
                    AddSeoMetaToContent(pageInfo, contentBuilder);
                }

                AddAdvertisementsToContent(pageInfo);

                if (isDynamic)
                {
                    var    pageUrl        = PageUtils.AddProtocolToUrl(PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, filePath));
                    string templateString = $@"
<base href=""{pageUrl}"" />";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateBrowserNoCache)
                {
                    const string templateString = @"
<META HTTP-EQUIV=""Pragma"" CONTENT=""no-cache"">
<META HTTP-EQUIV=""Expires"" CONTENT=""-1"">";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateIe8Compatible)
                {
                    const string templateString = @"
<META HTTP-EQUIV=""x-ua-compatible"" CONTENT=""ie=7"" />";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateJsIgnoreError)
                {
                    const string templateString = @"
<script type=""text/javascript"">window.onerror=function(){return true;}</script>";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PageContentId > 0 && pageInfo.PublishmentSystemInfo.Additional.IsCountHits && !pageInfo.IsPageScriptsExists(PageInfo.JsAdStlCountHits))
                {
                    pageInfo.AddPageEndScriptsIfNotExists(PageInfo.JsAdStlCountHits, $@"
<script src=""{ActionsAddContentHits.GetUrl(pageInfo.ApiUrl, pageInfo.PublishmentSystemId, pageInfo.PageNodeId, pageInfo.PageContentId)}"" type=""text/javascript""></script>");
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsTracker && !pageInfo.IsPageScriptsExists(PageInfo.JsAdAddTracker))
                {
                    pageInfo.AddPageEndScriptsIfNotExists(PageInfo.JsAdAddTracker, $@"
<script src=""{SiteFilesAssets.Tracker.GetScriptUrl(pageInfo.ApiUrl)}"" type=""text/javascript""></script>
<script type=""text/javascript"">AddTrackerCount('{ActionsAddTrackerCount.GetUrl(pageInfo.ApiUrl, pageInfo.PublishmentSystemId, pageInfo.PageNodeId, pageInfo.PageContentId)}', {pageInfo.PublishmentSystemId});</script>");
                }

                var headScripts = StlParserManager.GetPageInfoHeadScript(pageInfo, contextInfo);
                if (!string.IsNullOrEmpty(headScripts))
                {
                    if (contentBuilder.ToString().IndexOf("</head>", StringComparison.Ordinal) != -1 || contentBuilder.ToString().IndexOf("</HEAD>", StringComparison.Ordinal) != -1)
                    {
                        StringUtils.InsertBefore(new[] { "</head>", "</HEAD>" }, contentBuilder, headScripts);
                    }
                    else
                    {
                        contentBuilder.Insert(0, headScripts);
                    }
                }

                var afterBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, true);

                if (!string.IsNullOrEmpty(afterBodyScripts))
                {
                    if (contentBuilder.ToString().IndexOf("<body", StringComparison.Ordinal) != -1 || contentBuilder.ToString().IndexOf("<BODY", StringComparison.Ordinal) != -1)
                    {
                        var index = contentBuilder.ToString().IndexOf("<body", StringComparison.Ordinal);
                        if (index == -1)
                        {
                            index = contentBuilder.ToString().IndexOf("<BODY", StringComparison.Ordinal);
                        }
                        index = contentBuilder.ToString().IndexOf(">", index, StringComparison.Ordinal);
                        contentBuilder.Insert(index + 1, StringUtils.Constants.ReturnAndNewline + afterBodyScripts + StringUtils.Constants.ReturnAndNewline);
                    }
                    else
                    {
                        contentBuilder.Insert(0, afterBodyScripts);
                    }
                }

                var beforeBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, false);

                if (!string.IsNullOrEmpty(beforeBodyScripts))
                {
                    if (contentBuilder.ToString().IndexOf("</body>", StringComparison.Ordinal) != -1 || contentBuilder.ToString().IndexOf("</BODY>", StringComparison.Ordinal) != -1)
                    {
                        var index = contentBuilder.ToString().IndexOf("</body>", StringComparison.Ordinal);
                        if (index == -1)
                        {
                            index = contentBuilder.ToString().IndexOf("</BODY>", StringComparison.Ordinal);
                        }
                        contentBuilder.Insert(index, StringUtils.Constants.ReturnAndNewline + beforeBodyScripts + StringUtils.Constants.ReturnAndNewline);
                    }
                    else
                    {
                        contentBuilder.Append(beforeBodyScripts);
                    }
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateDoubleClick)
                {
                    var fileTemplateId = 0;
                    if (pageInfo.TemplateInfo.TemplateType == ETemplateType.FileTemplate)
                    {
                        fileTemplateId = pageInfo.TemplateInfo.TemplateId;
                    }
                    var ajaxUrl = ActionsTrigger.GetUrl(pageInfo.PublishmentSystemInfo.Additional.ApiUrl, pageInfo.PublishmentSystemId, contextInfo.ChannelID, contextInfo.ContentID, fileTemplateId, true);
                    pageInfo.AddPageEndScriptsIfNotExists("CreateDoubleClick", $@"
<script type=""text/javascript"" language=""javascript"">document.ondblclick=function(x){{location.href = '{ajaxUrl}';}}</script>");
                }

                if (pageInfo.PageEndScriptKeys.Count > 0)
                {
                    var endScriptBuilder = new StringBuilder();
                    foreach (string scriptKey in pageInfo.PageEndScriptKeys)
                    {
                        endScriptBuilder.Append(pageInfo.GetPageEndScripts(scriptKey));
                    }
                    endScriptBuilder.Append(StringUtils.Constants.ReturnAndNewline);

                    //contentBuilder.Append(endScriptBuilder.ToString());
                    //StringUtils.InsertBeforeOrAppend(new string[] { "</body>", "</BODY>" }, contentBuilder, endScriptBuilder.ToString());
                    StringUtils.InsertAfterOrAppend(new[] { "</html>", "</html>" }, contentBuilder, endScriptBuilder.ToString());
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateShowPageInfo)
                {
                    contentBuilder.Append($@"
<!-- {pageInfo.TemplateInfo.RelatedFileName}({ETemplateTypeUtils.GetText(pageInfo.TemplateInfo.TemplateType)}) -->");
                }
            }
        }
Пример #24
0
        private static string ParseImpl(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, string testType, string testOperate, string testValue)
        {
            string successTemplateString;
            string failureTemplateString;

            StlParserUtility.GetYesOrNoTemplateString(node, pageInfo, out successTemplateString, out failureTemplateString);

            if (StringUtils.EqualsIgnoreCase(testType, TypeIsUserLoggin) ||
                StringUtils.EqualsIgnoreCase(testType, TypeIsAdministratorLoggin) ||
                StringUtils.EqualsIgnoreCase(testType, TypeIsUserOrAdministratorLoggin) ||
                StringUtils.EqualsIgnoreCase(testType, TypeUserGroup))
            {
                return(TestTypeDynamic(pageInfo, contextInfo, testType, testValue, testOperate, successTemplateString,
                                       failureTemplateString));
            }

            var isSuccess = false;

            if (StringUtils.EqualsIgnoreCase(testType, TypeChannelName))
            {
                var channelName = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId).NodeName;
                isSuccess = TestTypeValue(testOperate, testValue, channelName);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeChannelIndex))
            {
                var channelIndex = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId).NodeIndexName;
                isSuccess = TestTypeValue(testOperate, testValue, channelIndex);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeTemplateName))
            {
                isSuccess = TestTypeValue(testOperate, testValue, pageInfo.TemplateInfo.TemplateName);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeTemplateType))
            {
                isSuccess = TestTypeValue(testOperate, testValue, ETemplateTypeUtils.GetValue(pageInfo.TemplateInfo.TemplateType));
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeTopLevel))
            {
                var topLevel = NodeManager.GetTopLevel(pageInfo.PublishmentSystemId, contextInfo.ChannelId);
                isSuccess = IsNumber(topLevel, testOperate, testValue);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeUpChannel))
            {
                isSuccess = TestTypeUpChannel(pageInfo, contextInfo, testOperate, testValue);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeUpChannelOrSelf))
            {
                isSuccess = TestTypeUpChannelOrSelf(pageInfo, contextInfo, testOperate, testValue);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeSelfChannel))
            {
                isSuccess = pageInfo.PageNodeId == contextInfo.ChannelId;
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeGroupChannel))
            {
                var groupChannels =
                    TranslateUtils.StringCollectionToStringList(
                        NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId).NodeGroupNameCollection);
                isSuccess = TestTypeValues(testOperate, testValue, groupChannels);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeGroupContent))
            {
                if (contextInfo.ContextType == EContextType.Content)
                {
                    var tableName     = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId);
                    var groupContents =
                        TranslateUtils.StringCollectionToStringList(BaiRongDataProvider.ContentDao.GetValue(tableName,
                                                                                                            contextInfo.ContentId, ContentAttribute.ContentGroupNameCollection));
                    isSuccess = TestTypeValues(testOperate, testValue, groupContents);
                }
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeAddDate))
            {
                var addDate = GetAddDateByContext(pageInfo, contextInfo);
                isSuccess = IsDateTime(addDate, testOperate, testValue);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeLastEditDate))
            {
                var lastEditDate = GetLastEditDateByContext(pageInfo, contextInfo);
                isSuccess = IsDateTime(lastEditDate, testOperate, testValue);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeItemIndex))
            {
                var itemIndex = StlParserUtility.GetItemIndex(contextInfo);
                isSuccess = IsNumber(itemIndex, testOperate, testValue);
            }
            else if (StringUtils.EqualsIgnoreCase(testType, TypeOddItem))
            {
                var itemIndex = StlParserUtility.GetItemIndex(contextInfo);
                isSuccess = itemIndex % 2 == 1;
            }
            else
            {
                isSuccess = TestTypeDefault(pageInfo, contextInfo, testType, testOperate, testValue);
            }

            var parsedContent = isSuccess ? successTemplateString : failureTemplateString;

            if (string.IsNullOrEmpty(parsedContent))
            {
                return(string.Empty);
            }

            var innerBuilder = new StringBuilder(parsedContent);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);

            parsedContent = innerBuilder.ToString();

            return(parsedContent);
        }
Пример #25
0
        public void Main(int publishmentSystemId, int uniqueId, string area, int channelId, int fileTemplateId, string templateType)
        {
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            var eTemplateType         = ETemplateTypeUtils.GetEnumType(templateType);

            if (!string.IsNullOrEmpty(area) && !string.IsNullOrEmpty(templateType))
            {
                AdvInfo advInfo = null;
                if (eTemplateType == ETemplateType.IndexPageTemplate || eTemplateType == ETemplateType.ChannelTemplate || eTemplateType == ETemplateType.ContentTemplate)
                {
                    advInfo = AdvManager.GetAdvInfoByAdAreaName(eTemplateType, area, publishmentSystemId, channelId, 0);
                }
                else if (eTemplateType == ETemplateType.FileTemplate)
                {
                    advInfo = AdvManager.GetAdvInfoByAdAreaName(eTemplateType, area, publishmentSystemId, 0, fileTemplateId);
                }
                if (advInfo != null)
                {
                    ArrayList adMaterialInfoList;
                    var       adMaterialInfo = AdvManager.GetShowAdMaterialInfo(publishmentSystemId, advInfo, out adMaterialInfoList);
                    if (advInfo.RotateType == EAdvRotateType.Equality || advInfo.RotateType == EAdvRotateType.HandWeight)
                    {
                        if (adMaterialInfo.AdMaterialType == EAdvType.HtmlCode)
                        {
                            HttpContext.Current.Response.Write($@"<!--
document.write('{StringUtils.ToJsString(adMaterialInfo.Code)}');
-->
");
                        }
                        else if (adMaterialInfo.AdMaterialType == EAdvType.Text)
                        {
                            var style = string.Empty;
                            if (!string.IsNullOrEmpty(adMaterialInfo.TextColor))
                            {
                                style += $"color:{adMaterialInfo.TextColor};";
                            }
                            if (adMaterialInfo.TextFontSize > 0)
                            {
                                style += $"font-size:{adMaterialInfo.TextFontSize}px;";
                            }
                            HttpContext.Current.Response.Write($@"<!--
document.write('<a href=""{PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, adMaterialInfo.TextLink))}"" target=""_blank"" style=""{style}"">{StringUtils.ToJsString(adMaterialInfo.TextWord)}</a>\r\n');
-->
");
                        }
                        else if (adMaterialInfo.AdMaterialType == EAdvType.Image)
                        {
                            var attribute = string.Empty;
                            if (adMaterialInfo.ImageWidth > 0)
                            {
                                attribute += $@" width=""{adMaterialInfo.ImageWidth}""";
                            }
                            if (adMaterialInfo.ImageHeight > 0)
                            {
                                attribute += $@" height=""{adMaterialInfo.ImageHeight}""";
                            }
                            if (!string.IsNullOrEmpty(adMaterialInfo.ImageAlt))
                            {
                                attribute += $@" title=""{adMaterialInfo.ImageAlt}""";
                            }
                            HttpContext.Current.Response.Write($@"<!--
document.write('<a href=""{PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, adMaterialInfo.ImageLink))}"" target=""_blank""><img src=""{PageUtility.ParseNavigationUrl(publishmentSystemInfo, adMaterialInfo.ImageUrl)}"" {attribute} border=""0"" /></a>\r\n');
-->
");
                        }
                        else if (adMaterialInfo.AdMaterialType == EAdvType.Flash)
                        {
                            var imageUrl = PageUtility.ParseNavigationUrl(publishmentSystemInfo,
                                                                          adMaterialInfo.ImageUrl);
                            HttpContext.Current.Response.Write($@"<!--
document.write('<div id=""flashcontent_{uniqueId}""></div>');
var so_{uniqueId} = new SWFObject(""{imageUrl}"", ""flash_{uniqueId}"", ""{adMaterialInfo.ImageWidth}"", ""{adMaterialInfo.ImageHeight}"", ""7"", """");

so_{uniqueId}.addParam(""quality"", ""high"");
so_{uniqueId}.addParam(""wmode"", ""transparent"");

so_{uniqueId}.write(""flashcontent_{uniqueId}"");
-->
");
                        }
                    }
                }
            }

            HttpContext.Current.Response.End();
        }
Пример #26
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            _templateType = Body.GetQueryString("templateType");
            _keywords     = Body.GetQueryString("keywords");

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdTemplate, "模板管理", AppManager.Cms.Permission.WebSite.Template);

                DdlTemplateType.Items.Add(new ListItem("<所有类型>", string.Empty));
                ETemplateTypeUtils.AddListItems(DdlTemplateType);
                ControlUtils.SelectListItems(DdlTemplateType, _templateType);

                TbKeywords.Text = _keywords;

                if (Body.IsQueryExists("Delete"))
                {
                    var templateId = Body.GetQueryInt("TemplateID");

                    try
                    {
                        var templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId);
                        if (templateInfo != null)
                        {
                            DataProvider.TemplateDao.Delete(PublishmentSystemId, templateId);
                            Body.AddSiteLog(PublishmentSystemId,
                                            $"删除{ETemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                            $"模板名称:{templateInfo.TemplateName}");
                        }
                        SuccessDeleteMessage();
                    }
                    catch (Exception ex)
                    {
                        FailDeleteMessage(ex);
                    }
                }
                else if (Body.IsQueryExists("SetDefault"))
                {
                    var templateId = Body.GetQueryInt("TemplateID");

                    try
                    {
                        var templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId);
                        if (templateInfo != null)
                        {
                            DataProvider.TemplateDao.SetDefault(PublishmentSystemId, templateId);
                            Body.AddSiteLog(PublishmentSystemId,
                                            $"设置默认{ETemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                            $"模板名称:{templateInfo.TemplateName}");
                        }
                        SuccessMessage();
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "操作失败");
                    }
                }

                if (string.IsNullOrEmpty(_templateType))
                {
                    LtlCommands.Text = $@"
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.IndexPageTemplate)}';"" value=""添加首页模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.ChannelTemplate)}';"" value=""添加栏目模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.ContentTemplate)}';"" value=""添加内容模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.FileTemplate)}';"" value=""添加单页模板"" />
";
                }
                else
                {
                    var eTemplateType = ETemplateTypeUtils.GetEnumType(_templateType);
                    LtlCommands.Text = $@"
<input type=""button"" class=""btn btn-success"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, eTemplateType)}';"" value=""添加{ETemplateTypeUtils.GetText(eTemplateType)}"" />
";
                }

                DgContents.DataSource     = DataProvider.TemplateDao.GetDataSource(PublishmentSystemId, _keywords, _templateType);
                DgContents.ItemDataBound += DgContents_ItemDataBound;
                DgContents.DataBind();
            }
        }
Пример #27
0
        private void DgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var templateId          = SqlUtils.EvalInt(e.Item.DataItem, "TemplateID");
                var templateType        = ETemplateTypeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, "TemplateType"));
                var templateName        = SqlUtils.EvalString(e.Item.DataItem, "TemplateName");
                var createdFileFullName = SqlUtils.EvalString(e.Item.DataItem, "CreatedFileFullName");
                var isDefault           = TranslateUtils.ToBool(SqlUtils.EvalString(e.Item.DataItem, "IsDefault"));

                var ltlTemplateName = (Literal)e.Item.FindControl("ltlTemplateName");
                var ltlFileName     = (Literal)e.Item.FindControl("ltlFileName");
                var ltlUseCount     = (Literal)e.Item.FindControl("ltlUseCount");
                var ltlTemplateType = (Literal)e.Item.FindControl("ltlTemplateType");
                var ltlDefaultUrl   = (Literal)e.Item.FindControl("ltlDefaultUrl");
                var ltlCopyUrl      = (Literal)e.Item.FindControl("ltlCopyUrl");
                var ltlLogUrl       = (Literal)e.Item.FindControl("ltlLogUrl");
                var ltlCreateUrl    = (Literal)e.Item.FindControl("ltlCreateUrl");
                var ltlDeleteUrl    = (Literal)e.Item.FindControl("ltlDeleteUrl");

                var templateAddUrl = PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, templateId, templateType);
                ltlTemplateName.Text = $@"<a href=""{templateAddUrl}"">{templateName}</a>";

                if (templateType == ETemplateType.IndexPageTemplate || templateType == ETemplateType.FileTemplate)
                {
                    var url = PageUtility.ParseNavigationUrl(PublishmentSystemInfo, createdFileFullName);
                    ltlFileName.Text = $"<a href='{url}' target='_blank'>{createdFileFullName}</a>";
                }

                ltlUseCount.Text = DataProvider.TemplateDao.GetTemplateUseCount(PublishmentSystemId, templateId, templateType, isDefault).ToString();

                ltlTemplateType.Text = ETemplateTypeUtils.GetText(templateType);

                if (templateType != ETemplateType.FileTemplate)
                {
                    if (isDefault)
                    {
                        ltlDefaultUrl.Text = "默认模板";
                    }
                    else
                    {
                        var defaultUrl = PageUtils.GetCmsUrl(nameof(PageTemplate), new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "TemplateID", templateId.ToString() },
                            { "SetDefault", true.ToString() }
                        });
                        ltlDefaultUrl.Text =
                            $@"<a href=""{defaultUrl}"" onClick=""javascript:return confirm('此操作将把此模板设为默认,确认吗?');"">设为默认</a>";
                    }
                }

                var copyUrl = PageTemplateAdd.GetRedirectUrlToCopy(PublishmentSystemId, templateId);
                ltlCopyUrl.Text = $@"<a href=""{copyUrl}"">快速复制</a>";

                var logUrl = PageTemplateLog.GetRedirectUrl(PublishmentSystemId, templateId);
                ltlLogUrl.Text = $@"<a href=""{logUrl}"">修订历史</a>";

                ltlCreateUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(
                        PublishmentSystemId, templateId)}"">生成页面</a>";

                if (!isDefault)
                {
                    var deleteUrl = PageUtils.GetCmsUrl(nameof(PageTemplate), new NameValueCollection
                    {
                        { "PublishmentSystemID", PublishmentSystemId.ToString() },
                        { "TemplateID", templateId.ToString() },
                        { "Delete", true.ToString() }
                    });
                    ltlDeleteUrl.Text =
                        $@"<a href=""{deleteUrl}"" onClick=""javascript:return confirm('此操作将删除模板“{templateName}”,确认吗?');"">删除</a>";
                }
            }
        }
Пример #28
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);
        }
Пример #29
0
        public Dictionary <int, TemplateInfo> GetTemplateInfoDictionaryByPublishmentSystemId(int publishmentSystemId)
        {
            var dictionary = new Dictionary <int, TemplateInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId)
            };

            using (var rdr = ExecuteReader(SqlSelectAllTemplateByPublishmentSystemId, parms))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ETemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i));
                    dictionary.Add(info.TemplateId, info);
                }
                rdr.Close();
            }

            return(dictionary);
        }
Пример #30
0
        public List <TemplateInfo> GetTemplateInfoListOfFile(int publishmentSystemId)
        {
            var list = new List <TemplateInfo>();

            string sqlString =
                $"SELECT TemplateID, PublishmentSystemID, TemplateName, TemplateType, RelatedFileName, CreatedFileFullName, CreatedFileExtName, Charset, IsDefault FROM siteserver_Template WHERE PublishmentSystemID = {publishmentSystemId} AND TemplateType = '{ETemplateTypeUtils.GetValue(ETemplateType.FileTemplate)}' ORDER BY RelatedFileName";

            using (var rdr = ExecuteReader(sqlString))
            {
                while (rdr.Read())
                {
                    var i    = 0;
                    var info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ETemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i));
                    list.Add(info);
                }
                rdr.Close();
            }
            return(list);
        }