|
@@ -12,11 +12,33 @@ using System.Threading.Tasks;
|
|
|
using System.ComponentModel;
|
|
|
using NPOI.SS.Formula;
|
|
|
using System.Web.Configuration;
|
|
|
+using LJLib.Net.SPI.Com;
|
|
|
+using LJLib.SQLEX;
|
|
|
+using JLHHJSvr.Com;
|
|
|
|
|
|
namespace JLHHJSvr.Helper
|
|
|
{
|
|
|
internal class LockHelper : HelperBase
|
|
|
{
|
|
|
+ public static bool PreCheckBillLock<T>(ILJLockRequest<T> request, out string arg_msg)
|
|
|
+ where T : LJResponse, new()
|
|
|
+ {
|
|
|
+ arg_msg = string.Empty;
|
|
|
+ var tokendata = BllHelper.GetToken(request.token);
|
|
|
+
|
|
|
+ if (request.billid <= 0)
|
|
|
+ {
|
|
|
+ arg_msg = $"单据ID参数不合法({request.billid})";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ using (var con = GlobalVar.ConnectionString.NewSqlConnection())
|
|
|
+ using (var cmd = con.CreateCommand())
|
|
|
+ {
|
|
|
+ con.Open();
|
|
|
+ return CheckIsLock(cmd, request.keyword, request.billid, tokendata.username, out arg_msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 加锁单据
|
|
|
/// </summary>
|
|
@@ -24,7 +46,7 @@ namespace JLHHJSvr.Helper
|
|
|
/// <param name="billid"></param>
|
|
|
public static void LockBill(SqlCommand cmd, string keyword, int billid, string billcode,string opemp, int lockMinutes = 30)
|
|
|
{
|
|
|
- return;
|
|
|
+ //return;
|
|
|
try
|
|
|
{
|
|
|
cmd.CommandText = "sp_lock_record";
|
|
@@ -60,7 +82,7 @@ namespace JLHHJSvr.Helper
|
|
|
/// <param name="billid"></param>
|
|
|
public static void UnLockBill(SqlCommand cmd, string keyword, int billid, string opemp, byte is_admin)
|
|
|
{
|
|
|
- return;
|
|
|
+ //return;
|
|
|
try
|
|
|
{
|
|
|
cmd.CommandText = "sp_unlock_record";
|
|
@@ -116,14 +138,14 @@ namespace JLHHJSvr.Helper
|
|
|
public static bool CheckIsLock(SqlCommand cmd, string keyword, int billid, string opemp,out string arg_msg)
|
|
|
{
|
|
|
arg_msg = string.Empty;
|
|
|
- return false;
|
|
|
+ //return false;
|
|
|
var item = CheckLockAll(cmd, keyword, billid, opemp);
|
|
|
if (item.Code == LockCheckResultCode.LockedByOther)
|
|
|
{
|
|
|
arg_msg = item.log_msg;
|
|
|
return true;
|
|
|
}
|
|
|
- return !(item.Code == LockCheckResultCode.Success || item.Code == LockCheckResultCode.LockedBySelf);
|
|
|
+ return !(item.Code == LockCheckResultCode.Success || item.Code == LockCheckResultCode.LockedBySelf || item.Code == LockCheckResultCode.Expired);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// DFS方式检查单据及依赖链上的锁
|
|
@@ -144,7 +166,11 @@ namespace JLHHJSvr.Helper
|
|
|
new Dictionary<string, object> { { "@keyword", keyword }, { "@billid", billid } },
|
|
|
mainLock, "keyword,billid,billcode,opemp,is_locked,lock_time,expire_time");
|
|
|
|
|
|
- if (mainLock.expire_time < DateTime.Now) mainLock.Code = LockCheckResultCode.Expired;
|
|
|
+ if (mainLock.expire_time < DateTime.Now)
|
|
|
+ {
|
|
|
+ mainLock.Code = LockCheckResultCode.Expired;
|
|
|
+ return mainLock;
|
|
|
+ }
|
|
|
if (mainLock.is_locked == 1)
|
|
|
{
|
|
|
mainLock.Code = mainLock.opemp.Equals(opemp) ? LockCheckResultCode.LockedBySelf : LockCheckResultCode.LockedByOther;
|