LockTableExcutor.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using JLHHJSvr.BLL;
  6. using JLHHJSvr.Com;
  7. using JLHHJSvr.Com.Model;
  8. using JLHHJSvr.Helper;
  9. using JLHHJSvr.LJException;
  10. using LJLib.DAL.SQL;
  11. using LJLib.Net.SPI.Server;
  12. using LJLib.SQLEX;
  13. namespace JLHHJSvr.Excutor
  14. {
  15. internal sealed class LockTableExcutor : ExcutorBase<LockTableRequest, LockTableResponse>
  16. {
  17. protected override void ExcuteInternal(LockTableRequest request, object state, LockTableResponse rslt)
  18. {
  19. if (string.IsNullOrEmpty(request.keyword)) throw new LJCommonException("加锁单据关键字错误,请检查!");
  20. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  21. using (var cmd = con.CreateCommand())
  22. {
  23. con.Open();
  24. using (cmd.Transaction = con.BeginTransaction())
  25. {
  26. try
  27. {
  28. LockHelper.LockBill(cmd, request.keyword, request.billid, request.billcode, BllHelper.GetToken(request.token).username);
  29. cmd.Transaction.Commit();
  30. }
  31. catch (Exception e)
  32. {
  33. cmd.Transaction?.Rollback();
  34. rslt.ErrMsg = e.Message;
  35. }
  36. }
  37. }
  38. }
  39. }
  40. }