CheckTableIsLockExcutor.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Data.SqlClient;
  3. using System.Linq;
  4. using System.Threading;
  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 CheckTableIsLockExcutor : ExcutorBase<CheckTableIsLockRequest, CheckTableIsLockResponse>
  16. {
  17. protected override void ExcuteInternal(CheckTableIsLockRequest request, object state, CheckTableIsLockResponse rslt)
  18. {
  19. var tokendata = BllHelper.GetToken(request.token);
  20. if (tokendata == null)
  21. {
  22. rslt.ErrMsg = "会话已经中断,请重新登录";
  23. return;
  24. }
  25. if(string.IsNullOrEmpty(request.keyword))
  26. {
  27. rslt.ErrMsg = "传入的关键表名为空,请检查!";
  28. return;
  29. }
  30. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  31. using (var cmd = con.CreateCommand())
  32. {
  33. con.Open();
  34. try
  35. {
  36. var lockItem = LockHelper.CheckLockAll(cmd, request.keyword, request.billid,tokendata.username);
  37. if (lockItem.Code == LockCheckResultCode.LockedByOther) throw new LJCommonException(lockItem.log_msg);
  38. if(lockItem.Code == LockCheckResultCode.Success || lockItem.Code == LockCheckResultCode.Expired)
  39. {
  40. LockHelper.LockBill(cmd,request.keyword,request.billid,request.billcode,tokendata.username);
  41. }
  42. }catch(Exception ex)
  43. {
  44. rslt.ErrMsg = ex.Message;
  45. }
  46. }
  47. }
  48. }
  49. }