MattressJSAuditExcutor.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Data.SqlClient;
  3. using System.Linq;
  4. using JLHHJSvr.BLL;
  5. using JLHHJSvr.Com;
  6. using JLHHJSvr.Com.Model;
  7. using JLHHJSvr.Helper;
  8. using JLHHJSvr.LJException;
  9. using LJLib.DAL.SQL;
  10. using LJLib.Net.SPI.Server;
  11. using LJLib.SQLEX;
  12. namespace JLHHJSvr.Excutor
  13. {
  14. internal sealed class MattressJSAuditExcutor : ExcutorBase<MattressJSAuditRequest, MattressJSAuditResponse>
  15. {
  16. protected override void ExcuteInternal(MattressJSAuditRequest request, object state, MattressJSAuditResponse rslt)
  17. {
  18. var tokendata = BllHelper.GetToken(request.token);
  19. if (tokendata == null)
  20. {
  21. rslt.ErrMsg = "会话已经中断,请重新登录";
  22. return;
  23. }
  24. if (!request.list.Any())
  25. {
  26. rslt.ErrMsg = "至少提交一条需要审核的记录";
  27. return;
  28. }
  29. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  30. using (var cmd = con.CreateCommand())
  31. {
  32. con.Open();
  33. if (request.type == 1)
  34. {
  35. var power83 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 83);
  36. if (!power83)
  37. {
  38. throw new LJCommonException("你没有审核权限");
  39. }
  40. }
  41. else
  42. {
  43. var power84 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 84);
  44. if (!power84)
  45. {
  46. throw new LJCommonException("你没有撤审权限");
  47. }
  48. }
  49. var mattressHelper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  50. using (cmd.Transaction = con.BeginTransaction())
  51. {
  52. try
  53. {
  54. foreach (var bill in request.list)
  55. {
  56. if (request.type == 1) mattressHelper.MattressJSAudit(bill.mattressid);
  57. else mattressHelper.MattressJSCancelAudit(bill.mattressid);
  58. }
  59. cmd.Transaction.Commit();
  60. }
  61. catch (Exception e)
  62. {
  63. cmd.Transaction.Rollback();
  64. rslt.ErrMsg = e.ToString();
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }