12345市长热线标准版-后端

ApplicationsRefreshController.cs 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.Client
  10. {
  11. public class ApplicationsRefreshController : BaseController
  12. {
  13. BLL.T_Client_Applications bll = new BLL.T_Client_Applications();
  14. /// <summary>
  15. /// 获取所有库列表
  16. /// </summary>
  17. /// <returns></returns>
  18. public ActionResult GetAllList()
  19. {
  20. DataTable dt = new DataTable();
  21. string appliName = HttpUtility.UrlDecode(RequestString.GetQueryString("appliName"));
  22. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("strstarttime"));
  23. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("strendtime"));
  24. string strpageindex = RequestString.GetQueryString("page");
  25. int pageindex = 1;
  26. string strpagesize = RequestString.GetQueryString("pagesize");
  27. int pagesize = 10;
  28. string sql = string.Empty;
  29. if (appliName.Trim() != "") {
  30. sql += " and F_AppliName like '%" + appliName + "%'";
  31. }
  32. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  33. {
  34. sql += " and datediff(day,F_CreateTime,'" + strstarttime + "')<=0 ";
  35. }
  36. if (strendtime.Trim() != "" && strendtime != "undefined")
  37. {
  38. sql += " and datediff(day,F_CreateTime,'" + strendtime + "')>=0 ";
  39. }
  40. if (strpageindex.Trim() != "")
  41. {
  42. pageindex = Convert.ToInt32(strpageindex);
  43. }
  44. if (strpagesize.Trim() != "")
  45. {
  46. pagesize = Convert.ToInt32(strpagesize);
  47. }
  48. int recordCount = 0;
  49. dt = BLL.PagerBLL.GetListPager(
  50. "T_Client_Applications",
  51. "F_Id",
  52. "*",
  53. sql,
  54. "ORDER BY F_Id desc",
  55. pagesize,
  56. pageindex,
  57. true,
  58. out recordCount);
  59. var obj = new
  60. {
  61. rows = dt,
  62. total = recordCount
  63. };
  64. return Content(obj.ToJson());
  65. }
  66. /// <summary>
  67. /// 获取一条详细信息
  68. /// </summary>
  69. /// <param name="infoid"></param>
  70. /// <returns></returns>
  71. public ActionResult GetInfo(string infoid)
  72. {
  73. if (infoid != null && infoid.Trim() != "")
  74. {
  75. Model.T_Client_Applications model = bll.GetModel(int.Parse(infoid.Trim()));
  76. if (model != null)
  77. {
  78. return Success("获取成功", model);
  79. }
  80. else
  81. {
  82. return Error("获取失败");
  83. };
  84. }
  85. else {
  86. return Error("获取参数失败");
  87. }
  88. }
  89. /// <summary>
  90. /// 保存信息
  91. /// </summary>
  92. /// <returns></returns>
  93. [Authority]
  94. public ActionResult SaveInfo()
  95. {
  96. int id = RequestString.GetInt("id", 0);
  97. string appliName = RequestString.GetFormString("appliName");
  98. string versionName = RequestString.GetFormString("versionName");
  99. string versionCode = RequestString.GetFormString("versionCode");
  100. string downUrl = RequestString.GetFormString("downUrl");
  101. int userId = RequestString.GetInt("userId", 0);
  102. string userCode = RequestString.GetFormString("userCode");
  103. int isDelete = RequestString.GetInt("isDelete", 0);
  104. int order = RequestString.GetInt("order", 0);
  105. string note = RequestString.GetFormString("note");
  106. if (!string.IsNullOrWhiteSpace(appliName) || !string.IsNullOrWhiteSpace(versionCode))
  107. {
  108. Model.T_Client_Applications model = new Model.T_Client_Applications();
  109. if (id == 0)
  110. {
  111. model.F_AppliName = appliName;
  112. model.F_VersionName = versionName;
  113. model.F_VersionCode = versionCode;
  114. model.F_DownUrl = downUrl;
  115. model.UserId = userId;
  116. model.UserCode = userCode;
  117. model.F_CreateTime = DateTime.Now;
  118. //model.F_UpdateTime = DateTime.Now;
  119. //model.F_DeleteTime = DateTime.Now;
  120. model.F_IsDelete = 0;
  121. model.F_Order = 0;
  122. model.F_Note = note;
  123. int n = bll.Add(model);
  124. if (n > 0)
  125. {
  126. return Success("添加成功", n);
  127. }
  128. else
  129. {
  130. return Error("添加失败");
  131. }
  132. }
  133. else
  134. {
  135. model = bll.GetModel(id);
  136. if (model != null)
  137. {
  138. model.F_Id = id;
  139. model.F_AppliName = appliName;
  140. model.F_VersionName = versionName;
  141. model.F_VersionCode = versionCode;
  142. model.F_DownUrl = downUrl;
  143. model.UserId = userId;
  144. model.UserCode = userCode;
  145. model.F_CreateTime = model.F_CreateTime;
  146. model.F_UpdateTime = DateTime.Now;
  147. //model.F_DeleteTime = model.F_DeleteTime;
  148. model.F_IsDelete = isDelete;
  149. model.F_Order = order;
  150. model.F_Note = note;
  151. if (bll.Update(model))
  152. {
  153. return Success("修改成功");
  154. }
  155. else
  156. {
  157. return Error("修改失败");
  158. }
  159. }
  160. return Error("信息不存在");
  161. }
  162. }
  163. else {
  164. return Error("获取参数失败");
  165. }
  166. }
  167. /// <summary>
  168. /// 删除信息
  169. /// </summary>
  170. /// <param name="ids"></param>
  171. /// <returns></returns>
  172. [Authority]
  173. public ActionResult DelInfo(string[] ids)
  174. {
  175. if (ids != null && ids.Length > 0)
  176. {
  177. string idd = " ";
  178. foreach (string str in ids)
  179. {
  180. idd += str + ",";
  181. }
  182. if (bll.DeleteList(idd.TrimEnd(',')))
  183. {
  184. return Success("删除成功");
  185. }
  186. else
  187. return Error("删除失败");
  188. }
  189. else
  190. {
  191. return Error("获取参数失败");
  192. }
  193. }
  194. }
  195. }