DownLoadWarehouse.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using cuidian.OpenApi.Api;
  8. using cuidian.OpenApi.Utils;
  9. using cuidian.OpenApi.Model;
  10. using cuidian.Common;
  11. using cuidian.Sql;
  12. namespace TempDbToUfida.OpenApi
  13. {
  14. /// <summary>
  15. /// 从中间库将仓库资料下载到U8数据库
  16. /// </summary>
  17. public class DownLoadWarehouse : BaseDataDownLoad
  18. {
  19. protected override void _Init()
  20. {
  21. _loadSql = "select * from warehouse where processflag=0";
  22. base._Init();
  23. }
  24. protected override BusinessObject _ImportData(DataRow row)
  25. {
  26. WarehouseApi api = new WarehouseApi();
  27. WarehouseRoot wr = new WarehouseRoot();
  28. Warehouse w = new Warehouse();
  29. w.code = row["cwhcode"].ToString();
  30. w.name = row["cwhname"].ToString();
  31. wr.warehouse = w;
  32. BusinessObject result = api.Add(JsonUtils.GetJsonString(wr));
  33. return result;
  34. }
  35. protected override void _LogError(int id, string msg)
  36. {
  37. OperationLog.Utils.WriteErrorLog("向U8导入仓库资料", "sysid = " + id.ToString() + " " + msg);
  38. }
  39. protected override void _LogSucess(int id, string newCode)
  40. {
  41. string sql = "update Warehouse set processflag = 1,processdate = getdate() where sysid = {0} ";
  42. sql += string.Format(@" update {0}..Warehouse set cWhValueStyle='{1}',bMRP='1',bROP='1',bControlSerial='1',bInCost='1',bInAvailCalcu='1',bCheckSubitemCost='1' where cwhCode='{2}' ", ConnectionUtils.Instance.GetConnection().Database,"移动平均法",newCode);
  43. OperationLog.Utils.UpdateTempRecord(string.Format(sql,id));
  44. }
  45. }
  46. }