MattressJS2AuditExcutor.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 MattressJS2AuditExcutor : ExcutorBase<MattressJS2AuditRequest, MattressJS2AuditResponse>
  15. {
  16. protected override void ExcuteInternal(MattressJS2AuditRequest request, object state, MattressJS2AuditResponse rslt)
  17. {
  18. var tokendata = BllHelper.GetToken(request.token);
  19. if (!request.list.Any())
  20. {
  21. rslt.ErrMsg = "至少提交一条需要审核的记录";
  22. return;
  23. }
  24. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  25. using (var cmd = con.CreateCommand())
  26. {
  27. con.Open();
  28. if (request.type == 1)
  29. {
  30. var power86 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 86);
  31. if (!power86)
  32. {
  33. throw new LJCommonException("你没有审核权限");
  34. }
  35. }
  36. else
  37. {
  38. var power87 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 87);
  39. if (!power87)
  40. {
  41. throw new LJCommonException("你没有撤审权限");
  42. }
  43. }
  44. var mattressHelper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  45. using (cmd.Transaction = con.BeginTransaction())
  46. {
  47. try
  48. {
  49. foreach (var bill in request.list)
  50. {
  51. if (request.type == 1) mattressHelper.MattressJS2Audit(bill.mattressid);
  52. else mattressHelper.MattressJS2CancelAudit(bill.mattressid);
  53. }
  54. cmd.Transaction.Commit();
  55. }
  56. catch (Exception e)
  57. {
  58. cmd.Transaction?.Rollback();
  59. rslt.ErrMsg = e.Message;
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }