2、审批角色 添加 是否总部【ISHEAD】属性 ,总部会同步到子公司,子公司不能修改总部传入的数据 3、审批明细 添加【ISHEAD】属性 ,功能暂未处理 4、首页获取待办修改 使不过滤ORGID 5、用户添加时,如果是总公司 同步到子公司,同步修改了一些bug 6、审批页面数据获取方法【FullGet】提供修改前提 后续功能待完善 7、HeadHelper.GetIsHead 判断是否总部 ["Tenant"]"0003"
103 lines
4.1 KiB
C#
103 lines
4.1 KiB
C#
using APT.BaseData.Domain.ApiModel.Platform;
|
|
using APT.BaseData.Domain.Entities.FM;
|
|
using APT.BaseData.Domain.Entities.OP;
|
|
using APT.BaseData.Domain.Enums.OP;
|
|
using APT.BaseData.Domain.IServices.OP;
|
|
using APT.Infrastructure.Api;
|
|
using APT.Infrastructure.Api.Redis;
|
|
using APT.Infrastructure.Core;
|
|
using APT.Migrations;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Net;
|
|
|
|
namespace APT.BaseData.Services.Services.OP
|
|
{
|
|
public class OPTenantDBConnService : CommonService, IOPTenantDBConnService
|
|
{
|
|
public OPTenantDBConnService(IRepository repository) : base(repository)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取 除 ORG_IDBeside 之外对应的数据库链接字典 ORG_ID DB_CONN
|
|
/// </summary>
|
|
/// <param name="ORG_IDBeside">过滤值 没有就不过滤</param>
|
|
/// <returns></returns>
|
|
public Dictionary<Guid, string> GetConnDictionary(Guid? ORG_IDBeside)
|
|
{
|
|
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)
|
|
{
|
|
if (ORG_IDBeside.HasValue)
|
|
{
|
|
Dictionary<Guid, string> dicORGCONN1 = new Dictionary<Guid, string>();
|
|
foreach (var item in dicORGCONN)
|
|
{
|
|
if (item.Key == ORG_IDBeside.Value)
|
|
continue;
|
|
|
|
dicORGCONN1.Add(item.Key, item.Value);
|
|
}
|
|
dicORGCONN = dicORGCONN1;
|
|
}
|
|
}
|
|
return dicORGCONN;
|
|
}
|
|
}
|
|
}
|