using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data; using cuidian.Sql; using System.Data.SqlClient; namespace TempDbToUfida.Sql { /// /// 从中间库下载到U8数据库的基类 /// public abstract class BaseDownLoad : IDownLoad { /// /// 中间库源数据 /// protected DataSet _sourceData; /// /// 主表名称 /// protected string _mainTable; protected SqlConnection _tragetCon; protected string _operType; public void DownLoad() { _DownLoad(); } /// /// 初始化源数据 /// protected virtual void _InitSourceData() { } public BaseDownLoad() { _Init(); _InitSourceData(); } protected virtual void _DownLoad() { DataTable dt = _sourceData.Tables[_mainTable]; foreach (DataRow item in dt.Rows) { _Process(item); } } protected virtual void _Init() { _tragetCon = ConnectionUtils.Instance.GetConnection(); } protected virtual void _Process(DataRow dr) { } /// /// 检查数据是否存在 /// /// /// protected bool _CheckDup(string sql) { int i = Convert.ToInt16(DbUtils.ExecuteScalar(sql, _tragetCon)); return i > 0; } protected virtual void _updateTempDb(DataRow dr) { } protected virtual string _buildUpdSql(DataRow dr) { return string.Empty; } } }