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

📄 modelmanager.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
            modelInfo.ManageInfoFilePath = DataSecurity.HtmlDecode(modelInfo.ManageInfoFilePath);
            modelInfo.PreviewInfoFilePath = DataSecurity.HtmlDecode(modelInfo.PreviewInfoFilePath);
            modelInfo.BatchInfoFilePath = DataSecurity.HtmlDecode(modelInfo.BatchInfoFilePath);
            modelInfo.PrintTemplate = DataSecurity.HtmlDecode(modelInfo.PrintTemplate);
            modelInfo.SearchTemplate = DataSecurity.HtmlDecode(modelInfo.SearchTemplate);
            modelInfo.AdvanceSearchFormTemplate = DataSecurity.HtmlDecode(modelInfo.AdvanceSearchFormTemplate);
            modelInfo.AdvanceSearchTemplate = DataSecurity.HtmlDecode(modelInfo.AdvanceSearchTemplate);
        }

        public static bool Delete(int modelId)
        {
            DeleteTemplateAndLabel(modelId);
            if (dal.Delete(modelId))
            {
                RemoveCache();
                return true;
            }
            return false;
        }

        public static bool DeleteNodeModel(int nodeId)
        {
            return dal.DeleteNodeModel(nodeId);
        }

        public static bool DeleteNodesModelTemplateRelationShip(int nodeId)
        {
            return dal.DeleteNodesModelTemplateRelationShip(nodeId);
        }

        public static bool DeleteNodeTemplateId(int nodeId)
        {
            return dal.DeleteNodeTemplateId(nodeId);
        }

        public static bool DeleteTableField(string fieldName, string tableName)
        {
            return dal.DeleteTableField(fieldName, tableName);
        }

        private static void DeleteTemplateAndLabel(int modelId)
        {
            if (modelId > 0x17)
            {
                ModelInfo modelInfoById = GetModelInfoById(modelId);
                if (!modelInfoById.IsNull)
                {
                    string virtualPath = HttpContext.Current.Server.MapPath("~/");
                    string path = VirtualPathUtility.AppendTrailingSlash(virtualPath) + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.TemplateDir) + VirtualPathUtility.AppendTrailingSlash(modelInfoById.ModelName);
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path, true);
                    }
                    FileInfo[] files = new DirectoryInfo(VirtualPathUtility.AppendTrailingSlash(virtualPath) + "Template/CommonTemplate/").GetFiles();
                    string str4 = VirtualPathUtility.AppendTrailingSlash(virtualPath + SiteConfig.SiteOption.LabelDir);
                    foreach (FileInfo info3 in files)
                    {
                        if ((string.Compare(info3.Extension, ".config", true) == 0) && (string.Compare(info3.Name.Replace(".config", ""), "内容页", true) != 0))
                        {
                            string str5 = info3.Name.ToLower().Replace(".config", "_" + modelInfoById.ModelName + ".config");
                            if (File.Exists(str4 + str5))
                            {
                                File.Delete(str4 + str5);
                            }
                        }
                    }
                }
            }
        }

        public static bool Disable(int id, bool disabled)
        {
            return dal.Disable(id, disabled);
        }

        public static bool EnableCharge(int id, bool charge)
        {
            return dal.EnableCharge(id, charge);
        }

        public static bool EnableSignin(int id, bool signin)
        {
            return dal.EnableSignin(id, signin);
        }

        private static void EncodeModelInfo(ModelInfo modelInfo)
        {
            modelInfo.ModelName = DataSecurity.HtmlEncode(modelInfo.ModelName);
            modelInfo.Description = DataSecurity.HtmlEncode(modelInfo.Description);
            modelInfo.ItemName = DataSecurity.HtmlEncode(modelInfo.ItemName);
            modelInfo.ItemUnit = DataSecurity.HtmlEncode(modelInfo.ItemUnit);
            modelInfo.DefaultTemplateFile = DataSecurity.HtmlEncode(modelInfo.DefaultTemplateFile);
            modelInfo.AddInfoFilePath = DataSecurity.HtmlEncode(modelInfo.AddInfoFilePath);
            modelInfo.ManageInfoFilePath = DataSecurity.HtmlEncode(modelInfo.ManageInfoFilePath);
            modelInfo.PreviewInfoFilePath = DataSecurity.HtmlEncode(modelInfo.PreviewInfoFilePath);
            modelInfo.BatchInfoFilePath = DataSecurity.HtmlEncode(modelInfo.BatchInfoFilePath);
            modelInfo.PrintTemplate = DataSecurity.HtmlEncode(modelInfo.PrintTemplate);
            modelInfo.SearchTemplate = DataSecurity.HtmlEncode(modelInfo.SearchTemplate);
            modelInfo.AdvanceSearchFormTemplate = DataSecurity.HtmlEncode(modelInfo.AdvanceSearchFormTemplate);
            modelInfo.AdvanceSearchTemplate = DataSecurity.HtmlEncode(modelInfo.AdvanceSearchTemplate);
        }

        public static bool ExistsNodesModelTemplateRelationShip(NodesModelTemplateRelationShipInfo info)
        {
            return dal.ExistsNodesModelTemplateRelationShip(info);
        }

        public static bool ExistsNodesModelTemplateRelationShip(int nodeId)
        {
            return dal.ExistsNodesModelTemplateRelationShip(nodeId);
        }

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

        public static ModelInfo GetCacheModelById(int modelId)
        {
            IList<ModelInfo> cacheModelList = GetCacheModelList();
            ModelInfo info = new ModelInfo(true);
            foreach (ModelInfo info2 in cacheModelList)
            {
                if (info2.ModelId == modelId)
                {
                    return info2;
                }
            }
            return info;
        }

        public static ModelInfo GetCacheModelByTableName(string tableName)
        {
            IList<ModelInfo> cacheModelList = GetCacheModelList();
            ModelInfo info = new ModelInfo(true);
            foreach (ModelInfo info2 in cacheModelList)
            {
                if (info2.TableName == tableName)
                {
                    return info2;
                }
            }
            return info;
        }

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

        public static DataTable GetContentModelListByNodeId(int nodeId, bool enable)
        {
            return dal.GetContentModelListByNodeId(nodeId, enable);
        }

        public static IList<FieldInfo> GetFieldListByModelId(int modelId)
        {
            string xmlFieldByModelId = GetXmlFieldByModelId(modelId);
            List<FieldInfo> list = ser.DeserializeFieldList(xmlFieldByModelId);
            if (list != null)
            {
                list.Sort(new FieldInfoComparer());
            }
            return list;
        }

        public static ArrayList GetLookupField(string tableName, string fieldName, int modelId)
        {
            return dal.GetLookupField(tableName, fieldName, modelId);
        }

        public static int GetMaxId()
        {
            return dal.GetMaxId();
        }

        public static ModelInfo GetModelInfoById(int id)
        {
            string key = "CK_CommonModel_ModelInfo_ModelId_" + id.ToString();
            ModelInfo modelInfo = SiteCache.Get(key) as ModelInfo;
            if (modelInfo == null)
            {
                modelInfo = dal.GetModelInfoById(id);
                DecodeModelInfo(modelInfo);
                SiteCache.Insert(key, modelInfo);
            }
            return modelInfo;
        }

        public static IList<ModelInfo> GetModelList(ModelType modelType, ModelShowType showType)
        {
            return dal.GetModelList(modelType, showType);
        }

        public static DataTable GetModelListByNodeId(int nodeId, bool enable)
        {
            return dal.GetModelListByNodeId(nodeId, enable);
        }

        public static IList<NodesModelTemplateRelationShipInfo> GetNodesModelTemplateList(int nodeId)
        {
            return dal.GetNodesModelTemplateList(nodeId);
        }

        public static NodesModelTemplateRelationShipInfo GetNodesModelTemplateRelationShip(int nodeId, int modelId)
        {
            NodesModelTemplateRelationShipInfo nodesModelTemplateRelationShip = dal.GetNodesModelTemplateRelationShip(nodeId, modelId);
            nodesModelTemplateRelationShip.DefaultTemplateFile = DataSecurity.HtmlDecode(nodesModelTemplateRelationShip.DefaultTemplateFile);
            return nodesModelTemplateRelationShip;
        }

        public static IList<ModelInfo> GetShopModelList(ModelShowType showType)
        {
            return GetModelList(ModelType.Shop, showType);
        }

        public static DataTable GetShopModelListByNodeId(int nodeId, bool enable)
        {
            return dal.GetShopModelListByNodeId(nodeId, enable);
        }

        public static IList<int> GetTemplateIdList(int nodeId)
        {
            return dal.GetTemplateIdList(nodeId);
        }

        public static string GetXmlFieldByModelId(int id)
        {
            return dal.GetXmlFieldByModelId(id);
        }

        public static bool ModelIdExists(int nodeId, int modelId)
        {
            return dal.ModelIdExists(nodeId, modelId);
        }

        public static bool ModelNameExists(string modelName)
        {
            return dal.ModelNameExists(modelName);
        }

        public static void RemoveCache()
        {
            SiteCache.RemoveByPattern(@"CK_CommonModel_\S*");
        }

        public static bool TableNameExists(string tableName)
        {
            return dal.TableNameExists(tableName);
        }

        public static bool TemplateIdExists(int nodeId, int templateId)
        {
            return dal.TemplateIdExists(nodeId, templateId);
        }

        public static bool Update(ModelInfo modelInfo)
        {
            EncodeModelInfo(modelInfo);
            if (dal.Update(modelInfo))
            {
                RemoveCache();
                return true;
            }
            return false;
        }

        public static bool UpdateField(int modelId, string fieldList)
        {
            return dal.UpdateField(modelId, fieldList);
        }

        public static bool UpdateFieldOfTable(FieldInfo fieldInfo, int modelId)
        {
            IList<FieldInfo> fieldListByModelId = new List<FieldInfo>();
            fieldListByModelId = GetFieldListByModelId(modelId);
            FieldInfo item = null;
            foreach (FieldInfo info2 in fieldListByModelId)
            {
                if (info2.Id == fieldInfo.Id)
                {
                    item = info2;
                }
            }
            fieldListByModelId.Remove(item);
            fieldListByModelId.Add(fieldInfo);
            string fieldList = ser.SerializeFieldList(fieldListByModelId);
            if (!UpdateField(modelId, fieldList))
            {
                return false;
            }
            return ((fieldInfo.FieldLevel == 0) || ((fieldInfo.FieldType == FieldType.Property) || UpdateTableField(fieldInfo, modelId)));
        }

        public static bool UpdateNodesModelTemplateRelationShip(int nodeId, IList<NodesModelTemplateRelationShipInfo> infoList)
        {
            bool flag = true;
            bool flag2 = true;
            if (ExistsNodesModelTemplateRelationShip(nodeId))
            {
                flag2 = DeleteNodesModelTemplateRelationShip(nodeId);
            }
            if (!flag2)
            {
                return false;
            }
            foreach (NodesModelTemplateRelationShipInfo info in infoList)
            {
                info.NodeId = nodeId;
                if ((!string.IsNullOrEmpty(info.DefaultTemplateFile) && (info.NodeId > 0)) && (info.ModelId > 0))
                {
                    flag = AddNodesModelTemplateRelationShip(info);
                }
            }
            return flag;
        }

        public static bool UpdateTableField(FieldInfo fieldInfo, int modelId)
        {
            ModelInfo modelInfoById = GetModelInfoById(modelId);
            return dal.UpdateTableField(fieldInfo, modelInfoById.TableName);
        }
    }
}

⌨️ 快捷键说明

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