Exemple #1
0
        public static LabelManageInfo GetCacheLabelByName(string labelName)
        {
            string str2;
            string key = "CK_Label_LabelManageInfo_" + labelName;

            if (HttpContext.Current != null)
            {
                str2 = HttpContext.Current.Server.MapPath("~/" + LabelLibPath) + @"\" + labelName + ".config";
            }
            else
            {
                str2 = AppDomain.CurrentDomain.BaseDirectory + LabelLibPath + @"\" + labelName + ".config";
            }
            LabelManageInfo labelByName = SiteCache.Get(key) as LabelManageInfo;

            if (labelByName == null)
            {
                labelByName = GetLabelByName(labelName);
                if (File.Exists(str2))
                {
                    SiteCache.Insert(key, labelByName, new System.Web.Caching.CacheDependency(str2));//将EasyOne.Components.改了
                }
            }
            return(labelByName);
        }
        public static string ReplaceInsideLink(string inputText)
        {
            inputText = inputText.Replace("&lt;", "<");
            inputText = inputText.Replace("&gt;", ">");
            IList <WordReplaceInfo> list = SiteCache.Get("CK_Accessories_ReplaceInsideLinkList") as List <WordReplaceInfo>;
            string input = inputText;

            if (list == null)
            {
                list = dal.GetInsideLink(0, 0, "", 2);
                SiteCache.Insert("CK_Accessories_ReplaceInsideLinkList", list);
            }
            foreach (WordReplaceInfo info in list)
            {
                int replaceTimes = 0;
                s_SourceWord   = info.SourceWord;
                s_ReplaceTimes = info.ReplaceTimes;
                if (info.OpenType)
                {
                    s_LinkType = "<a class=\"insidelink\" href=\"" + info.TargetWord + "\">" + info.SourceWord + "</a>";
                }
                else
                {
                    s_LinkType = "<a class=\"insidelink\" href=\"" + info.TargetWord + "\" target=\"_blank\">" + info.SourceWord + "</a>";
                }
                if (input.IndexOf("</a>", StringComparison.Ordinal) > 0)
                {
                    Regex regex = new Regex(@"((^|</a>)[\s\S]*?<a|</a>[\s\S]*$)", RegexOptions.IgnoreCase);
                    foreach (Match match in regex.Matches(input))
                    {
                        Regex regex2 = new Regex("(?<!<[^<>]*)" + s_SourceWord + "(?![^<>]*>)", RegexOptions.IgnoreCase);
                        int   count  = regex2.Matches(match.Value).Count;
                        if (count <= (info.ReplaceTimes - replaceTimes))
                        {
                            input         = input.Replace(match.Value, regex2.Replace(match.Value, s_LinkType));
                            replaceTimes += count;
                        }
                        else
                        {
                            input        = input.Replace(match.Value, regex2.Replace(match.Value, s_LinkType, (int)(info.ReplaceTimes - replaceTimes)));
                            replaceTimes = info.ReplaceTimes;
                        }
                    }
                    continue;
                }
                Regex regex3 = new Regex("(?<!<[^<>]*)" + s_SourceWord + "(?![^<>]*>)", RegexOptions.IgnoreCase);
                if (regex3.Matches(input).Count <= (info.ReplaceTimes - replaceTimes))
                {
                    input = input.Replace(input, regex3.Replace(input, s_LinkType));
                }
                else
                {
                    input        = input.Replace(input, regex3.Replace(input, s_LinkType, (int)(info.ReplaceTimes - replaceTimes)));
                    replaceTimes = info.ReplaceTimes;
                }
            }
            return(input.Replace("<", "&lt;").Replace(">", "&gt;"));
        }
Exemple #3
0
        public static IList <PagerManageInfo> GetPagerList(string type)
        {
            string key = "CK_Label_PagerLabelList_Type_" + type;
            List <PagerManageInfo> list = new List <PagerManageInfo>();

            if (SiteCache.Get(key) == null)
            {
                string str2;
                if (HttpContext.Current != null)
                {
                    str2 = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath);
                }
                else
                {
                    str2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PagerLabelLibPath);
                }
                DirectoryInfo info = new DirectoryInfo(str2);
                if (info.Exists)
                {
                    foreach (FileInfo info2 in info.GetFiles())
                    {
                        try
                        {
                            using (StreamReader reader = info2.OpenText())
                            {
                                XmlDocument document = new XmlDocument();
                                document.Load(reader);
                                PagerManageInfo item = new PagerManageInfo();
                                item.Name  = Path.GetFileNameWithoutExtension(info2.Name);
                                item.Type  = document.SelectSingleNode("root/LabelType").InnerText;
                                item.Image = document.SelectSingleNode("root/LabelImage").InnerText;
                                item.Intro = document.SelectSingleNode("root/LabelIntro").InnerText;
                                if (string.IsNullOrEmpty(item.Image))
                                {
                                    item.Image = "~/Admin/Images/LabelIco/def.ico";
                                }
                                item.UpDateTime = info2.LastWriteTime;
                                if (((type == item.Type) || string.IsNullOrEmpty(type)) || (type == "全部分类"))
                                {
                                    list.Add(item);
                                }
                            }
                        }
                        catch (XmlException exception)
                        {
                            exception.ToString();
                        }
                    }
                }
                SiteCache.Insert(key, list, new CacheDependency(str2));//add sql
                return(list);
            }
            return((List <PagerManageInfo>)SiteCache.Get(key));
        }
Exemple #4
0
        public static ModelInfo GetModelInfoById(int id)
        {
            string    key           = "CK_CommonModel_ModelInfo_ModelId_" + id.ToString();
            ModelInfo modelInfoById = SiteCache.Get(key) as ModelInfo;

            if (modelInfoById == null)
            {
                modelInfoById = dal.GetModelInfoById(id);
                SiteCache.Insert(key, modelInfoById);
            }
            return(modelInfoById);
        }
Exemple #5
0
        public static IList <ModelInfo> GetCacheModelList()
        {
            string            key       = "CK_CommonModel_ModelList_All";
            IList <ModelInfo> modelList = SiteCache.Get(key) as IList <ModelInfo>;

            if (modelList == null)
            {
                modelList = GetModelList(ModelType.None, ModelShowType.None);
                SiteCache.Insert(key, modelList, 0x4380);
            }
            return(modelList);
        }
Exemple #6
0
        public static IList <PagerManageInfo> GetPagerTypeList()
        {
            string key = "CK_Label_PagerLabel_Type";
            List <PagerManageInfo> list = new List <PagerManageInfo>();

            if (SiteCache.Get(key) == null)
            {
                string        str2;
                List <string> list2 = new List <string>();
                if (HttpContext.Current != null)
                {
                    str2 = HttpContext.Current.Server.MapPath("~/" + PagerLabelLibPath);
                }
                else
                {
                    str2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PagerLabelLibPath);
                }
                DirectoryInfo info = new DirectoryInfo(str2);
                if (info.Exists)
                {
                    foreach (FileInfo info2 in info.GetFiles())
                    {
                        XmlDocument document = new XmlDocument();
                        try
                        {
                            using (StreamReader reader = info2.OpenText())
                            {
                                document.Load(reader);
                                string innerText = document.SelectSingleNode("root/LabelType").InnerText;
                                if (!list2.Contains(innerText) && !string.IsNullOrEmpty(innerText))
                                {
                                    list2.Add(innerText);
                                }
                            }
                        }
                        catch (XmlException exception)
                        {
                            exception.ToString();
                        }
                    }
                }
                foreach (string str4 in list2)
                {
                    list.Add(new PagerManageInfo(str4));
                }
                SiteCache.Insert(key, list, new CacheDependency(str2));//add sql
                return(list);
            }
            return((List <PagerManageInfo>)SiteCache.Get(key));
        }
        public static string CurrentVersion()
        {
            string str = "0.0.0.0";
            string key = "CK_System_DataBaseCurrentVersion";

            if (SiteCache.Get(key) == null)
            {
                DataBaseVersionInfo info = LastVersion();
                str = info.Major.ToString(CultureInfo.CurrentCulture) + "." + info.Minor.ToString(CultureInfo.CurrentCulture) + "." + info.Build.ToString(CultureInfo.CurrentCulture) + "." + info.Revision.ToString(CultureInfo.CurrentCulture);
                SiteCache.Insert(key, str, 0x4380);
                return(str);
            }
            return(SiteCache.Get(key).ToString());
        }
        public static string ReplaceText(string inputText)
        {
            IList <WordReplaceInfo> wordFilterList = SiteCache.Get("CK_Accessories_WordReplaceInfoList") as List <WordReplaceInfo>;
            StringBuilder           builder        = new StringBuilder(inputText);

            if (wordFilterList == null)
            {
                wordFilterList = GetWordFilterList();
                SiteCache.Insert("CK_Accessories_WordReplaceInfoList", wordFilterList);
            }
            foreach (WordReplaceInfo info in wordFilterList)
            {
                builder.Replace(info.SourceWord, info.TargetWord);
            }
            return(builder.ToString());
        }
Exemple #9
0
        public static NodeInfo GetCacheNodeById(int nodeId)
        {
            if ((nodeId != -2) && (nodeId <= 0))
            {
                return(new NodeInfo(true));
            }
            string   key      = "CK_Content_NodeInfo_NodeId_" + nodeId.ToString();
            NodeInfo nodeById = SiteCache.Get(key) as NodeInfo;

            if (nodeById == null)
            {
                nodeById = dal.GetNodeById(nodeId);
                if (!nodeById.IsNull)
                {
                    SiteCache.Insert(key, nodeById, 0x4380);
                }
            }
            return(nodeById);
        }
        private string ContentLabelProc(string getlabel, string lrootpath, string lpagename, int lpage)
        {
            if (string.IsNullOrEmpty(getlabel))
            {
                return(string.Empty);
            }
            getlabel = getlabel.Replace("{", "<").Replace("}", ">");
            XmlDocument document  = new XmlDocument();
            LabelInfo   labelInfo = new LabelInfo();

            labelInfo.RootPath = lrootpath;
            labelInfo.PageName = lpagename;
            labelInfo.Page     = lpage;
            try
            {
                document.LoadXml(getlabel);
                foreach (XmlAttribute attribute in document.FirstChild.Attributes)
                {
                    labelInfo.OriginalData[attribute.Name] = attribute.Value;
                }
            }
            catch (XmlException exception)
            {
                return("[err:内容标签" + getlabel.Replace("<", string.Empty).Replace("/>", string.Empty) + "错,原因:" + exception.Message + "]");
            }
            string key     = "CK_Label_TransformCacheData_" + labelInfo.OriginalData["id"] + "_" + labelInfo.OriginalData["cacheid"];
            int    seconds = DataConverter.CLng(labelInfo.OriginalData["cachetime"]);

            if ((seconds > 0) && (SiteCache.Get(key) != null))
            {
                labelInfo = (LabelInfo)SiteCache.Get(key);
            }
            else
            {
                labelInfo = LabelTransform.GetLabel(labelInfo);
                if (seconds > 0)
                {
                    SiteCache.Insert(key, labelInfo, seconds);
                }
            }
            return(labelInfo.LabelContent.ToString());
        }
Exemple #11
0
        public static IList <LabelManageInfo> GetLabelTypeList()
        {
            string key = "CK_Label_LabelTypeList";
            List <LabelManageInfo> list = new List <LabelManageInfo>();

            if (SiteCache.Get(key) == null)
            {
                string        path  = HttpContext.Current.Server.MapPath("~/" + LabelLibPath);
                DirectoryInfo info  = new DirectoryInfo(path);
                List <string> list2 = new List <string>();
                if (info.Exists)
                {
                    foreach (FileInfo info2 in info.GetFiles("*.config"))
                    {
                        XmlDocument document = new XmlDocument();
                        try
                        {
                            using (StreamReader reader = info2.OpenText())
                            {
                                document.Load(reader);
                                string innerText = document.SelectSingleNode("root/LabelType").InnerText;
                                if (!list2.Contains(innerText) && !string.IsNullOrEmpty(innerText))
                                {
                                    list2.Add(innerText);
                                }
                            }
                        }
                        catch (XmlException exception)
                        {
                            exception.ToString();
                        }
                    }
                }
                foreach (string str4 in list2)
                {
                    list.Add(new LabelManageInfo(str4));
                }
                SiteCache.Insert(key, list, new CacheDependency(path));
                return(list);
            }
            return((List <LabelManageInfo>)SiteCache.Get(key));
        }
Exemple #12
0
        public static string GetCacheContentModelIdList()
        {
            string key  = "CK_CommonModel_String_ModelIdArr_Content";
            string str2 = SiteCache.Get(key) as string;

            if (string.IsNullOrEmpty(str2))
            {
                StringBuilder builder = new StringBuilder();
                foreach (ModelInfo info in GetModelList(ModelType.Content, ModelShowType.Enable))
                {
                    if (builder.Length > 0)
                    {
                        builder.Append(",");
                    }
                    builder.Append(info.ModelId.ToString());
                }
                str2 = builder.ToString();
                SiteCache.Insert(key, str2, 0x4380);
            }
            return(str2);
        }
Exemple #13
0
        public static IList <LabelManageInfo> GetLabelList(string type)
        {
            string key = "CK_Label_LabelManageInfoList_Type__" + type;
            List <LabelManageInfo> list = new List <LabelManageInfo>();

            if (SiteCache.Get(key) == null)
            {
                string        path = HttpContext.Current.Server.MapPath("~/" + LabelLibPath);
                DirectoryInfo info = new DirectoryInfo(path);
                if (info.Exists)
                {
                    foreach (FileInfo info2 in info.GetFiles())
                    {
                        try
                        {
                            XmlDocument document = new XmlDocument();
                            using (StreamReader reader = info2.OpenText())
                            {
                                document.Load(reader);
                                LabelManageInfo item = new LabelManageInfo();
                                item.Name       = Path.GetFileNameWithoutExtension(info2.Name);
                                item.Type       = document.SelectSingleNode("root/LabelType").InnerText;
                                item.UpDateTime = info2.LastWriteTime;
                                if (((type == item.Type) || string.IsNullOrEmpty(type)) || (type == "全部分类"))
                                {
                                    list.Add(item);
                                }
                            }
                        }
                        catch (XmlException exception)
                        {
                            exception.ToString();
                        }
                    }
                }
                SiteCache.Insert(key, list, new CacheDependency(path));
                return(list);
            }
            return((List <LabelManageInfo>)SiteCache.Get(key));
        }
Exemple #14
0
        private static XmlNode GetNode()
        {
            XmlDocument document = SiteCache.Get("CK_System_XmlDocument_API_EnableConfig") as XmlDocument;

            if (document == null)
            {
                string str;
                document = new XmlDocument();
                HttpContext current = HttpContext.Current;
                if (current != null)
                {
                    str = current.Server.MapPath("~/API/API.Config");
                }
                else
                {
                    str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/Security.config");
                }
                try
                {
                    document.Load(str);
                }
                catch (XmlException exception)
                {
                    HttpContext.Current.Items["ErrorMessage"] = "API.Config配置文件不符合XML规范,具体错误信息:" + exception.Message;
                    HttpContext.Current.Server.Transfer("~/Prompt/ShowError.aspx");
                }
                SiteCache.Insert("CK_System_XmlDocument_API_EnableConfig", document, new CacheDependency(str));
            }
            XmlNode node = document.SelectSingleNode("Config/APISettings");

            if (node == null)
            {
                HttpContext.Current.Items["ErrorMessage"] = "Security.config配置文件不存在checkPermissions根元素";
                HttpContext.Current.Server.Transfer("~/Prompt/ShowError.aspx");
            }
            return(node);
        }
        public static string ToFieldType(string fieldValue, FieldType fieldtype)
        {
            string str = "";
            Dictionary <FieldType, string> dictionary = SiteCache.Get("CK_Content_Dictionary_ConvertFieldType") as Dictionary <FieldType, string>;

            if (dictionary == null)
            {
                dictionary = new Dictionary <FieldType, string>();
                dictionary.Add(FieldType.TextType, "Original");
                dictionary.Add(FieldType.MultipleTextType, "Original");
                dictionary.Add(FieldType.MultipleHtmlTextType, "Original");
                dictionary.Add(FieldType.ListBoxType, "Original");
                dictionary.Add(FieldType.NumberType, "Original");
                dictionary.Add(FieldType.MoneyType, "Original");
                dictionary.Add(FieldType.DateTimeType, "Original");
                dictionary.Add(FieldType.LookType, "Original");
                dictionary.Add(FieldType.LinkType, "Original");
                dictionary.Add(FieldType.BoolType, "ConvertBool");
                dictionary.Add(FieldType.CountType, "Original");
                dictionary.Add(FieldType.PictureType, "Original");
                dictionary.Add(FieldType.FileType, "Original");
                dictionary.Add(FieldType.MultiplePhotoType, "Original");
                dictionary.Add(FieldType.ColorType, "Original");
                dictionary.Add(FieldType.NodeType, "Original");
                dictionary.Add(FieldType.TemplateType, "Original");
                dictionary.Add(FieldType.InfoType, "Original");
                dictionary.Add(FieldType.SpecialType, "Original");
                dictionary.Add(FieldType.AuthorType, "Original");
                dictionary.Add(FieldType.SourceType, "Original");
                dictionary.Add(FieldType.KeywordType, "Original");
                dictionary.Add(FieldType.OperatingType, "Original");
                dictionary.Add(FieldType.SkinType, "Original");
                dictionary.Add(FieldType.StatusType, "Original");
                dictionary.Add(FieldType.Producer, "Original");
                dictionary.Add(FieldType.Trademark, "Original");
                dictionary.Add(FieldType.ContentType, "Original");
                dictionary.Add(FieldType.TitleType, "Original");
                dictionary.Add(FieldType.DownServerType, "Original");
                SiteCache.Insert("CK_Content_Dictionary_ConvertFieldType", dictionary);
            }
            string str2 = dictionary[fieldtype];

            if (str2 == null)
            {
                return(str);
            }
            if (!(str2 == "ConvertBool"))
            {
                if (str2 != "Original")
                {
                    return(str);
                }
            }
            else
            {
                if (string.Compare(fieldValue, "true", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return("1");
                }
                return("0");
            }
            return(fieldValue);
        }
        /// <summary>
        /// 内容标签转换
        /// </summary>
        /// <param name="OrangeStr"></param>
        /// <param name="templateInfo"></param>
        private void ContentLabelProc(string OrangeStr, TemplateInfo templateInfo)
        {
            XmlDocument document  = new XmlDocument();
            LabelInfo   labelInfo = new LabelInfo();

            labelInfo.RootPath = templateInfo.RootPath;
            labelInfo.PageName = templateInfo.PageName;
            try
            {
                document.LoadXml(FormatLabel(OrangeStr));
                foreach (XmlAttribute attribute in document.FirstChild.Attributes)
                {
                    labelInfo.OriginalData[attribute.Name.ToLower()] = attribute.Value;
                }
            }
            catch (XmlException exception)
            {
                templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(OrangeStr, "[err:内容标签" + OrangeStr.Replace("{", string.Empty).Replace("/}", string.Empty) + "错,原因:" + exception.Message + "]");
                return;
            }
            bool flag = DataConverter.CBoolean(labelInfo.OriginalData["urlpage"]);

            if (flag)
            {
                labelInfo.Page = templateInfo.CurrentPage;
            }
            string key     = "CK_Label_TransformCacheData_" + labelInfo.OriginalData["id"] + "_" + labelInfo.OriginalData["cacheid"];
            int    seconds = DataConverter.CLng(labelInfo.OriginalData["cachetime"]);

            if ((seconds > 0) && (SiteCache.Get(key) != null))
            {
                labelInfo = (LabelInfo)SiteCache.Get(key);
            }
            else
            {
                labelInfo = LabelTransform.GetLabel(labelInfo);
                if (seconds > 0)
                {
                    SiteCache.Insert(key, labelInfo, seconds);
                }
            }
            string str2 = labelInfo.OriginalData["span"];
            string str3 = labelInfo.OriginalData["id"].ToLower().Trim();
            string str4 = labelInfo.OriginalData["class"];

            if (!string.IsNullOrEmpty(str2))
            {
                if (string.IsNullOrEmpty(str4))
                {
                    labelInfo.LabelContent.Insert(0, "<" + str2 + " id=\"pe100_" + str3 + "\">");
                }
                else
                {
                    labelInfo.LabelContent.Insert(0, "<" + str2 + " id=\"pe100_" + str3 + "\" class=\"" + str4 + "\">");
                }
                labelInfo.LabelContent.Append("</" + str2 + ">");
            }
            if (DataConverter.CBoolean(labelInfo.OriginalData["noprocinlabel"]))
            {
                this.tempstr.Add(this.loopmark.ToString(), labelInfo.LabelContent.ToString());
                templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(OrangeStr, "###labelmark" + this.loopmark.ToString() + "###");
                this.loopmark++;
            }
            else
            {
                templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(OrangeStr, labelInfo.LabelContent.ToString());
            }
            if (DataConverter.CBoolean(labelInfo.OriginalData["page"]))
            {
                PageInfo item = new PageInfo();
                item.PageName      = templateInfo.PageName;
                item.SpanName      = str3;
                item.IsDynamicPage = templateInfo.IsDynamicPage;
                if ((labelInfo.PageSize > 0) && (labelInfo.TotalPub > 0))
                {
                    int num2 = labelInfo.TotalPub / labelInfo.PageSize;
                    if ((labelInfo.TotalPub % labelInfo.PageSize) > 0)
                    {
                        num2++;
                    }
                    if (num2 < 1)
                    {
                        num2 = 1;
                    }
                    item.PageNum     = num2;
                    item.PageSize    = labelInfo.PageSize;
                    item.CurrentPage = templateInfo.CurrentPage;
                    item.TotalPub    = labelInfo.TotalPub;
                    if (flag)
                    {
                        item.IsMainPage = true;
                    }
                    this.tempLabelPageList.Add(item);
                }
            }
        }
        /// <summary>
        /// 数据源标签转换
        /// </summary>
        /// <param name="getLabel"></param>
        /// <param name="templateInfo"></param>
        private void DatasourceLabelProc(string getLabel, TemplateInfo templateInfo)
        {
            XmlDocument document = new XmlDocument();
            string      xml      = getLabel.Replace("{", "<").Replace("}", ">");
            LabelInfo   inLabel  = new LabelInfo();

            inLabel.RootPath = templateInfo.RootPath;
            inLabel.PageName = templateInfo.PageName;
            try
            {
                document.LoadXml(xml);
                foreach (XmlAttribute attribute in document.FirstChild.Attributes)
                {
                    inLabel.OriginalData[attribute.Name.ToLower()] = attribute.Value;
                }
            }
            catch (XmlException exception)
            {
                templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(getLabel, "[err:数据源标签" + getLabel.Replace("{", string.Empty).Replace("}", string.Empty) + "格式错,原因:" + exception.Message + "]");
                return;
            }
            string str2 = inLabel.OriginalData["id"];
            string str3 = inLabel.OriginalData["datasource"];

            if (!string.IsNullOrEmpty(str2))
            {
                str2 = str2.ToLower().Trim();
                if (string.IsNullOrEmpty(str3))
                {
                    templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(getLabel, "[err:数据源标签" + getLabel.Replace("{", string.Empty).Replace("}", string.Empty) + "错,原因:请指定DataSource]");
                }
                else
                {
                    str3 = str3.ToLower().Trim();
                    bool flag = DataConverter.CBoolean(inLabel.OriginalData["urlpage"]);
                    if (flag)
                    {
                        inLabel.Page = templateInfo.CurrentPage;
                    }
                    string key     = "CK_Label_TransformCacheXmlData_" + str2 + "_" + inLabel.OriginalData["cacheid"];
                    int    seconds = DataConverter.CLng(inLabel.OriginalData["cachetime"]);
                    if ((seconds > 0) && (SiteCache.Get(key) != null))
                    {
                        inLabel = (LabelInfo)SiteCache.Get(key);
                    }
                    else
                    {
                        inLabel = LabelTransform.GetLabelDataTable(str3, templateInfo.CurrentPage, inLabel);
                        if (seconds > 0)
                        {
                            SiteCache.Insert(key, inLabel, seconds);
                        }
                    }
                    try
                    {
                        document.LoadXml(inLabel.LabelContent.ToString());
                    }
                    catch (XmlException exception2)
                    {
                        templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(getLabel, "[err:数据源标签" + getLabel.Replace("{", string.Empty).Replace("}", string.Empty) + "返回数据错,原因:" + exception2.Message + ",源码:" + inLabel.LabelContent.ToString() + "]");
                        return;
                    }
                    templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(getLabel, string.Empty);
                    string pattern = @"{PE\.Repeat(.*)}(([\s\S](?!{PE\.Repeat))*?)\{\/PE.Repeat}";
                    foreach (Match match in Regex.Matches(templateInfo.TemplateContent, pattern, RegexOptions.IgnoreCase))
                    {
                        XmlNode firstChild;
                        if (match.Groups.Count < 3)
                        {
                            templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.Value, "[err:循环标签" + match.Value.Replace("{", string.Empty).Replace("}", string.Empty) + "格式错");
                            continue;
                        }
                        XmlDocument document2 = new XmlDocument();
                        xml = "<root " + match.Groups[1].Value + " />";
                        try
                        {
                            document2.LoadXml(xml);
                            firstChild = document2.FirstChild;
                        }
                        catch (XmlException exception3)
                        {
                            templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.Value, "[err:循环标签{PE:Repeat " + match.Groups[1].Value + " /}错,原因:" + exception3.Message + "]");
                            continue;
                        }
                        if (string.Compare(XmlManage.GetAttributesValue(firstChild, "id"), str2, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            string input = match.Groups[2].Value;
                            int    num2  = 0;
                            string str7  = string.Empty;
                            string str8  = @"{PE\.RMod(.*)}(([\s\S](?!{PE\.RMod))*?)\{\/PE.RMod}";
                            foreach (Match match2 in Regex.Matches(input, str8, RegexOptions.IgnoreCase))
                            {
                                if (match2.Groups.Count >= 3)
                                {
                                    XmlDocument document3 = new XmlDocument();
                                    xml = "<root " + match2.Groups[1].Value + " />";
                                    bool flag2 = true;
                                    try
                                    {
                                        document3.LoadXml(xml);
                                        num2 = DataConverter.CLng(XmlManage.GetAttributesValue(document3.FirstChild, "mod"));
                                    }
                                    catch (XmlException)
                                    {
                                        flag2 = false;
                                    }
                                    if (flag2)
                                    {
                                        str7 = match2.Groups[2].Value;
                                    }
                                    input = input.Replace(match2.Value, string.Empty);
                                }
                            }
                            int num3  = DataConverter.CLng(XmlManage.GetAttributesValue(firstChild, "loopbegin"), 0);
                            int count = DataConverter.CLng(XmlManage.GetAttributesValue(firstChild, "loop"), 0);
                            int num5  = DataConverter.CLng(XmlManage.GetAttributesValue(firstChild, "countbase"), 0);
                            if ((num3 >= 0) && (count >= 0))
                            {
                                if (num3 >= document.DocumentElement.ChildNodes.Count)
                                {
                                    num3 = document.DocumentElement.ChildNodes.Count - 1;
                                    if (num3 < 0)
                                    {
                                        num3 = 0;
                                    }
                                }
                                if ((count == 0) || (count > document.DocumentElement.ChildNodes.Count))
                                {
                                    count = document.DocumentElement.ChildNodes.Count;
                                    if (count < 0)
                                    {
                                        count = 0;
                                    }
                                }
                                if (num3 > count)
                                {
                                    num3 = count;
                                }
                                StringBuilder builder = new StringBuilder();
                                for (int i = num3; i < count; i++)
                                {
                                    input = Regex.Replace(input, "{PE.Field.AutoId/}", (i + num5).ToString(), RegexOptions.IgnoreCase);
                                    str7  = Regex.Replace(str7, "{PE.Field.AutoId/}", (i + num5).ToString(), RegexOptions.IgnoreCase);
                                    builder.Append(this.FieldProc(input, str2, (XmlElement)document.DocumentElement.ChildNodes[i], 1, templateInfo));
                                    if ((num2 > 0) && (((i + 1) % num2) == 0))
                                    {
                                        builder.Append(str7);
                                    }
                                }
                                templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.Value, builder.ToString());
                                continue;
                            }
                            templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(match.Value, string.Empty);
                        }
                    }
                    templateInfo.TemplateContent = this.FieldProc(templateInfo.TemplateContent, str2, document.DocumentElement, 0, templateInfo);
                    if (DataConverter.CBoolean(inLabel.OriginalData["page"]))
                    {
                        PageInfo item = new PageInfo();
                        item.PageName      = templateInfo.PageName;
                        item.SpanName      = str2;
                        item.IsDynamicPage = templateInfo.IsDynamicPage;
                        if ((inLabel.PageSize > 0) && (inLabel.TotalPub > 0))
                        {
                            int num7 = inLabel.TotalPub / inLabel.PageSize;
                            if ((inLabel.TotalPub % inLabel.PageSize) > 0)
                            {
                                num7++;
                            }
                            if (num7 < 1)
                            {
                                num7 = 1;
                            }
                            item.PageNum     = num7;
                            item.PageSize    = inLabel.PageSize;
                            item.CurrentPage = inLabel.Page;
                            item.TotalPub    = inLabel.TotalPub;
                            if (flag)
                            {
                                item.IsMainPage = true;
                            }
                            this.tempLabelPageList.Add(item);
                        }
                    }
                }
            }
            else
            {
                templateInfo.TemplateContent = templateInfo.TemplateContent.Replace(getLabel, "[err:数据源标签" + getLabel.Replace("{", string.Empty).Replace("}", string.Empty) + "错,原因:请指定ID]");
            }
        }
Exemple #18
0
        public static IList <LabelManageInfo> GetLabelList(int type, int field, string keyword, string labelCategory)
        {
            string key = "CK_Label_LabelManageInfoList_Type_Search__" + labelCategory;
            List <LabelManageInfo> list = new List <LabelManageInfo>();

            if (!string.IsNullOrEmpty(keyword))
            {
                keyword = keyword.Trim();
            }
            if ((type == 1) || (SiteCache.Get(key) == null))
            {
                string        path = HttpContext.Current.Server.MapPath("~/" + LabelLibPath);
                DirectoryInfo info = new DirectoryInfo(path);
                if (info.Exists)
                {
                    List <FileInfo> list2 = new List <FileInfo>();
                    list2.AddRange(info.GetFiles());
                    foreach (FileInfo info2 in list2)
                    {
                        try
                        {
                            using (StreamReader reader = info2.OpenText())
                            {
                                XmlDocument document = new XmlDocument();
                                document.Load(reader);
                                LabelManageInfo item = new LabelManageInfo();
                                item.Name       = Path.GetFileNameWithoutExtension(info2.Name);
                                item.Type       = document.SelectSingleNode("root/LabelType").InnerText;
                                item.Intro      = document.SelectSingleNode("root/LabelIntro").InnerText;
                                item.UpDateTime = info2.LastWriteTime;
                                switch (type)
                                {
                                case 0:
                                {
                                    list.Add(item);
                                    continue;
                                }

                                case 1:
                                {
                                    if ((field != 0) || string.IsNullOrEmpty(keyword))
                                    {
                                        break;
                                    }
                                    if (item.Name.IndexOf(keyword, 0, StringComparison.CurrentCultureIgnoreCase) >= 0)
                                    {
                                        list.Add(item);
                                    }
                                    continue;
                                }

                                default:
                                    goto Label_016C;
                                }
                                if ((field == 1) && (document.SelectSingleNode("root").InnerText.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0))
                                {
                                    list.Add(item);
                                }
                                continue;
Label_016C:
                                if (((labelCategory == item.Type) || string.IsNullOrEmpty(labelCategory)) || (labelCategory == "全部分类"))
                                {
                                    list.Add(item);
                                }
                            }
                            continue;
                        }
                        catch (XmlException exception)
                        {
                            exception.ToString();
                            continue;
                        }
                    }
                }
                if (type != 1)
                {
                    SiteCache.Insert(key, list, new CacheDependency(path));
                }
                return(list);
            }
            return((List <LabelManageInfo>)SiteCache.Get(key));
        }
        private void PutLabelBody(XmlDocument xmldoc)
        {
            string      nodeInnerText = GetNodeInnerText(xmldoc, "//labelname");
            string      lrootpath     = GetNodeInnerText(xmldoc, "//rootpath");
            string      str3          = GetNodeInnerText(xmldoc, "//pagename");
            string      input         = GetNodeInnerText(xmldoc, "//currentpage", "1");
            XmlNodeList list          = xmldoc.DocumentElement.SelectNodes("//attrib");

            if (string.IsNullOrEmpty(nodeInnerText))
            {
                this.PutErrMessage("标签名不能为空!");
            }
            else if (!this.CheckLabel(nodeInnerText))
            {
                this.PutErrMessage(nodeInnerText + "标签禁止AJAX访问!");
            }
            else
            {
                LabelInfo labelInfo = new LabelInfo();
                new XmlDocument();
                labelInfo.RootPath           = lrootpath;
                labelInfo.PageName           = str3;
                labelInfo.Page               = DataConverter.CLng(input);
                labelInfo.TotalPub           = 0;
                labelInfo.OriginalData["id"] = nodeInnerText;
                foreach (XmlNode node in list)
                {
                    if (node.FirstChild != null)
                    {
                        labelInfo.OriginalData[node.FirstChild.Name.Trim()] = DataSecurity.FilterSqlKeyword(DataSecurity.PELabelEncode(node.FirstChild.InnerText.Trim()));
                    }
                }
                string key     = "CK_Label_TransformCacheData_" + nodeInnerText + "_" + labelInfo.OriginalData["cacheid"];
                int    seconds = DataConverter.CLng(labelInfo.OriginalData["cachetime"]);
                if ((seconds > 0) && (SiteCache.Get(key) != null))
                {
                    labelInfo = (LabelInfo)SiteCache.Get(key);
                }
                else
                {
                    labelInfo = LabelTransform.GetLabel(labelInfo);
                    string pattern = @"{PE\.Label([\s\S](?!{PE))*?\/}";
                    bool   flag    = false;
                    do
                    {
                        flag = false;
                        foreach (Match match in Regex.Matches(labelInfo.LabelContent.ToString(), pattern, RegexOptions.IgnoreCase))
                        {
                            labelInfo.LabelContent.Replace(match.Value, this.ContentLabelProc(match.Value, lrootpath, labelInfo.PageName, labelInfo.Page));
                            flag = true;
                        }
                    }while (flag);
                    if (seconds > 0)
                    {
                        SiteCache.Insert(key, labelInfo, seconds);
                    }
                }
                this.XmlResponseWriter.WriteElementString("status", "ok");
                this.XmlResponseWriter.WriteElementString("body", DataSecurity.PELabelDecode(labelInfo.LabelContent.ToString()));
                this.XmlResponseWriter.WriteElementString("pagename", str3);
                this.XmlResponseWriter.WriteElementString("total", labelInfo.TotalPub.ToString());
                this.XmlResponseWriter.WriteElementString("currentpage", labelInfo.Page.ToString());
                this.XmlResponseWriter.WriteElementString("pagesize", labelInfo.PageSize.ToString());
            }
        }
Exemple #20
0
        /// <summary>
        /// 用来判断用户对该页面是否有访问权限
        /// </summary>
        private void CheckPagePermission()
        {
            bool        flag     = false;
            string      str      = base.Request.AppRelativeCurrentExecutionFilePath.ToLower(CultureInfo.CurrentCulture).Replace("~/admin/", "");
            string      strA     = "";
            XmlDocument document = SiteCache.Get("CK_System_XmlDocument_FilePermissionConfig") as XmlDocument;//从缓存获取文件权限

            if (document == null)
            {
                //缓存对象所依赖的文件或目录的路径。当该资源更改时,缓存的对象将过时,并从缓存中移除
                string str3;
                document = new XmlDocument();
                HttpContext current = HttpContext.Current;
                if (current != null)
                {
                    str3 = current.Server.MapPath("~/Config/Security.config");
                }
                else
                {
                    str3 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/Security.config");
                }
                try
                {
                    document.Load(str3);
                }
                catch (XmlException exception)
                {
                    WriteErrMsg("Security.config配置文件不符合XML规范,具体错误信息:" + exception.Message);
                }
                // CacheDpendency(string filename)初始化 CacheDependency 类的新实例,它监视文件或目录的更改情况
                SiteCache.Insert("CK_System_XmlDocument_FilePermissionConfig", document, new CacheDependency(str3));
            }
            XmlNode xmlNode = document.SelectSingleNode("security/checkPermissions");

            if (xmlNode == null)
            {
                WriteErrMsg("Security.config配置文件不存在checkPermissions根元素");
            }
            string      attributeValue = GetAttributeValue(xmlNode, "mode");
            XmlNodeList list           = document.SelectNodes("//*[@url='" + str + "']");

            if ((string.Compare(attributeValue, "All", StringComparison.CurrentCultureIgnoreCase) == 0) && (list.Count <= 0))
            {
                WriteErrMsg("<li>对不起,您没有当前页面的访问权限!</li>");
            }
            if (list.Count > 0)
            {
                foreach (XmlNode node2 in list)
                {
                    string[] strArray4;
                    strA = GetAttributeValue(node2, "operateCode");
                    if (string.Compare(strA, "None", StringComparison.CurrentCultureIgnoreCase) == 0)
                    {
                        flag = true;
                        break;
                    }
                    if (!strA.Contains(","))
                    {
                        goto Label_022D;
                    }
                    string[] strArray = strA.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    string   str5     = GetAttributeValue(node2, "checkType");
                    if (string.IsNullOrEmpty(str5))
                    {
                        str5 = "or";
                    }
                    string str8 = str5;
                    if (str8 != null)
                    {
                        if (!(str8 == "or"))
                        {
                            if (str8 == "and")
                            {
                                goto Label_0200;
                            }
                        }
                        else
                        {
                            foreach (string str6 in strArray)
                            {
                                if (RolePermissions.AccessCheck(str6))
                                {
                                    flag = true;//为真时返回
                                    break;
                                }
                            }
                        }
                    }
                    goto Label_0237;
Label_0200:
                    strArray4 = strArray;
                    for (int i = 0; i < strArray4.Length; i++)
                    {
                        string operateCode = strArray4[i];
                        if (!RolePermissions.AccessCheck(operateCode))
                        {
                            flag = false;//为假时返回
                            break;
                        }
                    }
                    goto Label_0237;
Label_022D:
                    if (RolePermissions.AccessCheck(strA))
                    {
                        flag = true;
                    }
Label_0237:
                    if (flag)
                    {
                        break;
                    }
                }
                if (!flag)
                {
                    WriteErrMsg("<li>对不起,您没有当前页面的访问权限!</li>");
                }
            }
        }