地铁二期项目正式开始

RepositoryCategoryController.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. 
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using YTSoft.BaseCallCenter.Model;
  10. using YTSoft.BaseCallCenter.MVCWeb.Models;
  11. //using YTSoft.Common;
  12. //using CallCenter.Utility;
  13. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  14. {
  15. public class RepositoryCategoryController : BaseController
  16. {
  17. #region 知识库分类管理
  18. BLL.T_RepositoryCategory reposcategoryBLL = new BLL.T_RepositoryCategory();
  19. public ActionResult RepositoryCategoryList()
  20. {
  21. WorkOrderMyModel model = new WorkOrderMyModel();
  22. return View(model);
  23. }
  24. ///通过dic编码获取dic值
  25. /// </summary>
  26. /// <param name="fid"></param>
  27. /// <returns></returns>
  28. public string GetrepositorycategoryJsonModel(int parentId)
  29. {
  30. return Newtonsoft.Json.JsonConvert.SerializeObject(reposcategoryBLL.GetRepositoryCategoryJsonModel(parentId));
  31. }
  32. /// <summary>
  33. /// 获取知识库分类数据
  34. /// </summary>
  35. /// <param name="page">当前页码</param>
  36. /// <param name="limit">每页数据量</param>
  37. /// <returns></returns>
  38. [ActionName("RepositoryCategoryDate")]
  39. [HttpGet]
  40. public string RepositoryCategoryDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  41. {
  42. //数据结果集
  43. ResponseData dataModel = new ResponseData();
  44. string sql = " and F_DeleteFlag=0";
  45. if (parentId != null)
  46. {
  47. sql += " and F_ParentId=" + parentId;
  48. }
  49. DataTable dt = new DataTable();
  50. int recordCount = 0;
  51. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  52. dt = BLL.PagerBLL.GetListPager(
  53. "T_RepositoryCategory",
  54. "F_CategoryId",
  55. "*",
  56. sql,
  57. "ORDER BY F_Sort asc ",
  58. limit,
  59. page,
  60. true,
  61. out recordCount);
  62. dataModel.code = 0;
  63. dataModel.count = recordCount;
  64. dataModel.data = dt;
  65. return JsonConvert.SerializeObject(dataModel);
  66. }
  67. /// <summary>
  68. /// 编辑分类
  69. /// </summary>
  70. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  71. /// <param name="editType">类型1、新增 2、修改</param>
  72. /// <returns></returns>
  73. public ActionResult RepositoryCategoryEdit(int categoryId, int editType)
  74. {
  75. Model.T_RepositoryCategory viewModel = new Model.T_RepositoryCategory();
  76. //当前对象实体
  77. Model.T_RepositoryCategory categoryModel = reposcategoryBLL.GetModel(categoryId);
  78. if (editType == 1)
  79. {
  80. viewModel.F_ParentId = categoryModel.F_CategoryId;
  81. viewModel.F_Sort = 1;
  82. viewModel.F_CategoryType = categoryModel.F_CategoryType;
  83. }
  84. else
  85. {
  86. viewModel = categoryModel;
  87. }
  88. return View(viewModel);
  89. }
  90. /// <summary>
  91. /// 保存编辑
  92. /// </summary>
  93. /// <param name="workOrderBaseModel"></param>
  94. /// <returns></returns>
  95. [AcceptVerbs(HttpVerbs.Post)]
  96. public bool SaveRepositoryCategoryData(T_RepositoryCategory categoryModel)
  97. {
  98. // 获取当前电脑名:
  99. string a = System.Net.Dns.GetHostName();
  100. // 根据电脑名取出全部IP地址:
  101. System.Net.IPAddress[] addressList = System.Net.Dns.Resolve(a).AddressList;
  102. string b = Convert.ToString(addressList[0]);
  103. if (categoryModel.F_CategoryId > 0)
  104. {
  105. //int id = Common.CommonRequest.dtUserId;
  106. //string usercode = Common.CommonRequest.dtUserCode;
  107. //string pp = Common.DTRequest.GetIP();
  108. return reposcategoryBLL.Update(categoryModel);
  109. }
  110. else
  111. {
  112. return reposcategoryBLL.Add(categoryModel) > 0;
  113. }
  114. }
  115. /// <summary>
  116. /// 删除数据
  117. /// </summary>
  118. /// <param name="workOrderBaseModel"></param>
  119. /// <returns></returns>
  120. [AcceptVerbs(HttpVerbs.Get)]
  121. public bool DeleteCategoryData(int categoryId)
  122. {
  123. return reposcategoryBLL.Delete(categoryId);
  124. }
  125. #endregion
  126. #region 知识库内容管理
  127. BLL.T_RepositoryInformation reposCategoryContentBLL = new BLL.T_RepositoryInformation();
  128. //知识库导出模板
  129. //public string ToExcel()
  130. //{
  131. // NPOIHelper npoi = new NPOIHelper();
  132. // DataTable dt = new DataTable();
  133. // dt.Columns.Add("标题", typeof(string));//一列
  134. // dt.Columns.Add("内容", typeof(string));//二列
  135. // npoi.ExportToExcel("导出模板",dt);
  136. // return Success("导出成功");
  137. //}
  138. //public string importKnowledgeBase()
  139. //{
  140. // // int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  141. // HttpPostedFile _upfile = RequestString.GetFile("upFile");
  142. // int headrow = 0;
  143. // NPOIHelper npoi = new NPOIHelper();
  144. // DataTable dt = npoi.ExcelToTable(_upfile, headrow);
  145. // foreach (DataRow dr in dt.Rows)
  146. // {
  147. // headrow = headrow + 1;
  148. // if (dr[0].ToString() != "" && dr[1].ToString() != "")
  149. // {
  150. // Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase();
  151. // model.F_CustomerName = dr[0].ToString(); //客户姓名
  152. // //model.F_CustomerEName = dr[1].ToString(); //联系人
  153. // model.F_Sex = dr[1].ToString(); //性别
  154. // model.F_Mobile = dr[2].ToString(); //手机号码
  155. // model.F_Telephone = dr[3].ToString(); //单位电话
  156. // model.F_ChargeTelephone = dr[4].ToString(); //其它号码
  157. // model.F_PostCode = dr[5].ToString(); //邮编
  158. // model.F_Email = dr[6].ToString(); //Email
  159. // model.F_ChargeDept = dr[7].ToString(); //所在单位
  160. // model.F_ServiceDept = dr[8].ToString(); //部门
  161. // model.F_CustomerIndustry = dr[9].ToString(); //职务
  162. // model.F_CreateBy = userId;
  163. // model.F_CreatedOn = DateTime.Now;
  164. // model.F_DeleteFlag = 0;
  165. // if (new BLL.T_Cus_CustomerBase().Add(model) <= 0)
  166. // {
  167. // return Error("第" + headrow + "行,导入失败!");
  168. // }
  169. // }
  170. // else
  171. // {
  172. // return Error("第" + headrow + "行,第1,2列信息不能为空,未导入");
  173. // }
  174. // }
  175. // return Success("导入成功");
  176. //}
  177. public ActionResult RepositoryCategoryContentList(int dType)
  178. {
  179. WorkOrderMyModel model = new WorkOrderMyModel();
  180. model.DType = dType;
  181. return View(model);
  182. }
  183. /// <summary>
  184. /// 获取知识库内容数据
  185. /// </summary>
  186. /// <param name="page">当前页码</param>
  187. /// <param name="limit">每页数据量</param>
  188. /// <returns></returns>
  189. [ActionName("RepositoryCategoryContentDate")]
  190. [HttpGet]
  191. public string RepositoryCategoryContentDate(DateTime? NowDateTime, int page,
  192. int limit,int dType, int? parentId, string keyWord)
  193. {
  194. //数据结果集
  195. ResponseData dataModel = new ResponseData();
  196. string sql = " and t.F_DeleteFlag=0 ";
  197. //and F_CreateBy="+F_UserID+"
  198. if (!string.IsNullOrEmpty(keyWord))
  199. {
  200. sql += " and ( t.F_Description like '%" + keyWord + "%' or F_Title like '%" + keyWord + "%')";
  201. }
  202. if (parentId != null && parentId > 1)
  203. {
  204. sql += " and t.F_CategoryId=" + parentId;
  205. }
  206. string tableName = "";
  207. if(dType>1)
  208. {
  209. 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";
  210. }
  211. else
  212. {
  213. 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";
  214. }
  215. DataTable dt = new DataTable();
  216. int recordCount = 0;
  217. //Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  218. dt = BLL.PagerBLL.GetListPager(
  219. tableName,
  220. "F_RepositoryId",
  221. "*",
  222. sql,
  223. "ORDER BY F_RepositoryId desc ",
  224. limit,
  225. page,
  226. true,
  227. out recordCount);
  228. dataModel.code = 0;
  229. dataModel.count = recordCount;
  230. dataModel.data = dt;
  231. return JsonConvert.SerializeObject(dataModel);
  232. }
  233. /// <summary>
  234. /// 编辑内容
  235. /// </summary>
  236. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  237. /// <param name="editType">类型1、新增 2、修改</param>
  238. /// <returns></returns>
  239. public ActionResult RepositoryCategoryContentEdit(int categoryContentId, int editType)
  240. {
  241. Model.T_RepositoryInformation viewModel = new Model.T_RepositoryInformation();
  242. //当前对象实体
  243. Model.T_RepositoryInformation categoryContentModel = reposCategoryContentBLL.GetModel(categoryContentId);
  244. if (editType == 1)
  245. {
  246. viewModel.F_CategoryId = categoryContentId;
  247. }
  248. else
  249. {
  250. viewModel = categoryContentModel;
  251. }
  252. return View(viewModel);
  253. }
  254. /// <summary>
  255. /// 查看内容
  256. /// </summary>
  257. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  258. /// <returns></returns>
  259. public ActionResult RepositoryCategoryContentView(int categoryContentId)
  260. {
  261. return View(reposCategoryContentBLL.GetModel(categoryContentId));
  262. }
  263. /// <summary>
  264. /// 保存编辑
  265. /// </summary>
  266. /// <param name="workOrderBaseModel"></param>
  267. /// <returns></returns>
  268. [AcceptVerbs(HttpVerbs.Post)]
  269. public bool SaveRepositoryCategoryContentData(T_RepositoryInformation categoryContentModel)
  270. {
  271. categoryContentModel.F_CreateBy = F_UserID;
  272. if (categoryContentModel.F_RepositoryId > 0)
  273. {
  274. return reposCategoryContentBLL.Update(categoryContentModel);
  275. }
  276. else
  277. {
  278. return reposCategoryContentBLL.Add(categoryContentModel) > 0;
  279. }
  280. }
  281. /// <summary>
  282. /// 删除数据
  283. /// </summary>
  284. /// <param name="workOrderBaseModel"></param>
  285. /// <returns></returns>
  286. [AcceptVerbs(HttpVerbs.Get)]
  287. public bool DeleteCategoryContentData(int categoryContentId)
  288. {
  289. return reposCategoryContentBLL.Delete(categoryContentId);
  290. }
  291. #endregion
  292. }
  293. }