/// <summary>
        /// 连接信息构建
        /// </summary>
        /// <param name="dbContextOption"></param>
        /// <param name="dbcs"></param>
        /// <returns></returns>
        public static IEnumerable <DbContextOption> DbContextOption(this DbContextOption dbContextOption, IDictionary <string, DbContextOption> dbcs)
        {
            if (dbcs.Count > 0)
            {
                using (var connContext = new ProtocolDbContext(dbContextOption))
                {
                    var        conn    = connContext.Set <ProtocolInfo>().Where(p => p.ProtocalType == ProtocalType.DB && dbcs.Keys.Contains(p.ContainerName)).ToList();
                    List <int> cfgIds  = conn.Select(p => p.CfgID).ToList();
                    var        details = connContext.Set <ProtocolCfgInfo>().Where(p => cfgIds.Contains(p.CfgID)).ToList();
                    if (conn != null && conn.Count > 0)
                    {
                        foreach (var item in conn)
                        {
                            if (details != null && details.Count > 0)
                            {
                                var connDetail = details.FirstOrDefault(p => p.CfgID == item.CfgID);
                                if (connDetail != null)
                                {
                                    if (connDetail.ProviderName == DbProviderNames.Oracle && !string.IsNullOrWhiteSpace(connDetail.ServerName))
                                    {
                                        connDetail.Driver = DbProviderNames.Oracle_Managed_ODP;
                                        item.DataBaseName = connDetail.ServerName;
                                    }
                                    var connectStrings = dbContextOption.ConnectionString;
                                    if (connDetail.ProviderName == DbProviderNames.Oracle)
                                    {
                                        connectStrings = BuildOracleClientConnectionString(item.DataBaseName, connDetail.DesUserID, connDetail.DesPassword, item.IsConnPool, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                                    }
                                    else if (connDetail.ProviderName == DbProviderNames.Oracle_Managed_ODP)
                                    {
                                        connectStrings = BuildOracleManagedODPConnectionString(connDetail.Url, connDetail.Port, item.DataBaseName, connDetail.DesUserID, connDetail.DesPassword, item.IsConnPool, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                                    }
                                    else if (connDetail.ProviderName == DbProviderNames.Oracle_ODP)
                                    {
                                        connectStrings = BuildOracleODPConnectionString(connDetail.Url, connDetail.Port, item.DataBaseName, connDetail.DesUserID, connDetail.DesPassword, item.IsConnPool, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                                    }
                                    else if (connDetail.ProviderName == DbProviderNames.SqlServer)
                                    {
                                        connectStrings = BuildSqlServerConnectionString(connDetail.Url, connDetail.DesUserID, connDetail.DesPassword, item.DataBaseName, connDetail.Port);
                                    }
                                    else if (connDetail.ProviderName == DbProviderNames.MySQL)
                                    {
                                        connectStrings = BuildMySqlConnectionString(connDetail.Url, connDetail.DesUserID, connDetail.DesPassword, item.DataBaseName, connDetail.Port, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                                    }
                                    if (dbcs.ContainsKey(item.ContainerName))
                                    {
                                        dbcs[item.ContainerName].ConnectionString = connectStrings;
                                        dbcs[item.ContainerName].Provider         = connDetail.ProviderName;
                                    }
                                    else
                                    {
                                        var key = dbcs.Keys.FirstOrDefault(p => p.StartsWith(item.ContainerName));
                                        if (!string.IsNullOrEmpty(key))
                                        {
                                            dbcs[key].ConnectionString = connectStrings;
                                            dbcs[key].Provider         = connDetail.ProviderName;
                                            dbcs[key].LogggerFactory   = dbContextOption.LogggerFactory;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }


            return(dbcs.Values);
        }
        /// <summary>
        /// 单一连接构建
        /// </summary>
        /// <param name="dbContextOption"></param>
        /// <param name="defaultContainer"></param>
        /// <returns></returns>
        public static DbContextOption SingleDbContextOption(this DbContextOption dbContextOption, string defaultContainer)
        {
            using (var connContext = new ProtocolDbContext(dbContextOption))
            {
                var conn = connContext.Set <ProtocolInfo>().Where(p => p.ProtocalType == ProtocalType.DB && p.ContainerName.Equals(defaultContainer)).ToList();

                if (conn != null && conn.Count > 0)
                {
                    var item       = conn.FirstOrDefault();
                    var connDetail = connContext.Set <ProtocolCfgInfo>().Get(item.CfgID);
                    if (connDetail != null)
                    {
                        if (connDetail.ProviderName == DbProviderNames.Oracle && !string.IsNullOrWhiteSpace(connDetail.ServerName))
                        {
                            connDetail.Driver = DbProviderNames.Oracle_Managed_ODP;
                            item.DataBaseName = connDetail.ServerName;
                        }
                        var connectStrings = dbContextOption.ConnectionString;
                        if (connDetail.ProviderName == DbProviderNames.Oracle)
                        {
                            connectStrings = BuildOracleClientConnectionString(item.DataBaseName, connDetail.DesUserID, connDetail.DesPassword, item.IsConnPool, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                        }
                        else if (connDetail.ProviderName == DbProviderNames.Oracle_Managed_ODP)
                        {
                            connectStrings = BuildOracleManagedODPConnectionString(connDetail.Url, connDetail.Port, item.DataBaseName, connDetail.DesUserID, connDetail.DesPassword, item.IsConnPool, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                        }
                        else if (connDetail.ProviderName == DbProviderNames.Oracle_ODP)
                        {
                            connectStrings = BuildOracleODPConnectionString(connDetail.Url, connDetail.Port, item.DataBaseName, connDetail.DesUserID, connDetail.DesPassword, item.IsConnPool, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                        }
                        else if (connDetail.ProviderName == DbProviderNames.SqlServer)
                        {
                            connectStrings = BuildSqlServerConnectionString(connDetail.Url, connDetail.DesUserID, connDetail.DesPassword, item.DataBaseName, connDetail.Port);
                        }
                        else if (connDetail.ProviderName == DbProviderNames.MySQL)
                        {
                            connectStrings = BuildMySqlConnectionString(connDetail.Url, connDetail.DesUserID, connDetail.DesPassword, item.DataBaseName, connDetail.Port, connDetail.CONNET_POOL_MAXACTIVE, connDetail.CONNET_POOL_MAXIDLE);
                        }
                        return(new DbContextOption()
                        {
                            Container = "upms",
                            Provider = connectStrings,
                            ConnectionString = connDetail.ProviderName,
                            ModuleAssemblyName = dbContextOption.ModuleAssemblyName,
                            MappingFile = dbContextOption.MappingFile,
                            LogggerFactory = dbContextOption.LogggerFactory
                        });
                    }
                }

                return(new DbContextOption()
                {
                    Container = defaultContainer,
                    Provider = dbContextOption.Provider,
                    ConnectionString = dbContextOption.ConnectionString,
                    ModuleAssemblyName = dbContextOption.ModuleAssemblyName,
                    MappingFile = dbContextOption.MappingFile,
                    LogggerFactory = dbContextOption.LogggerFactory
                });
            }
        }