WarehouseUpLoad.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using cuidian.Sql;
  2. using System.Text;
  3. using WdtUtils;
  4. using WdtUtils.Load;
  5. using WdtUtils.Proxy;
  6. namespace WangToTempDb
  7. {
  8. /// <summary>
  9. /// 旺店通仓库上传中间库
  10. /// </summary>
  11. public class WarehouseUpLoad : BaseUpLoad
  12. {
  13. private string __sql = "if not exists (select 1 from Warehouse where cWhCode ='{0}') insert into Warehouse(cWhCode,cWhName) values('{0}','{1}')";
  14. protected override void _ImportData()
  15. {
  16. _operType = "插入仓库中间表数据";
  17. Warehouse[] entitys = ((WarehouseProxy)_proxy).warehouses;
  18. StringBuilder sb = new StringBuilder();
  19. foreach (Warehouse item in entitys)
  20. {
  21. //item.warehouse_no = (item.warehouse_no.Length > 10) ? item.warehouse_no.Substring(0, 10) : item.warehouse_no;
  22. //string code = item.warehouse_no;
  23. sb.AppendLine(string.Format(__sql, _ConvertStr(item.warehouse_no), _ConvertStr(item.name)));
  24. _InsertIntoTempDb(sb.ToString(), item.warehouse_no);
  25. }
  26. }
  27. protected override void _DeleteDup()
  28. {
  29. _operType = "删除仓库中间表重复数据";
  30. string sql = "delete a from {0}..Warehouse a,{1}..Warehouse b where a.cWhCode = b.cWhCode";
  31. DbUtils.ExecuteNonQuery(string.Format(sql,_tempDb.Database, _targetDb.Database), _tempDb);
  32. }
  33. protected override void _LoadNextPage()
  34. {
  35. _proxy = _load.Load<WarehouseProxy>(_args);
  36. }
  37. protected override void _SetLoader()
  38. {
  39. _load = new WarehouseLoad();
  40. }
  41. protected override Result _LoadFirstPage()
  42. {
  43. WarehouseProxy tmp = new WarehouseProxy();
  44. Result rtn = _load.Load<WarehouseProxy>(_args,ref tmp);
  45. _proxy = tmp;
  46. return rtn;
  47. }
  48. }
  49. }