/// <summary> /// 保存到目标数据库 /// </summary> /// <param name="tableMap"></param> /// <param name="dtSource"></param> private void SaveToTargetDB(TableMap tableMap, DataTable dtSource) { // 目标为数据表的情况 string curProcess = ""; DataAccessBroker broker = DataAccessFactory.Instance(this.TargetDataAccessCfg); try { // 事务开始 curProcess = "事务开始"; broker.BeginTransaction(); DatabaseCommand.SaveToTargetDB(broker, tableMap, dtSource); // 事务提交 curProcess = "事务提交"; broker.Commit(); } catch (Exception ex) { // 事务回滚 broker.RollBack(); throw ex; } finally { broker.Close(); } // 写日志 LogManager.Current.WriteCommonLog(this.JobCode, "成功将数据保存到目标表" + tableMap.TargetTable.TableName, this.ThreadName); }
/// <summary> /// 得到来源数据 /// </summary> /// <param name="tableMap"></param> /// <returns></returns> public DataTable GetSourceData(Hashtable parameters, TableMap tableMap) { DataTable dt = null; if (this.SourceConnEntity.Type == DDPConst.Conn_TYPE_ORACLE || this.SourceConnEntity.Type == DDPConst.Conn_TYPE_SQLSERVER) { dt = this.GetSourceDataFromDB(parameters, tableMap); } else { dt = DatabaseCommand.GetSourceDataFromFile(parameters, tableMap, false, "", 0); } return(dt); }
/// <summary> /// 根据xml配置创建命令 /// </summary> /// <param name="node"></param> /// <returns></returns> public static ICommand CreateCommand(string appDir, XmlNode node) { ICommand command = null; if (node.Name == "Database") { command = new DatabaseCommand(); } else if (node.Name == "DatabaseHeaderDetail") { command = new DBHeaderDetailCommand(); } else if (node.Name == "DBtoFile") { command = new DBtoFileCommand(); } else if (node.Name == "Zip") { command = new ZipCommand(); } else if (node.Name == "File") { command = new FileCommand(); } //else if (node.Name == "LIPS_UpdateItemFlagCmd") // command = new LIPS_UpdateItemFlagCmd(); //else if (node.Name == "LIPS_UpdateOrderFlagCmd") // command = new LIPS_UpdateOrderFlagCmd(); //else if (node.Name == "LIPS_UpdateASNFlagCmd") // command = new LIPS_UpdateASNFlagCmd(); else { string dllName = XmlUtil.GetAttrValue(node, "DLL"); if (dllName != "") { dllName = appDir + "\\" + dllName; } string className = XmlUtil.GetAttrValue(node, "Class"); if (dllName != "" && className != "") { command = CreateCommandInstance(dllName, className); } } return(command); }