Beispiel #1
0
        /// <summary>
        /// AssignPallet
        /// </summary>
        /// <param name="plt">plt</param>
        /// <param name="editor">editor</param>
        public S_common_ret AssignPallet(string plt, string editor)
        {
            try
            {

                Pallet curPallet = palletRepository.Find(plt);
                if (null != curPallet)
                {
                    curPallet.Station = "WH";
                    curPallet.Editor = editor;
                    curPallet.Udt = DateTime.Now;
                    PalletLog newPalletLog = new PalletLog();
                    newPalletLog.Editor = editor;
                    newPalletLog.Line = "";
                    newPalletLog.Station = "WH";
                    newPalletLog.Cdt = DateTime.Now;
                    curPallet.AddLog(newPalletLog);

                    IUnitOfWork uow = new UnitOfWork();
                    palletRepository.Update(curPallet, uow);
                    uow.Commit();
                }
                              
                
                S_common_ret ret = new S_common_ret();
                ret.state = 0;
                WhPltLogInfo newLog = new WhPltLogInfo();
                newLog.plt = plt;
                newLog.editor = editor;
                newLog.wc = "IN";
                newLog.cdt = DateTime.Now;
                palletRepository.InsertWhPltLog(newLog);
                WhPltMasInfo haveRecord = palletRepository.GetWHPltMas(plt);
                if (null != haveRecord)
                {
                    WhPltMasInfo newMasInfo = new WhPltMasInfo();
                    newMasInfo.plt = plt;
                    newMasInfo.editor = editor;
                    newMasInfo.wc = "IN";
                    newMasInfo.udt = DateTime.Now;
                    palletRepository.UpdateWhPltMas(newMasInfo, plt);
                }
                else
                {
                    WhPltMasInfo newMasInfo = new WhPltMasInfo();
                    newMasInfo.plt = plt;
                    newMasInfo.editor = editor;
                    newMasInfo.wc = "IN";
                    newMasInfo.cdt = DateTime.Now;
                    newMasInfo.udt = DateTime.Now;
                    palletRepository.InsertWhPltMas(newMasInfo);
                }

                IList<PakWhPltTypeInfo> reGetTypeList = palletRepository.GetPakWhPltTypeListByPlt(plt);
                string bol = "";
                string carrier = "";
                string tp = "";
                foreach (PakWhPltTypeInfo tmp in reGetTypeList)
                {
                    if (null != tmp)
                    {
                        if (tmp.bol != null && tmp.bol.Length > 0
                            || tmp.carrier != null && tmp.carrier.Length > 0
                            || tmp.tp != null && tmp.tp.Length > 0)
                        {
                            if (bol == "" || tmp.bol != null)
                            {
                                bol = tmp.bol;
                            }
                            if (carrier == "" || tmp.carrier != null)
                            {
                                carrier = tmp.carrier;
                            }
                            if (tp == "" || tmp.tp != null)
                            {
                                tp = tmp.tp;
                            }
                        }
                    }
                }
                if (bol == "")
                {
                    ret.state = 30;
                    return ret;
                }
                
                
                
                
                /*S_DN_Extended value = GetDN(plt);
                
                
                
                
                
                if (value.success == 0)
                {
                    ret.state = 3;
                    return ret;
                }*/
                string col = "";
                int loc = 0;
                IList<PakWhLocMasInfo> getLocList = palletRepository.GetPakWhLocMasListByBolAndPlt1(bol, "");
                if (null == getLocList ||
                    getLocList.Count == 0)
                {
                    ret.state = 3;
                    return ret;
                }
                foreach (PakWhLocMasInfo aLoc in getLocList)
                {
                    if (aLoc.col == "")
                    {
                        //此貨代庫位已滿,請自行處理擺放
                        ret.state = 2;
                        return ret;
                    }
                    else
                    {
                        col = aLoc.col;
                        loc = aLoc.loc;
                    }
                    break;
                }
                WhPltLocLogInfo item = new WhPltLocLogInfo();
                item.plt = plt;
                item.loc = col + loc.ToString();
                palletRepository.InsertWhPltLocLogInfo(item);
                PakWhLocMasInfo newLoc = new PakWhLocMasInfo();
                newLoc.plt1 = plt;
                newLoc.udt = DateTime.Now;
                palletRepository.UpdatePakWhLocByColAndLoc(newLoc, col, loc);
                ret.describe = col;
                ret.describe = ret.describe + "#@#";
                ret.describe = ret.describe + loc.ToString();
                //成功结束,請將此棧板放入'+@col+'區'+@loc+'庫位”
                ret.state = 101;
                return ret;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// RemovePallet
        /// </summary>
        /// <param name="plt">plt</param>
        /// <param name="editor">editor</param>
        public void RemovePallet(string plt, string editor)
        {
            try
            {
                palletRepository.UpdatePakWhLocByPltForClearPlt1AndPlt2(plt);
                WhPltMasInfo newMasInfo = new WhPltMasInfo();
                newMasInfo.plt = plt;
                newMasInfo.editor = editor;
                newMasInfo.wc = "RW";
                newMasInfo.udt = DateTime.Now;
                palletRepository.UpdateWhPltMas(newMasInfo, plt);
                WhPltLogInfo newLog = new WhPltLogInfo();
                newLog.plt = plt;
                newLog.editor = editor;
                newLog.wc = "RW";
                newLog.cdt = DateTime.Now;
                palletRepository.InsertWhPltLog(newLog);

                Pallet curPallet = palletRepository.Find(plt);
                if (null != curPallet)
                {
                    curPallet.Station = "RW";
                    curPallet.Editor = editor;
                    curPallet.Udt = DateTime.Now;
                    PalletLog newPalletLog = new PalletLog();
                    newPalletLog.Editor = editor;
                    newPalletLog.Line = "";
                    newPalletLog.Station = "RW";
                    newPalletLog.Cdt = DateTime.Now;
                    curPallet.AddLog(newPalletLog);

                    IUnitOfWork uow = new UnitOfWork();
                    palletRepository.Update(curPallet, uow);
                    uow.Commit();
                }

            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
        }
        /// <summary>
        /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Session session = CurrentSession;
            string CurrentDeliveryNo = (string)session.GetValue(Session.SessionKeys.DeliveryNo);


            IProductRepository currentProductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();
            IDeliveryRepository currentDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository>();
            IPalletRepository currentPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>();

            /*
             * Answer to: ITC-1360-0845
             * Description: Update PAKLocMas info.
             */
            IList<string> pnList = currentDeliveryRepository.GetPalletNoListByDeliveryNo(CurrentDeliveryNo);
            currentProductRepository.UnPackProductByDeliveryNoDefered(session.UnitOfWork, CurrentDeliveryNo);
            foreach (string pn in pnList)
            {
                //mantis1666: Unpack DN by DN,清除棧板庫位時若unpack 的 DN為棧板唯一的DN才能清庫位
                //在Pallet 結合DN最後一筆時,才能清空Pallet Location 
                Pallet pallet = currentPalletRepository.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";
                    currentPalletRepository.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;
                PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RETURN", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor };
                pallet.AddLog(palletLog);
                currentPalletRepository.Update(pallet, session.UnitOfWork);
            }
            return base.DoExecute(executionContext);
        }
Beispiel #4
0
        /// <summary>
        /// 备份Product / ProductStatus / Product_Part / ProductInfo 表中将被解绑的记录
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IDeliveryRepository currentRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

            Session session = CurrentSession;
            string DN = (string)session.GetValue(Session.SessionKeys.DeliveryNo);

            IList<IProduct> productList = (IList<IProduct>)session.GetValue(Session.SessionKeys.ProdNoList);

            IProduct currentProduct = null;
            foreach (IProduct ele in productList)
            {
                currentProduct = ele;
                productList.Remove(ele);
                break;
            }
            if (productList.Count == 0)
            {
                session.AddValue(Session.SessionKeys.IsComplete, true);
            }
            session.AddValue(Session.SessionKeys.ProdNoList, productList);
            session.AddValue(Session.SessionKeys.Product, currentProduct);
            IList<string> itemTypes = new List<string>();

            itemTypes.Add("CKK");

            productRepository.BackUpProductInfoDefered(session.UnitOfWork, currentProduct.ProId, this.Editor, "CKK");

            productRepository.RemoveProductInfosByTypeDefered(session.UnitOfWork, currentProduct.ProId, itemTypes);



            //// Delete CartonInfo

            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();

            CartonInfoInfo infoCond = new CartonInfoInfo();

            infoCond.cartonNo = currentProduct.CartonSN;

            cartRep.DeleteCartonInfoDefered(session.UnitOfWork, infoCond);



            //Delete Product_Part 

           
            string[] prodList = new string[1];

            prodList[0] = currentProduct.ProId;

            ProductPart tmp = new ProductPart();

            tmp.Station = "8C";
            productRepository.BackUpProductPartDefered(session.UnitOfWork, prodList, tmp, this.Editor);
            productRepository.DeleteProductPartsDefered(session.UnitOfWork, prodList, tmp);

            
            //Update Product       

            productRepository.BackUpProductStatusDefered(session.UnitOfWork, currentProduct.ProId, this.Editor);

            productRepository.BackUpProductDefered(session.UnitOfWork, currentProduct.ProId, this.Editor);
            currentProduct.CartonSN = string.Empty;
            currentProduct.PalletNo = string.Empty;
            currentProduct.DeliveryNo = string.Empty;
            currentProduct.Udt = DateTime.Now;
            productRepository.Update(currentProduct, session.UnitOfWork);


            Delivery oldDelivery = currentRepository.Find(DN);
            if (oldDelivery != null)
            {
                oldDelivery.Status = "00";
                currentRepository.Update(oldDelivery, session.UnitOfWork);
                #region 清空Pallet weight
                IPalletRepository currentPltRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                IList<string> palletNoList = currentRepository.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 = productRepository.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;

                    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);
        }
Beispiel #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            PalletLog newPalletLog = new PalletLog();

            newPalletLog.Editor = Editor;
            newPalletLog.Line = Line;
            newPalletLog.Station = Station;



            Pallet CurrentPallet = (Pallet)CurrentSession.GetValue(Session.SessionKeys.Pallet);
            newPalletLog.PalletNo = CurrentPallet.PalletNo;

            CurrentPallet.AddLog(newPalletLog);

            IPalletRepository PalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            PalletRepository.Update(CurrentPallet, CurrentSession.UnitOfWork);
            return base.DoExecute(executionContext);
        }
Beispiel #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IList<string> ScanedProductIDList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.NewScanedProductIDList);
            IList<string> palletList = new List<string>();

            Line = string.IsNullOrEmpty(this.Line) ? string.Empty : this.Line;

            foreach (string iprodId in ScanedProductIDList)
            {

                var currentProduct = productRepository.Find(iprodId);

                if (palletList != null && palletList.Count > 0)
                {
                    Boolean exitFlag = false;
                    foreach (string ipalletno in palletList)
                    {
                        if (ipalletno == currentProduct.PalletNo)
                        {
                            exitFlag = true;
                            break;
                        }

                    }

                    if (!exitFlag)
                    {
                        palletList.Add(currentProduct.PalletNo);
                    }
                }
                else palletList.Add(currentProduct.PalletNo);

            }

            foreach(string ipalletno in palletList)
            {
            
                PalletLog newPalletLog = new PalletLog();

                newPalletLog.PalletNo = ipalletno;
                newPalletLog.Editor = Editor;
                newPalletLog.Line = Line;
                newPalletLog.Station = Station;

                

                IPalletRepository PalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                Pallet CurrentPallet = PalletRepository.Find(ipalletno);

                CurrentPallet.Station = this.Station;
                CurrentPallet.Editor = this.Editor;
                CurrentPallet.Udt = DateTime.Now;

                CurrentPallet.AddLog(newPalletLog);

                PalletRepository.Update(CurrentPallet, CurrentSession.UnitOfWork);
            }
            return base.DoExecute(executionContext);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            //Product currentProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            Session session =CurrentSession;
            ICartonRepository cartonRep = RepositoryFactory.GetInstance().GetRepository<ICartonRepository, Carton>();
            IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

            IList<string> nameList = InfoTypeList.Split(new char[] { ',', ';' }).ToList();

            if (UnPackBy == UnPackByEnum.Carton)
            {
                Carton carton = (Carton)session.GetValue(Session.SessionKeys.Carton);
                IList<IProduct> prodList = (IList<IProduct>)session.GetValue(Session.SessionKeys.ProdList);
                string palletNo = null;
                IList<String> deliveryNoList = prodList.Where(y => !string.IsNullOrEmpty(y.DeliveryNo))
                                                                        .Select(x => x.DeliveryNo).Distinct().ToList();
                foreach (Product item in prodList)
                {
                    if (!string.IsNullOrEmpty(item.PalletNo))
                    {
                        palletNo = item.PalletNo;
                    }
                    prodRep.BackUpProductDefered(session.UnitOfWork, item.ProId, CurrentSession.Editor);

                    prodRep.BackUpProductStatusDefered(session.UnitOfWork, item.ProId, CurrentSession.Editor);

                    foreach (string name in nameList)
                    {
                        prodRep.BackUpProductInfoDefered(session.UnitOfWork, item.ProId, CurrentSession.Editor, name);
                    }

                    if (IsBckupProductPart)
                    {
                        prodRep.BackUpProductPartDefered(session.UnitOfWork, item.ProId, CurrentSession.Editor);
                    }
                }

                #region 清空Pallet weight
                if (!string.IsNullOrEmpty(palletNo))
                {
                    IPalletRepository currentPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>();
                    //IList<string> dnList = prodRep.GetDeliveryNoListByPalletNo(palletNo);
                    Pallet pallet = currentPalletRepository.Find(palletNo);
                    //if (dnList.Count < 2)
                    //{
                    //    PakLocMasInfo setVal = new PakLocMasInfo();
                    //    PakLocMasInfo cond = new PakLocMasInfo();
                    //    setVal.editor = Editor;
                    //    setVal.pno = "";
                    //    cond.pno = palletNo;
                    //    cond.tp = "PakLoc";
                    //    currentPalletRepository.UpdatePakLocMasInfoDefered(session.UnitOfWork, setVal, cond);
                    //    //Clear Floor in Pallet
                    //    pallet.Floor = "";
                    //}

                    //Clear  weight in Pallet 
                    pallet.Weight = 0;
                    pallet.Weight_L = 0;
                    PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RE", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor };
                    pallet.AddLog(palletLog);
                    currentPalletRepository.Update(pallet, session.UnitOfWork);
                    //Clear weight in Pallet
                    if (deliveryNoList.Count > 0)
                    {
                        session.AddValue(Session.SessionKeys.DeliveryNoList, deliveryNoList);
                    }
                }
                else if (deliveryNoList.Count > 0)
                {
                    session.AddValue(Session.SessionKeys.DeliveryNoList, deliveryNoList);
                }
                #endregion

            }
            else
            {
                //Backup DN 相關的ProductID的資料
                string dnNo = (string)session.GetValue(Session.SessionKeys.DeliveryNo);

                prodRep.BackUpProductByDnDefered(session.UnitOfWork, dnNo, session.Editor);

                prodRep.BackUpProductStatusByDnDefered(session.UnitOfWork, dnNo, session.Editor);

                prodRep.BackUpProductInfoByDnDefered(session.UnitOfWork, dnNo, session.Editor, nameList);
                prodRep.BackUpProductPartByDnDefered(session.UnitOfWork, dnNo, session.Editor);


                //此DN與其他DN相關的ProductID (剩餘相關CartonSNProductID)
                IList<IProduct> prodList = (IList<IProduct>)session.GetValue(Session.SessionKeys.ProdList);

                foreach (Product item in prodList)
                {
                    prodRep.BackUpProductDefered(session.UnitOfWork, item.ProId, session.Editor);

                    prodRep.BackUpProductStatusDefered(session.UnitOfWork, item.ProId, session.Editor);

                    foreach (string name in nameList)
                    {
                        prodRep.BackUpProductInfoDefered(session.UnitOfWork, item.ProId, session.Editor, name);
                    }

                    if (IsBckupProductPart)
                    {
                        prodRep.BackUpProductPartDefered(session.UnitOfWork, item.ProId, session.Editor);
                    }
                }

                #region 清空 Reset Pallet weight
                IDeliveryRepository currentDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository>();
                IPalletRepository currentPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>();
                IList<string> pnList = currentDeliveryRepository.GetPalletNoListByDeliveryNo(dnNo);
                foreach (string pn in pnList)
                {
                    //mantis1666: Unpack DN by DN,清除棧板庫位時若unpack 的 DN為棧板唯一的DN才能清庫位
                    //在Pallet 結合DN最後一筆時,才能清空Pallet Location 
                    Pallet pallet = currentPalletRepository.Find(pn);
                    IList<string> dnList = prodRep.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";
                        currentPalletRepository.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;
                    PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RETURN", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor };
                    pallet.AddLog(palletLog);
                    currentPalletRepository.Update(pallet, session.UnitOfWork);
                }
                #endregion
            }
            return base.DoExecute(executionContext);

        }
        /// <summary>
        /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Session session = CurrentSession;
            Product currentProduct = ((Product)session.GetValue(Session.SessionKeys.Product));
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();

            string palletNo = currentProduct.PalletNo;
            string deliveryNo = currentProduct.DeliveryNo;

            IList<string> itemTypes = new List<string>();
            itemTypes.Add("CKK");

            productRepository.BackUpProductInfo(currentProduct.ProId, this.Editor, "CKK");
            productRepository.RemoveProductInfosByType(currentProduct.ProId, itemTypes);

            ////	Delete CartonInfo
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();
            CartonInfoInfo infoCond = new CartonInfoInfo();
            infoCond.cartonNo = currentProduct.CartonSN;
            cartRep.DeleteCartonInfoDefered(session.UnitOfWork, infoCond);
            
            //Delete Product_Part 
            if (Station == "SP")
            {
                Delivery CurrentDelivery = DeliveryRepository.Find(currentProduct.DeliveryNo);
               
                CurrentSession.AddValue(Session.SessionKeys.Delivery, CurrentDelivery);
                string[] prodList = new string[1];
                prodList[0] = currentProduct.ProId;
                ProductPart tmp = new ProductPart();
                tmp.Station = "8C";
                productRepository.BackUpProductPartDefered(session.UnitOfWork, prodList, tmp, Editor);

                productRepository.DeleteProductPartsDefered(session.UnitOfWork, prodList, tmp);
            }

      //Update Product       
            currentProduct.CartonSN = string.Empty; 
            currentProduct.PalletNo = string.Empty;
            if (Station == "SP")
            {
                currentProduct.DeliveryNo = string.Empty;
            }
            productRepository.Update(currentProduct, session.UnitOfWork);
            productRepository.BackUpProduct(currentProduct.ProId, this.Editor);
            productRepository.BackUpProductStatus(currentProduct.ProId, this.Editor);

            #region 清空Pallet weight
            if (!string.IsNullOrEmpty(palletNo))
            {
                IPalletRepository currentPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>();
                //IList<string> dnList = productRepository.GetDeliveryNoListByPalletNo(palletNo);
                Pallet pallet = currentPalletRepository.Find(palletNo);
                //if (dnList.Count < 2)
                //{
                //    PakLocMasInfo setVal = new PakLocMasInfo();
                //    PakLocMasInfo cond = new PakLocMasInfo();
                //    setVal.editor = Editor;
                //    setVal.pno = "";
                //    cond.pno = palletNo;
                //    cond.tp = "PakLoc";
                //    currentPalletRepository.UpdatePakLocMasInfoDefered(session.UnitOfWork, setVal, cond);
                //    //Clear Floor in Pallet
                //    pallet.Floor = "";
                //}

                //Clear  weight in Pallet 
                pallet.Weight = 0;
                pallet.Weight_L = 0;
                PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RETURN", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor };
                pallet.AddLog(palletLog);
                currentPalletRepository.Update(pallet, session.UnitOfWork);
                //Clear weight in Pallet
                if (!string.IsNullOrEmpty(deliveryNo))
                {
                    session.AddValue(Session.SessionKeys.DeliveryNo, deliveryNo);
                }
            }
            else if (!string.IsNullOrEmpty(deliveryNo))
            {
                session.AddValue(Session.SessionKeys.DeliveryNo, deliveryNo);
            }
            #endregion

            return base.DoExecute(executionContext);
        }
Beispiel #9
0
        /// <summary>
        /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Session session = CurrentSession;
            Product currentProduct = ((Product)session.GetValue(Session.SessionKeys.Product));
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IDeliveryRepository deliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            string unpackType = ((string)session.GetValue(Session.SessionKeys.CN));
            bool isPallet = ((bool)session.GetValue(Session.SessionKeys.Pallet));
            productRepository.BackUpProduct(currentProduct.ProId,this.Editor);

            ShipBoxDetInfo setValue = new ShipBoxDetInfo();
            ShipBoxDetInfo condition = new ShipBoxDetInfo();
            setValue.snoId = "";
            setValue.editor = this.Editor;
            condition.snoId = currentProduct.ProId;
            deliveryRepository.UpdateShipBoxDetInfo(setValue, condition);
            string palletNo = currentProduct.PalletNo;
            string deliveryNo = currentProduct.DeliveryNo;

            if (unpackType == "ALL")
            {
                currentProduct.PizzaID = string.Empty;
                currentProduct.CartonSN = string.Empty;
            }
            currentProduct.PalletNo = string.Empty;
            if (!isPallet)
            {
                currentProduct.DeliveryNo = string.Empty;
            }
            currentProduct.CartonWeight = 0;
            if (!currentProduct.IsBT)
            { currentProduct.UnitWeight = 0; }
            
           
            #region 清空Pallet weight
            if (!string.IsNullOrEmpty(palletNo))
            {
                //Don't  change PAKLocMAS 
                IPalletRepository currentPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>();
                //IList<string> dnList = productRepository.GetDeliveryNoListByPalletNo(palletNo);
                Pallet pallet = currentPalletRepository.Find(palletNo);
                //if (dnList.Count < 2)
                //{
                //    PakLocMasInfo setVal = new PakLocMasInfo();
                //    PakLocMasInfo cond = new PakLocMasInfo();
                //    setVal.editor = Editor;
                //    setVal.pno = "";
                //    cond.pno = palletNo;
                //    cond.tp = "PakLoc";
                //    currentPalletRepository.UpdatePakLocMasInfoDefered(session.UnitOfWork, setVal, cond);
                //    //Clear Floor in Pallet
                //    pallet.Floor = "";
                //}

                //Clear  weight in Pallet 
                pallet.Weight = 0;
                pallet.Weight_L = 0;
                PalletLog palletLog = new PalletLog { PalletNo = pallet.PalletNo, Station = "RETURN", Line = "Weight:0", Cdt = DateTime.Now, Editor = this.Editor };
                pallet.AddLog(palletLog);
                currentPalletRepository.Update(pallet, session.UnitOfWork);
                //Clear weight in Pallet
               if (!string.IsNullOrEmpty(deliveryNo))
               {
                    session.AddValue(Session.SessionKeys.DeliveryNo, deliveryNo);
               }
            }
            else if (!string.IsNullOrEmpty(deliveryNo))
            {
                session.AddValue(Session.SessionKeys.DeliveryNo, deliveryNo);
            }
            #endregion

            productRepository.Update(currentProduct, session.UnitOfWork);

            productRepository.BackUpProductStatus(currentProduct.ProId, this.Editor);

            return base.DoExecute(executionContext);
        }