BLL_iNethinkCMS_Channel.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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_Channel
  21. /// </summary>
  22. public partial class BLL_iNethinkCMS_Channel
  23. {
  24. private readonly iNethinkCMS.DAL.DAL_iNethinkCMS_Channel dal = new iNethinkCMS.DAL.DAL_iNethinkCMS_Channel();
  25. public BLL_iNethinkCMS_Channel()
  26. {
  27. }
  28. #region Method
  29. /// <summary>
  30. /// 得到最大ID
  31. /// </summary>
  32. public int GetMaxID()
  33. {
  34. return dal.GetMaxID();
  35. }
  36. /// <summary>
  37. /// 是否存在该记录
  38. /// </summary>
  39. public bool Exists(int ID)
  40. {
  41. return dal.Exists(ID);
  42. }
  43. /// <summary>
  44. /// 获得栏目深度
  45. /// </summary>
  46. public int GetDeepPath(int FatherID)
  47. {
  48. return dal.GetDeepPath(FatherID);
  49. }
  50. /// <summary>
  51. /// 增加一条数据
  52. /// </summary>
  53. public bool Add(iNethinkCMS.Model.Model_iNethinkCMS_Channel model)
  54. {
  55. return dal.Add(model);
  56. }
  57. /// <summary>
  58. /// 更新一条数据
  59. /// </summary>
  60. public bool Update(iNethinkCMS.Model.Model_iNethinkCMS_Channel model)
  61. {
  62. return dal.Update(model);
  63. }
  64. /// <summary>
  65. /// 删除一条数据
  66. /// </summary>
  67. public bool Delete(int ID)
  68. {
  69. return dal.Delete(ID);
  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. public iNethinkCMS.Model.Model_iNethinkCMS_Channel GetModel(int ID)
  82. {
  83. return dal.GetModel(ID);
  84. }
  85. /// <summary>
  86. /// 得到一个对象实体,从缓存中
  87. /// </summary>
  88. public iNethinkCMS.Model.Model_iNethinkCMS_Channel GetModelByCache(int ID)
  89. {
  90. string CacheKey = iNethinkCMS.Command.Command_Configuration.GetConfigString("CacheKey");
  91. CacheKey = CacheKey + "_Model_iNethinkCMS_ChannelModel_" + ID;
  92. object objModel = iNethinkCMS.Command.Command_DataCache.GetCache(CacheKey);
  93. if (objModel == null)
  94. {
  95. try
  96. {
  97. objModel = dal.GetModel(ID);
  98. if (objModel != null)
  99. {
  100. int ModelCache = iNethinkCMS.Command.Command_Configuration.GetConfigInt("CacheTime");
  101. iNethinkCMS.Command.Command_DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddSeconds(ModelCache), TimeSpan.Zero);
  102. }
  103. }
  104. catch
  105. {
  106. }
  107. }
  108. return (iNethinkCMS.Model.Model_iNethinkCMS_Channel)objModel;
  109. }
  110. /// <summary>
  111. /// 获得数据列表
  112. /// </summary>
  113. public DataSet GetList(string strWhere)
  114. {
  115. return dal.GetList(strWhere);
  116. }
  117. /// <summary>
  118. /// 获得前几行数据
  119. /// </summary>
  120. public DataSet GetList(int Top, string strWhere, string filedOrder)
  121. {
  122. return dal.GetList(Top, strWhere, filedOrder);
  123. }
  124. /// <summary>
  125. /// 获得数据列表
  126. /// </summary>
  127. public List<iNethinkCMS.Model.Model_iNethinkCMS_Channel> GetModelList(string strWhere)
  128. {
  129. DataSet ds = dal.GetList(strWhere);
  130. return DataTableToList(ds.Tables[0]);
  131. }
  132. /// <summary>
  133. /// 获得数据列表
  134. /// </summary>
  135. public List<iNethinkCMS.Model.Model_iNethinkCMS_Channel> DataTableToList(DataTable dt)
  136. {
  137. List<iNethinkCMS.Model.Model_iNethinkCMS_Channel> modelList = new List<iNethinkCMS.Model.Model_iNethinkCMS_Channel>();
  138. int rowsCount = dt.Rows.Count;
  139. if (rowsCount > 0)
  140. {
  141. iNethinkCMS.Model.Model_iNethinkCMS_Channel model;
  142. for (int n = 0; n < rowsCount; n++)
  143. {
  144. model = new iNethinkCMS.Model.Model_iNethinkCMS_Channel();
  145. if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
  146. {
  147. model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
  148. }
  149. if (dt.Rows[n]["Mold"] != null && dt.Rows[n]["Mold"].ToString() != "")
  150. {
  151. model.Mold = int.Parse(dt.Rows[n]["Mold"].ToString());
  152. }
  153. if (dt.Rows[n]["Cid"] != null && dt.Rows[n]["Cid"].ToString() != "")
  154. {
  155. model.Cid = int.Parse(dt.Rows[n]["Cid"].ToString());
  156. }
  157. if (dt.Rows[n]["FatherID"] != null && dt.Rows[n]["FatherID"].ToString() != "")
  158. {
  159. model.FatherID = int.Parse(dt.Rows[n]["FatherID"].ToString());
  160. }
  161. if (dt.Rows[n]["ChildID"] != null && dt.Rows[n]["ChildID"].ToString() != "")
  162. {
  163. model.ChildID = dt.Rows[n]["ChildID"].ToString();
  164. }
  165. if (dt.Rows[n]["ChildIDs"] != null && dt.Rows[n]["ChildIDs"].ToString() != "")
  166. {
  167. model.ChildIDs = dt.Rows[n]["ChildIDs"].ToString();
  168. }
  169. if (dt.Rows[n]["DeepPath"] != null && dt.Rows[n]["DeepPath"].ToString() != "")
  170. {
  171. model.DeepPath = int.Parse(dt.Rows[n]["DeepPath"].ToString());
  172. }
  173. if (dt.Rows[n]["Name"] != null && dt.Rows[n]["Name"].ToString() != "")
  174. {
  175. model.Name = dt.Rows[n]["Name"].ToString();
  176. }
  177. if (dt.Rows[n]["OrderNum"] != null && dt.Rows[n]["OrderNum"].ToString() != "")
  178. {
  179. model.OrderNum = int.Parse(dt.Rows[n]["OrderNum"].ToString());
  180. }
  181. if (dt.Rows[n]["Domain"] != null && dt.Rows[n]["Domain"].ToString() != "")
  182. {
  183. model.Domain = dt.Rows[n]["Domain"].ToString();
  184. }
  185. if (dt.Rows[n]["OutSideLink"] != null && dt.Rows[n]["OutSideLink"].ToString() != "")
  186. {
  187. model.OutSideLink = int.Parse(dt.Rows[n]["OutSideLink"].ToString());
  188. }
  189. if (dt.Rows[n]["Templatechannel"] != null && dt.Rows[n]["Templatechannel"].ToString() != "")
  190. {
  191. model.Templatechannel = dt.Rows[n]["Templatechannel"].ToString();
  192. }
  193. if (dt.Rows[n]["Templateclass"] != null && dt.Rows[n]["Templateclass"].ToString() != "")
  194. {
  195. model.Templateclass = dt.Rows[n]["Templateclass"].ToString();
  196. }
  197. if (dt.Rows[n]["Templateview"] != null && dt.Rows[n]["Templateview"].ToString() != "")
  198. {
  199. model.Templateview = dt.Rows[n]["Templateview"].ToString();
  200. }
  201. if (dt.Rows[n]["Picture"] != null && dt.Rows[n]["Picture"].ToString() != "")
  202. {
  203. model.Picture = dt.Rows[n]["Picture"].ToString();
  204. }
  205. if (dt.Rows[n]["Contents"] != null && dt.Rows[n]["Contents"].ToString() != "")
  206. {
  207. model.Contents = dt.Rows[n]["Contents"].ToString();
  208. }
  209. if (dt.Rows[n]["Keywords"] != null && dt.Rows[n]["Keywords"].ToString() != "")
  210. {
  211. model.Keywords = dt.Rows[n]["Keywords"].ToString();
  212. }
  213. if (dt.Rows[n]["Description"] != null && dt.Rows[n]["Description"].ToString() != "")
  214. {
  215. model.Description = dt.Rows[n]["Description"].ToString();
  216. }
  217. if (dt.Rows[n]["Display"] != null && dt.Rows[n]["Display"].ToString() != "")
  218. {
  219. model.Display = int.Parse(dt.Rows[n]["Display"].ToString());
  220. }
  221. modelList.Add(model);
  222. }
  223. }
  224. return modelList;
  225. }
  226. /// <summary>
  227. /// 获得数据列表
  228. /// </summary>
  229. public DataSet GetAllList()
  230. {
  231. return GetList("");
  232. }
  233. /// <summary>
  234. /// 分页获取数据列表
  235. /// </summary>
  236. public int GetRecordCount(string strWhere)
  237. {
  238. return dal.GetRecordCount(strWhere);
  239. }
  240. /// <summary>
  241. /// 分页获取数据列表
  242. /// </summary>
  243. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  244. {
  245. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  246. }
  247. #endregion Method
  248. }
  249. }