public static ModelAddState Add(ContModelInfo model) { int num = ContModel.ExistsModel(model.ModelName, model.TableName); ModelAddState result; if (num > 0) { result = (ModelAddState)num; } else { string tableName = "dbo." + model.TableName; int num2 = BizBase.dbo.InsertModel <ContModelInfo>(model); if (num2 > 0) { try { TableManager.CreateTable(tableName, "AutoID"); TableManager.AddTableColumn(tableName, "ContID", "INT", false, "0"); ContModel.AddDefaultField(num2); CacheUtils.Del("JsonLeeCMS_CacheForGetContModel"); result = ModelAddState.Success; return(result); } catch { result = ModelAddState.CreateTableError; return(result); } } CacheUtils.Del("JsonLeeCMS_CacheForGetContModel"); result = ModelAddState.Error; } return(result); }
public static ModelDeleteStatus Delete(int modelID) { ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(modelID); ModelDeleteStatus result; if (cacheModelByID == null) { result = ModelDeleteStatus.ModelNotExists; } else { int num = ContModel.IsModelRefing(modelID); if (num > 0) { result = (ModelDeleteStatus)num; } else if (BizBase.dbo.DeleteModel <ContModelInfo>(cacheModelByID)) { ContField.DeleteByModelID(modelID); BizBase.dbo.ExecSQL(" DROP TABLE " + cacheModelByID.TableName); CacheUtils.Del("JsonLeeCMS_CacheForGetContModel"); result = ModelDeleteStatus.Success; } else { CacheUtils.Del("JsonLeeCMS_CacheForGetContModel"); result = ModelDeleteStatus.Error; } } return(result); }
public static DataSet GetPagerData(int intPageSize, int intCurrentPageIndex) { int num = 0; int num2 = 0; return(ContModel.GetPagerData(intPageSize, intCurrentPageIndex, ref num, ref num2)); }
public static FieldAddState Add(ContFieldInfo field) { ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(field.ModelID); FieldAddState result; if (cacheModelByID == null) { result = FieldAddState.ModelNotExists; } else { int value = BizBase.dbo.GetValue <int>(string.Concat(new object[] { "SELECT COUNT(*) FROM cms_ContField WHERE ModelID=", field.ModelID, " AND FieldName='", field.FieldName, "'" })); if (value > 0) { result = FieldAddState.FieldNameExists; } else { if (BizBase.dbo.InsertModel <ContFieldInfo>(field) > 0) { try { string text = field.DataType; if (string.Compare(text, "nvarchar", true) == 0) { object obj = text; text = string.Concat(new object[] { obj, "(", field.DataLength, ")" }); } TableManager.AddTableColumn(cacheModelByID.TableName, field.FieldName, text, true, field.DefaultValue); } catch { result = FieldAddState.CreateColumnError; return(result); } } CacheUtils.Del("JsonLeeCMS_CacheForGetContModel"); result = FieldAddState.Success; } } return(result); }
public static bool Delete(int fieldID) { ContFieldInfo dataById = ContField.GetDataById(fieldID); ContModelInfo dataById2 = ContModel.GetDataById(dataById.ModelID); if (BizBase.dbo.DeleteModel <ContFieldInfo>(dataById)) { TableManager.DropTableColumn(dataById2.TableName, dataById.FieldName); } CacheUtils.Del("JsonLeeCMS_CacheForGetContModel"); return(true); }
public static IList <ContModelInfo> GetCacheUsingModelList() { IList <ContModelInfo> cacheModelList = ContModel.GetCacheModelList(); IList <ContModelInfo> list = new List <ContModelInfo>(); if (cacheModelList != null && cacheModelList.Count > 0) { foreach (ContModelInfo current in cacheModelList) { if (current.IsUsing) { list.Add(current); } } } return(list); }
public static ContModelInfo GetModelByName(string strModelName) { List <ContModelInfo> list = (List <ContModelInfo>)ContModel.GetCacheModelList(); ContModelInfo result; if (list != null && list.Count > 0) { result = (from p in list where p.ModelName == strModelName select p).FirstOrDefault <ContModelInfo>(); } else { result = null; } return(result); }
public static ContModelInfo GetCacheModelByID(int modelID) { ContModelInfo result = null; IList <ContModelInfo> cacheModelList = ContModel.GetCacheModelList(); if (cacheModelList != null && cacheModelList.Count > 0) { foreach (ContModelInfo current in cacheModelList) { if (current.AutoID == modelID) { result = current; break; } } } return(result); }
public static bool Update(ContFieldInfo field) { ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(field.ModelID); ContFieldInfo dataById = ContField.GetDataById(field.AutoID); bool result; if (BizBase.dbo.UpdateModel <ContFieldInfo>(field)) { if (!dataById.IsSystem) { try { string text = field.DataType; if (string.Compare(text, "nvarchar", true) == 0) { object obj = text; text = string.Concat(new object[] { obj, "(", field.DataLength, ")" }); } TableManager.AlterTableColumn(cacheModelByID.TableName, dataById.FieldName, field.FieldName, text, true, field.DefaultValue); } catch (Exception ex) { throw ex; } } CacheUtils.Del("JsonLeeCMS_CacheForGetContModel"); result = true; } else { result = false; } return(result); }
public static ContModelInfo GetTopData() { return(ContModel.GetTopData(" Sort ASC,AutoID desc ")); }
public static DataSet GetPagerData(string strFilter, string strCondition, int intPageSize, int intCurrentPageIndex, ref int intTotalCount, ref int intTotalPage) { return(ContModel.GetPagerData(strFilter, strCondition, " Sort asc,AutoID desc ", intPageSize, intCurrentPageIndex, ref intTotalCount, ref intTotalPage)); }
public static IList <ContModelInfo> GetPagerList(int intCurrentPageIndex, int intPageSize, ref int intTotalCount, ref int intTotalPage) { return(ContModel.GetPagerList("", "Sort ASC,AutoID DESC", intCurrentPageIndex, intPageSize, ref intTotalCount, ref intTotalPage)); }
public static bool UpdateContent(ContentInfo content, Dictionary <string, ContFieldInfo> dicField) { bool result; if (content == null) { result = false; } else { ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(content.ModelID); if (cacheModelByID == null) { result = false; } else { content.Title = Content.GetStringFromDic("Title", dicField); if (string.IsNullOrEmpty(content.Title)) { content.Title = "默认的标题"; } content.SubTitle = Content.GetStringFromDic("SubTitle", dicField); content.Summary = Content.GetStringFromDic("Summary", dicField); content.Author = Content.GetStringFromDic("Author", dicField); content.Editor = Content.GetStringFromDic("Editor", dicField); content.Source = Content.GetStringFromDic("Source", dicField); content.SourceUrl = Content.GetStringFromDic("SourceUrl", dicField); content.Content = Content.GetStringFromDic("Content", dicField); content.TagKey = Content.GetStringFromDic("TagKey", dicField); content.ContentImage = Content.GetStringFromDic("ContentImage", dicField); content.Attachment = Content.GetStringFromDic("Attachment", dicField); content.RelateContent = Content.GetStringFromDic("RelateContent", dicField); content.SeoKey = Content.GetStringFromDic("SeoKey", dicField); content.SeoDescription = Content.GetStringFromDic("SeoDescription", dicField); content.IsTop = Content.GetBoolFromDic("IsTop", dicField, false); content.IsRecommend = Content.GetBoolFromDic("IsRecommend", dicField, false); content.IsNew = Content.GetBoolFromDic("IsNew", dicField, false); content.TemplateFile = Content.GetStringFromDic("TemplateFile", dicField); content.Hit = Content.GetIntFromDic("Hit", dicField, 0); content.Sort = Content.GetIntFromDic("Sort", dicField, 999); content.AutoTimeStamp = Content.GetDateTimeFromDic("AutoTimeStamp", dicField, new DateTime(1900, 1, 1)); Content.Update(content); IList <ContFieldInfo> customFieldListByModelID = ContField.GetCustomFieldListByModelID(content.ModelID); foreach (ContFieldInfo current in customFieldListByModelID) { if (current.FieldName == "ContID") { current.Value = content.AutoID.ToString(); } else { current.Value = Content.GetStringFromDic(current.FieldName, dicField); } } if (Content.ExistsCustomTableData(cacheModelByID.TableName, content.AutoID)) { Content.UpdateCustomContent(content.AutoID, content.TableName, customFieldListByModelID); } else { Content.AddCustomContent(cacheModelByID, customFieldListByModelID); } result = true; } } return(result); }
public static DataSet GetPagerData(string strCondition, int intPageSize, int intCurrentPageIndex, ref int intTotalCount, ref int intTotalPage) { return(ContModel.GetPagerData("*", strCondition, intPageSize, intCurrentPageIndex, ref intTotalCount, ref intTotalPage)); }
public static IList <ContModelInfo> GetList(int intTopCount, string strCondition) { string strSort = " Sort asc,AutoID desc "; return(ContModel.GetList(intTopCount, strCondition, strSort)); }
public static IList <ContModelInfo> GetTopNList(int intTopCount, string strSort) { return(ContModel.GetList(intTopCount, string.Empty, strSort)); }
public static IList <ContModelInfo> GetAllList() { return(ContModel.GetList(0, string.Empty)); }
public static int Add(ContentInfo content, Dictionary <string, ContFieldInfo> dicField) { NodeInfo cacheNodeById = Node.GetCacheNodeById(content.NodeID); int result; if (cacheNodeById == null) { result = 0; } else { ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(cacheNodeById.ModelID); if (cacheModelByID == null) { result = 0; } else { content.NodeName = cacheNodeById.NodeName; content.ModelID = cacheModelByID.AutoID; content.TableName = cacheModelByID.TableName; content.Title = Content.GetStringFromDic("Title", dicField); if (string.IsNullOrEmpty(content.Title)) { content.Title = "默认的标题"; } content.SubTitle = Content.GetStringFromDic("SubTitle", dicField); content.Summary = Content.GetStringFromDic("Summary", dicField); content.Author = Content.GetStringFromDic("Author", dicField); content.Editor = Content.GetStringFromDic("Editor", dicField); content.Source = Content.GetStringFromDic("Source", dicField); content.SourceUrl = Content.GetStringFromDic("SourceUrl", dicField); content.Content = Content.GetStringFromDic("Content", dicField); content.TagKey = Content.GetStringFromDic("TagKey", dicField); content.ContentImage = Content.GetStringFromDic("ContentImage", dicField); content.Attachment = Content.GetStringFromDic("Attachment", dicField); content.RelateContent = Content.GetStringFromDic("RelateContent", dicField); content.SeoKey = Content.GetStringFromDic("SeoKey", dicField); content.SeoDescription = Content.GetStringFromDic("SeoDescription", dicField); content.IsTop = Content.GetBoolFromDic("IsTop", dicField, false); content.IsRecommend = Content.GetBoolFromDic("IsRecommend", dicField, false); content.IsNew = Content.GetBoolFromDic("IsNew", dicField, false); content.TemplateFile = Content.GetStringFromDic("TemplateFile", dicField); content.Hit = Content.GetIntFromDic("Hit", dicField, 0); content.Sort = Content.GetIntFromDic("Sort", dicField, 999); content.Inputer = Account.GetLoginAccount().AccountName; content.Lang = JObject.cultureLang; if (dicField.ContainsKey("AutoTimeStamp")) { content.AutoTimeStamp = Content.GetDateTimeFromDic("AutoTimeStamp", dicField, DateTime.Now); } else { content.AutoTimeStamp = DateTime.Now; } int num = Content.Add(content); IList <ContFieldInfo> customFieldListByModelID = ContField.GetCustomFieldListByModelID(cacheModelByID.AutoID); foreach (ContFieldInfo current in customFieldListByModelID) { if (current.FieldName == "ContID") { current.Value = num.ToString(); } else { current.Value = Content.GetStringFromDic(current.FieldName, dicField); } } Content.AddCustomContent(cacheModelByID, customFieldListByModelID); result = num; } } return(result); }
public static bool CopyContent(int intContID) { ContentInfo dataById = Content.GetDataById(intContID); bool result; if (dataById != null) { ContModelInfo cacheModelByID = ContModel.GetCacheModelByID(dataById.ModelID); string strSQL = string.Concat(new object[] { "INSERT INTO cms_Content ( NodeID, NodeName, ModelID, TableName, Title, SubTitle, Summary, Author, Editor, Source, SourceUrl, Content, Attachment, TagKey, ContentImage, SeoKey, SeoDescription, Lang, Inputer, Sort, Status, AutoTimeStamp ) SELECT NodeID, NodeName, ModelID, TableName, '复制:'+Title, SubTitle, Summary, Author, Editor, Source, SourceUrl, Content, Attachment, TagKey, ContentImage, SeoKey, SeoDescription, Lang, '", Account.GetLoginAccount().AccountName, "', (SELECT MAX(Sort)+1 FROM cms_Content) AS CurrSort, 0, getdate() FROM cms_Content WHERE AutoID=", intContID, ";if @@rowcount>0 select @@IDENTITY" }); object @object = BizBase.dbo.GetObject(strSQL); int num = (@object == null) ? 0 : Convert.ToInt32(@object); if (num > 0) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(" INSERT INTO " + dataById.TableName + " ( "); IList <ContFieldInfo> customFieldListByModelID = ContField.GetCustomFieldListByModelID(cacheModelByID.AutoID); for (int i = 0; i < customFieldListByModelID.Count; i++) { if (customFieldListByModelID[i].FieldName != "AutoID") { if (i == customFieldListByModelID.Count - 1) { stringBuilder.Append(customFieldListByModelID[i].FieldName); } else { stringBuilder.Append(customFieldListByModelID[i].FieldName + ","); } } } stringBuilder.Append(" ) "); stringBuilder.Append(" SELECT "); for (int i = 0; i < customFieldListByModelID.Count; i++) { if (customFieldListByModelID[i].FieldName != "AutoID") { if (i == customFieldListByModelID.Count - 1) { if (customFieldListByModelID[i].FieldName.Equals("ContID")) { stringBuilder.Append(num.ToString()); } else { stringBuilder.Append(customFieldListByModelID[i].FieldName); } } else if (customFieldListByModelID[i].FieldName.Equals("ContID")) { stringBuilder.Append(num.ToString() + ","); } else { stringBuilder.Append(customFieldListByModelID[i].FieldName + ","); } } } stringBuilder.Append(string.Concat(new object[] { " FROM ", dataById.TableName, " WHERE ContID=", dataById.AutoID })); result = BizBase.dbo.ExecSQL(stringBuilder.ToString()); return(result); } } result = false; return(result); }