MattressYWAuditExcutor.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. namespace JLHHJSvr.Excutor
  12. {
  13. internal sealed class MattressYWAuditExcutor : ExcutorBase<MattressYWAuditRequest, MattressYWAuditResponse>
  14. {
  15. protected override void ExcuteInternal(MattressYWAuditRequest request, object state, MattressYWAuditResponse rslt)
  16. {
  17. var tokendata = BllHelper.GetToken(request.token);
  18. if (tokendata == null)
  19. {
  20. rslt.ErrMsg = "会话已经中断,请重新登录";
  21. return;
  22. }
  23. if (!request.list.Any())
  24. {
  25. rslt.ErrMsg = "至少提交一条需要审核的记录";
  26. return;
  27. }
  28. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  29. using (var cmd = con.CreateCommand())
  30. {
  31. con.Open();
  32. if (request.type == 1)
  33. {
  34. var power80 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 80);
  35. if (!power80)
  36. {
  37. throw new LJCommonException("你没有审核权限");
  38. }
  39. }
  40. else
  41. {
  42. var power81 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 81);
  43. if (!power81)
  44. {
  45. throw new LJCommonException("你没有撤审权限");
  46. }
  47. }
  48. var mattressHelper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  49. using (cmd.Transaction = con.BeginTransaction())
  50. {
  51. try
  52. {
  53. foreach (var bill in request.list)
  54. {
  55. if (request.type == 1) mattressHelper.MattressYWAudit(bill.mattressid);
  56. else mattressHelper.MattressYWCancelAudit(bill.mattressid);
  57. }
  58. cmd.Transaction.Commit();
  59. }
  60. catch (Exception e)
  61. {
  62. cmd.Transaction.Rollback();
  63. rslt.ErrMsg = e.ToString();
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }