Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbs"></param>
 /// <param name="provider"></param>
 /// <param name="currentConnectionString"></param>
 public DbsSetting(Dbs dbs, DbsProvider provider, string currentConnectionString)
 {
     this.Dbs = dbs;
     this.CurrentConnectionString = currentConnectionString;
     this.Provider = provider;
     this.HistoryConnectionString = string.Empty;
     this.IsEmpty = false;
 }
Пример #2
0
        private void LoadDbs(XElement doc)
        {
            byte        code;
            DbsProvider provider;
            XElement    currentElement;
            XElement    historyElement;
            string      currentConnectionString;
            string      historyConnectionString;
            bool        currentConnectionStringIsCryptograph;
            bool        historyConnectionStringIsCryptograph;

            foreach (XElement e in doc.GetChildElements(ConnectionKey))
            {
                if (Dbs.IsQualifiedName(e.Name.ToString()))
                {
                    Dbs dbs = Dbs.Create(e.Name.ToString());
                    if (byte.TryParse(GetElementValue(e, PrivoderKey), out code))
                    {
                        DbsProvider.TryGetProvider(code, out provider);
                    }
                    else
                    {
                        provider = DbsProvider.MsSql;
                    }

                    currentConnectionString = GetElementValue(e, CurrentKey);
                    currentElement          = e.GetElement(CurrentKey);
                    if (currentElement != null)
                    {
                        currentConnectionStringIsCryptograph = currentElement.GetAttributeValue <bool>(IsCryptographKey, false);
                        if (currentConnectionStringIsCryptograph)
                        {
                            currentConnectionString = Decrypt(currentConnectionString);
                        }
                    }
                    historyConnectionString = GetElementValue(e, HistoryKey);
                    historyElement          = e.GetElement(HistoryKey);
                    if (historyElement != null)
                    {
                        historyConnectionStringIsCryptograph = historyElement.GetAttributeValue <bool>(IsCryptographKey, false);
                        if (historyConnectionStringIsCryptograph)
                        {
                            historyConnectionString = Decrypt(historyConnectionString);
                        }
                    }

                    DbsSetting setting = new DbsSetting(dbs, DbsProvider.MsSql, currentConnectionString)
                    {
                        Provider = provider,
                        HistoryConnectionString  = historyConnectionString,
                        MetadataAssemblyFullName = GetElementValue(e, MetadataAssemblyKey)
                    };
                    Add(setting);
                }
            }
        }
Пример #3
0
        private void LoadFromCofiguration(Dbs dbs)
        {
            ConnectionStringSettings css = WebConfigurationManager.ConnectionStrings[dbs.QualifiedName]
                                           ?? ConfigurationManager.ConnectionStrings[dbs.QualifiedName];

            if (css != null)
            {
                DbsProvider provider = DbsProvider.Providers.FirstOrDefault(a => string.Equals(a.Provider, css.ProviderName, StringComparison.CurrentCultureIgnoreCase) && a.Validate(css.ConnectionString));

                DbsSetting setting = new DbsSetting(dbs, provider, css.ConnectionString)
                {
                    Provider = provider
                };
                Add(setting);
            }
        }
Пример #4
0
 /// <summary>
 /// 获取与指定代码相同的<see cref="DbsProvider"/>实例。
 /// </summary>
 /// <param name="code"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static bool TryGetProvider(byte code, out DbsProvider provider)
 {
     return(_providers.TryGetValue(code, out provider));
 }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbs"></param>
 /// <param name="provider"></param>
 public DbsSetting(Dbs dbs, DbsProvider provider)
     : this(dbs, provider, string.Empty)
 {
 }