获取某用户的conn
FullGet 测试
This commit is contained in:
parent
1c9f67e3dd
commit
7e474a002a
@ -15,5 +15,12 @@ namespace APT.BaseData.Domain.IServices.OP
|
||||
/// <param name="ORG_IDBeside"></param>
|
||||
/// <returns></returns>
|
||||
Dictionary<Guid, string> GetConnDictionary(Guid? ORG_IDBeside);
|
||||
|
||||
/// <summary>
|
||||
/// 获取 ORG_ID的数据库链接
|
||||
/// </summary>
|
||||
/// <param name="ORG_ID">过滤值</param>
|
||||
/// <returns></returns>
|
||||
string GetConnByORGID(Guid ORG_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,5 +98,71 @@ namespace APT.BaseData.Services.Services.OP
|
||||
}
|
||||
return dicORGCONN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 ORG_ID的数据库链接
|
||||
/// </summary>
|
||||
/// <param name="ORG_ID">过滤值</param>
|
||||
/// <returns></returns>
|
||||
public string GetConnByORGID(Guid ORG_ID)
|
||||
{
|
||||
Dictionary<Guid, string> dicORGCONN = new Dictionary<Guid, string>();
|
||||
//从Redis中获取所有数据库链接值
|
||||
|
||||
bool isRedisConfig = true;
|
||||
var redisConfig = APT.Infrastructure.Api.ConfigurationManager.AppSettings["RedisFormConfig"];
|
||||
if (!string.IsNullOrEmpty(redisConfig))
|
||||
isRedisConfig = bool.Parse(redisConfig);
|
||||
if (isRedisConfig)
|
||||
{
|
||||
if (CsRedisManager.KeyExists(RedisCacheKey.ConnAll))
|
||||
dicORGCONN = CsRedisManager.StringGet<Dictionary<Guid, string>>(RedisCacheKey.ConnAll);
|
||||
}
|
||||
#region Redis没找到 去数据库查找
|
||||
|
||||
if (dicORGCONN == null || dicORGCONN.Count < 1)
|
||||
{
|
||||
string conn = string.Empty;
|
||||
IEnumerable<T_OP_TENANT> listTent = null;
|
||||
using (var context = new MigrationContext())
|
||||
{
|
||||
Expression<Func<T_OP_TENANT, bool>> expression = e => e.DB_CONN_ID.HasValue;
|
||||
listTent = context.GetEntities(expression, null, null);
|
||||
List<Guid> listConnID = listTent.Select(e => e.DB_CONN_ID.Value).ToList();
|
||||
var listDbConn = context.GetEntities<T_OP_TENANT_DB_CONN>(e => listConnID.Contains(e.ID), null, null);
|
||||
if (listDbConn != null && listDbConn.Count() > 0)
|
||||
{
|
||||
var env = ConfigurationManager.AppSettings["Env"];
|
||||
foreach (var item in listDbConn)
|
||||
{
|
||||
conn = item.DB_CONN;
|
||||
if (env == ((int)EnvType.外网).ToString())
|
||||
{
|
||||
conn = item.DB_CONN_WAN;
|
||||
}
|
||||
if (!dicORGCONN.ContainsKey(item.ID))
|
||||
{
|
||||
dicORGCONN.Add(listTent.First(e => e.DB_CONN_ID == item.ID).ID, conn);
|
||||
}
|
||||
}
|
||||
if (isRedisConfig && dicORGCONN.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
CsRedisManager.StringSet<Dictionary<Guid, string>>(RedisCacheKey.ConnAll, dicORGCONN);//所有数据库链接 存入 Redis
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (dicORGCONN != null && dicORGCONN.Count > 0 && dicORGCONN.ContainsKey(ORG_ID))
|
||||
{
|
||||
return dicORGCONN[ORG_ID];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
using APT.BaseData.Services.Services.FM;
|
||||
using APT.BaseData.Services.Sys;
|
||||
using APT.MS.Domain.Entities.FO;
|
||||
using APT.BaseData.Domain.IServices.OP;
|
||||
|
||||
[Route("api/PF/PFApprove")]
|
||||
public partial class ApproveController : AuthorizeApiController<T_PF_APPROVE>
|
||||
@ -43,8 +44,9 @@
|
||||
|
||||
IFMDepartmentService DepartmentService { get; set; }
|
||||
IFMUserService UserService { get; set; }
|
||||
IOPTenantDBConnService OPTenantDBConnService { get; set; }
|
||||
|
||||
public ApproveController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IRepository repository, IPFCodeRuleService codeRuleService, IFMDepartmentService departmentService, IFMUserService userService)
|
||||
public ApproveController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IRepository repository, IPFCodeRuleService codeRuleService, IFMDepartmentService departmentService, IFMUserService userService, IOPTenantDBConnService oPTenantDBConnService)
|
||||
{
|
||||
NotificationTaskService = notificationTaskService;
|
||||
SysLogService = sysLogService;
|
||||
@ -52,6 +54,7 @@
|
||||
CodeRuleService = codeRuleService;
|
||||
DepartmentService = departmentService;
|
||||
UserService = userService;
|
||||
OPTenantDBConnService = oPTenantDBConnService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新或新增数据
|
||||
@ -653,8 +656,17 @@
|
||||
//集团人员 通过 首页点击 获取对应的数据库链接 返回结果
|
||||
//这边怎么调用 原生的 GetEntity 方法
|
||||
|
||||
//ICommonService service = _serviceLocator.GetService<ICommonService>();
|
||||
|
||||
string conn = OPTenantDBConnService.GetConnByORGID(new Guid(filter.Parameter1));
|
||||
//var service = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<IFMNotificatoinService>();
|
||||
filter.IgnoreOrgRule = true;
|
||||
//filter.OrgId = null;
|
||||
filter.SpecifyDbConn = conn;
|
||||
filter.SpecifyTenant = "0005";
|
||||
//var ccc = service.GetEntities<T_PF_APPROVE>(e => !e.IS_DELETED, filter, null);
|
||||
|
||||
|
||||
var aaa = GetEntities<T_PF_APPROVE>(e => !e.IS_DELETED, filter, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user