IcsFromERPJob
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.1 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. using ICSSoft.FromERP.Model;
  2. using Newtonsoft.Json;
  3. using Quartz;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace ICSSoft.FromERP
  11. {
  12. /// <summary>
  13. /// 数采上传(金杨)
  14. /// </summary>
  15. public class SyncCas_Jinyang : IJob
  16. {
  17. private static object key = new object();
  18. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  19. public void Execute(IJobExecutionContext context)
  20. {
  21. try
  22. {
  23. lock (key)
  24. {
  25. log.Info("开始……………………………………………………………………");
  26. Execute();
  27. log.Info("结束……………………………………………………………………");
  28. }
  29. }
  30. catch (Exception ex)
  31. {
  32. log.Error(ex.ToString());
  33. }
  34. }
  35. public void Execute()
  36. {
  37. try
  38. {
  39. string conStr = ICSHelper.GetConnectString();
  40. string Namespace = this.GetType().Namespace;
  41. //string Class = this.GetType().Name;
  42. DataTable dt = ICSHelper.GetERPDB(conStr);
  43. foreach (DataRow dr in dt.Rows)
  44. {
  45. //var dtNowBegin = new DateTime(2000, 1, 1, 0, 0, 0);//默认开始时间
  46. //var dtNow = DateTime.Now;
  47. //string erpName = ICSHelper.GetConfigString()["ERPDB"];
  48. //string TenantId = dr["TenantId"].ToString();//mes 组织
  49. //string TenantCode = dr["TenantCode"].ToString();
  50. //string ErpId = dr["ErpID"].ToString(); //erpID
  51. //string Class = this.GetType().Name + TenantCode;
  52. //erpName = string.Format(erpName, TenantId);
  53. //string sql0 = " SELECT top 1 ModifyDate FROM ICSERPTime where ClassName='" + Class + "'";
  54. //var lastDate = ICSHelper.ExecuteScalar(conStr, sql0).ToDateOrNull();
  55. //if (!lastDate.HasValue)
  56. //{
  57. // lastDate = dtNowBegin;
  58. //}
  59. //string sql = @" select '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' as MTIME into #TempVendor ";
  60. //sql = ICSHelper.Time(Namespace, Class, TenantId, sql, "#TempVendor");
  61. //sql += "DROP TABLE #TempVendor";
  62. //ICSHelper.ExecuteDate(conStr, sql);
  63. List<CapInputDto> list = new List<CapInputDto>();
  64. var input = new CapInputDto();
  65. input.WorkshopID = "1";
  66. input.EquipmentID = "1";
  67. input.ProductNo = "1";
  68. input.LotNo = "1";
  69. input.CollectionTime = "1";
  70. input.ParamValue_Resistance = 12;
  71. input.ParamValue_Height = 12;
  72. input.Msg = "";
  73. list.Add(input);
  74. var inputObj = JsonConvert.SerializeObject(list);
  75. //string url = ICSHelper.GetConfigString()["JinyangCapUrl"]+ @"?deipaaskeyauth=a5P1RTL4380zd9jpb57qXx63rdynUHN2";
  76. string url = ICSHelper.GetConfigString()["JinyangCapUrl"];
  77. var result = HttpHelper.HttpClientPost<ResponseInfoDto>(url, inputObj, new Dictionary<string, string>() { { "deipaaskeyauth", "a5P1RTL4380zd9jpb57qXx63rdynUHN2" } }).Result;
  78. // var result = HttpHelper.HttpClientPost<ResponseInfoDto>(url, inputObj).Result;
  79. if (result.Result == "OK")
  80. {
  81. }
  82. else
  83. {
  84. throw new Exception(result.Result);
  85. }
  86. }
  87. }
  88. catch (Exception ex)
  89. {
  90. log.Error(ex.ToString());
  91. }
  92. }
  93. }
  94. }