⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 labelmanage.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:

        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);
        }

        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))
            {
                return (List<LabelManageInfo>) SiteCache.Get(key);
            }
            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;
        }

        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())
                    {
                        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);
        }

        public static DataTable GetSchemaDataBase(string dbconn, DataSourceType dataSourceType)
        {
            return dal.GetSchemaDataBase(dbconn, dataSourceType);
        }

        public static DataTable GetSchemaTable(string tableName, string dbconn, DataSourceType dataSourceType)
        {
            return dal.GetSchemaTable(tableName, dbconn, dataSourceType);
        }

        public static DataTable GetSystemSchemaDataBases()
        {
            return GetSchemaDataBase(null, DataSourceType.None);
        }

        public static bool TestOutSideDatabase(string dbtype, string dbconn)
        {
            if (!string.IsNullOrEmpty(dbconn))
            {
                switch (dbtype)
                {
                    case "sql_outquery":
                        return dal.TestOutSql(dbconn);

                    case "sql_outstoredquery":
                        return dal.TestOutSql(dbconn);

                    case "ole_read":
                        return dal.TestOle(dbconn);

                    case "xml_read":
                        return XmlManage.CheckXmlDataSource(dbconn);

                    case "odbc_read":
                        return dal.TestOdbc(dbconn);

                    case "orc_read":
                        return dal.TestOracle(dbconn);
                }
            }
            return false;
        }

        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;
            }
        }

        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;
        }

        public static bool UpdateAttribute(string xmlfilepath, string attributename, string defaultvalue, string intro)
        {
            XmlDocument document = new XmlDocument();
            try
            {
                document.Load(xmlfilepath);
                foreach (XmlNode node in document.SelectNodes("root/attributes"))
                {
                    if (string.Compare(node.FirstChild.InnerText, attributename, true) != 0)
                    {
                        continue;
                    }
                    foreach (XmlNode node2 in node.ChildNodes)
                    {
                        if (string.Compare(node2.Name, "default", true) == 0)
                        {
                            node2.InnerText = defaultvalue;
                        }
                        if (string.Compare(node2.Name, "intro", true) == 0)
                        {
                            node2.InnerText = intro;
                        }
                    }
                    break;
                }
                document.Save(xmlfilepath);
                return true;
            }
            catch (XmlException)
            {
                return false;
            }
        }

        public static string LabelLibPath
        {
            get
            {
                return SiteConfig.SiteOption.LabelDir;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -