BaseDataDownLoad.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Data;
  7. using cuidian.Sql;
  8. using OperationLog;
  9. namespace TempDbToUfida.Sql
  10. {
  11. /// <summary>
  12. /// 基础资料下载(直接sql插入)
  13. /// </summary>
  14. public abstract class BaseDataDownLoad : BaseDownLoad
  15. {
  16. /// <summary>
  17. /// 插入用友系统
  18. /// </summary>
  19. /// <param name="sql"></param>
  20. /// <returns></returns>
  21. protected virtual bool _InsertData(string sql)
  22. {
  23. bool flag = false;
  24. try
  25. {
  26. DbUtils.ExecuteNonQuery(sql, _tragetCon);
  27. flag = true;
  28. }
  29. catch (Exception ex)
  30. {
  31. Utils.WriteErrorLog(_operType,ex.Message);
  32. }
  33. return flag;
  34. }
  35. /// <summary>
  36. /// 构造检查重复值语句
  37. /// </summary>
  38. /// <param name="dr"></param>
  39. /// <returns></returns>
  40. protected virtual string _buildCheckSql(DataRow dr)
  41. {
  42. return string.Empty;
  43. }
  44. protected override void _Process(DataRow dr)
  45. {
  46. if (_CheckDup(_buildCheckSql(dr))) return;
  47. if (_InsertData(_buildInsertSql(dr)))
  48. {
  49. Utils.UpdateTempRecord(_buildUpdSql(dr));
  50. }
  51. }
  52. protected virtual string _buildInsertSql(DataRow dr)
  53. {
  54. return string.Empty;
  55. }
  56. }
  57. }