1.修复多账套对接时报工切换账套不生效(严重bug)
2.切换底层逻辑,增加外部增加数据源的接口 3.增加缓存,减少频繁登录导致可能存在的突发数据库连接异常
This commit is contained in:
@@ -19,7 +19,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
private NetLogin _netLogin { get; set; }
|
||||
private VBLogin _vbLogin { get; set; }
|
||||
|
||||
private ProductContext _productContext { get; set; }
|
||||
public ProductContext _productContext { get; set; }
|
||||
|
||||
public Connection Connection { get; set; }
|
||||
|
||||
@@ -83,49 +83,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
|
||||
Trace.WriteLine($"3--登录令牌:{_vbLogin.userToken}");
|
||||
|
||||
|
||||
|
||||
//Trace.WriteLine($"4--正在创建应用池:{_netLogin.userToken}");
|
||||
|
||||
//var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
|
||||
|
||||
//U8LoginInfoPool.Add(_netLogin.userToken, info);
|
||||
|
||||
//Trace.WriteLine($"4--创建应用池:{info.U8LoginToken}");
|
||||
|
||||
//Trace.WriteLine($"4--正在设置线程登录信息:{_netLogin.userToken}");
|
||||
//ThreadContext.SetLoginInfo(_netLogin.userToken);
|
||||
//Trace.WriteLine($"4--设置线程登录信息:{_netLogin.userToken}");
|
||||
Trace.WriteLine($"4--正在创建应用池:{_netLogin.userToken}");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//if (_vbLogin ==null)
|
||||
//{
|
||||
// _vbLogin = new VBLogin();
|
||||
|
||||
// _vbLogin.ClearError();
|
||||
|
||||
// if (!_vbLogin.Login(paramter.pSubId, paramter.pAccId, paramter.pYearId, paramter.pUserId, paramter.pPassword, paramter.pDate, paramter.cSrv, paramter.cSerial) && string.IsNullOrWhiteSpace(_vbLogin.userToken))
|
||||
// {
|
||||
// //_vbLogin.ShutDown();
|
||||
// throw new Exception(_vbLogin.ShareString);
|
||||
// }
|
||||
// Trace.WriteLine($"U8版本:{_vbLogin.GetVersionInfo()}");
|
||||
// Trace.WriteLine($"1--登录令牌:{_netLogin.userToken}");
|
||||
|
||||
// if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
|
||||
// {
|
||||
// Cryptography.m_userToken = "";
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
|
||||
//{
|
||||
// Cryptography.m_userToken = "";
|
||||
//}
|
||||
|
||||
_productContext = _netLogin.Login("AS", _vbLogin.userToken);
|
||||
|
||||
Trace.WriteLine($"3--上下文令牌:{_productContext.calledContext.token}");
|
||||
@@ -133,25 +96,33 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
if (_productContext == null)
|
||||
throw new Exception($"2--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
|
||||
|
||||
ClientUserContext.Instance.RefreshContext();
|
||||
Connection = new Connection();
|
||||
Connection.Open(_vbLogin.UfDbName);
|
||||
}
|
||||
|
||||
public void ShutDown()
|
||||
{
|
||||
U8LoginInfoPool.Clear();
|
||||
|
||||
U8LoginInfoPool.Remove(_netLogin.userToken);
|
||||
|
||||
_vbLogin.ShutDown();
|
||||
|
||||
_netLogin.ShutDown();
|
||||
_netLogin.Dispose();
|
||||
ThreadContext.ServerToken = null;
|
||||
|
||||
_vbLogin?.ShutDown();
|
||||
_productContext=null;
|
||||
_netLogin?.ShutDown();
|
||||
_netLogin?.Dispose();
|
||||
_vbLogin = null;
|
||||
_netLogin = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
|
||||
{
|
||||
Cryptography.m_userToken = "";
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckAccId(string cAccId)
|
||||
{
|
||||
return _vbLogin.get_cAcc_Id() == cAccId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Models;
|
||||
using UFSoft.U8.Framework.BizBase;
|
||||
using UFSoft.U8.Framework.ContextSrv;
|
||||
using UFSoft.U8.Framework.DBConnection;
|
||||
using UFSoft.U8.Framework.LoginContext;
|
||||
using UFSoft.U8.U8M.BFDispatcher;
|
||||
using UFSoft.U8.U8M.Common;
|
||||
using UFSoft.U8.U8M.DOSchema.SF;
|
||||
using ThreadContext = UFSoft.U8.Framework.ContextSrv.ThreadContext;
|
||||
// ReSharper disable IdentifierTypo
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable StringLiteralTypo
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
public class MoRoutingBill
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
private MoRoutingBillDs GetEmptyDs(string cCardNum)
|
||||
{
|
||||
var ds = SFExecutor.BFMoRoutingBill_LoadData("LoadFirst", 0, "", cCardNum, new DefaultContextContainer());
|
||||
|
||||
#region 清除数据集里的数据
|
||||
|
||||
if (ds.Tables.Contains("fc_MoRoutingBilldetail_ExtraDefine"))
|
||||
{
|
||||
ds.Tables["fc_MoRoutingBilldetail_ExtraDefine"].Clear();
|
||||
}
|
||||
if (ds.Tables.Contains("fc_MoRoutingBill_ExtraDefine"))
|
||||
{
|
||||
ds.Tables["fc_MoRoutingBill_ExtraDefine"].Clear();
|
||||
}
|
||||
|
||||
ds.MoRoutingBillRes.Clear();
|
||||
ds.MoRoutingBillDetail.Clear();
|
||||
ds.MoRoutingBill.Clear();
|
||||
|
||||
#endregion
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
private MoRoutingBillDs GetVoucherDs(string cCardNum, AutoDocNoGenerateParam docNoParam, Dictionary<string, object> input)
|
||||
{
|
||||
|
||||
var ds = GetEmptyDs(cCardNum);
|
||||
|
||||
var head = ds.MoRoutingBill.NewMoRoutingBillRow();
|
||||
|
||||
ds.MoRoutingBill.AddMoRoutingBillRow(head);
|
||||
|
||||
var docNo = U8MCommonExecutor.BFVoucher_GetVoucherID(cCardNum, docNoParam.Paramaters, false, new DefaultContextContainer());
|
||||
|
||||
var be = new UFSoft.U8.SF.BE.MoRoutingBill(ds);
|
||||
|
||||
be.cVouchType = cCardNum;
|
||||
be.cVouchCode = "";
|
||||
|
||||
var beHead = new BEHelper(be);
|
||||
|
||||
beHead.SetValue(input);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(be.cVouchCode))
|
||||
{
|
||||
be.cVouchCode = docNo;
|
||||
}
|
||||
|
||||
var bodys = input["body"] as List<Dictionary<string, object>> ?? $"{input["body"]}".ToObject<List<Dictionary<string, object>>>();
|
||||
|
||||
for (var i = 0; i < bodys.Count; i++)
|
||||
{
|
||||
var body = bodys[i];
|
||||
var detail = be.MoRoutingBillDetails[i];
|
||||
|
||||
var beBody = new BEHelper(detail);
|
||||
|
||||
beBody.SetValue(body);
|
||||
}
|
||||
|
||||
|
||||
return (MoRoutingBillDs)be.DataObject;
|
||||
}
|
||||
|
||||
|
||||
public BaseResult<dynamic> Save(string cCardNum, Dictionary<string, object> input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var docNoParam = new AutoDocNoGenerateParam(EnumAutoDocNoType.HandAuto, cCardNum)
|
||||
{
|
||||
IsCurrentDocNoByHand = false
|
||||
};
|
||||
|
||||
var ds = GetVoucherDs(cCardNum, docNoParam, input);
|
||||
|
||||
if (ds == null)
|
||||
{
|
||||
throw new Exception("未能构建数据集");
|
||||
}
|
||||
|
||||
//var context = new DefaultContextContainer();
|
||||
//context.context["taskid"] = taskId;
|
||||
|
||||
var id = SFExecutor.BFMoRoutingBill_MoRoutingBillSave(ds, docNoParam, new DefaultContextContainer());
|
||||
|
||||
return new BaseResult<dynamic>() { bSuccess = true, message = "新增成功", result = id };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic>() { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user