123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- 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 LockTableExcutor : ExcutorBase<LockTableRequest, LockTableResponse>
- {
- protected override void ExcuteInternal(LockTableRequest request, object state, LockTableResponse rslt)
- {
- var tokendata = BllHelper.GetToken(request.token);
- if (tokendata == null)
- {
- rslt.ErrMsg = "会话已经中断,请重新登录";
- return;
- }
- using (var con = GlobalVar.ConnectionString.NewSqlConnection())
- using (var cmd = con.CreateCommand())
- {
- con.Open();
- foreach(var bill in request.lockList)
- {
- if (string.IsNullOrEmpty(bill.keyword)) throw new LJCommonException("加锁单据关键字错误,请检查!");
- }
- using (cmd.Transaction = con.BeginTransaction())
- {
- try
- {
- foreach(var bill in request.lockList)
- {
- LockHelper.LockBill(cmd, bill.keyword, bill.billid, bill.billcode,tokendata.username);
- }
- cmd.Transaction.Commit();
- }
- catch (Exception e)
- {
- cmd.Transaction?.Rollback();
- rslt.ErrMsg = e.Message;
- }
- }
- }
- }
- }
- }
|