/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { string PalletNo =(string) CurrentSession.GetValue(Session.SessionKeys.Pallet) ; IPalletRepository PalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>(); Pallet CurrentPallet = PalletRepository.Find(PalletNo); CurrentPallet.Editor = Editor; PalletLog newPalletLog = new PalletLog(); newPalletLog.Editor = Editor; newPalletLog.Line = ""; newPalletLog.Station = Station; CurrentPallet.AddLog(newPalletLog); CurrentPallet.Station = Station; CurrentPallet.Editor = Editor; PalletRepository.UpdatePakLocMasForPno("", PalletNo, "PakLoc"); PalletRepository.Update(CurrentPallet, CurrentSession.UnitOfWork); return base.DoExecute(executionContext); }
/// <summary> /// /// </summary> /// <param name="executionContext"></param> /// <returns></returns> protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext) { Session session = CurrentSession; string dn = (string)session.GetValue(Session.SessionKeys.DeliveryNo); string ship = (string)session.GetValue("ShipmentNo"); string prj = (string)session.GetValue("Project"); IDeliveryRepository currentDNRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IPalletRepository currentPltRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>(); if (dn != null && dn != "") { session.AddValue("ShipmentNo", currentDNRepository.Find(dn).ShipmentNo); IList<string> pnList = currentDNRepository.GetPalletNoListByDnAndWithSoloDn(dn); currentDNRepository.DeleteDeliveryAttrLogByDnDefered(session.UnitOfWork, dn); currentDNRepository.DeleteDeliveryAttrsByDnDefered(session.UnitOfWork, dn); currentDNRepository.DeleteDeliveryInfoByDnDefered(session.UnitOfWork, dn); currentDNRepository.DeleteDeliveryPalletByDnDefered(session.UnitOfWork, dn); currentDNRepository.DeleteDeliveryByDnDefered(session.UnitOfWork, dn); currentDNRepository.RemoveDeliveryExDefered(session.UnitOfWork, dn); //currentDNRepository.DeleteDnDefered(CurrentSession.UnitOfWork, dn); //Includes above three calls. currentDNRepository.DeletePalletAttrLogDefered(session.UnitOfWork, pnList); currentPltRepository.DeletePalletAttrsDefered(session.UnitOfWork, pnList); currentPltRepository.DeletePalletsDefered(session.UnitOfWork, pnList); if (prj != null && prj == "Docking") { //Call SP:Docking_DeleteDeliveryOfPC to delete DN related records. //SP in-args: // @DeliveryNo char(20) IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); productRepository.ExecSpForNonQuery(SqlHelper.ConnectionString_PAK, "Docking_DeleteDeliveryOfPC", new SqlParameter("DeliveryNo", dn)); } #region 清空Pallet weight IProductRepository currentProductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); IList<string> palletNoList = currentDNRepository.GetPalletNoListByDeliveryNo(dn); foreach (string pn in palletNoList) { //mantis1666: Unpack DN by DN,清除棧板庫位時若unpack 的 DN為棧板唯一的DN才能清庫位 //在Pallet 結合DN最後一筆時,才能清空Pallet Location Pallet pallet = currentPltRepository.Find(pn); IList<string> dnList = currentProductRepository.GetDeliveryNoListByPalletNo(pn); if (dnList.Count < 2) { PakLocMasInfo setVal = new PakLocMasInfo(); PakLocMasInfo cond = new PakLocMasInfo(); setVal.editor = Editor; setVal.pno = ""; cond.pno = pn; cond.tp = "PakLoc"; currentPltRepository.UpdatePakLocMasInfoDefered(session.UnitOfWork, setVal, cond); //Clear Floor in Pallet pallet.Floor = ""; //Clear Floor in Pallet } //Clear weight in Pallet pallet.Weight = 0; pallet.Weight_L = 0; if (!pnList.Contains(pn)) { PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RETURN", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor }; pallet.AddLog(palletLog); currentPltRepository.Update(pallet, session.UnitOfWork); } } #endregion } else if (ship != null && ship != "") { IList<string> pnList = currentDNRepository.GetPalletNoListByShipmentAndWithSoloShipment(ship); currentDNRepository.DeleteDeliveryAttrLogByShipmentNoDefered(session.UnitOfWork, ship); currentDNRepository.DeleteDeliveryAttrsByShipmentNoDefered(session.UnitOfWork, ship); currentDNRepository.DeleteDeliveryInfoByShipmentNoDefered(session.UnitOfWork, ship); currentDNRepository.DeleteDeliveryPalletByShipmentNoDefered(session.UnitOfWork, ship); currentDNRepository.DeleteDeliveryByShipmentNoDefered(session.UnitOfWork, ship); currentDNRepository.RemoveDeliveryExDefered(session.UnitOfWork, ship); currentDNRepository.DeletePalletAttrLogDefered(session.UnitOfWork, pnList); currentPltRepository.DeletePalletAttrsDefered(session.UnitOfWork, pnList); currentPltRepository.DeletePalletsDefered(session.UnitOfWork, pnList); if (prj != null && prj == "Docking") { //Call SP:Docking_DeleteShipmentOfPC to delete Shipment related records. //SP in-args: // @ShipmentNo char(20) IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); productRepository.ExecSpForNonQuery(SqlHelper.ConnectionString_PAK, "Docking_DeleteShipmentOfPC", new SqlParameter("ShipmentNo", ship)); } #region 清空Pallet weight IProductRepository currentProductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); IList<string> palletNoList = currentDNRepository.GetPalletNoListByShipmentNo(ship); foreach (string pn in palletNoList) { //mantis1666: Unpack DN by DN,清除棧板庫位時若unpack 的 DN為棧板唯一的DN才能清庫位 //在Pallet 結合DN最後一筆時,才能清空Pallet Location Pallet pallet = currentPltRepository.Find(pn); IList<string> dnList = currentProductRepository.GetDeliveryNoListByPalletNo(pn); if (dnList.Count < 2) { PakLocMasInfo setVal = new PakLocMasInfo(); PakLocMasInfo cond = new PakLocMasInfo(); setVal.editor = Editor; setVal.pno = ""; cond.pno = pn; cond.tp = "PakLoc"; currentPltRepository.UpdatePakLocMasInfoDefered(session.UnitOfWork, setVal, cond); //Clear Floor in Pallet pallet.Floor = ""; //Clear Floor in Pallet } //Clear weight in Pallet pallet.Weight = 0; pallet.Weight_L = 0; if (!pnList.Contains(pn)) { PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RETURN", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor }; pallet.AddLog(palletLog); currentPltRepository.Update(pallet, session.UnitOfWork); } } #endregion } return base.DoExecute(executionContext); }
/// <summary> /// 用来记录Pallet过站Log /// </summary> /// <param name="log">Pallet过站记录</param> public void AddLog(PalletLog log) { if (log == null) return; lock (_syncObj_palletLogs) { object naught = this.PalletLogs; if (this._palletLogs.Contains(log)) return; log.Tracker = this._tracker.Merge(log.Tracker); this._palletLogs.Add(log); this._tracker.MarkAsAdded(log); this._tracker.MarkAsModified(this); } }