public void Run(JobContext context) { CurrentContext = context; Stopwatch sw = new Stopwatch(); WriteLog("本轮开始..."); sw.Start(); try { AutoClose.Biz.AutoCLosePoBP.DoWork(CurrentContext); //MonitorBP.DoWork(are); } catch (Exception ex) { WriteLog(string.Format("应用程序出现了异常!:{0}", ex.Message)); WriteLog(ex.StackTrace); AutoCloseDA.SendEmail(0, Settings.ExceptionMeil, "PO关闭JOB邮件", ex.StackTrace); } sw.Stop(); WriteLog("本轮结束!"); WriteLog(string.Format("本次任务共耗时 {0} 秒", sw.Elapsed.TotalSeconds)); }
//(PO中该商品采购数量 –实际入库数量) 进行扣减采购在途库存(inventory .purQty); //负po不需要进行采购在途库存设置。关闭时,需要把占用库存剩下的还给可用库存 public static void InventoryPurQtyChange(PoSysNoItem poInfo) { List <PoPurQtyInfo> listPurQty = AutoCloseDA.GetPoPurQtyInfoList(poInfo.PoSysNo); //var data = listPurQty.GroupBy(p => p.poSysno); //int storySyno = 0; //foreach (var d in data) //{ // List<KeyValuePair<int, int>> kv = new List<KeyValuePair<int, int>>(); // foreach (var f in d) // { // storySyno = f.StockSysNo; // kv.Add(new KeyValuePair<int, int>(f.productSysno, f.pruCount)); // } // if (storySyno != 0) // { // InventoryPurQty(storySyno, kv, d.Key, 2);//0 审核; 1 撤销审核;2 中止入库 // storySyno = 0; // } //} InventoryAdjustContractInfo info = new InventoryAdjustContractInfo(); info.SourceActionName = InventoryAdjustSourceAction.StopInStock; info.SourceBizFunctionName = InventoryAdjustSourceBizFunction.PO_Order; info.AdjustItemList = new List <InventoryAdjustItemInfo>(); info.ReferenceSysNo = poInfo.PoSysNo.ToString(); foreach (var item in listPurQty) { info.AdjustItemList.Add(new InventoryAdjustItemInfo { AdjustQuantity = -1 * item.pruCount, ProductSysNo = item.productSysno, StockSysNo = item.StockSysNo }); } string baseUrl = System.Configuration.ConfigurationManager.AppSettings["PORestFulBaseUrl"]; string languageCode = System.Configuration.ConfigurationManager.AppSettings["LanguageCode"]; string companyCode = System.Configuration.ConfigurationManager.AppSettings["CompanyCode"]; ECCentral.Job.Utility.RestClient client = new ECCentral.Job.Utility.RestClient(baseUrl, languageCode); ECCentral.Job.Utility.RestServiceError error; var ar = client.Update("/PurchaseOrder/AdjustPurchaseOrderQtyInventory", info, out error); if (error != null && error.Faults != null && error.Faults.Count > 0) { string errorMsg = ""; foreach (var errorItem in error.Faults) { errorMsg += errorItem.ErrorDescription; } Logger.WriteLog(errorMsg, "JobConsole"); OnShowInfo(errorMsg); OnShowInfo("PO单编号为:" + poInfo.PoSysNo.ToString() + "在途数量修改失败"); AutoCloseDA.SendEmail(poInfo.PoSysNo, Settings.ExceptionMeil, "PO单编号为:" + poInfo.PoSysNo.ToString() + "在途数量修改失败", errorMsg); } else { OnShowInfo("PO单编号为:" + poInfo.PoSysNo.ToString() + "在途数量修改成功"); } }
//发送邮件 public void SendMail(string coutent, string email) { AutoCloseDA.SendEmail(0, email, "PO关闭邮件", coutent); }