Exemple #1
0
        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;
        }
Exemple #2
0
        public static ADataLoader GetDataLoader(ADBInstance dbInstance, VandorType type)
        {
            switch (type)
            {
            case VandorType.DataCenter:
            case VandorType.Wind:
                return(new DataLoaderWind(dbInstance));

            case VandorType.CaiHui:
                return(new DataLoaderCaiHui(dbInstance));

            case VandorType.JuYuan:
                return(new DataLoaderJuYuan(dbInstance));

            default:
                return(null);
            }
        }
Exemple #3
0
 public DataCenter(ADBInstance dbInstance)
 {
     DataLoader  = new DataLoaderWind(dbInstance);
     _DBInstance = dbInstance;
 }
Exemple #4
0
 public DataLoaderJuYuan(ADBInstance dbInstance)
 {
     base._DBInstance        = dbInstance;
     base.CurrentVandor      = VandorType.JuYuan;
     base._MarketDataAdapter = MarketDataAdapterFactory.GetAdapter(VandorType.JuYuan);
 }
Exemple #5
0
 public DataLoaderCaiHui(ADBInstance dbInstance)
 {
     base._DBInstance        = dbInstance;
     base.CurrentVandor      = VandorType.CaiHui;
     base._MarketDataAdapter = MarketDataAdapterFactory.GetAdapter(VandorType.CaiHui);
 }
Exemple #6
0
        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);
            }
        }