示例#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);
        }
示例#2
0
 public static bool Update(LabelManageInfo ainfo)
 {
     try
     {
         File.WriteAllText(HttpContext.Current.Server.MapPath("~/" + LabelLibPath) + @"\" + ainfo.Name + ".config", ainfo.Define.ToString(), Encoding.UTF8);
         return(true);
     }
     catch (IOException)
     {
         return(false);
     }
 }
示例#3
0
        protected void ShowLabelAdd()
        {
            string str = BasePage.RequestString("n");

            if (!string.IsNullOrEmpty(str))
            {
                this.LabelName.Text = str;
                LabelManageInfo labelByName = LabelManage.GetLabelByName(str);
                if (!labelByName.IsNull)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("<table width='100%'>");
                    XmlDocument document = new XmlDocument();
                    document.LoadXml(labelByName.Define.ToString());
                    foreach (XmlNode node in document.SelectNodes("root/attributes"))
                    {
                        string   innerText = node.SelectSingleNode("default").InnerText;
                        string[] sArray    = innerText.Split(new string[] { "|||" }, StringSplitOptions.None);
                        builder.Append(this.CtrlProc(node.SelectSingleNode("name").InnerText, innerText, innerText, node.SelectSingleNode("intro").InnerText, sArray));
                    }
                    string input = (document.SelectSingleNode("root/UsePage") == null) ? "" : document.SelectSingleNode("root/UsePage").InnerText.Trim();
                    if (DataConverter.CBoolean(input))
                    {
                        builder.Append("<tr><td align=\"right\">是否分页:</td><td align=\"left\"><input id=\"page\" type=\"checkbox\"/></td></tr>");
                        builder.Append("<tr><td align=\"right\">分页显示数:</td><td align=\"left\"><input type=\"text\" id=\"pagesize\" value=\"10\"/></td></tr>");
                        builder.Append("<tr><td align=\"right\">是否主分页:</td><td align=\"left\"><input id=\"urlpage\" type=\"checkbox\" value=\"true\"/></td></tr>");
                    }
                    builder.Append("<tr><td align=\"right\">缓存时间:</td><td align=\"left\"><input type=\"text\" id=\"cachetime\" value=\"0\" /></td></tr>");
                    builder.Append("<tr><td align=\"right\">不解析内部标签:</td><td align=\"left\"><input id=\"nolabelproc\" type=\"checkbox\"/></td></tr>");
                    builder.Append("<tr><td align=\"right\">容器类型:</td><td align=\"left\"><input type=\"text\" id=\"spantype\" /></td></tr>");
                    builder.Append("<tr><td align=\"right\">容器风格:</td><td align=\"left\"><input type=\"text\" id=\"cssname\" /></td></tr>");
                    builder.Append("</table>");
                    this.labelbody.Text = builder.ToString();
                    input = (document.SelectSingleNode("root/LabelIntro") == null) ? "" : document.SelectSingleNode("root/LabelIntro").InnerText.Trim();
                    if (!string.IsNullOrEmpty(input))
                    {
                        this.labelintro.Text = input;
                    }
                }
            }
        }
示例#4
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));
        }
示例#5
0
        public static bool Add(LabelManageInfo ainfo)
        {
            string path = HttpContext.Current.Server.MapPath("~/" + LabelLibPath);

            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (!Exists(ainfo.Name))
                {
                    File.WriteAllText(HttpContext.Current.Server.MapPath("~/" + LabelLibPath) + @"\" + ainfo.Name + ".config", ainfo.Define.ToString(), Encoding.UTF8);
                    return(true);
                }
                return(false);
            }
            catch (IOException)
            {
                return(false);
            }
        }
示例#6
0
 public static bool Update(LabelManageInfo ainfo, string newLableName)
 {
     if (ainfo.Name == newLableName)
     {
         return(Update(ainfo));
     }
     if (!Exists(newLableName))
     {
         try
         {
             string path = HttpContext.Current.Server.MapPath("~/" + LabelLibPath) + @"\" + ainfo.Name + ".config";
             string str2 = HttpContext.Current.Server.MapPath("~/" + LabelLibPath) + @"\" + newLableName + ".config";
             File.Delete(path);
             File.WriteAllText(str2, ainfo.Define.ToString(), Encoding.UTF8);
             return(true);
         }
         catch (IOException)
         {
             return(false);
         }
     }
     return(false);
 }
示例#7
0
        public static LabelManageInfo GetLabelByName(string labelName)
        {
            string          str;
            XmlDocument     document = new XmlDocument();
            LabelManageInfo info     = new LabelManageInfo();

            if (HttpContext.Current != null)
            {
                str = HttpContext.Current.Server.MapPath("~/" + LabelLibPath) + @"\" + labelName + ".config";
            }
            else
            {
                str = AppDomain.CurrentDomain.BaseDirectory + LabelLibPath + @"\" + labelName + ".config";
            }
            if (!File.Exists(str))
            {
                return(new LabelManageInfo(true));
            }
            try
            {
                FileInfo info2 = new FileInfo(str);
                using (StreamReader reader = info2.OpenText())
                {
                    document.Load(reader);
                    info.Name     = labelName;
                    info.Type     = document.SelectSingleNode("root/LabelType").InnerText;
                    info.Define   = new StringBuilder(document.InnerXml.ToString());
                    info.Template = new StringBuilder(document.SelectSingleNode("root/LabelTemplate").InnerText);
                    return(info);
                }
            }
            catch (XmlException)
            {
                return(new LabelManageInfo(true));
            }
            return(info);
        }
示例#8
0
        protected void ShowLabelModify()
        {
            string labelName = string.Empty;
            string str2      = BasePage.RequestString("n");

            if (!string.IsNullOrEmpty(str2))
            {
                str2 = str2.Replace("{", "<").Replace("}", ">");
                XmlDocument document = new XmlDocument();
                document.LoadXml(str2);
                XmlElement documentElement = document.DocumentElement;
                if (documentElement.HasAttribute("id"))
                {
                    labelName           = documentElement.GetAttribute("id");
                    this.LabelName.Text = labelName;
                    LabelManageInfo labelByName = LabelManage.GetLabelByName(labelName);
                    if (!labelByName.IsNull)
                    {
                        StringBuilder builder = new StringBuilder();
                        builder.Append("<table width='100%'>");
                        XmlDocument document2 = new XmlDocument();
                        document2.LoadXml(labelByName.Define.ToString());
                        foreach (XmlNode node in document2.SelectNodes("root/attributes"))
                        {
                            string innerText = node.SelectSingleNode("name").InnerText;
                            string avalue    = string.Empty;
                            if (documentElement.HasAttribute(innerText))
                            {
                                avalue = documentElement.GetAttribute(innerText);
                            }
                            else
                            {
                                avalue = node.SelectSingleNode("default").InnerText;
                            }
                            string[] sArray = node.SelectSingleNode("default").InnerText.Split(new string[] { "|||" }, StringSplitOptions.None);
                            builder.Append(this.CtrlProc(node.SelectSingleNode("name").InnerText, avalue, node.SelectSingleNode("default").InnerText, node.SelectSingleNode("intro").InnerText, sArray));
                        }
                        string input     = (document2.SelectSingleNode("root/UsePage") == null) ? "" : document2.SelectSingleNode("root/UsePage").InnerText.Trim();
                        string attribute = string.Empty;
                        if (DataConverter.CBoolean(input))
                        {
                            if (documentElement.HasAttribute("page") && DataConverter.CBoolean(documentElement.GetAttribute("page")))
                            {
                                attribute = " checked";
                            }
                            builder.Append("<tr><td align=\"right\">是否分页:</td><td align=\"left\"><input id=\"page\" type=\"checkbox\"" + attribute + "/></td></tr>");
                            attribute = "10";
                            if (documentElement.HasAttribute("pagesize") && !string.IsNullOrEmpty(documentElement.GetAttribute("pagesize")))
                            {
                                attribute = documentElement.GetAttribute("pagesize");
                            }
                            builder.Append("<tr><td align=\"right\">分页显示数:</td><td align=\"left\"><input type=\"text\" id=\"pagesize\" value=\"" + attribute + "\"/></td></tr>");
                            attribute = string.Empty;
                            if (documentElement.HasAttribute("urlpage") && DataConverter.CBoolean(documentElement.GetAttribute("urlpage")))
                            {
                                attribute = " checked";
                            }
                            builder.Append("<tr><td align=\"right\">是否主分页:</td><td align=\"left\"><input id=\"urlpage\" type=\"checkbox\"" + attribute + "/></td></tr>");
                        }
                        builder.Append("<tr><td align=\"right\">缓存时间:</td><td align=\"left\"><input type=\"text\" id=\"cachetime\"");
                        if (documentElement.HasAttribute("cachetime"))
                        {
                            builder.Append("value=\"" + documentElement.GetAttribute("cachetime") + "\"");
                        }
                        builder.Append("/></td></tr>");
                        if (documentElement.HasAttribute("noprocinlabel") && DataConverter.CBoolean(documentElement.GetAttribute("noprocinlabel")))
                        {
                            attribute = " checked";
                        }
                        builder.Append("<tr><td align=\"right\">不解析内部标签:</td><td align=\"left\"><input id=\"nolabelproc\" type=\"checkbox\"" + attribute + "/></td></tr>");
                        builder.Append("<tr><td align=\"right\">容器类型:</td><td align=\"left\"><input type=\"text\" id=\"spantype\"");
                        if (documentElement.HasAttribute("span"))
                        {
                            builder.Append("value=\"" + documentElement.GetAttribute("span") + "\"");
                        }
                        builder.Append("/></td></tr>");
                        builder.Append("<tr><td align=\"right\">容器风格:</td><td align=\"left\"><input type=\"text\" id=\"cssname\"");
                        if (documentElement.HasAttribute("class"))
                        {
                            builder.Append("value=\"" + documentElement.GetAttribute("class") + "\"");
                        }
                        builder.Append("/></td></tr>");
                        builder.Append("</table>");
                        this.labelbody.Text = builder.ToString();
                        input = (document2.SelectSingleNode("root/LabelIntro") == null) ? "" : document2.SelectSingleNode("root/LabelIntro").InnerText.Trim();
                        if (!string.IsNullOrEmpty(input))
                        {
                            this.labelintro.Text = input;
                        }
                    }
                }
            }
        }
        protected bool ReplaceProc(string labelName)
        {
            LabelManageInfo ainfo = new LabelManageInfo();

            ainfo = LabelManage.GetLabelByName(labelName);
            if (string.Compare(this.RadioButtonList2.SelectedValue, "labelname", StringComparison.OrdinalIgnoreCase) == 0)
            {
                string str = ainfo.Name.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                if (this.ChkAdd.Checked)
                {
                    ainfo.Name = str;
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo, str));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "labeltype", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(ainfo.Define.ToString());
                if (document.SelectSingleNode("root/LabelType") != null)
                {
                    document.SelectSingleNode("root/LabelType").InnerText = document.SelectSingleNode("root/LabelType").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "labelintro", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document2 = new XmlDocument();
                document2.LoadXml(ainfo.Define.ToString());
                if (document2.SelectSingleNode("root/LabelIntro") != null)
                {
                    document2.SelectSingleNode("root/LabelIntro").InnerText = document2.SelectSingleNode("root/LabelIntro").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document2.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "sql", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document3 = new XmlDocument();
                document3.LoadXml(ainfo.Define.ToString());
                if (document3.SelectSingleNode("root/LabelSqlString") != null)
                {
                    document3.SelectSingleNode("root/LabelSqlString").InnerText = document3.SelectSingleNode("root/LabelSqlString").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document3.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "template", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document4 = new XmlDocument();
                document4.LoadXml(ainfo.Define.ToString());
                if (document4.SelectSingleNode("root/LabelTemplate") != null)
                {
                    document4.SelectSingleNode("root/LabelTemplate").InnerText = document4.SelectSingleNode("root/LabelTemplate").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document4.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            string      newLableName = ainfo.Name.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            XmlDocument document5    = new XmlDocument();

            document5.LoadXml(ainfo.Define.ToString());
            if (document5.SelectSingleNode("root/LabelType") != null)
            {
                document5.SelectSingleNode("root/LabelType").InnerText = document5.SelectSingleNode("root/LabelType").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            if (document5.SelectSingleNode("root/LabelIntro") != null)
            {
                document5.SelectSingleNode("root/LabelIntro").InnerText = document5.SelectSingleNode("root/LabelIntro").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            if (document5.SelectSingleNode("root/LabelSqlString") != null)
            {
                document5.SelectSingleNode("root/LabelSqlString").InnerText = document5.SelectSingleNode("root/LabelSqlString").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            if (document5.SelectSingleNode("root/LabelTemplate") != null)
            {
                document5.SelectSingleNode("root/LabelTemplate").InnerText = document5.SelectSingleNode("root/LabelTemplate").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            ainfo.Define = new StringBuilder(document5.InnerXml);
            if (this.ChkAdd.Checked)
            {
                ainfo.Name = newLableName;
                return(LabelManage.Add(ainfo));
            }
            return(LabelManage.Update(ainfo, newLableName));
        }
示例#10
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));
        }