123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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
- {
- /// <summary>
- /// 从中间库下载到U8数据库的基类
- /// </summary>
- public abstract class BaseDownLoad : IDownLoad
- {
- /// <summary>
- /// 中间库源数据
- /// </summary>
- protected DataSet _sourceData;
- /// <summary>
- /// 主表名称
- /// </summary>
- protected string _mainTable;
- protected SqlConnection _tragetCon;
- protected string _operType;
- public void DownLoad()
- {
- _DownLoad();
- }
- /// <summary>
- /// 初始化源数据
- /// </summary>
- 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)
- { }
- /// <summary>
- /// 检查数据是否存在
- /// </summary>
- /// <param name="sql"></param>
- /// <returns></returns>
- 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;
- }
- }
- }
|