Exemple #1
0
        /// <summary>
        /// 產生BOX ID號號相关逻辑
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
        {
            IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();

            try
            {

                //仅当Delivery 的Flag 属性为N 的时候,需要Generate Ship to Carton Label Pdf Document:
                //1.	Generate Box Id
                //2.	Generate and Record Data for Ship to Carton Label   
                //3.	Generate Ship to Carton Label Pdf Document
                string boxID = "";
                Delivery curDev = deliveryRep.Find(product.DeliveryNo);
                //curDev.Editor = this.Editor;
                CurrentSession.AddValue(Session.SessionKeys.Delivery, curDev);

                string flagstr = (string)curDev.GetExtendedProperty("Flag");
                string setSPValue = "";
                bool uccremoveflag = false;
                if (flagstr == "N")
                {
                    // 1.	解除Carton 结合的旧的Box Id
                    //参考方法:
                    //IF EXISTS (SELECT * FROM CartonInfo (NOLOCK ) WHERE CartonNo=@cn AND InfoType='BoxId')
                    //BEGIN
                    //DELETE CartonInfo WHERE artonNo=@cn AND InfoType='BoxId'
                    //END
                    CartonInfoInfo infoCond = new CartonInfoInfo();
                    infoCond.cartonNo = product.CartonSN;
                    infoCond.infoType = "BoxId";
                    //IList<CartonInfoInfo> infoList = null;// cartRep.GetCartonInfoInfo(infoCond);

                    cartRep.DeleteCartonInfoDefered(CurrentSession.UnitOfWork, infoCond);
                    //IF EXISTS (SELECT * FROM CartonInfo (NOLOCK ) WHERE CartonNo=@cn AND InfoType='UCC')
                    //BEGIN
	                //DELETE CartonInfo WHERE artonNo=@cn AND InfoType='UCC'
                    //END
                    CartonInfoInfo uccCond = new CartonInfoInfo();
                    uccCond.cartonNo = product.CartonSN;
                    uccCond.infoType = "UCC";

                    cartRep.DeleteCartonInfoDefered(CurrentSession.UnitOfWork, uccCond);

                    uccremoveflag = true;

                    //2.	取当前日期/ Pallet UCC
                    //参考方法:
                    //SELECT @dt=GETDATE(),@ucc=''
                    //SELECT @ucc = UCC FROM Pallet (NOLOCK) WHERE PalletNo = @plt
                    string ucc = "";

                    Pallet curPallet = palletRep.Find(product.PalletNo);
                    ucc = curPallet.UCC;
                    int ucclength = ucc.TrimEnd().Length;
                    int index = ucc.TrimEnd().IndexOf(",");

                    //3.	取Delivery 相关属性
                    //参考方法:
                    //SELECT @po = RTRIM(PoNo), @model = Model FROM Delivery NOLOCK WHERE DeliveryNo = @dn
                    //SELECT @Flag = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'Flag'
                    //SELECT @BoxId_Tag = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'BoxId'
                    //SET @BoxId_Tag = LEFT(@BoxId_Tag, 10)
                    //SELECT @Region = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'RegId'
                    //SELECT @Deport = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'Deport'
                    //SELECT @boxReg = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'BoxReg'

                    string po = "";
                    string model = "";
                    //string descr = "";
                    string flag = "";
                    string boxId_Tag = "";
                    string region = "";
                    string deport = "";
                    string boxReg = "";

                    po = curDev.PoNo.TrimEnd();
                    model = curDev.ModelName;
                    flag = (string)curDev.GetExtendedProperty("Flag");
                    boxId_Tag = (string)curDev.GetExtendedProperty("BoxId");
                    if (!string.IsNullOrEmpty(boxId_Tag) && boxId_Tag.Length >= 10)
                    {
                        boxId_Tag = boxId_Tag.Substring(0, 10);
                    }
                    else
                    {
                        boxId_Tag = "";
                    }
                    region = (string)curDev.GetExtendedProperty("RegId");
                    deport = (string)curDev.GetExtendedProperty("Deport");
                    boxReg = (string)curDev.GetExtendedProperty("BoxReg");
                    string uccFlag = (string)curDev.GetExtendedProperty("UCC");

                    
                    //4.	如果@boxReg<>'',则按照如下规则产生Box Id,并将产生的Box Id 存到变量@BoxId 中
                    if (uccFlag == "X")
                    {
                        if (!curPallet.PalletNo.StartsWith("NA"))
                        {
                            ucc = getUCCIDList();
                            ucclength = ucc.TrimEnd().Length;
                            index = -1;
                        }
                        else
                        {
                            ucc = curPallet.UCC;
                            ucclength = ucc.TrimEnd().Length;
                            index = -1;
                        }
                    }
                    else
                    {
                        #region none UCC case
                        if (!string.IsNullOrEmpty(boxReg))
                        {                         
                            boxID = getBoxId(boxReg);  
                        }
                        else
                        {
                            #region none boxId Prefix Code
                            //5.	如果@boxReg='',则按照如下规则产生Box Id,并将产生的Box Id 存到变量@BoxId 中
                            //a)	当满足(LEN(RTRIM(@ucc))<>20 or (LEN(RTRIM(@ucc))=20 AND CHARINDEX(',',RTRIM(@ucc))>0)) AND RTRIM(@BoxId_Tag) ='' AND @Flag='N'条件时,按照如下规则产生Box Id
                            IPartRepository PartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                            IList<string> valueList = PartRepository.GetValueFromSysSettingByName("Site");
                            if (valueList.Count == 0)
                            {
                                throw new FisException("PAK095", new string[] { "Site" });
                            }

                           // if ((ucclength != 20) || (ucclength == 20 && index >= 0 && string.IsNullOrEmpty(boxId_Tag.TrimEnd()) && flag == "N"))
                           // {
                            string alarm = "";
                            if (valueList[0] == "ICC")//重慶
                            {
                                //Vincent used ConstValue setting
                                IList<ConstValueInfo> boxIdPrefixList = PartRepository.GetConstValueListByType("BoxIdPreFixRule");
                                var prefixList = (from p in boxIdPrefixList
                                                  where p.name == region
                                                  select p.value).ToList();
                                if (prefixList != null && prefixList.Count > 0)
                                {
                                    alarm = prefixList[0].Trim();
                                }

                                if (string.IsNullOrEmpty(alarm))
                                {
                                    throw new FisException("CQCHK0049", new string[] { "BoxIdPreFixRule", region });
                                }
                            }
                            else
                            {
                                switch (region)
                                {
                                    case "SNA":
                                        alarm = "H410-Y";
                                        break;
                                    case "SNL":
                                        alarm = "LA" + deport + "Y";
                                        break;
                                    case "SNU":
                                        alarm = "D7" + deport + "Y";
                                        break;
                                    case "SNE":
                                        alarm = "63D7-QY";
                                        break;
                                    case "SAF":
                                        alarm = "H4FN-0C";
                                        break;
                                }

                            }


                            //SET ROWCOUNT 1
                            //SELECT @BoxId=RTRIM(BoxId) FROM SnoCtrl_BoxId WHERE Cust=@alarm AND valid=@editor
                            //IF @BoxId is not null
                            //DELETE FROM SnoCtrl_BoxId WHERE BoxId=@BoxId
                            //SET ROWCOUNT 0
                            //如果@BoxId IS NULL or @BoxId='',则报告错误:'BoxId已用完.'+@alarm
                            SnoCtrlBoxIdInfo snoConf = new SnoCtrlBoxIdInfo();
                            SnoCtrlBoxIdInfo snoSet = new SnoCtrlBoxIdInfo();
                            snoConf.cust = alarm;
                            snoConf.valid = "1";
                            IList<string> boxList = deliveryRep.GetBoxIdListFromSnoCtrlBoxId(snoConf);

                            snoSet.valid = Editor;
                            //deliveryRep.UpdateSnoCtrlBoxIdInfoDefered(CurrentSession.UnitOfWork, snoSet, snoConf);

                            if (boxList != null && boxList.Count > 0 && !string.IsNullOrEmpty(boxList[0]))
                            {
                                SnoCtrlBoxIdInfo dsnoConf = new SnoCtrlBoxIdInfo();
                                boxID = boxList[0].TrimEnd();
                                dsnoConf.boxId = boxID;
                                deliveryRep.DeleteSnoCtrlBoxIdInfoDefered(CurrentSession.UnitOfWork, dsnoConf);
                            }
                            else
                            {
                                List<string> erpara = new List<string>();
                                erpara.Add(alarm);
                                FisException fe = new FisException("PAK135", erpara);   //BoxId已用完.'+@alarm
                                throw fe;
                            }

                            // }
                            #endregion
                        }

                        #endregion
                    }
                    //6.	如果LEN(RTRIM(@ucc))=20 AND CHARINDEX(',',@ucc)=0,则UCC 保存到CartonInfo 中;
                    //否则,将Box Id 保存到CartonInfo

                    //Record UCC
                    //IF EXISTS(SELECT * FROM CartonInfo NOLOCK WHERE CartonNo = @cn AND InfoType = 'UCC')
                    //UPDATE CartonInfo SET InfoValue = @ucc, Editor = @editor, Udt = GETDATE()
                    //WHERE CartonNo = @cn AND InfoType = 'UCC'
                    //ELSE
                    //INSERT INTO CartonInfo([CartonNo],[InfoType],[InfoValue],[Editor],[Cdt],[Udt])
                    //VALUES(@cn, 'UCC', @ucc, @editor, GETDATE(), GETDATE())
                    //Record Box Id
                    //IF EXISTS(SELECT * FROM CartonInfo NOLOCK WHERE CartonNo = @cn AND InfoType = 'BoxId')
                    //UPDATE CartonInfo SET InfoValue = @BoxId, Editor = @editor, Udt = GETDATE()
                    //WHERE CartonNo = @cn AND InfoType = 'BoxId'
                    //ELSE
                    //INSERT INTO CartonInfo([CartonNo],[InfoType],[InfoValue],[Editor],[Cdt],[Udt])
                    //VALUES(@cn, 'BoxId', @BoxId, @editor, GETDATE(), GETDATE())
                    string namestr = "";
                    string valuestr = "";

                    //if ((ucclength == 20) && (index < 0))
                    if (uccFlag == "X")
                    {
                        namestr = "UCC";
                        valuestr = ucc;
                    }
                    else
                    {
                        namestr = "BoxId";
                        valuestr = boxID;
                    }
                    setSPValue = valuestr;

                    infoCond.infoType = namestr;

                    //070031 2012.10.24 Unite the Ucc with BoxId Logic.
                    //070031 2012.09.27
                    if (namestr == "BoxId")
                    {
                        InvokeBody ivkBdy = null;

                        CartonInfoInfo setCarton = new CartonInfoInfo();
                        setCarton.infoType = namestr;
                        setCarton.infoValue = valuestr;
                        setCarton.cartonNo = product.CartonSN;
                        setCarton.editor = Editor;

                        var cond = new CartonInfoInfo();
                        cond.cartonNo = infoCond.cartonNo;
                        cond.infoType = namestr;
                        cond.infoValue = valuestr;
                        ivkBdy = cartRep.CheckTheBoxIdAndInsertOrUpdateDefered(CurrentSession.UnitOfWork, setCarton, cond, namestr);

                        var ivkBdy2 = cartRep.CheckTheBoxIdAndInsertOrUpdateDefered(CurrentSession.UnitOfWork, setCarton, cond, namestr);
                        ivkBdy2.DependencyIvkbdy = ivkBdy;
                        ivkBdy.ExpectRetVal = true;
                    }
                    else//Ucc
                    {
                        IList<CartonInfoInfo>  infoList = cartRep.GetCartonInfoInfo(infoCond);

                        CartonInfoInfo setCarton = new CartonInfoInfo();
                        setCarton.infoValue = valuestr;
                        setCarton.editor = Editor;
                        setCarton.udt = DateTime.Now;

                        if (infoList.Count > 0 && uccremoveflag==false)
                        {
                            
                            cartRep.UpdateCartonInfoDefered(CurrentSession.UnitOfWork, setCarton, infoCond);
                        }
                        else
                        {
                            setCarton.cartonNo = product.CartonSN;
                            setCarton.infoType = namestr;
                            cartRep.InsertCartonInfoDefered(CurrentSession.UnitOfWork, setCarton);
                        }
                    }
                    //070031 2012.09.27
                    //070031 2012.10.24 Unite the Ucc with BoxId Logic.
                }

                //Generate and Record Data for Ship to Carton Label 
                //调用HP_EDI.dbo.op_PackingData @BoxId,@dn,@plt,@cn,@cdtEDI实现
                //Parameters:@BoxId – Box Id @dn – Delivery No @plt – Pallet No @cn – Carton No @cdtEDI - GETDATE()
                if (flagstr == "N")
                {
                    palletRep.CallOp_PackingDataDefered(CurrentSession.UnitOfWork, setSPValue, product.DeliveryNo, product.PalletNo, product.CartonSN, DateTime.Now);
                }
                
            }
            catch (Exception)
            {              
                throw;
            }
          

            return base.DoExecute(executionContext);
        }
Exemple #2
0
        /// <summary>
        /// 產生BOX ID號號相关逻辑
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
        {
            IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            Delivery delivery = (Delivery)CurrentSession.GetValue(Session.SessionKeys.Delivery);

            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();

            try
            {
                //New Format of Box Id
                //Format of RU No
                //WWSSSSSS
                //Remark:
                //WW – HP Week Code
                //SSSSSS – 流水号,36进制,基字符
                string maxnum = "";
                string prestr = "";

                DateTime dateTime = DateTime.Now;
               // var ret = IMES.Infrastructure.Utility.Generates.WeekRuleEngine.Calculate("103", dateTime);
                IList<string> codeList = modelRep.GetCodeFromHPWeekCodeInRangeOfDescr();
                string weekCode = "";
                if (codeList.Count > 0)
                {
                    weekCode = codeList[0];
                }

                string runo = "";
                runo = weekCode ;
                prestr = runo;
                // 自己管理事务开始
                SqlTransactionManager.Begin();
                IUnitOfWork uof = new UnitOfWork();//使用自己的UnitOfWork

                //从NumControl中获取流水号
                //GetMaxNumber
                INumControlRepository numControl = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();

                bool addflag = false;

                maxnum = numControl.GetMaxNumber("RUNO", prestr + "{0}");
                if (string.IsNullOrEmpty(maxnum))
                {
                    maxnum = "000001";
                    addflag = true;
                }
                else
                {
                    MathSequenceWithCarryNumberRule marc = new MathSequenceWithCarryNumberRule(6, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");

                    string numstr = maxnum.Substring(maxnum.Length - 6);
                    if (numstr.ToUpper() == "ZZZZZZ")
                    {
                        FisException fe = new FisException("CHK867", new string[] { });   //流水号已满!
                        throw fe;
                    }
                    numstr = marc.IncreaseToNumber(numstr, 1);
                    maxnum = numstr;

                }

                runo = runo + maxnum.ToUpper();

                NumControl item = new NumControl();
                item.NOType = "RUNO";
                item.Value = runo;
                item.NOName = "";
                item.Customer = "HP";

                numControl.SaveMaxNumber(item, addflag, prestr + "{0}");

                uof.Commit();  //立即提交UnitOfWork更新NumControl里面的最大值

                SqlTransactionManager.Commit();//提交事物,释放行级更新锁

                //INSERT INTO [CartonInfo]([CartonNo],[InfoType],[InfoValue],[Editor],[Cdt],[Udt])
	            //VALUES (@CartonNo, 'RUNo', @RUNo, @Editor, GETDATE(), GETDATE())
                CartonInfoInfo sinfo = new CartonInfoInfo();
                sinfo.cartonNo = product.CartonSN;
                sinfo.infoType = "RUNo";
                sinfo.infoValue = runo;
                sinfo.editor = Editor;
                sinfo.cdt = DateTime.Now;
                sinfo.udt = DateTime.Now;
                cartRep.InsertCartonInfoDefered(CurrentSession.UnitOfWork, sinfo);

                //Product结合Delivery and Carton
                //将页面上[Products in Carton] 中的每一个Product和页面选定的Delivery 已经上文生成的Carton No 进行结合 – Update Product
                //Product.DeliveryNo – Delivery No
                //Product.CartonSN – Carton No

                

                IList<IProduct> productList = (List<IProduct>)CurrentSession.GetValue(Session.SessionKeys.ProdList);
                foreach (var prod in productList)
                {
                    prod.DeliveryNo = delivery.DeliveryNo;
                    prod.CartonSN = product.CartonSN;
                    productRep.Update(prod, CurrentSession.UnitOfWork);
                }

                //6.	Update ProductStatus / Insert ProductLog


            } 

            catch (Exception)
            {
                SqlTransactionManager.Rollback();
                throw;
            }
            finally
            {
                SqlTransactionManager.Dispose();
                SqlTransactionManager.End();
            }

            return base.DoExecute(executionContext);
        }
Exemple #3
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);
        }
Exemple #4
0
        /// <summary>
        /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string Delivery = (string)CurrentSession.GetValue(Session.SessionKeys.DeliveryNo);
            Delivery CurrentDelivery = (Delivery)CurrentSession.GetValue(Session.SessionKeys.Delivery);

            IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IProductRepository repProduct = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            ////
           

            IList<string> nameList = new List<string>();
            nameList.Add("UCC");
            nameList.Add("BoxId");
            repProduct.BackUpProductByDnPure( Delivery, Editor);
            repProduct.BackUpProductInfoByDn( Delivery, Editor, nameList);
            repProduct.BackUpProductStatusByDnPure( Delivery, Editor);
           
            ////
            ProductStatus newStatus = new ProductStatus();
            newStatus.Editor = Editor;
            newStatus.Line = Line;
            newStatus.StationId = Station;
            newStatus.Status = StationStatus.Pass;
            newStatus.ReworkCode = "";

            repProduct.UpdateUnPackProductStatusByDn(newStatus, Delivery);
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();

            ////
            ProductLog newLog = new ProductLog();
            newLog.Editor = Editor;
            newLog.Line = Line;
            newLog.Station = Station;
            newLog.Status = StationStatus.Pass;

            repProduct.WriteUnPackProductLogByDn(Delivery,newLog);

            //////
            repProduct.UnPackProductInfoByDeliveryNoAndInfoType("UCC",Delivery);
            repProduct.UnPackProductInfoByDeliveryNoAndInfoType("BoxId", Delivery);
            
            ////////
            if (Station != "8U")
            {
                IList<IProduct> lstProduct = repProduct.GetProductObjListByDn(Delivery);
                if (lstProduct != null && lstProduct.Count > 0)
                {
                    foreach(IProduct tmp in lstProduct)
                    {
                        string carton = tmp.CartonSN;
                        DM.CartonInfoInfo condition = new DM.CartonInfoInfo();
                        condition.cartonNo = carton;
                        cartRep.DeleteCartonInfo(condition);

                        //mantis 1395
                        DM.CartonStatusInfo cond = new DM.CartonStatusInfo();
                        DM.CartonStatusInfo sv = new DM.CartonStatusInfo();
                        cond.cartonNo = tmp.CartonSN;
                        sv.station = Station;
                        sv.status = 1;
                        sv.editor = Editor;
                        sv.udt = DateTime.Now;
                        cartRep.UpdateCartonStatusDefered(CurrentSession.UnitOfWork, sv, cond);

                        DM.CartonLogInfo item = new DM.CartonLogInfo();
                        item.cartonNo = tmp.CartonSN;
                        item.cdt = DateTime.Now;
                        item.editor = Editor;
                        item.line = tmp.Status.Line;
                        item.station = Station;
                        item.status = 1;
                        cartRep.AddCartonLogInfoDefered(CurrentSession.UnitOfWork, item);
                        //mantis 1395


                        string palletNo = tmp.PalletNo;
                        DM.PakLocMasInfo setValue = new DM.PakLocMasInfo();
                        DM.PakLocMasInfo pakLoc_condition = new DM.PakLocMasInfo();
                        setValue.pno = "";
                        setValue.editor = Editor;
                        pakLoc_condition.pno = palletNo;
                        pakLoc_condition.tp = "PakLoc";
                        palletRep.UpdatePakLocMasInfo(setValue, pakLoc_condition);
                    }
                }
            }

            if (Station != "8U")
                repProduct.UnPackProductByDn(Delivery);
            else
                repProduct.UnPackProductByDnWithoutCartonSN(Delivery);

    /////////////////////
            CurrentDelivery.Status = "00";
            CurrentDelivery.Editor = this.Editor;
            CurrentDelivery.Udt = DateTime.Now;
            DeliveryRepository.Update(CurrentDelivery, CurrentSession.UnitOfWork);
    /////////////////////


            return base.DoExecute(executionContext);
        }
Exemple #5
0
        /// <summary>
        /// 產生BOX ID號號相关逻辑
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
        {
            IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();

            try
            {

                //仅当Delivery 的Flag 属性为N 的时候,需要Generate Ship to Carton Label Pdf Document:
                //1.	Generate Box Id
                //2.	Generate and Record Data for Ship to Carton Label   
                //3.	Generate Ship to Carton Label Pdf Document
                string boxID = "";
                Delivery curDev = deliveryRep.Find(product.DeliveryNo);
                //curDev.Editor = this.Editor;
                CurrentSession.AddValue(Session.SessionKeys.Delivery, curDev);

                string flagstr = (string)curDev.GetExtendedProperty("Flag");
                if (flagstr == "N")
                {

                    // 1.	解除Carton 结合的旧的Box Id
                    //参考方法:
                    //IF EXISTS (SELECT * FROM CartonInfo (NOLOCK ) WHERE CartonNo=@cn AND InfoType='BoxId')
                    //BEGIN
                    //DELETE CartonInfo WHERE artonNo=@cn AND InfoType='BoxId'
                    //END
                    CartonInfoInfo infoCond = new CartonInfoInfo();
                    infoCond.cartonNo = product.CartonSN;
                    infoCond.infoType = "BoxId";
                    IList<CartonInfoInfo> infoList = cartRep.GetCartonInfoInfo(infoCond);
                    if (infoList.Count > 0)
                    {
                        cartRep.DeleteCartonInfoDefered(CurrentSession.UnitOfWork, infoCond);
                    }

                    //2.	取当前日期/ Pallet UCC
                    //参考方法:
                    //SELECT @dt=GETDATE(),@ucc=''
                    //SELECT @ucc = UCC FROM Pallet (NOLOCK) WHERE PalletNo = @plt
                    string ucc = "";

                    Pallet curPallet = palletRep.Find(product.PalletNo);
                    ucc = curPallet.UCC;
                    int ucclength = ucc.TrimEnd().Length;
                    int index = ucc.TrimEnd().IndexOf(",");

                    //3.	取Delivery 相关属性
                    //参考方法:
                    //SELECT @po = RTRIM(PoNo), @model = Model FROM Delivery NOLOCK WHERE DeliveryNo = @dn
                    //SELECT @Flag = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'Flag'
                    //SELECT @BoxId_Tag = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'BoxId'
                    //SET @BoxId_Tag = LEFT(@BoxId_Tag, 10)
                    //SELECT @Region = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'RegId'
                    //SELECT @Deport = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'Deport'
                    //SELECT @boxReg = InfoValue FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @dn AND InfoType = 'BoxReg'

                    string po = "";
                    string model = "";
                    //string descr = "";
                    string flag = "";
                    string boxId_Tag = "";
                    string region = "";
                    string deport = "";
                    string boxReg = "";

                    po = curDev.PoNo.TrimEnd();
                    model = curDev.ModelName;
                    flag = (string)curDev.GetExtendedProperty("Flag");
                    boxId_Tag = (string)curDev.GetExtendedProperty("BoxId");
                    if (!string.IsNullOrEmpty(boxId_Tag) && boxId_Tag.Length >= 10)
                    {
                        boxId_Tag = boxId_Tag.Substring(0, 10);
                    }
                    else
                    {
                        boxId_Tag = "";
                    }
                    region = (string)curDev.GetExtendedProperty("RegId");
                    deport = (string)curDev.GetExtendedProperty("Deport");
                    boxReg = (string)curDev.GetExtendedProperty("BoxReg");


                    //4.	如果@boxReg<>'',则按照如下规则产生Box Id,并将产生的Box Id 存到变量@BoxId 中
                    if (!string.IsNullOrEmpty(boxReg))
                    {
                        //New Format of Box Id
                        //RRRR-SSSSS 
                        //Remark:
                        //RRRR – @boxReg
                        //- – 固定字符’-‘
                        //SSSSS – 流水号,31进制,基字符'0123456789BCDFGHJKLMNPQRSTVWXYZ';起始值为R0000;最大值为VZZZZ

                        string maxnum = "";
                        string prestr = "";

                        boxID = boxReg + "-";
                        prestr = boxID;
                        // 自己管理事务开始
                        SqlTransactionManager.Begin();
                        IUnitOfWork uof = new UnitOfWork();//使用自己的UnitOfWork

                        //ITC-1414-0065
                        //从NumControl中获取流水号
                        //GetMaxNumber
                        INumControlRepository numControl = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();

                        bool addflag = false;

                        maxnum = numControl.GetMaxNumber("BOXID", prestr + "{0}");
                        if (string.IsNullOrEmpty(maxnum))
                        {
                            maxnum = "R0000";
                            addflag = true;
                        }
                        else
                        {
                            MathSequenceWithCarryNumberRule marc = new MathSequenceWithCarryNumberRule(5, "0123456789BCDFGHJKLMNPQRSTVWXYZ");

                            //maxnum="CNU248000Y";                   
                            string numstr = maxnum.Substring(maxnum.Length - 5);
                            if (numstr.ToUpper() == "VZZZZ")
                            {
                                FisException fe = new FisException("CHK867", new string[] { });   //流水号已满!
                                throw fe;
                            }
                            numstr = marc.IncreaseToNumber(numstr, 1);
                            maxnum = numstr;

                        }

                        boxID = boxID + maxnum.ToUpper();

                        NumControl item = new NumControl();
                        item.NOType = "BOXID";
                        item.Value = boxID;
                        item.NOName = "";
                        item.Customer = "HP";

                        numControl.SaveMaxNumber(item, addflag, prestr + "{0}");

                        uof.Commit();  //立即提交UnitOfWork更新NumControl里面的最大值

                        SqlTransactionManager.Commit();//提交事物,释放行级更新锁

                    }
                    else
                    {
                        //5.	如果@boxReg='',则按照如下规则产生Box Id,并将产生的Box Id 存到变量@BoxId 中
                        //a)	当满足(LEN(RTRIM(@ucc))<>20 or (LEN(RTRIM(@ucc))=20 AND CHARINDEX(',',RTRIM(@ucc))>0)) AND RTRIM(@BoxId_Tag) ='' AND @Flag='N'条件时,按照如下规则产生Box Id

                        if ((ucclength != 20) || (ucclength == 20 && index >= 0 && string.IsNullOrEmpty(boxId_Tag.TrimEnd()) && flag == "N"))
                        {
                            string alarm = "";
                            switch (region)
                            {
                                case "SNA":
                                    alarm = "H410-Y";
                                    break;
                                case "SNL":
                                    alarm = "LA" + deport + "Y";
                                    break;
                                case "SNU":
                                    alarm = "D7" + deport + "Y";
                                    break;
                                case "SNE":
                                    alarm = "63D7-QY";
                                    break;
                                case "SAF":
                                    alarm = "H4FN-0C";
                                    break;
                            }
                            //SET ROWCOUNT 1
                            //SELECT @BoxId=RTRIM(BoxId) FROM SnoCtrl_BoxId WHERE Cust=@alarm AND valid=@editor
                            //IF @BoxId is not null
                            //DELETE FROM SnoCtrl_BoxId WHERE BoxId=@BoxId
                            //SET ROWCOUNT 0
                            //如果@BoxId IS NULL or @BoxId='',则报告错误:'BoxId已用完.'+@alarm
                            SnoCtrlBoxIdInfo snoConf = new SnoCtrlBoxIdInfo();
                            SnoCtrlBoxIdInfo snoSet = new SnoCtrlBoxIdInfo();
                            snoConf.cust = alarm;
                            snoConf.valid = "1";
                            IList<string> boxList = deliveryRep.GetBoxIdListFromSnoCtrlBoxId(snoConf);

                            snoSet.valid = Editor;
                            //deliveryRep.UpdateSnoCtrlBoxIdInfoDefered(CurrentSession.UnitOfWork, snoSet, snoConf);

                            if (boxList != null && boxList.Count > 0 && !string.IsNullOrEmpty(boxList[0]))
                            {
                                SnoCtrlBoxIdInfo dsnoConf = new SnoCtrlBoxIdInfo();
                                boxID = boxList[0].TrimEnd();
                                dsnoConf.boxId = boxID;
                                deliveryRep.DeleteSnoCtrlBoxIdInfoDefered(CurrentSession.UnitOfWork, dsnoConf);
                            }
                            else
                            {
                                List<string> erpara = new List<string>();
                                erpara.Add(alarm);
                                FisException fe = new FisException("PAK135", erpara);   //BoxId已用完.'+@alarm
                                throw fe;
                            }

                        }

                    }
                    //6.	如果LEN(RTRIM(@ucc))=20 AND CHARINDEX(',',@ucc)=0,则UCC 保存到CartonInfo 中;
                    //否则,将Box Id 保存到CartonInfo

                    //Record UCC
                    //IF EXISTS(SELECT * FROM CartonInfo NOLOCK WHERE CartonNo = @cn AND InfoType = 'UCC')
                    //UPDATE CartonInfo SET InfoValue = @ucc, Editor = @editor, Udt = GETDATE()
                    //WHERE CartonNo = @cn AND InfoType = 'UCC'
                    //ELSE
                    //INSERT INTO CartonInfo([CartonNo],[InfoType],[InfoValue],[Editor],[Cdt],[Udt])
                    //VALUES(@cn, 'UCC', @ucc, @editor, GETDATE(), GETDATE())
                    //Record Box Id
                    //IF EXISTS(SELECT * FROM CartonInfo NOLOCK WHERE CartonNo = @cn AND InfoType = 'BoxId')
                    //UPDATE CartonInfo SET InfoValue = @BoxId, Editor = @editor, Udt = GETDATE()
                    //WHERE CartonNo = @cn AND InfoType = 'BoxId'
                    //ELSE
                    //INSERT INTO CartonInfo([CartonNo],[InfoType],[InfoValue],[Editor],[Cdt],[Udt])
                    //VALUES(@cn, 'BoxId', @BoxId, @editor, GETDATE(), GETDATE())
                    string namestr = "";
                    string valuestr = "";
                    if ((ucclength == 20) && (index < 0))
                    {
                        namestr = "UCC";
                        valuestr = ucc;
                    }
                    else
                    {
                        namestr = "BoxId";
                        valuestr = boxID;
                    }

                    infoCond.infoType = namestr;
                    infoList = cartRep.GetCartonInfoInfo(infoCond);

                    CartonInfoInfo setCarton = new CartonInfoInfo();
                    setCarton.infoValue = valuestr;
                    setCarton.editor = Editor;
                    setCarton.udt = DateTime.Now;

                    if (infoList.Count > 0)
                    {
                        cartRep.UpdateCartonInfoDefered(CurrentSession.UnitOfWork, setCarton, infoCond);
                    }
                    else
                    {
                        setCarton.cartonNo = product.CartonSN;
                        setCarton.infoType = namestr;
                        setCarton.infoValue = valuestr;
                        cartRep.InsertCartonInfoDefered(CurrentSession.UnitOfWork, setCarton);
                    }
                }

                //Generate and Record Data for Ship to Carton Label 
                //调用HP_EDI.dbo.op_PackingData_20111031 @BoxId,@dn,@plt,@cn,@cdtEDI实现
                //Parameters:@BoxId – Box Id @dn – Delivery No @plt – Pallet No @cn – Carton No @cdtEDI - GETDATE()
                if (flagstr == "N")
                {
                    palletRep.CallOp_PackingDataDefered(CurrentSession.UnitOfWork, boxID, product.DeliveryNo, product.PalletNo, product.CartonSN, DateTime.Now);
                }
                
            }
            catch (Exception)
            {
                SqlTransactionManager.Rollback();
                throw;
            }
            finally
            {
                SqlTransactionManager.Dispose();
                SqlTransactionManager.End();
            }

            return base.DoExecute(executionContext);
        }
Exemple #6
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>();

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

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

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

            itemTypes.Add("CKK");

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

            productRepository.RemoveProductInfosByTypeDefered(CurrentSession.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(CurrentSession.UnitOfWork, infoCond);



            //Delete Product_Part 

           
            string[] prodList = new string[1];

            prodList[0] = currentProduct.ProId;

            ProductPart tmp = new ProductPart();

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

            
            //Update Product       

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

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


            Delivery oldDelivery = currentRepository.Find(DN);
            if (oldDelivery != null)
            {
                oldDelivery.Status = "00";
                currentRepository.Update(oldDelivery, CurrentSession.UnitOfWork);
            }
            return base.DoExecute(executionContext);
        }
Exemple #7
0
        /// <summary>
        /// 获取记入c:\serial.txt的信息
        /// </summary>
        /// <param name="dns">DN list</param>
        public IList<string> GetFileData(IList<S_DnUdt> dns)
        {
            logger.Debug("(_UploadShipmentData)GetFileData start");
            try
            {
                IList<string> ret = new List<string>();
                //foreach (string tmpDn in dns)
                string tmpDn;
                foreach (S_DnUdt sDnUdt in dns)
                {
                    tmpDn = sDnUdt.dn;
                    IList<string> subRet = new List<string>();
                    int caseNoByDN = 2; //0 - case A; 1 - case B; 2 - case C

                    Delivery dlv = deliveryRepository.Find(tmpDn);
                    //Check Udt..
                    if (sDnUdt.udt != dlv.Udt)
                    {
                        throw new FisException("PAK173", new string[] { tmpDn });

                    }
                    //Check Udt..

                    //IList<string> subRet = new List<string>();
                    
                    //Delivery dlv = deliveryRepository.Find(tmpDn);
                    
                    IList<DNInfoForUI> dlvInfoList = deliveryRepository.GetDNInfoList(tmpDn);
                    IList<IProduct> proList = productRepository.GetProductListByDeliveryNo(tmpDn);
                    foreach (IProduct p in proList)
                    {
                        string s = "";

                        string palletNo = "";
                        //UC Exception 1
                        if (p.PalletNo.Equals(""))
                        {
                            throw new FisException("PAK111", new string[] { tmpDn });
                            //subRet.Clear();
                            //subRet.Add(tmpDn + " Pallet Qty is error!");
                            //break;
                        }
                        else
                        {
                            //PalletNo:若Product.PalletNo的前两位等于NA or BA时,PalletNo=’~’+Product.PalletNo从第3位开始取10位;否则PalletNo=Product.PalletNo+’~’
                            if (p.PalletNo.StartsWith("NA") || p.PalletNo.StartsWith("BA"))
                            {
                                palletNo = "~" + p.PalletNo.Substring(2, 10);
                            }
                            else
                            {
                                palletNo = p.PalletNo + "~";
                            }
                        }
                        
                        //Boxid:Product 结合的Carton在CartonInfo里InfoType=BoxId或UCC对应记录的InfoValue
                        string boxId = "";

                        CartonInfoInfo cond = new CartonInfoInfo();
                        cond.cartonNo = p.CartonSN;
                        cond.infoType = "BoxId";

                        IList<CartonInfoInfo> pInfoList = cartonRepository.GetCartonInfoInfo(cond);
                        if (pInfoList.Count <= 0)
                        {
                            cond.infoType = "UCC";
                            pInfoList = cartonRepository.GetCartonInfoInfo(cond);
                        }

                        if (pInfoList.Count > 0)
                        {
                            boxId = pInfoList[0].infoValue;
                        }
                        
                        s += dlv.DeliveryNo.Substring(0, 10);
                        s += "~";
                        s += dlv.DeliveryNo.Substring(dlv.DeliveryNo.Length - 6);
                        s += "~";
                        s += dlv.PoNo;
                        s += "~";
                        s += palletNo;
                        s += "~";
                        s += p.CUSTSN;
                        s += "~";
                        s += boxId;
                        s += "~1~";
                        s += p.Model.Substring(1,1)=="C" ? "C" : "O";
                        s += "~~~~~";
                        subRet.Add(s);
                    }
                    foreach (string ele in subRet)
                    {
                        ret.Add(ele);
                    }
                }
                //   Check Udt again
                foreach (S_DnUdt dnUdt in dns)
                {
                    Delivery dnObj = deliveryRepository.Find(dnUdt.dn);
                    if (dnUdt.udt != dnObj.Udt)
                    {
                        throw new FisException("PAK173", new string[] { dnUdt.dn });

                    }

                }
                //Check Udt again
                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);
            }
            finally
            {
                logger.Debug("(_UploadShipmentData)GetFileData end");
            }
        }
Exemple #8
0
        /// <summary>
        /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string CartonNo = (string)CurrentSession.GetValue(Session.SessionKeys.Carton);
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();
            IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IProductRepository repProduct = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
    
            IList<IProduct> lstProduct = repProduct.GetProductListByCartonNo(CartonNo);

            CartonInfoInfo condition = new CartonInfoInfo();
            condition.cartonNo = CartonNo;
            cartRep.DeleteCartonInfo(condition);
            DeliveryRepository.UpdateDeliveryForStatusChange(Editor,  CartonNo);
            //
            CartonStatusInfo setValue = new CartonStatusInfo();
            CartonStatusInfo status_condition = new CartonStatusInfo();
            setValue.cartonNo = CartonNo;
            setValue.status = 1;
            setValue.editor = Editor;
            setValue.station = Station;

            status_condition.cartonNo = CartonNo; 
            cartRep.UpdateCartonStatus( setValue,  status_condition);

           
            ///////////////
            CartonLogInfo item = new CartonLogInfo();
            item.cartonNo = CartonNo;
            item.editor = Editor;
            item.line = Line;
            item.station = Station;
            item.status = 1;
            cartRep.AddCartonLogInfo(item);
            
           //////////////////

            CurrentSession.AddValue(Session.SessionKeys.ProdList, lstProduct);
            CurrentSession.AddValue(Session.SessionKeys.DnIndex, 0);
            CurrentSession.AddValue(Session.SessionKeys.DnCount, lstProduct.Count);

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

            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(CurrentSession.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(CurrentSession.UnitOfWork, prodList, tmp, Editor);

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

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


            return base.DoExecute(executionContext);
        }