Нет описания

HotspotGlossaryController.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. using CallCenter.Utility;
  2. using CallCenterApi.Interface.Controllers.Base;
  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. namespace CallCenterApi.Interface.Controllers.Wiki
  10. {
  11. [Authority]
  12. public class HotspotGlossaryController : BaseController
  13. {
  14. // GET: HotspotGlossary
  15. /// <summary>
  16. /// 上传附件
  17. /// </summary>
  18. /// <returns></returns>
  19. public ActionResult UploadFile()
  20. {
  21. HttpFileCollection files = RequestString.GetFiles();
  22. if (files.Count > 0)
  23. {
  24. List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
  25. string path = "/Upload/Wiki/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
  26. for (int i = 0; i < files.Count; i++)
  27. {
  28. HttpPostedFile file = files[i];
  29. FileUp fu = new FileUp();
  30. string name = fu.Upload(file, path);
  31. Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
  32. model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
  33. model_T_Sys_Accessories.F_FileName = name;//附件名称
  34. model_T_Sys_Accessories.F_FileType = System.IO.Path.GetExtension(file.FileName);//附件类型
  35. model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
  36. model_T_Sys_Accessories.F_Size = file.ContentLength;
  37. model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人
  38. int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
  39. model_T_Sys_Accessories.F_FileId = id;
  40. acs.Add(model_T_Sys_Accessories);
  41. }
  42. return Success("成功", acs);
  43. }
  44. else
  45. {
  46. return Error("请选择要上传的文件");
  47. }
  48. }
  49. /// <summary>
  50. /// 列表
  51. /// </summary>
  52. /// <param name="page"></param>
  53. /// <param name="pagesize"></param>
  54. /// <param name="isdc"></param>
  55. /// <returns></returns>
  56. public ActionResult GetList(string keyvalue, string stime, string etime, int key = 0, int page = 1, int pagesize = 10, int isdc = 0)
  57. {
  58. DataTable dt = new DataTable();
  59. string sql = " and F_IsDelete=0 ";
  60. string sqldt = "";
  61. if (stime.Trim() != "" && stime != "undefined")
  62. {
  63. sql += " and F_FaBuShiJian >= '" + stime + " 00:00:00" + "' ";
  64. }
  65. if (etime.Trim() != "" && etime != "undefined")
  66. {
  67. sql += " and F_FaBuShiJian <= '" + etime + " 23:59:59" + "' ";
  68. }
  69. if (key > 0)
  70. {
  71. //sql += " and F_Key = " + key;
  72. sqldt = " INNER JOIN [GetValueId]('" + key + "') Value on a.F_Key = Value.F_ValueId";
  73. }
  74. if (!string.IsNullOrEmpty(keyvalue))
  75. {
  76. sql += " and (F_ZhengCeMingCi like '%" + keyvalue + "%' or F_QiTaShuoMing like '%" + keyvalue + "%' or F_BanLiLiuCheng like '%" + keyvalue + "%' or F_BeiZhu like '%" + keyvalue + "%')";
  77. }
  78. string cols = "a.*,dbo.GetDictionaryName(F_Key) as KeyName";
  79. if (isdc > 0)
  80. {
  81. var dtdc = DB.DbHelperSQL.Query(" select " + cols + " from T_Wiki_HotspotGlossary a with(nolock) " + sqldt + " where 1=1 " + sql).Tables[0];
  82. var msg = new NPOIHelper().ExportToExcel("办事指南", dtdc);
  83. if (msg == "")
  84. {
  85. return Success("导出成功");
  86. }
  87. else
  88. {
  89. return Error("导出失败");
  90. }
  91. }
  92. int recordCount = 0;
  93. dt = BLL.PagerBLL.GetListPager(
  94. "T_Wiki_HotspotGlossary a with(nolock) " + sqldt,
  95. "F_Id",
  96. cols,
  97. sql,
  98. "ORDER BY F_DianJiLiang,F_CreateTime DESC",
  99. pagesize,
  100. page,
  101. true,
  102. out recordCount);
  103. var obj = new
  104. {
  105. state = "success",
  106. message = "成功",
  107. rows = dt,
  108. total = recordCount
  109. };
  110. return Content(obj.ToJson());
  111. }
  112. /// <summary>
  113. /// 获取
  114. /// </summary>
  115. /// <param name="id"></param>
  116. /// <returns></returns>
  117. public ActionResult GetModel(int id = 0)
  118. {
  119. if (id != 0)
  120. {
  121. var model = new BLL.T_Wiki_HotspotGlossary().GetModel(id);
  122. if (model != null)
  123. {
  124. DB.DbHelperSQL.ExecuteSql(" update T_Wiki_HotspotGlossary set F_DianJiLiang=F_DianJiLiang+1 where F_Id=" + id);
  125. DataTable dtkey = new DataTable();
  126. if (model.F_Key > 0)
  127. {
  128. dtkey = DB.DbHelperSQL.Query(" select * from View_KeysSplit where id=" + model.F_Key).Tables[0];
  129. }
  130. DataTable dtfile = new DataTable();
  131. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  132. if (!string.IsNullOrEmpty(model.F_File) && configfj != null)
  133. {
  134. dtfile = DB.DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + model.F_File + ")").Tables[0];
  135. foreach (DataRow dr in dtfile.Rows)
  136. {
  137. dr["F_FileUrl"] = configfj.F_ParamValue + dr["F_FileUrl"].ToString();
  138. }
  139. }
  140. var obj = new { model, dtkey, dtfile };
  141. return Success("成功", obj);
  142. }
  143. return Error("参数错误");
  144. }
  145. else
  146. {
  147. return Error("参数错误");
  148. }
  149. }
  150. /// <summary>
  151. /// 添加
  152. /// </summary>
  153. /// <param name="input"></param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. public ActionResult AddModel(int id = 0, int key = 0)
  157. {
  158. string fabudanwei = RequestString.GetFormString("fabudanwei");
  159. string faburen = RequestString.GetFormString("faburen");
  160. string hangye = RequestString.GetFormString("hangye");
  161. string diqu = RequestString.GetFormString("diqu");
  162. string shengxiaoshijian = RequestString.GetFormString("shengxiaoshijian");
  163. string shixiaoshijian = RequestString.GetFormString("shixiaoshijian");
  164. string fabushijian = RequestString.GetFormString("fabushijian");
  165. string fawenwenhao = RequestString.GetFormString("fawenwenhao");
  166. string fawendanwei = RequestString.GetFormString("fawendanwei");
  167. string biaoshibianma = RequestString.GetFormString("biaoshibianma");
  168. string jiedadanwei = RequestString.GetFormString("jiedadanwei");
  169. string zhengcemingci = RequestString.GetFormString("zhengcemingci");
  170. string file = RequestString.GetFormString("file");
  171. string redianwenti = RequestString.GetFormString("redianwenti");
  172. string wentijieda = RequestString.GetFormString("wentijieda");
  173. Model.T_Wiki_HotspotGlossary dModel = new Model.T_Wiki_HotspotGlossary();
  174. if (id == 0)
  175. {
  176. //var list = new BLL.T_Wiki_HotspotGlossary().GetList(" F_FaBuDanWei='" + fabudanwei + "' and F_IsDelete=0 ").Tables[0];
  177. //if (list.Rows.Count > 0)
  178. //{
  179. // return Error("已经存在");
  180. //}
  181. //else
  182. //{
  183. dModel.F_FaBuRen = faburen;
  184. dModel.F_FaBuDanWei = fabudanwei;
  185. dModel.F_HangYe = hangye;
  186. dModel.F_DiQu = diqu;
  187. try
  188. {
  189. dModel.F_ShengXiaoShiJian = DateTime.Parse(shengxiaoshijian);
  190. }
  191. catch { };
  192. try
  193. {
  194. dModel.F_ShiXiaoShiJian = DateTime.Parse(shixiaoshijian);
  195. }
  196. catch { };
  197. try
  198. {
  199. dModel.F_FaBuShiJian = DateTime.Parse(fabushijian);
  200. }
  201. catch { };
  202. dModel.F_Key = key;
  203. dModel.F_FaWenWenHao = fawenwenhao;
  204. dModel.F_FaWenDanWei = fawendanwei;
  205. dModel.F_BiaoShiBianMa = biaoshibianma;
  206. dModel.F_JieDaDanWei = jiedadanwei;
  207. dModel.F_ZhengCeMingCi = zhengcemingci;
  208. dModel.F_File = file;
  209. dModel.F_ReDianWenTi = redianwenti;
  210. dModel.F_WenTiJieDa = wentijieda;
  211. dModel.F_DianJiLiang = 0;
  212. dModel.F_IsDelete = 0;
  213. dModel.F_CreateUser = User.F_UserCode;
  214. dModel.F_CreateTime = DateTime.Now;
  215. int n = new BLL.T_Wiki_HotspotGlossary().Add(dModel);
  216. if (n > 0)
  217. return Success("添加成功", n);
  218. else
  219. return Error("添加失败");
  220. //}
  221. }
  222. else
  223. {
  224. dModel = new BLL.T_Wiki_HotspotGlossary().GetModel(id);
  225. if (dModel != null)
  226. {
  227. //var list = new BLL.T_Wiki_HotspotGlossary().GetList(" F_FaBuDanWei='" + fabudanwei + "' and F_IsDelete=0 and F_Id!='" + id + "' ").Tables[0];
  228. //if (list.Rows.Count > 0)
  229. //{
  230. // return Error("已经存在");
  231. //}
  232. //else
  233. //{
  234. dModel.F_FaBuRen = faburen;
  235. dModel.F_FaBuDanWei = fabudanwei;
  236. dModel.F_HangYe = hangye;
  237. dModel.F_DiQu = diqu;
  238. try
  239. {
  240. dModel.F_ShengXiaoShiJian = DateTime.Parse(shengxiaoshijian);
  241. }
  242. catch { };
  243. try
  244. {
  245. dModel.F_ShiXiaoShiJian = DateTime.Parse(shixiaoshijian);
  246. }
  247. catch { };
  248. try
  249. {
  250. dModel.F_FaBuShiJian = DateTime.Parse(fabushijian);
  251. }
  252. catch { };
  253. dModel.F_Key = key;
  254. dModel.F_FaWenWenHao = fawenwenhao;
  255. dModel.F_FaWenDanWei = fawendanwei;
  256. dModel.F_BiaoShiBianMa = biaoshibianma;
  257. dModel.F_JieDaDanWei = jiedadanwei;
  258. dModel.F_ZhengCeMingCi = zhengcemingci;
  259. dModel.F_File = file;
  260. dModel.F_ReDianWenTi = redianwenti;
  261. dModel.F_WenTiJieDa = wentijieda;
  262. if (new BLL.T_Wiki_HotspotGlossary().Update(dModel))
  263. return Success("修改成功");
  264. else
  265. return Error("修改失败");
  266. //}
  267. }
  268. else
  269. {
  270. return Error("修改失败");
  271. }
  272. }
  273. }
  274. /// <summary>
  275. /// 删除
  276. /// </summary>
  277. /// <param name="ids"></param>
  278. /// <returns></returns>
  279. public ActionResult DelModel(string[] ids)
  280. {
  281. if (ids == null || ids.Length <= 0)
  282. {
  283. return Error("请选择要删除的选项");
  284. }
  285. var idStr = string.Join(",", ids);
  286. if (string.IsNullOrEmpty(idStr.Trim()))
  287. {
  288. return Error("请选择要删除的选项");
  289. }
  290. int n = DB.DbHelperSQL.ExecuteSql(" update T_Wiki_HotspotGlossary set F_IsDelete=1,F_DeleteUser='" + User.F_UserCode + "',F_DeleteTime=getdate() where F_Id in (" + idStr + ")");
  291. if (n > 0)
  292. {
  293. return Success("删除成功");
  294. }
  295. return Error("删除失败");
  296. }
  297. }
  298. }