SmartFormController.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. using PMS.BusinessModels.SmartForm;
  2. using PMS.BusinessModels.SMS;
  3. using PMS.EntityModels.SmartForm;
  4. using PMS.Interface;
  5. using PMS.Interface.MessageManage;
  6. using PMS.Interface.SmartForm;
  7. using QWPlatform.SystemLibrary;
  8. using QWPlatform.SystemLibrary.Email;
  9. using QWPlatform.SystemLibrary.Utils;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading;
  15. using System.Web;
  16. using System.Web.Mvc;
  17. namespace PMS.WebUI.Controllers
  18. {
  19. public class SmartFormController : BaseController
  20. {
  21. /// <summary>
  22. /// 实例接口
  23. /// </summary>
  24. ISmartForm SmartForm = InterfaceFactory.CreateBusinessInstance<ISmartForm>();
  25. //推送消息
  26. IMessageManage notice = InterfaceFactory.CreateBusinessInstance<IMessageManage>();
  27. private static EmailServerInfo emailServerInfo;
  28. private static SmtpEmail smtpClient;
  29. private static Plugins.Email.SmtpEmail _smtpClient;//内部重写
  30. // GET: SmartForm
  31. public ActionResult SmartIndex()
  32. {
  33. return View();
  34. }
  35. public ActionResult AddSmartForm()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. /// 新增分类
  41. /// </summary>
  42. /// <returns></returns>
  43. public ActionResult AddClass()
  44. {
  45. return View();
  46. }
  47. /// <summary>
  48. /// 项目填报管理
  49. /// </summary>
  50. /// <returns></returns>
  51. public ActionResult FillingManagement()
  52. {
  53. return View();
  54. }
  55. /// <summary>
  56. /// 新增修改分类
  57. /// </summary>
  58. /// <param name="model"></param>
  59. /// <returns></returns>
  60. public ActionResult AddCategory(ZNBDFL model)
  61. {
  62. ZNBDFLModel zNBDFLModel = new ZNBDFLModel();
  63. zNBDFLModel.ID = model.ID;
  64. zNBDFLModel.上级ID = model.上级ID;
  65. zNBDFLModel.名称 = model.名称;
  66. zNBDFLModel.应用性质 = model.应用性质;
  67. zNBDFLModel.应用范围 = model.应用范围;
  68. var r= SmartForm.AddCategory(model.type, zNBDFLModel);
  69. if (r)
  70. {//保存成功
  71. return this.ResponseJson(System.Net.HttpStatusCode.OK, "操作成功");
  72. }
  73. else
  74. {//保存失败
  75. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "操作失败");
  76. }
  77. }
  78. /// <summary>
  79. /// 删除智能表单分类
  80. /// </summary>
  81. /// <param name="zNBDFLModel"></param>
  82. /// <returns></returns>
  83. public ActionResult DelCategory(ZNBDFLModel zNBDFLModel)
  84. {
  85. var msg = "删除成功!";
  86. var r = SmartForm.DelCategory(zNBDFLModel,ref msg);
  87. if (r)
  88. {//保存成功
  89. return this.ResponseJson(System.Net.HttpStatusCode.OK, msg);
  90. }
  91. else
  92. {//保存失败
  93. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, msg);
  94. }
  95. }
  96. /// <summary>
  97. /// 获取分类下来树
  98. /// </summary>
  99. /// <returns></returns>
  100. public ActionResult GetCategory(string id)
  101. {
  102. var list= SmartForm.GetCategory(id);
  103. var json = Strings.ObjectToJson(list);
  104. return Content(json, "application/json");
  105. }
  106. /// <summary>
  107. /// 审核通过时,邮件需要推送附件
  108. /// </summary>
  109. /// <param name="id">记录id</param>
  110. /// <param name="BDXXID">表单id</param>
  111. /// <param name="XM">项目</param>
  112. /// <returns></returns>
  113. public ActionResult UploadFileInfo(string id,string BDXXID, string XM)
  114. {
  115. ViewBag.ID = id;
  116. ViewBag.BDXXID = BDXXID;
  117. ViewBag.CLR = GetCurrentUser().Name;
  118. ViewBag.XM = XM;
  119. return View();
  120. }
  121. /// <summary>
  122. /// 保存智能表单
  123. /// </summary>
  124. /// <param name="model"></param>
  125. /// <returns></returns>
  126. public ActionResult AddSmartFormInfo(ZNBCXX model)
  127. {
  128. ZNBCXXModel XMmodel = new ZNBCXXModel();
  129. XMmodel.FLID = model.FLID;
  130. XMmodel.MC = model.MC;
  131. XMmodel.BT = model.BT;
  132. //XMmodel.TXTS = model.TXTS;
  133. XMmodel.TXXZ = model.TXXZ;
  134. XMmodel.CLMS = model.CLMS;
  135. XMmodel.BZ = model.BZ;
  136. XMmodel.SFTX = model.SFTX;
  137. XMmodel.TXHM = model.TXHM;
  138. XMmodel.YJTS = model.YJTS;
  139. XMmodel.SHTX = model.SHTX;
  140. XMmodel.SHTXHM = model.SHTXHM;
  141. XMmodel.SHYJTS = model.SHYJTS;
  142. XMmodel.SHBHFJ = model.SHBHFJ;
  143. ZNBCMBModel BBModel = new ZNBCMBModel();
  144. BBModel.BDNR = HttpUtility.UrlDecode(model.BDNR);
  145. BBModel.BDCLNR = HttpUtility.UrlDecode(model.BDCLNR);
  146. BBModel.CZR= GetCurrentUser().Name;
  147. var r = SmartForm.Add(XMmodel, BBModel);
  148. if (r)
  149. {//保存成功
  150. return this.ResponseJson(System.Net.HttpStatusCode.OK, "操作成功");
  151. }
  152. else
  153. {//保存失败
  154. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "操作失败");
  155. }
  156. }
  157. /// <summary>
  158. /// 更新智能表单
  159. /// </summary>
  160. /// <param name="model"></param>
  161. /// <returns></returns>
  162. public ActionResult UpdateSmartForm(ZNBCXX model)
  163. {
  164. ZNBCXXModel XMmodel = new ZNBCXXModel();
  165. XMmodel.FLID = model.FLID;
  166. XMmodel.MC = model.MC;
  167. XMmodel.BT = model.BT;
  168. //XMmodel.TXTS = model.TXTS;
  169. XMmodel.TXXZ = model.TXXZ;
  170. XMmodel.CLMS = model.CLMS;
  171. XMmodel.BZ = model.BZ;
  172. XMmodel.SFTX = model.SFTX;
  173. XMmodel.TXHM = model.TXHM;
  174. XMmodel.YJTS = model.YJTS;
  175. XMmodel.SHTX = model.SHTX;
  176. XMmodel.SHTXHM = model.SHTXHM;
  177. XMmodel.SHYJTS = model.SHYJTS;
  178. XMmodel.SHBHFJ = model.SHBHFJ;
  179. XMmodel.ID = model.ID;
  180. XMmodel.ZT = model.ZT;
  181. ZNBCMBModel BBModel = new ZNBCMBModel();
  182. BBModel.BDNR = HttpUtility.UrlDecode(model.BDNR);
  183. BBModel.BDCLNR = HttpUtility.UrlDecode(model.BDCLNR);
  184. BBModel.CZR = GetCurrentUser().Name;
  185. var r = SmartForm.UpdateSmartForm(XMmodel, BBModel);
  186. if (r)
  187. {//保存成功
  188. return this.ResponseJson(System.Net.HttpStatusCode.OK, "操作成功");
  189. }
  190. else
  191. {//保存失败
  192. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "操作失败");
  193. }
  194. }
  195. /// <summary>
  196. /// 查询数据对象并进行赋值【查询智能表单信息】
  197. /// </summary>
  198. /// <param name="id"></param>
  199. /// <returns></returns>
  200. public ActionResult BdxxSelect(string id)
  201. {
  202. var list = SmartForm.BdxxSelect(id);
  203. var json = Strings.ObjectToJson(list);
  204. return Content(json, "application/json");
  205. }
  206. /// <summary>
  207. /// 表单信息列表查询
  208. /// </summary>
  209. /// <param name="model"></param>
  210. /// <returns></returns>
  211. public ActionResult BdxxSelectList(ZNBCXXModel model)
  212. {
  213. var list = SmartForm.BdxxSelectList(model);
  214. var json = Strings.ObjectToJson(list);
  215. return Content(json, "application/json");
  216. }
  217. /// <summary>
  218. /// 复制表单
  219. /// </summary>
  220. /// <param name="id">表单id</param>
  221. /// <returns></returns>
  222. public ActionResult CopySmartForm(string id)
  223. {
  224. var CZR = GetCurrentUser().Name;
  225. var r = SmartForm.CopySmartForm(id, CZR);
  226. if (r)
  227. {//保存成功
  228. return this.ResponseJson(System.Net.HttpStatusCode.OK, "操作成功");
  229. }
  230. else
  231. {//保存失败
  232. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "操作失败");
  233. }
  234. }
  235. #region 表单填写记录
  236. /// <summary>
  237. /// 表单信息列表查询
  238. /// </summary>
  239. /// <param name="model"></param>
  240. /// <returns></returns>
  241. public ActionResult SelectRecordList(SelectBDTXJLModel model)
  242. {
  243. var list = SmartForm.SelectRecordList(model);
  244. var json = Strings.ObjectToJson(new { total = model.total, rows = list });
  245. return Content(json, "application/json");
  246. }
  247. /// <summary>
  248. /// 查询所有的分类下面【表单填写记录】
  249. /// </summary>
  250. /// <param name="model"></param>
  251. /// <param name="classID"></param>
  252. /// <returns></returns>
  253. public ActionResult SelectRecordListAll(SelectBDTXJLModel model)
  254. {
  255. var list = SmartForm.SelectRecordListAll(model,"0");
  256. var json = Strings.ObjectToJson(new { total = model.total, rows = list });
  257. return Content(json, "application/json");
  258. }
  259. /// <summary>
  260. /// 保存表单内容
  261. /// </summary>
  262. /// <param name="model"></param>
  263. /// <returns></returns>
  264. public ActionResult AddRecord(BDTXJLModel model)
  265. {
  266. model.TBR = GetCurrentUser().Name;
  267. model.TBRID = GetCurrentUser().PersonID;
  268. model.QDID = GetCurrentUser().CompanyID;
  269. model.QDMC = GetCurrentUser().Company;
  270. model.BDNR = HttpUtility.UrlDecode(model.BDNR);
  271. model.BDCLNR = HttpUtility.UrlDecode(model.BDCLNR);
  272. model.BDJG = HttpUtility.UrlDecode(model.BDJG);
  273. var rs = SmartForm.AddRecord(model);
  274. if (rs)
  275. {
  276. if(model.TBZT==0)
  277. {
  278. //通知线程(邮件等)
  279. ThreadPool.QueueUserWorkItem(new WaitCallback(PushMessg), model);
  280. }
  281. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json");
  282. }
  283. else
  284. {
  285. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json");
  286. }
  287. }
  288. //填报推送
  289. private void PushMessg(object model)
  290. {
  291. var processModel = model as BDTXJLModel;
  292. try
  293. {
  294. var dtmodel = SmartForm.BdxxSelect(processModel.BDXXID);
  295. if (dtmodel.SFTX == 1)
  296. {
  297. NotificationDto no = new NotificationDto();
  298. no.style = "3";
  299. no.template_code = "_irn5-4QRA2cFx7MWC0S_5AGlf1VVMXWIM1BPxi_RwQ";
  300. var time = DateTime.Now;
  301. var coutent ="【"+ processModel.QDMC+"-"+ processModel.TBR+ "】对【" + processModel.XMMC + "】提交了【"+ dtmodel.MC+ "】";
  302. var title = "您收到新的表单填报!";
  303. no.template_value = "{\"first\":{\"value\":\"" + title + "\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + time + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + dtmodel.MC + "\",\"color\":\"#173177\"},\"keyword3\":{\"value\":\"" + coutent + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"请登录问题管理系统进行处理。\",\"color\":\"#173177\"}}";
  304. //no.url = "https://zlpms.zlsoft.com:8078/MobileProblem/ProblemDetail/" + ProblemID;
  305. List<MessageDetailsDto> list = new List<MessageDetailsDto>();
  306. var dt= SmartForm.GetPushAccountInfo(dtmodel.TXHM);
  307. if (dt != null && dt.Rows.Count > 0)
  308. {
  309. for (int i = 0; i < dt.Rows.Count; i++)
  310. {
  311. MessageDetailsDto mdd = new MessageDetailsDto();
  312. mdd.接收人id = dt.Rows[i].GetValueByName<string>("微信id");
  313. list.Add(mdd);
  314. }
  315. no.record_items = list;
  316. notice.SendWeChartTempletMessge(no);
  317. }
  318. //邮件
  319. //touser.Add("zp@zlsoft.cn");
  320. //touser.Add("zxm@zlsoft.cn");
  321. List<string> ccuser = new List<string>();
  322. List<string> touser = new List<string>();
  323. if (dtmodel.YJTS != null || dtmodel.YJTS != "")
  324. {
  325. var arr = dtmodel.YJTS.Split(',');
  326. for (int i = 0; i < arr.Length; i++)
  327. {
  328. touser.Add(arr[i]);
  329. }
  330. emailServerInfo = new EmailServerInfo("m.zlsoft.cn", "问题管理工具", "zljtysywpt@zlsoft.cn", "zlsoft@2019");
  331. //实例化发送对象 ""
  332. smtpClient = new SmtpEmail(emailServerInfo);
  333. var emai = new EmailInfo(title, coutent, touser.ToArray(), ccuser.ToArray());
  334. var user = emailServerInfo.SendEmail;
  335. var name = emailServerInfo.SendUserName;
  336. emai.FromUser(user, name);
  337. //发送邮件
  338. smtpClient?.Send(emai);
  339. }
  340. }
  341. }
  342. catch (Exception ex)
  343. {
  344. }
  345. }
  346. /// <summary>
  347. /// 审核推送
  348. /// </summary>
  349. /// <param name="model"></param>
  350. private void AuditPushMessg(object model)
  351. {
  352. var processModel = model as BDTXJLModel;
  353. try
  354. {
  355. BDTXJLModel bdmodel = new BDTXJLModel();
  356. bdmodel.ID = processModel.ID;
  357. var fromInfor= SmartForm.MyRecordList(bdmodel);
  358. NotificationDto no = new NotificationDto();
  359. no.style = "3";
  360. no.template_code = "OIE51OsXeECnoPxGgPTQ7acXybc7t1plgAbdlH-mMWE";
  361. var time = DateTime.Now;
  362. var state = processModel.TBZT == 1 ? "通过" : "退回";
  363. var coutent ="【" + fromInfor.FirstOrDefault().XMMC + "】填报的表单已被【" + processModel.SHR + "】" + state;
  364. var title = "表单处理结果通知!";
  365. var color = "#173177";
  366. if (processModel.TBZT == 1)
  367. {
  368. no.url = "https://zlpms.zlsoft.com:8078/SmartForm/MobileSmartDetailPreview/" + processModel.ID;
  369. }
  370. else
  371. {
  372. color = "#2ab8ff";
  373. no.url = "https://zlpms.zlsoft.com:8078/SmartForm/EditMobileSmartDetail/" + processModel.ID;
  374. }
  375. no.template_value = "{\"first\":{\"value\":\"" + title + "\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + time + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + coutent + "\",\"color\":\"" + color + "\"},\"remark\":{\"value\":\"点击【查看详情】立即查阅您填写的表单\",\"color\":\"#173177\"}}";
  376. List<MessageDetailsDto> list = new List<MessageDetailsDto>();
  377. var dt = SmartForm.GetSysAccountInfo(fromInfor.FirstOrDefault().TBRID);
  378. if (dt != null && dt.Rows.Count > 0)
  379. {
  380. //邮件
  381. List<string> ccuser = new List<string>();
  382. List<string> touser = new List<string>();
  383. for (int i = 0; i < dt.Rows.Count; i++)
  384. {
  385. MessageDetailsDto mdd = new MessageDetailsDto();
  386. if(dt.Rows[i].GetValueByName<string>("微信id")!=null)
  387. {
  388. mdd.接收人id = dt.Rows[i].GetValueByName<string>("微信id");
  389. list.Add(mdd);
  390. }
  391. if (dt.Rows[i].GetValueByName<string>("邮箱") != null)
  392. {
  393. touser.Add(dt.Rows[i].GetValueByName<string>("邮箱"));
  394. }
  395. }
  396. no.record_items = list;
  397. if(no.record_items.Count>0)
  398. {
  399. notice.SendWeChartTempletMessge(no);
  400. }
  401. if(touser.Count>0)
  402. {
  403. emailServerInfo = new EmailServerInfo("m.zlsoft.cn", "问题管理工具", "zljtysywpt@zlsoft.cn", "zlsoft@2019");
  404. //实例化发送对象 ""
  405. smtpClient = new SmtpEmail(emailServerInfo);
  406. var emai = new EmailInfo(title, coutent, touser.ToArray(), ccuser.ToArray());
  407. var user = emailServerInfo.SendEmail;
  408. var name = emailServerInfo.SendUserName;
  409. emai.FromUser(user, name);
  410. //发送邮件
  411. smtpClient?.Send(emai);
  412. }
  413. }
  414. }
  415. catch (Exception ex)
  416. {
  417. }
  418. }
  419. /// <summary>
  420. /// 更新记录
  421. /// </summary>
  422. /// <param name="model"></param>
  423. /// <returns></returns>
  424. public ActionResult UpdateRecord(BDTXJLModel model)
  425. {
  426. model.SHR = GetCurrentUser().Name;
  427. model.SHRID = GetCurrentUser().PersonID;
  428. model.TBR = GetCurrentUser().Name;
  429. model.QDID = GetCurrentUser().CompanyID;
  430. model.QDMC = GetCurrentUser().Company;
  431. //处理页面有html
  432. model.BDJG = HttpUtility.UrlDecode(model.BDJG);
  433. model.BDCLJG = HttpUtility.UrlDecode(model.BDCLJG);
  434. var rs = SmartForm.UpdateRecord(model, int.Parse(model.BZ));//这个地方的备注传界面操作状态
  435. if (rs)
  436. {
  437. if (model.BZ=="3")//退回重新填报
  438. {
  439. //通知线程(邮件等)
  440. ThreadPool.QueueUserWorkItem(new WaitCallback(PushMessg), model);
  441. }
  442. else if(model.BZ=="2")
  443. { //审核通过通知填报人
  444. ThreadPool.QueueUserWorkItem(new WaitCallback(AuditPushMessg), model);
  445. }
  446. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json");
  447. }
  448. else
  449. {
  450. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json");
  451. }
  452. }
  453. /// <summary>
  454. /// 审核推送带附件
  455. /// </summary>
  456. /// <param name="emailPush"></param>
  457. /// <returns></returns>
  458. public ActionResult AuditAttachmentPush(EmailPush emailPush)
  459. {
  460. BDTXJLModel model =new BDTXJLModel();
  461. model.SHR = GetCurrentUser().Name;
  462. model.SHRID = GetCurrentUser().PersonID;
  463. model.TBR = GetCurrentUser().Name;
  464. model.QDID = GetCurrentUser().CompanyID;
  465. model.QDMC = GetCurrentUser().Company;
  466. model.TBZT = 1;
  467. model.BZ ="2";
  468. model.ID = emailPush.ID;
  469. //处理页面有html
  470. model.BDJG = HttpUtility.UrlDecode(model.BDJG);
  471. model.BDCLJG = HttpUtility.UrlDecode(model.BDCLJG);
  472. var rs = SmartForm.UpdateRecord(model, int.Parse(model.BZ));//这个地方的备注传界面操作状态
  473. if (rs)
  474. {
  475. //审核通过通知公司相关人员
  476. ThreadPool.QueueUserWorkItem(new WaitCallback(AuditEnclosurePushMessg), emailPush);
  477. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.OK, "成功", null).ToString(), "application/json");
  478. }
  479. else
  480. {
  481. return Content(new PmsJsonResoult(System.Net.HttpStatusCode.Forbidden, "失败", null).ToString(), "application/json");
  482. }
  483. }
  484. /// <summary>
  485. /// 审核带附件推送
  486. /// </summary>
  487. /// <param name="model"></param>
  488. private void AuditEnclosurePushMessg(object model)
  489. {
  490. var processModel = model as EmailPush;
  491. try
  492. {
  493. var dtmodel = SmartForm.BdxxSelect(processModel.BDXXID);
  494. if (dtmodel.SHTX == 1)
  495. {
  496. NotificationDto no = new NotificationDto();
  497. no.style = "3";
  498. no.template_code = "OIE51OsXeECnoPxGgPTQ7acXybc7t1plgAbdlH-mMWE";
  499. var time = DateTime.Now;
  500. var color = "#173177";
  501. no.url = "https://zlpms.zlsoft.com:8078/SmartForm/MobileSmartDetailPreview/" + processModel.ID;
  502. no.template_value = "{\"first\":{\"value\":\"" + processModel.TSBT + "\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + time + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + processModel.TSNR + "\",\"color\":\"" + color + "\"},\"remark\":{\"value\":\"点击【查看详情】立即查阅您填写的表单\",\"color\":\"#173177\"}}";
  503. //邮件
  504. List<string> ccuser = new List<string>();
  505. List<string> touser = new List<string>();
  506. List<MessageDetailsDto> list = new List<MessageDetailsDto>();
  507. //将当前填报人加入推送消息中
  508. BDTXJLModel bdmodel = new BDTXJLModel();
  509. bdmodel.ID = processModel.ID;
  510. var fromInfor = SmartForm.MyRecordList(bdmodel);
  511. var nowdt = SmartForm.GetSysAccountInfo(fromInfor.FirstOrDefault().TBRID);
  512. if (nowdt != null && nowdt.Rows.Count > 0)
  513. {
  514. for (int i = 0; i < nowdt.Rows.Count; i++)
  515. {
  516. MessageDetailsDto mdd = new MessageDetailsDto();
  517. if (nowdt.Rows[i].GetValueByName<string>("微信id") != null)
  518. {
  519. mdd.接收人id = nowdt.Rows[i].GetValueByName<string>("微信id");
  520. list.Add(mdd);
  521. }
  522. if (nowdt.Rows[i].GetValueByName<string>("邮箱") != null)
  523. {
  524. touser.Add(nowdt.Rows[i].GetValueByName<string>("邮箱"));
  525. }
  526. }
  527. }
  528. //将审核人员添加到推送消息列表
  529. var dt = SmartForm.GetPushAccountInfo(dtmodel.TXHM);
  530. if (dt != null && dt.Rows.Count > 0)
  531. {
  532. for (int i = 0; i < dt.Rows.Count; i++)
  533. {
  534. MessageDetailsDto mdd = new MessageDetailsDto();
  535. if (dt.Rows[i].GetValueByName<string>("微信id") != null)
  536. {
  537. mdd.接收人id = dt.Rows[i].GetValueByName<string>("微信id");
  538. list.Add(mdd);
  539. }
  540. }
  541. no.record_items = list;
  542. if (no.record_items.Count > 0)
  543. {
  544. notice.SendWeChartTempletMessge(no);
  545. }
  546. }
  547. //邮件推送
  548. if(dtmodel.SHYJTS!=null || dtmodel.SHYJTS!="")
  549. {
  550. var arr = dtmodel.SHYJTS.Split(',');
  551. for (int i = 0; i < arr.Length; i++)
  552. {
  553. touser.Add(arr[i]);
  554. }
  555. if (touser.Count > 0)
  556. {
  557. List<string> AttachFiles = new List<string>();
  558. List<Plugins.Email.FileArray> AttachFilesArray = new List<Plugins.Email.FileArray>();
  559. if (processModel.File!=null)
  560. {
  561. foreach (var item in processModel.File)
  562. {
  563. Plugins.Email.FileArray _fileArray = new Plugins.Email.FileArray();
  564. byte[] imageBytes = Convert.FromBase64String(item.data.Replace("data:image/jpeg;base64,", "").Replace("data:image/png;base64,", "").Replace("data:image/gif;base64,", "").Replace("data:image/jpg;base64,", ""));
  565. _fileArray.filesBate = imageBytes;
  566. _fileArray.filesName = item.name;
  567. AttachFilesArray.Add(_fileArray);
  568. }
  569. }
  570. var _emailServerInfo = new Plugins.Email.EmailServerInfo("m.zlsoft.cn", "问题管理工具", "zljtysywpt@zlsoft.cn", "zlsoft@2019");
  571. //实例化发送对象 ""
  572. var _smtpClient = new Plugins.Email.SmtpEmail(_emailServerInfo);
  573. var emai = new Plugins.Email.EmailInfo(processModel.TSBT, processModel.TSNR, touser.ToArray(), ccuser.ToArray(), AttachFiles, AttachFilesArray);
  574. var user = _emailServerInfo.SendEmail;
  575. var name = _emailServerInfo.SendUserName;
  576. emai.FromUser(user, name);
  577. //发送邮件
  578. _smtpClient?.Send(emai);
  579. }
  580. }
  581. }
  582. }
  583. catch (Exception ex)
  584. {
  585. }
  586. }
  587. #region 智能表单
  588. /// <summary>
  589. /// 智能表单预览
  590. /// </summary>
  591. /// <returns></returns>
  592. public ActionResult SmarView()
  593. {
  594. return View();
  595. }
  596. //PC端新增智能表单
  597. public ActionResult PcSmartFormList(string id, string xmid,string xmmc)
  598. {
  599. ViewBag.ID = id;
  600. ViewBag.XMID = xmid;
  601. ViewBag.XMMC = xmmc;
  602. return View();
  603. }
  604. public ActionResult EditPcSmartFormList(string id)
  605. {
  606. ViewBag.ID = id;
  607. return View();
  608. }
  609. #endregion
  610. #endregion
  611. #region 移动端智能表单
  612. public ActionResult MobileSmart()
  613. {
  614. return View();
  615. }
  616. public ActionResult MobileSmartDetail(string id)
  617. {
  618. ViewBag.ID = id;
  619. return View();
  620. }
  621. /// <summary>
  622. /// 我的填写
  623. /// </summary>
  624. /// <param name="id"></param>
  625. /// <returns></returns>
  626. public ActionResult MobileMySmart()
  627. {
  628. ViewBag.TBRID = GetCurrentUser().PersonID;
  629. return View();
  630. }
  631. /// <summary>
  632. /// 我的填写记录
  633. /// </summary>
  634. /// <param name="model"></param>
  635. /// <returns></returns>
  636. public ActionResult MyRecordList(BDTXJLModel model)
  637. {
  638. if(model.TBRID != "-1")
  639. {
  640. model.TBRID = GetCurrentUser().PersonID;
  641. }
  642. else
  643. {
  644. model.TBRID = "";
  645. }
  646. var list = SmartForm.MyRecordList(model);
  647. var json = Strings.ObjectToJson(list);
  648. return Content(json, "application/json");
  649. }
  650. /// <summary>
  651. /// 表单预览
  652. /// </summary>
  653. /// <returns></returns>
  654. public ActionResult MobileSmartDetailPreview(string id)
  655. {
  656. ViewBag.ID = id;
  657. return View();
  658. }
  659. /// <summary>
  660. /// 编辑表单记录
  661. /// </summary>
  662. /// <param name="id"></param>
  663. /// <returns></returns>
  664. public ActionResult EditMobileSmartDetail(string id)
  665. {
  666. ViewBag.ID = id;
  667. return View();
  668. }
  669. #endregion
  670. }
  671. }