BLL_iNethinkCMS_Content.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*******************************************************************************
  2. * iNethinkCMS - 网站内容管理系统
  3. * Copyright (C) 2012-2013 inethink.com
  4. *
  5. * @author jackyang <69991000@qq.com>
  6. * @website http://cms.inethink.com
  7. * @version 1.3.6.0 (2013-08-14)
  8. *
  9. * This is licensed under the GNU LGPL, version 3.0 or later.
  10. * For details, see: http://www.gnu.org/licenses/gpl-3.0.html
  11. *******************************************************************************/
  12. using System;
  13. using System.Data;
  14. using System.Collections.Generic;
  15. using iNethinkCMS.Command;
  16. using iNethinkCMS.Model;
  17. namespace iNethinkCMS.BLL
  18. {
  19. /// <summary>
  20. /// BLL_iNethinkCMS_Content
  21. /// </summary>
  22. public partial class BLL_iNethinkCMS_Content
  23. {
  24. private readonly iNethinkCMS.DAL.DAL_iNethinkCMS_Content dal = new iNethinkCMS.DAL.DAL_iNethinkCMS_Content();
  25. public BLL_iNethinkCMS_Content()
  26. {
  27. }
  28. #region Method
  29. /// <summary>
  30. /// 是否存在该记录
  31. /// </summary>
  32. public bool Exists(int ID)
  33. {
  34. return dal.Exists(ID);
  35. }
  36. /// <summary>
  37. /// MaxID
  38. /// </summary>
  39. public int GetMaxID()
  40. {
  41. return dal.GetMaxID();
  42. }
  43. /// <summary>
  44. /// 增加一条数据
  45. /// </summary>
  46. public int Add(iNethinkCMS.Model.Model_iNethinkCMS_Content model)
  47. {
  48. return dal.Add(model);
  49. }
  50. /// <summary>
  51. /// 更新一条数据
  52. /// </summary>
  53. public bool Update(iNethinkCMS.Model.Model_iNethinkCMS_Content model)
  54. {
  55. return dal.Update(model);
  56. }
  57. /// <summary>
  58. /// 删除一条数据
  59. /// </summary>
  60. public bool Delete(int ID)
  61. {
  62. return dal.Delete(ID);
  63. }
  64. /// <summary>
  65. /// 通过栏目ID批量删除数据
  66. /// </summary>
  67. public bool DeleteList_ByCID(string CIDlist)
  68. {
  69. return dal.DeleteList_ByCID(CIDlist);
  70. }
  71. /// <summary>
  72. /// 批量删除数据
  73. /// </summary>
  74. public bool DeleteList(string IDlist)
  75. {
  76. return dal.DeleteList(IDlist);
  77. }
  78. /// <summary>
  79. /// 批量锁定或解锁数据
  80. /// </summary>
  81. /// <param name="IDlist"></param>
  82. /// <param name="byLock">0为解锁 1 为锁定</param>
  83. public bool LockingList(string IDlist, int byLock = 0)
  84. {
  85. return dal.LockingList(IDlist, byLock);
  86. }
  87. /// <summary>
  88. /// 批量审核(发布)数据
  89. /// </summary>
  90. public bool AuditList(string IDlist)
  91. {
  92. return dal.AuditList(IDlist);
  93. }
  94. /// <summary>
  95. /// 批量撤销审核(发布)数据
  96. /// </summary>
  97. public bool UndoAuditList(string IDlist)
  98. {
  99. return dal.UndoAuditList(IDlist);
  100. }
  101. /// <summary>
  102. /// 批量移动数据 至 相应栏目
  103. /// </summary>
  104. public bool MoveList(int Cid, string IDlist)
  105. {
  106. return dal.MoveList(Cid, IDlist);
  107. }
  108. /// <summary>
  109. /// 得到一个对象实体
  110. /// </summary>
  111. public iNethinkCMS.Model.Model_iNethinkCMS_Content GetModel(int ID)
  112. {
  113. return dal.GetModel(ID);
  114. }
  115. /// <summary>
  116. /// 得到一个对象实体,从缓存中
  117. /// </summary>
  118. public iNethinkCMS.Model.Model_iNethinkCMS_Content GetModelByCache(int ID)
  119. {
  120. string CacheKey = iNethinkCMS.Command.Command_Configuration.GetConfigString("CacheKey");
  121. CacheKey = CacheKey + "_Model_iNethinkCMS_ContentModel_" + ID;
  122. object objModel = iNethinkCMS.Command.Command_DataCache.GetCache(CacheKey);
  123. if (objModel == null)
  124. {
  125. try
  126. {
  127. objModel = dal.GetModel(ID);
  128. if (objModel != null)
  129. {
  130. int ModelCache = iNethinkCMS.Command.Command_Configuration.GetConfigInt("CacheTime");
  131. iNethinkCMS.Command.Command_DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddSeconds(ModelCache), TimeSpan.Zero);
  132. }
  133. }
  134. catch
  135. {
  136. }
  137. }
  138. return (iNethinkCMS.Model.Model_iNethinkCMS_Content)objModel;
  139. }
  140. /// <summary>
  141. /// 获得数据列表
  142. /// </summary>
  143. public DataSet GetList(string strWhere)
  144. {
  145. return dal.GetList(strWhere);
  146. }
  147. /// <summary>
  148. /// 获得前几行数据
  149. /// </summary>
  150. public DataSet GetList(int Top, string strWhere, string filedOrder)
  151. {
  152. return dal.GetList(Top, strWhere, filedOrder);
  153. }
  154. /// <summary>
  155. /// 获得数据列表
  156. /// </summary>
  157. public List<iNethinkCMS.Model.Model_iNethinkCMS_Content> GetModelList(string strWhere)
  158. {
  159. DataSet ds = dal.GetList(strWhere);
  160. return DataTableToList(ds.Tables[0]);
  161. }
  162. /// <summary>
  163. /// 获得数据列表
  164. /// </summary>
  165. public List<iNethinkCMS.Model.Model_iNethinkCMS_Content> DataTableToList(DataTable dt)
  166. {
  167. List<iNethinkCMS.Model.Model_iNethinkCMS_Content> modelList = new List<iNethinkCMS.Model.Model_iNethinkCMS_Content>();
  168. int rowsCount = dt.Rows.Count;
  169. if (rowsCount > 0)
  170. {
  171. iNethinkCMS.Model.Model_iNethinkCMS_Content model;
  172. for (int n = 0; n < rowsCount; n++)
  173. {
  174. model = new iNethinkCMS.Model.Model_iNethinkCMS_Content();
  175. if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
  176. {
  177. model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
  178. }
  179. if (dt.Rows[n]["Cid"] != null && dt.Rows[n]["Cid"].ToString() != "")
  180. {
  181. model.Cid = int.Parse(dt.Rows[n]["Cid"].ToString());
  182. }
  183. if (dt.Rows[n]["Sid"] != null && dt.Rows[n]["Sid"].ToString() != "")
  184. {
  185. model.Sid = int.Parse(dt.Rows[n]["Sid"].ToString());
  186. }
  187. if (dt.Rows[n]["Title"] != null && dt.Rows[n]["Title"].ToString() != "")
  188. {
  189. model.Title = dt.Rows[n]["Title"].ToString();
  190. }
  191. if (dt.Rows[n]["SubTitle"] != null && dt.Rows[n]["SubTitle"].ToString() != "")
  192. {
  193. model.SubTitle = dt.Rows[n]["SubTitle"].ToString();
  194. }
  195. if (dt.Rows[n]["Title_Color"] != null && dt.Rows[n]["Title_Color"].ToString() != "")
  196. {
  197. model.Title_Color = dt.Rows[n]["Title_Color"].ToString();
  198. }
  199. if (dt.Rows[n]["Title_Style"] != null && dt.Rows[n]["Title_Style"].ToString() != "")
  200. {
  201. model.Title_Style = dt.Rows[n]["Title_Style"].ToString();
  202. }
  203. if (dt.Rows[n]["Author"] != null && dt.Rows[n]["Author"].ToString() != "")
  204. {
  205. model.Author = dt.Rows[n]["Author"].ToString();
  206. }
  207. if (dt.Rows[n]["Source"] != null && dt.Rows[n]["Source"].ToString() != "")
  208. {
  209. model.Source = dt.Rows[n]["Source"].ToString();
  210. }
  211. if (dt.Rows[n]["Jumpurl"] != null && dt.Rows[n]["Jumpurl"].ToString() != "")
  212. {
  213. model.Jumpurl = dt.Rows[n]["Jumpurl"].ToString();
  214. }
  215. if (dt.Rows[n]["Keywords"] != null && dt.Rows[n]["Keywords"].ToString() != "")
  216. {
  217. model.Keywords = dt.Rows[n]["Keywords"].ToString();
  218. }
  219. if (dt.Rows[n]["Description"] != null && dt.Rows[n]["Description"].ToString() != "")
  220. {
  221. model.Description = dt.Rows[n]["Description"].ToString();
  222. }
  223. if (dt.Rows[n]["Indexpic"] != null && dt.Rows[n]["Indexpic"].ToString() != "")
  224. {
  225. model.Indexpic = dt.Rows[n]["Indexpic"].ToString();
  226. }
  227. if (dt.Rows[n]["Views"] != null && dt.Rows[n]["Views"].ToString() != "")
  228. {
  229. model.Views = int.Parse(dt.Rows[n]["Views"].ToString());
  230. }
  231. if (dt.Rows[n]["Commend"] != null && dt.Rows[n]["Commend"].ToString() != "")
  232. {
  233. model.Commend = int.Parse(dt.Rows[n]["Commend"].ToString());
  234. }
  235. if (dt.Rows[n]["IsComment"] != null && dt.Rows[n]["IsComment"].ToString() != "")
  236. {
  237. model.IsComment = int.Parse(dt.Rows[n]["IsComment"].ToString());
  238. }
  239. if (dt.Rows[n]["Display"] != null && dt.Rows[n]["Display"].ToString() != "")
  240. {
  241. model.Display = int.Parse(dt.Rows[n]["Display"].ToString());
  242. }
  243. if (dt.Rows[n]["Createtime"] != null && dt.Rows[n]["Createtime"].ToString() != "")
  244. {
  245. model.Createtime = DateTime.Parse(dt.Rows[n]["Createtime"].ToString());
  246. }
  247. if (dt.Rows[n]["Modifytime"] != null && dt.Rows[n]["Modifytime"].ToString() != "")
  248. {
  249. model.Modifytime = DateTime.Parse(dt.Rows[n]["Modifytime"].ToString());
  250. }
  251. if (dt.Rows[n]["OrderNum"] != null && dt.Rows[n]["OrderNum"].ToString() != "")
  252. {
  253. model.OrderNum = int.Parse(dt.Rows[n]["OrderNum"].ToString());
  254. }
  255. if (dt.Rows[n]["Contents"] != null && dt.Rows[n]["Contents"].ToString() != "")
  256. {
  257. model.Contents = dt.Rows[n]["Contents"].ToString();
  258. }
  259. if (dt.Rows[n]["FieldsInfo"] != null && dt.Rows[n]["FieldsInfo"].ToString() != "")
  260. {
  261. model.FieldsInfo = dt.Rows[n]["FieldsInfo"].ToString();
  262. }
  263. modelList.Add(model);
  264. }
  265. }
  266. return modelList;
  267. }
  268. /// <summary>
  269. /// 获得数据列表
  270. /// </summary>
  271. public DataSet GetAllList()
  272. {
  273. return GetList("");
  274. }
  275. /// <summary>
  276. /// 分页获取数据列表
  277. /// </summary>
  278. public int GetRecordCount(string strWhere)
  279. {
  280. return dal.GetRecordCount(strWhere);
  281. }
  282. /// <summary>
  283. /// 分页获取数据列表
  284. /// </summary>
  285. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  286. {
  287. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  288. }
  289. public string GetTitle(int ID)
  290. {
  291. return this.dal.GetTitle(ID);
  292. }
  293. #endregion Method
  294. }
  295. }