コード例 #1
0
ファイル: TaskHandler.cs プロジェクト: windygu/AMS
        void ImportToDB()
        {
            if (!entities.EntityList.Any())
            {
                return;
            }
            OracleConPara para = new OracleConPara()
            {
                HostName    = Task.To.HostName,
                Password    = Task.To.Password,
                Port        = Task.To.Port,
                ServiceName = Task.To.ServiceName,
                UserID      = Task.To.UserID
            };
            var           obj    = entities.EntityList.First();
            var           dict   = (IDictionary <string, object>)obj;
            List <string> cols   = Task.From.Columns.Any(a => a == "*") ? ((IDictionary <string, object>)entities.EntityList.First()).Keys.ToList() : Task.From.Columns;
            string        sql    = string.Format("insert into {0} ({1})", Task.To.Table, string.Join(",", cols));
            List <string> values = new List <string>();

            foreach (IDictionary <string, object> item in entities.EntityList)
            {
                List <string> list = new List <string>();
                foreach (string c in cols)
                {
                    list.Add(FixSqlValue(item[c]));
                }
                values.Add(string.Join(",", list));
            }
            sql = string.Format("{0} values ({1})", sql, string.Join("),(", values));
            List <string> sqls = new List <string>();

            if (string.IsNullOrEmpty(Task.From.Sequence))
            {
                sqls.Add(string.Format("delete from {0}", Task.To.Table));
            }
            else if (fixSeqValue.Trim('\'') != "")
            {
                sqls.Add(string.Format("delete from {0} where {1} > {2}", Task.To.Table, Task.From.Sequence, fixSeqValue));
            }
            sqls.Add(sql);
            if (Task.To.DBType.ToLower() == "db2")
            {
                DB2Util db2 = new DB2Util(para);
                db2.UpdateBatchCommand(sqls);
            }
            else if (Task.To.DBType.ToLower() == "oracle")
            {
                OracleUtil oracle = new OracleUtil(para);
                oracle.UpdateBatchCommand(sqls);
            }
            else if (Task.To.DBType.ToLower() == "sqlserver")
            {
                MsUtil ms = new MsUtil(para);
                ms.UpdateBatchCommand(sqls);
            }
            WriteSeqValue();
        }
コード例 #2
0
ファイル: TaskHandler.cs プロジェクト: windygu/AMS
        void GetFromDBDatas()
        {
            string sql = string.Format("select {0} from {1}", string.Join(",", Task.From.Columns), Task.From.Table);

            if (!string.IsNullOrEmpty(Task.From.Sequence))
            {
                fixSeqValue = FixSeqValue(Task.From.SeqValue);
                if (fixSeqValue.Trim('\'') != "")
                {
                    sql = string.Format("{0} where {1} > {2}", sql, Task.From.Sequence, fixSeqValue);
                }
                sql = string.Format("{0} order by {1}", sql, Task.From.Sequence);
            }
            //限制每次最多复制500条数据
            // sql = sql + " fetch first 500 rows only";
            OracleConPara para = new OracleConPara()
            {
                HostName    = Task.From.HostName,
                Password    = Task.From.Password,
                Port        = Task.From.Port,
                ServiceName = Task.From.ServiceName,
                UserID      = Task.From.UserID
            };

            if (DbType == "db2")
            {
                DB2DynamicDataCatcher db2 = new DB2DynamicDataCatcher(Task.From.Table, para, sql);
                entities = db2.GetEntities();
            }
            else if (DbType == "oracle")
            {
                OracleDynamicDataCatcher oracle = new OracleDynamicDataCatcher(Task.From.Table, para, sql);
                entities = oracle.GetEntities();
            }
            else if (DbType == "sqlserver")
            {
                MsDynamicDataCatcher ms = new MsDynamicDataCatcher(Task.From.Table, para, sql);
                entities = ms.GetEntities();
            }
        }
コード例 #3
0
ファイル: OracleUtil.cs プロジェクト: windygu/AMSRPT
 public OracleUtil(OracleConPara para)
 {
     connStr = string.Format("User Id={0};Password={1};Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={2})(PORT={3})))(CONNECT_DATA=(SERVICE_NAME={4})))", para.UserID, para.Password, para.HostName, para.Port, para.ServiceName);
 }
コード例 #4
0
 public DB2DynamicDataCatcher(string tableName, List <string> columns, OracleConPara para) : base(tableName, columns, para)
 {
 }
コード例 #5
0
 public DB2DynamicDataCatcher(string tableName, OracleConPara para, string sql) : base(tableName, para, sql)
 {
 }
コード例 #6
0
 public OracleDynamicDataCatcher(string tableName, OracleConPara para, string sql)
 {
     entities = new DBDynamicEntities(tableName, new List <string>());
     Para     = para;
     _sql     = sql;
 }
コード例 #7
0
 public OracleDynamicDataCatcher(string tableName, List <string> columns, OracleConPara para)
 {
     entities = new DBDynamicEntities(tableName, columns);
     Para     = para;
 }
コード例 #8
0
ファイル: OracleDataCatcher.cs プロジェクト: windygu/AMSRPT
 public OracleDataCatcher(string tableName, OracleConPara para, string sql = "")
 {
     entities = new DBEntities <T>(tableName);
     Para     = para;
     _sql     = sql;
 }
コード例 #9
0
 public DB2Util(OracleConPara conn)
 {
     strConn = string.Format("Provider={0};Data Source={1};UID={2};PWD={3};", "IBMDADB2", conn.ServiceName, conn.UserID, conn.Password);
 }