public void AddDataCenter(string dBType, string connString) { DBInstanceType dbInstanceType = (DBInstanceType)Enum.Parse(typeof(DBInstanceType), dBType, true); ADBInstance dbInstance = DBInstanceFactory.GetDBInstance(dbInstanceType, connString); this._DataCenter = new DataCenter(dbInstance); this._DBInstance = dbInstance; }
public static DBInstanceBase GetDBInstance() { if (_Instance == null) { string strDBType = System.Configuration.ConfigurationManager.ConnectionStrings["DBType"].ConnectionString; DBInstanceType dbType = (DBInstanceType)Enum.Parse(typeof(DBInstanceType), strDBType, true); _Instance = GetDBInstance(dbType); } return(_Instance); }
public static DBInstanceBase GetDBInstance(DBInstanceType DBType) { switch (DBType) { case DBInstanceType.SqlServer: return(null); case DBInstanceType.Oracle: return(new DBInstanceOracle()); case DBInstanceType.OleDb: return(null); default: return(null); } }
public static ADBInstance GetDBInstance(DBInstanceType DBType, string connString) { if (connString.Length == 0) { return(null); } switch (DBType) { case DBInstanceType.SqlServer: return(null); case DBInstanceType.Oracle: return(new DBInstanceOracle(connString)); case DBInstanceType.OleDb: return(null); default: return(null); } }
public void BuildWorkerByDBConfig() { //============================== //搜索现有的数据源 //============================== string sql = "select * from datacentersrc where active = 1"; DataSet dsDataSrc = this._DBInstance.ExecuteSQL(sql); if (dsDataSrc == null || dsDataSrc.Tables.Count == 0 || dsDataSrc.Tables[0].Rows.Count == 0) { return; } foreach (DataRow oRow in dsDataSrc.Tables[0].Rows) { string dbType = oRow[LibConsts.C_Col_DBType].ToString(); string dbConn = oRow[LibConsts.C_Col_DBConnection].ToString(); string vandor = oRow[LibConsts.C_Col_DataVandor].ToString(); DBInstanceType dbInstanceType = (DBInstanceType)Enum.Parse(typeof(DBInstanceType), dbType, true); ADBInstance inst = DBInstanceFactory.GetDBInstance(dbInstanceType, dbConn); VandorType vandorType = (VandorType)Enum.Parse(typeof(VandorType), vandor, true); ADataLoader loader = DataLoaderFactory.GetDataLoader(inst, vandorType); _DataLoaderList.Add(loader); } //============================== //搜索现有的数据表 //============================== sql = @"Select A.Tablename, B.Vandor as Mainsrc, C.Vandor as Subsrc, D.Vandor as Chksrc, A.SaveDB From datacenterconfig A Left join datacentersrc B ON A.Mainsrc = B.Src Left join datacentersrc C ON A.Subsrc = C.Src Left join datacentersrc D ON A.Chksrc = D.Src "; if (OnTestMode) { sql += "Where A.ActiveTest = 1"; } else { sql += "Where A.Active = 1"; } DataSet dsDataTables = this._DBInstance.ExecuteSQL(sql); if (dsDataTables == null || dsDataTables.Tables.Count == 0 || dsDataTables.Tables[0].Rows.Count == 0) { return; } foreach (DataRow oRow in dsDataTables.Tables[0].Rows) { DataLoaderManager w = new DataLoaderManager(); w.TableName = oRow[LibConsts.C_Col_TableName].ToString(); //Main string strVandor = oRow[LibConsts.C_Col_MainSource].ToString(); VandorType vandorType = (VandorType)Enum.Parse(typeof(VandorType), strVandor, true); w.MainSource = _DataLoaderList.Find(delegate(ADataLoader l) { return(l.CurrentVandor == vandorType); }); //Sub strVandor = (oRow[LibConsts.C_Col_SubSource] == DBNull.Value) ? "" : oRow[LibConsts.C_Col_SubSource].ToString(); if (strVandor.Length > 0) { vandorType = (VandorType)Enum.Parse(typeof(VandorType), strVandor, true); w.SubSource = _DataLoaderList.Find(delegate(ADataLoader l) { return(l.CurrentVandor == vandorType); }); } //Check strVandor = (oRow[LibConsts.C_Col_CheckSource] == DBNull.Value) ? "" : oRow[LibConsts.C_Col_CheckSource].ToString(); if (strVandor.Length > 0) { vandorType = (VandorType)Enum.Parse(typeof(VandorType), strVandor, true); w.CheckSource = _DataLoaderList.Find(delegate(ADataLoader l) { return(l.CurrentVandor == vandorType); }); } //Save if (oRow[LibConsts.C_Col_SaveDB] == DBNull.Value) { w.SaveToDB = false; } else { if (oRow[LibConsts.C_Col_SaveDB].ToString() == "1") { w.SaveToDB = true; } else { w.SaveToDB = false; } } this.DataLoaderManagerList.Add(w); } }