地铁二期项目正式开始

RepositoryCategoryController.cs 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. using YTSoft.BaseCallCenter.Model;
  9. using YTSoft.BaseCallCenter.MVCWeb.Models;
  10. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  11. {
  12. public class RepositoryCategoryController : BaseController
  13. {
  14. #region 知识库分类管理
  15. BLL.T_RepositoryCategory reposcategoryBLL = new BLL.T_RepositoryCategory();
  16. public ActionResult RepositoryCategoryList()
  17. {
  18. WorkOrderMyModel model = new WorkOrderMyModel();
  19. return View(model);
  20. }
  21. ///通过dic编码获取dic值
  22. /// </summary>
  23. /// <param name="fid"></param>
  24. /// <returns></returns>
  25. public string GetrepositorycategoryJsonModel(int parentId)
  26. {
  27. return Newtonsoft.Json.JsonConvert.SerializeObject(reposcategoryBLL.GetRepositoryCategoryJsonModel(parentId));
  28. }
  29. /// <summary>
  30. /// 获取知识库分类数据
  31. /// </summary>
  32. /// <param name="page">当前页码</param>
  33. /// <param name="limit">每页数据量</param>
  34. /// <returns></returns>
  35. [ActionName("RepositoryCategoryDate")]
  36. [HttpGet]
  37. public string RepositoryCategoryDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  38. {
  39. //数据结果集
  40. ResponseData dataModel = new ResponseData();
  41. string sql = " and F_DeleteFlag=0";
  42. if (parentId != null)
  43. {
  44. sql += " and F_ParentId=" + parentId;
  45. }
  46. DataTable dt = new DataTable();
  47. int recordCount = 0;
  48. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  49. dt = BLL.PagerBLL.GetListPager(
  50. "T_RepositoryCategory",
  51. "F_CategoryId",
  52. "*",
  53. sql,
  54. "ORDER BY F_Sort asc ",
  55. limit,
  56. page,
  57. true,
  58. out recordCount);
  59. dataModel.code = 0;
  60. dataModel.count = recordCount;
  61. dataModel.data = dt;
  62. return JsonConvert.SerializeObject(dataModel);
  63. }
  64. /// <summary>
  65. /// 编辑分类
  66. /// </summary>
  67. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  68. /// <param name="editType">类型1、新增 2、修改</param>
  69. /// <returns></returns>
  70. public ActionResult RepositoryCategoryEdit(int categoryId, int editType)
  71. {
  72. Model.T_RepositoryCategory viewModel = new Model.T_RepositoryCategory();
  73. //当前对象实体
  74. Model.T_RepositoryCategory categoryModel = reposcategoryBLL.GetModel(categoryId);
  75. if (editType == 1)
  76. {
  77. viewModel.F_ParentId = categoryModel.F_CategoryId;
  78. viewModel.F_Sort = 1;
  79. viewModel.F_CategoryType = categoryModel.F_CategoryType;
  80. }
  81. else
  82. {
  83. viewModel = categoryModel;
  84. }
  85. return View(viewModel);
  86. }
  87. /// <summary>
  88. /// 保存编辑
  89. /// </summary>
  90. /// <param name="workOrderBaseModel"></param>
  91. /// <returns></returns>
  92. [AcceptVerbs(HttpVerbs.Post)]
  93. public bool SaveRepositoryCategoryData(T_RepositoryCategory categoryModel)
  94. {
  95. // 获取当前电脑名:
  96. string a = System.Net.Dns.GetHostName();
  97. // 根据电脑名取出全部IP地址:
  98. System.Net.IPAddress[] addressList = System.Net.Dns.Resolve(a).AddressList;
  99. string b = Convert.ToString(addressList[0]);
  100. if (categoryModel.F_CategoryId > 0)
  101. {
  102. //int id = Common.CommonRequest.dtUserId;
  103. //string usercode = Common.CommonRequest.dtUserCode;
  104. //string pp = Common.DTRequest.GetIP();
  105. return reposcategoryBLL.Update(categoryModel);
  106. }
  107. else
  108. {
  109. return reposcategoryBLL.Add(categoryModel) > 0;
  110. }
  111. }
  112. /// <summary>
  113. /// 删除数据
  114. /// </summary>
  115. /// <param name="workOrderBaseModel"></param>
  116. /// <returns></returns>
  117. [AcceptVerbs(HttpVerbs.Get)]
  118. public bool DeleteCategoryData(int categoryId)
  119. {
  120. return reposcategoryBLL.Delete(categoryId);
  121. }
  122. #endregion
  123. #region 知识库内容管理
  124. BLL.T_RepositoryInformation reposCategoryContentBLL = new BLL.T_RepositoryInformation();
  125. public ActionResult RepositoryCategoryContentList(int dType)
  126. {
  127. WorkOrderMyModel model = new WorkOrderMyModel();
  128. model.DType = dType;
  129. return View(model);
  130. }
  131. /// <summary>
  132. /// 获取知识库内容数据
  133. /// </summary>
  134. /// <param name="page">当前页码</param>
  135. /// <param name="limit">每页数据量</param>
  136. /// <returns></returns>
  137. [ActionName("RepositoryCategoryContentDate")]
  138. [HttpGet]
  139. public string RepositoryCategoryContentDate(DateTime? NowDateTime, int page,
  140. int limit,int dType, int? parentId, string keyWord)
  141. {
  142. //数据结果集
  143. ResponseData dataModel = new ResponseData();
  144. string sql = " and t.F_DeleteFlag=0 ";
  145. //and F_CreateBy="+F_UserID+"
  146. if (!string.IsNullOrEmpty(keyWord))
  147. {
  148. sql += " and ( t.F_Description like '%" + keyWord + "%' or F_Title like '%" + keyWord + "%')";
  149. }
  150. if (parentId != null && parentId > 1)
  151. {
  152. sql += " and t.F_CategoryId=" + parentId;
  153. }
  154. string tableName = "";
  155. if(dType>1)
  156. {
  157. tableName = " (SELECT m.* FROM T_RepositoryCategory t INNER JOIN T_RepositoryInformation m ON t.F_CategoryId=m.F_CategoryId WHERE t.F_DeleteFlag=0 and m.F_DeleteFlag=0 and t.F_CategoryType=" + dType + ") as t";
  158. }
  159. else
  160. {
  161. tableName = " (SELECT m.* FROM T_RepositoryCategory t INNER JOIN T_RepositoryInformation m ON t.F_CategoryId=m.F_CategoryId WHERE t.F_DeleteFlag=0 and m.F_DeleteFlag=0 ) as t";
  162. }
  163. DataTable dt = new DataTable();
  164. int recordCount = 0;
  165. //Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  166. dt = BLL.PagerBLL.GetListPager(
  167. tableName,
  168. "F_RepositoryId",
  169. "*",
  170. sql,
  171. "ORDER BY F_RepositoryId desc ",
  172. limit,
  173. page,
  174. true,
  175. out recordCount);
  176. dataModel.code = 0;
  177. dataModel.count = recordCount;
  178. dataModel.data = dt;
  179. return JsonConvert.SerializeObject(dataModel);
  180. }
  181. /// <summary>
  182. /// 编辑内容
  183. /// </summary>
  184. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  185. /// <param name="editType">类型1、新增 2、修改</param>
  186. /// <returns></returns>
  187. public ActionResult RepositoryCategoryContentEdit(int categoryContentId, int editType)
  188. {
  189. Model.T_RepositoryInformation viewModel = new Model.T_RepositoryInformation();
  190. //当前对象实体
  191. Model.T_RepositoryInformation categoryContentModel = reposCategoryContentBLL.GetModel(categoryContentId);
  192. if (editType == 1)
  193. {
  194. viewModel.F_CategoryId = categoryContentId;
  195. }
  196. else
  197. {
  198. viewModel = categoryContentModel;
  199. }
  200. return View(viewModel);
  201. }
  202. /// <summary>
  203. /// 查看内容
  204. /// </summary>
  205. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  206. /// <returns></returns>
  207. public ActionResult RepositoryCategoryContentView(int categoryContentId)
  208. {
  209. return View(reposCategoryContentBLL.GetModel(categoryContentId));
  210. }
  211. /// <summary>
  212. /// 保存编辑
  213. /// </summary>
  214. /// <param name="workOrderBaseModel"></param>
  215. /// <returns></returns>
  216. [AcceptVerbs(HttpVerbs.Post)]
  217. public bool SaveRepositoryCategoryContentData(T_RepositoryInformation categoryContentModel)
  218. {
  219. categoryContentModel.F_CreateBy = F_UserID;
  220. if (categoryContentModel.F_RepositoryId > 0)
  221. {
  222. return reposCategoryContentBLL.Update(categoryContentModel);
  223. }
  224. else
  225. {
  226. return reposCategoryContentBLL.Add(categoryContentModel) > 0;
  227. }
  228. }
  229. /// <summary>
  230. /// 删除数据
  231. /// </summary>
  232. /// <param name="workOrderBaseModel"></param>
  233. /// <returns></returns>
  234. [AcceptVerbs(HttpVerbs.Get)]
  235. public bool DeleteCategoryContentData(int categoryContentId)
  236. {
  237. return reposCategoryContentBLL.Delete(categoryContentId);
  238. }
  239. #endregion
  240. }
  241. }