MessageManageBLL.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using PMS.BusinessModels.Account;
  2. using PMS.BusinessModels.Problem;
  3. using PMS.DBService.MessageManage;
  4. using PMS.Interface.MessageManage;
  5. using QWPlatform.IService;
  6. using QWPlatform.SystemLibrary;
  7. using QWPlatform.SystemLibrary.Utils;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using PMS.EntityModels.NoticeManager;
  15. using PMS.Plugins.Common;
  16. using PMS.Plugins.WeChart;
  17. using PMS.Plugins.PluginsModels;
  18. using PMS.BusinessModels.SMS;
  19. namespace PMS.BusinessService.MessageManag
  20. {
  21. public class MessageManageBLL: IMessageManage
  22. {
  23. private MessageManageServe Message_Service = DataServiceBase.Instance<MessageManageServe>();
  24. public bool AddMessage(MessageManageModel model,UserInfo user,string ID)
  25. {
  26. if(user.PersonProperty!=1)
  27. {
  28. return Message_Service.AddMessageByQD(model, user,ID);
  29. }
  30. return Message_Service.AddMessageByBB(model,ID);
  31. }
  32. public bool DeleteMessage(MessageManageModel model)
  33. {
  34. return Message_Service.DeleteMessage(model);
  35. }
  36. public string SelecteMessageById(string id)
  37. {
  38. return Message_Service.SelecteMessageById(id).ToJson();
  39. }
  40. //公告信息绑定
  41. public string DataBind(int page, int rows, string query,UserInfo user)
  42. {
  43. int defaultrow = 10;
  44. int startnumber = Startnumber(page, rows, defaultrow);
  45. int endnumber = Endnumbers(page, rows, defaultrow);
  46. return Message_Service.DataBind(startnumber,endnumber,query, user);
  47. }
  48. public string GetHome(UserInfo user)
  49. {
  50. return Message_Service.GetHome(user).ToJson();
  51. }
  52. //首页获取公告列表
  53. public string HomeGetList(int page, int rows, UserInfo user)
  54. {
  55. var total = 0;
  56. var dt = Message_Service.HomeGetList(page, rows, user, out total);
  57. return QWPlatform.SystemLibrary.Utils.Strings.ObjectToJson(
  58. new { total = total, rows = dt });
  59. }
  60. //首页获取通知列表
  61. public string HomeGetNotice(int page, int rows, UserInfo user)
  62. {
  63. var total = 0;
  64. var dt = Message_Service.HomeGetNotice(page, rows, user, out total);
  65. return QWPlatform.SystemLibrary.Utils.Strings.ObjectToJson(
  66. new { total = total, rows = dt });
  67. }
  68. //结束行
  69. private int Endnumbers(int page, int row, int defaultrow)
  70. {
  71. if (page == 0 && row == 0)
  72. {
  73. row = defaultrow;
  74. page = 1;
  75. }
  76. return (page) * row;
  77. }
  78. //起始行
  79. private int Startnumber(int page, int row, int defaultrow)
  80. {
  81. if (page == 0 && row == 0)
  82. {
  83. row = defaultrow;
  84. page = 1;
  85. }
  86. return (page - 1) * row + 1;
  87. }
  88. /// <summary>
  89. /// 通知类型
  90. /// </summary>
  91. /// <returns></returns>
  92. public string NoticeType()
  93. {
  94. return Message_Service.NoticeType().ToJson();
  95. }
  96. /// <summary>
  97. /// 通知优先级
  98. /// </summary>
  99. /// <returns></returns>
  100. public string NoticeOrder()
  101. {
  102. return Message_Service.NoticeOrder().ToJson();
  103. }
  104. /// <summary>
  105. /// 通知对象
  106. /// </summary>
  107. /// <returns></returns>
  108. public string NoticePerson(int PersonProperty)
  109. {
  110. return Message_Service.NoticePerson(PersonProperty).ToJson();
  111. }
  112. /// <summary>
  113. /// 根据ID获取通知信息
  114. /// </summary>
  115. /// <param name="v"></param>
  116. /// <param name="id"></param>
  117. /// <returns></returns>
  118. public string GetNoticeByID(string id)
  119. {
  120. return Message_Service.GetNoticeByID(id).ToJson();
  121. }
  122. /// <summary>
  123. /// 根据公告ID获取通知对象
  124. /// </summary>
  125. /// <param name="v"></param>
  126. /// <param name="id"></param>
  127. /// <returns></returns>
  128. public string GetNatureByID(string id)
  129. {
  130. return Message_Service.GetNatureByID(id).ToJson();
  131. }
  132. /// <summary>
  133. /// 修改操作
  134. /// </summary>
  135. /// <param name="model"></param>
  136. /// <returns></returns>
  137. public bool Edit_Notice(MessageManageModel model)
  138. {
  139. return Message_Service.Edit_Notice(model)!=0;
  140. }
  141. /// <summary>
  142. /// 获取渠道
  143. /// </summary>
  144. /// <param name="personProperty"></param>
  145. /// <returns></returns>
  146. public string GetChannelByNature(UserInfo user)
  147. {
  148. return Message_Service.GetChannelByNature(user).ToJson();
  149. }
  150. public string ShowNotice(UserInfo user)
  151. {
  152. return Message_Service.ShowNotice(user).ToJson();
  153. }
  154. /// <summary>
  155. /// 显示总部和渠道的最新公告通知
  156. /// </summary>
  157. /// <param name="user"></param>
  158. /// <returns></returns>
  159. public string GetMessageOnIndex(UserInfo user)
  160. {
  161. return Message_Service.GetMessageOnIndexChannel(user).ToJson();
  162. }
  163. /// <summary>
  164. /// 查询通知数量
  165. /// </summary>
  166. /// <param name="ChannelId"></param>
  167. /// <returns></returns>
  168. public int GetCount(UserInfo user)
  169. {
  170. return Message_Service.GetCount(user);
  171. }
  172. /// <summary>
  173. /// 判断是否显示
  174. /// </summary>
  175. /// <param name="userInfo"></param>
  176. /// <returns></returns>
  177. public Mssage_config PanDuanIsShow(UserInfo userInfo)
  178. {
  179. return Message_Service.PanDuanIsShow(userInfo);
  180. }
  181. //保存单个公告显示配置
  182. public bool SaveNoticeConfig(string PersonId, string NoticeId, bool IsOpen)
  183. {
  184. return Message_Service.SaveNoticeConfig(PersonId, NoticeId, IsOpen);
  185. }
  186. //是否启用
  187. public int NoticeStatus(string id)
  188. {
  189. return Message_Service.NoticeStatus(id);
  190. }
  191. public int AppNoticeStatus(string id)
  192. {
  193. return Message_Service.AppNoticeStatus(id);
  194. }
  195. /// <summary>
  196. /// APP公告获取
  197. /// </summary>
  198. public string APPDataBind(int page, int rows)
  199. {
  200. var total = 0;
  201. int startnumber = Startnumber(page, rows,10);
  202. int endnumber = Endnumbers(page, rows,10);
  203. DataTable dt= Message_Service.APPDataBind(startnumber, endnumber,out total);
  204. return Strings.ObjectToJson(new
  205. {
  206. total = total,
  207. rows = dt,
  208. });
  209. }
  210. public string Add_AppPush(AppPush_Model model)
  211. {
  212. return Message_Service.Add_AppPush(model);
  213. }
  214. /// <summary>
  215. /// 修改App图片公告
  216. /// </summary>
  217. /// <param name="data"></param>
  218. public int Edit_AppNotice(AppPush_Model model)
  219. {
  220. return Message_Service.Edit_AppImg(model);
  221. }
  222. public int Del_AppNotice(string id)
  223. {
  224. return Message_Service.Del_AppNotice(id);
  225. }
  226. //获取启用的app公告
  227. public string GetWorkNotice()
  228. {
  229. return Message_Service.GetWorkNotice().ToJson();
  230. }
  231. public string GetWorkNotiveById(string id)
  232. {
  233. return Message_Service.GetWorkNotiveById(id).ToJson();
  234. }
  235. public int Edit_NoticeFJ(string v, string ID)
  236. {
  237. return Message_Service.Edit_NoticeFJ(v,ID);
  238. }
  239. public int DeleteFJ(string id)
  240. {
  241. return Message_Service.DeleteFJ(id);
  242. }
  243. public string ConvertWeChatTemp(int type, string TemplateID, Dictionary<string, string> TempParame, string sign_name)
  244. {
  245. return Message_Service.ConvertWeChatTemp(type, TemplateID, TempParame, sign_name);
  246. }
  247. /// <summary>
  248. /// 发送微信消息
  249. /// </summary>
  250. /// <param name="notification"></param>
  251. /// <returns></returns>
  252. public string SendWeChartTempletMessge(NotificationDto notificationDto)
  253. {
  254. string strReturn = string.Empty;
  255. try
  256. {
  257. foreach (var items in notificationDto.record_items)
  258. {
  259. WxMessgPush wxMessgPush = new WxMessgPush();
  260. wxMessgPush.wx_openid = items.接收人id;
  261. wxMessgPush.url = notificationDto.url;
  262. wxMessgPush.template_id = notificationDto.template_code;
  263. wxMessgPush.data = notificationDto.template_value;
  264. strReturn = WeChartMessage.SendWeChartTempletMessge(wxMessgPush);
  265. }
  266. }
  267. catch (Exception ex)
  268. {
  269. strReturn = ex.Message;
  270. }
  271. return strReturn;
  272. }
  273. }
  274. }