using System; using System.Data.SqlClient; using System.Linq; using System.Threading; using JLHHJSvr.BLL; using JLHHJSvr.Com; using JLHHJSvr.Com.Model; using JLHHJSvr.Helper; using JLHHJSvr.LJException; using LJLib.DAL.SQL; using LJLib.Net.SPI.Server; using LJLib.SQLEX; namespace JLHHJSvr.Excutor { internal sealed class CheckTableIsLockExcutor : ExcutorBase { protected override void ExcuteInternal(CheckTableIsLockRequest request, object state, CheckTableIsLockResponse rslt) { var tokendata = BllHelper.GetToken(request.token); if (tokendata == null) { rslt.ErrMsg = "会话已经中断,请重新登录"; return; } if(string.IsNullOrEmpty(request.keyword)) { rslt.ErrMsg = "传入的关键表名为空,请检查!"; return; } using (var con = GlobalVar.ConnectionString.NewSqlConnection()) using (var cmd = con.CreateCommand()) { con.Open(); try { var lockItem = LockHelper.CheckLockAll(cmd, request.keyword, request.billid,tokendata.username); if (lockItem.Code == LockCheckResultCode.LockedByOther) throw new LJCommonException(lockItem.log_msg); if(lockItem.Code == LockCheckResultCode.Success || lockItem.Code == LockCheckResultCode.Expired) { LockHelper.LockBill(cmd,request.keyword,request.billid,request.billcode,tokendata.username); } }catch(Exception ex) { rslt.ErrMsg = ex.Message; } } } } }