Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="custSN"></param>
        /// <param name="line"></param>
        /// <param name="code"></param>
        /// <param name="floor"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ArrayList InputSN(string custSN, string line, string editor, string station, string customer)
        {
            logger.Debug("(CombineCOAandDNNew)InputSN start, custSn:" + custSN);

            try
            {
                List<string> erpara = new List<string>();

                var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", SessionType);

                    string wfName, rlName;

                    RouteManagementUtils.GetWorkflow(station, "CombineCOAandDNNew.xoml", "", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }

                //========================================================
                ArrayList retList = new ArrayList();
                Product curProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product);
                Delivery curDn = (Delivery)currentSession.GetValue(Session.SessionKeys.Delivery);

                //如果是Win8 机型,如果Image D/L 未上传相关数据,则报告错误:“Win 8 信息不完整!”

                //if exists(select * from ModelBOM a (nolock), Part b (nolock) 
                //where a.Material = @Model
                //and a.Component = b.PartNo
                //and b.BomNodeType = 'P1'
                //and b.Descr LIKE 'ECOA%')
                //select 'This product is WIN8 Model'

                //if 3 <> (select COUNT(*) from ProductInfo nolock 
                //where ProductID = @ProductID and InfoType in ('P/N','Key', 'Hash'))
                //select 'Win 8 信息不完整!'
                string win8Flag = "";
                IList<MoBOMInfo> win8list = bomRep.GetPnListByModelAndBomNodeTypeAndDescr(curProduct.Model, "P1", "ECOA");
                if (win8list.Count > 0)
                {
                    IList<string> typeList = new List<string>();
                    typeList.Add("P/N");
                    typeList.Add("Key");
                    typeList.Add("Hash");
                    IList<IMES.FisObject.FA.Product.ProductInfo> infoList = productRep.GetProductInfoList(curProduct.ProId, typeList);
                    if (infoList == null || infoList.Count != 3)
                    {
                        SessionManager.GetInstance.RemoveSession(currentSession);
                        FisException ex;
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK885", erpara);//Win 8 信息不完整!
                        throw ex;
                    }
                    win8Flag = "WIN8";
                }

                //只有当前PRODUCT没有收集COA (Product_Part)并且在ModelBOM 中Model 下阶存在BomNodeType = 'P1',
                //且IMES_GetData..Part.Descr LIKE 'COA%' 的Part的情况下,才需要收集COA 
                string coaPn = "";
                string productCoa = "";
                IHierarchicalBOM curBom = bomRep.GetHierarchicalBOMByModel(curProduct.Model);
                IList<IBOMNode> bomNodeList = curBom.FirstLevelNodes;
                foreach (IBOMNode bomNode in bomNodeList)
                {
                    if ((bomNode.Part.BOMNodeType == "P1") && bomNode.Part.Descr.IndexOf("COA") == 0)
                    {
                        coaPn = bomNode.Part.PN;
                        currentSession.AddValue("COABOMPart", bomNode.Part);
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(coaPn))
                {
                    if (curProduct.ProductParts != null && curProduct.ProductParts.Count > 0)
                    {
                        foreach (ProductPart iprodpart in curProduct.ProductParts)
                        {
                            IPart curPart = partRep.GetPartByPartNo(iprodpart.PartID);
                            if (curPart.BOMNodeType == "P1" && curPart.Descr.IndexOf("COA") == 0)
                            {
                                productCoa = curPart.PN;
                                break;
                            }
                        }
                    }
                }
                //(此处存在例外情况:当使用Code = @CustomerSN and Type =  'SN' 
                //或者Code = @DeliveryNo and Type =  'DN'查询InternalCOA 表 存在记录时,不需要收集COA)
                if (!string.IsNullOrEmpty(coaPn))
                {
                    bool snflag = partRep.CheckExistInternalCOA(curProduct.CUSTSN, "SN");
                    bool dnflag = partRep.CheckExistInternalCOA(curProduct.CUSTSN, "DN");
                    if (snflag || dnflag)
                    {
                        coaPn = "";
                    }
                }

                ProductModel curModel = new ProductModel();
                curModel.ProductID = curProduct.ProId;
                curModel.CustSN = curProduct.CUSTSN;
                curModel.Model = curProduct.Model;

                string custPN = "";
                DNForUI autoDn = new DNForUI();
                if (!curProduct.IsBT)
                {
                    autoDn.DeliveryNo = curDn.DeliveryNo;
                    autoDn.ModelName = curDn.ModelName;
                    custPN = deliveryRep.GetDeliveryInfoValue(curDn.DeliveryNo, "PartNo");
                    int startindex = custPN.IndexOf("/") + 1;
                    if (startindex < 0)
                    {
                        startindex = 0;
                    }
                    autoDn.Editor = custPN.Substring(startindex, custPN.Length - startindex);//CustomerPN
                    autoDn.PoNo = curDn.PoNo;
                    autoDn.ShipDate_Str = curDn.ShipDate.Year.ToString("d4") + "/"
                        + curDn.ShipDate.Month.ToString("d2") + "/" + curDn.ShipDate.Day.ToString("d2");
                    autoDn.Qty = curDn.Qty;
                    IList<IProduct> productList = new List<IProduct>();
                    productList = productRep.GetProductListByDeliveryNo(curDn.DeliveryNo);
                    autoDn.ShipmentID = Convert.ToString(productList.Count);//packetQty
                }
                string cdsiFlag = (string)currentSession.GetValue("CDSI");

                //保存正确COAPN
                currentSession.AddValue("COAPN", coaPn);
                currentSession.AddValue(Session.SessionKeys.COASN, "");

                retList.Add(curModel);
                retList.Add(curProduct.IsBT);
                retList.Add(coaPn);
                retList.Add(autoDn);
                retList.Add(win8Flag);
                retList.Add(cdsiFlag);
                retList.Add(productCoa);
                //========================================================

                return retList;

            }
            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("(CombineCOAandDNNew)InputSN end, uutSn:" + custSN);
            }
        }
Example #2
0
        public ProductModel ScanSN(string firstSN, string custSN)
        {
            logger.Debug("(_052VirtualPallet)ScanSN start, firstSN:" + firstSN + " custSN:" + custSN);

            try
            {
                FisException ex;
                List<string> erpara = new List<string>();
                string sessionKey = firstSN;
                Session Session = SessionManager.GetInstance.GetSession(sessionKey, TheType);


                if (Session == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {
                    Session.AddValue(Session.SessionKeys.CustSN, custSN);
                    Session.Exception = null;
                    Session.SwitchToWorkFlow();

                    //check workflow exception
                    if (Session.Exception != null)
                    {
                        if (Session.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            Session.ResumeWorkFlow();
                        }
                        throw Session.Exception;
                    }

                    IProduct prod = (Product)(Session.GetValue(Session.SessionKeys.Product));
                   
                    ProductModel ProductModel = new ProductModel();

                    ProductModel.CustSN = prod.CUSTSN;
                    ProductModel.Model = prod.Model;
                    ProductModel.ProductID = prod.ProId;

                    return ProductModel;
                }
            }

            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(_052VirtualPallet)ScanSN end, firstSN:" + firstSN + " custSN:" + custSN);
            }
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="custSN"></param>
        /// <param name="line"></param>
        /// <param name="code"></param>
        /// <param name="floor"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ArrayList InputSN(Boolean queryflag, string custSN, string line, string code, string floor, 
                                                    string editor, string station, string customer)
        {
            logger.Debug("(PDPALabel01)InputSN start, custSn:" + custSN);

            try
            {
                var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", SessionType);
                    
                    //wfArguments.Add("Floor", floor);
                    //wfArguments.Add("Code", code);

                    string wfName, rlName;
                    string xmlname = "";
                    if (!queryflag)
                    {
                        xmlname = "PDPALabel02.xoml";
                    }
                    else
                    {
                        xmlname = "PDPALabel02Query.xoml";
                    }
                    RouteManagementUtils.GetWorkflow(station, xmlname, "", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);
                    
                    currentSession.AddValue(Session.SessionKeys.Floor, floor);
                    currentSession.AddValue(Session.SessionKeys.MBCode,code);
                    if (!queryflag)
                    {
                        currentSession.AddValue(Session.SessionKeys.IsComplete, false);

                    }
                    else
                    {
                        currentSession.AddValue(Session.SessionKeys.IsComplete, true);

                    }
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }

                //========================================================
                ArrayList retList = new ArrayList();
                Product curProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product);
                ProductModel curModel = new ProductModel();
                
                IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
                IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();

                //如果Product 已经结合Delivery,如果该Delivery 的状态(Delivery.Status)为“98”,
                //则报告错误:“该Product 结合Delivery 资料已经上传SAP,请联系相关人员!”
                if (!queryflag)
                {
                    Delivery assignDelivery = null;
                    if (!string.IsNullOrEmpty(curProduct.DeliveryNo))
                    {
                        assignDelivery = deliveryRep.Find(curProduct.DeliveryNo);
                        if (assignDelivery.Status == "98")
                        {
                            SessionManager.GetInstance.RemoveSession(currentSession);
                            FisException ex;
                            List<string> erpara = new List<string>();
                            erpara.Add(sessionKey);
                            ex = new FisException("PAK125", erpara);//该Product 结合Delivery 资料已经上传SAP,请联系相关人员!
                            throw ex;
                        }
                    }
                }

                //如果ModelBOM 中Model 的直接下阶存在BomNodeType = 'PL', UPPER(Descr) LIKE ‘WWAN%’ 
                //则需要进行WWAN Check,
                //如果ModelBOM 中Model 的直接下阶存在PartNo = '6060B0483201'的Part,则需要进行HITACHI Check No Check
                IHierarchicalBOM curBom = bomRep.GetHierarchicalBOMByModel(curProduct.Model);
                IList<IBOMNode> bomNodeList = curBom.FirstLevelNodes;
                Boolean wwanCheck = false;
                Boolean hitachiCheck = false;

                foreach (IBOMNode bomNode in bomNodeList)
                {
                    if (bomNode.Part.BOMNodeType == "PL")
                    {
                        if (bomNode.Part.Descr.Length >= 4)
                        {
                            if (bomNode.Part.Descr.ToUpper().Substring(0, 4) == "WWAN")
                            {
                                wwanCheck = true;
                            }
                        }
                    }
                    if (bomNode.Part.PN == "6060B0483201")
                    {
                        hitachiCheck = true;
                    }
                    if (wwanCheck && hitachiCheck)
                    {
                        break;
                    }
                }


                //如果Model 的10,11码为'29' 或者'39',
                //则需要进行Warranty Label Check,在Message 文本框中显示:“请刷Warranty Card 上的SN号码!”
                Boolean SNCheck = false;
                string tmpstr = string.Empty;
                if (curProduct.Model.Length > 11)
                {
                    tmpstr = curProduct.Model.Substring(9, 2);
                }

                if ((tmpstr == "29") || (tmpstr == "39"))
                {
                    SNCheck = true;
                }

                curModel.ProductID = curProduct.ProId;
                curModel.CustSN = curProduct.CUSTSN;
                curModel.Model = curProduct.Model;
                retList.Add(curModel);   
                retList.Add(wwanCheck);
                retList.Add(hitachiCheck);
                retList.Add(SNCheck);
                //========================================================

                return retList;
                
            }
            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("(PAQCOutputImpl)InputSN end, uutSn:" + custSN);
            }
        }
Example #4
0
        /// <summary>
        /// 输入Product Id和相关信息
        /// </summary>
        /// <param name="pdLine">Pd Line</param>
        /// <param name="prodId">Product Id</param>
        /// <param name="editor">operator</param>
        public ArrayList InputProdId(string pdLine, string prodId, string editor, string stationId, string customer)
        {
            logger.Debug("(GenerateCustomerSNImpl)InputProdId start, [pdLine]:" + pdLine
                + " [prodId]: " + prodId
                + " [editor]:" + editor
                + " [station]:" + stationId
                + " [customer]:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = prodId;

            try
            {
                Session session = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);

                if (session == null)
                {
                    session = new Session(sessionKey, ProductSessionType, editor, stationId, pdLine, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    //一个MB_SNo对应一个workflow
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", stationId);
                    wfArguments.Add("CurrentFlowSession", session);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", pdLine);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", ProductSessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(stationId, "022GenerateCustomerSN.xoml", "022GenerateCustomerSN.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    session.AddValue(Session.SessionKeys.IsComplete, false);
                    session.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(session))
                    {
                        session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    session.WorkflowInstance.Start();
                    session.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }

                //session.SwitchToWorkFlow();

                //check workflow exception
                if (session.Exception != null)
                {
                    if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        session.ResumeWorkFlow();
                    }

                    throw session.Exception;
                }

                ArrayList retList = new ArrayList();

                Product tempProduct = (Product)session.GetValue(Session.SessionKeys.Product);
                ProductModel curProduct = new ProductModel();

                curProduct.CustSN = tempProduct.CUSTSN;
                curProduct.ProductID = tempProduct.ProId;
                curProduct.Model = tempProduct.Model;


                //调用LabelType时,增加以下判断:
                //若该Product的Family.toUpper()中包含’ AKASHI’,则LabelType用’SN_AKASHI_Label’
                //若Product的Family.toUpper()中不包含’ AKASHI’,则LabelType用’SN Label’
                string labelType = "";
                if (tempProduct.Family.ToUpper().IndexOf("AKASHI") < 0)
                {
                    labelType = "SN Label";
                }
                else
                {
                    labelType = "SN_AKASHI_Label";
                }
                retList.Add(curProduct);
                retList.Add(labelType);

                return retList;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(GenerateCustomerSNImpl)InputProdId end, [pdLine]:" + pdLine
                    + " [prodId]: " + prodId
                    + " [editor]:" + editor
                    + " [station]:" + stationId
                    + " [customer]:" + customer);
            }
        }
Example #5
0
        /// <summary>
        /// 刷uutSn,启动工作流,检查输入的uutSn,卡站,获取ProductModel
        /// </summary>
        /// <param name="uutSn"></param>
        /// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <returns>ProductModel</returns>
        public ArrayList InputSN(string uutSn, string line, string editor, string station, string customer)
        {
            logger.Debug("(PAQCOutputImpl)InputSN start, uutSn:" + uutSn);

            try
            {
                //var currentProduct = CommonImpl.GetProductByInput(uutSn, CommonImpl.InputTypeEnum.CustSN);
                var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                var currentProduct = productRepository.GetProductByIdOrSn(uutSn);
                FisException ex;
                List<string> erpara = new List<string>();
                if (currentProduct == null)
                {
                    erpara.Add(uutSn);
                    throw new FisException("SFC002", erpara);
                }

                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", SessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "PAQCOutputForDocking.xoml", "PAQCOutputForDocking.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        //FisException ex;
                        //List<string> erpara = new List<string>();
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    //FisException ex;
                    //List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }
                //==============================================================================
                ArrayList retList = new ArrayList();
                //Get infomation
                Product curProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product);
                IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();
                
                //a.	如果Product 在QCStatus 中不存在记录,则报告错误:“此Product 在QCStatus 中不存在记录,请联系相关人员”

                if (curProduct.QCStatus.Count == 0)
                {
                    //ITC-1414-0077, Jessica Liu, 2012-6-6
                    cancel(sessionKey);

                    //FisException ex;
                    //List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("PAK110", erpara);//此Product 在QCStatus 中不存在记录,请联系相关人员
                    throw ex;

                }
                
                currentModel.CustSN = curProduct.CUSTSN;
                currentModel.ProductID = curProduct.ProId;
                currentModel.Model = curProduct.Model;

                retList.Add(currentModel);


                //select b.Line + ' ' + b.Descr from ProductStatus a (nolock), Line b (nolock)
	            //WHERE a.ProductID = @ProductId
		        //AND a.Line = b.Line
                ILineRepository lineRepository = RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
                Line pdline = lineRepository.Find(curProduct.Status.Line);

                string strline ="";
                strline = pdline.Id + " " + pdline.Descr;
                retList.Add(strline);
                //===============================================================================

                return retList;

            }
            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("(PAQCOutputImpl)InputSN end, uutSn:" + uutSn);
            }
        }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="prodId"></param>
        /// <param name="WWANSN"></param>
        /// <returns></returns>
        public ArrayList checkCOA(string prodId, string WWANSN)
        {
            logger.Debug("(PDPALabel02)checkCOA start,"
                + " [prodId]: " + prodId);

            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = prodId;

            try
            {

                Session curSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (curSession == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    //ex.logErr("", "", "", "", "83");
                    //logger.Error(ex);
                    throw ex;
                }
                else
                {
                    //========================================================

                    Product curProduct = (Product)curSession.GetValue(Session.SessionKeys.Product);
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                    ICOAStatusRepository coaRep = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();


                    IHierarchicalBOM curBom = bomRep.GetHierarchicalBOMByModel(curProduct.Model);
                    IList<IBOMNode> bomNodeList = curBom.FirstLevelNodes;
                    IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    Boolean needCheck = false;
                    Boolean errFlag = false;

                    //1.当ModelBOM 中Model 的直接下阶中有BomNodeType = 'P1',
                    //且Descr LIKE 'COA%' 的Part 存在时,需要按照如下步骤检查COA

                    foreach (IBOMNode bomNode in bomNodeList)
                    {
                        if ((bomNode.Part.BOMNodeType == "P1") && bomNode.Part.Descr.Contains("COA"))
                        {
                            needCheck = true;
                            break;
                        }
                    }

                    //2.取于Product 结合的COA 资料,如果其Part No 与该COA 在COAStatus 表中的IECPN 不同时,
                    //需要报告错误:'COA not matches! '
                    if (needCheck)
                    {
                        foreach (IProductPart partNode in curProduct.ProductParts)
                        {
                            if (partNode.PartType == "P1")
                            {
                                IPart part = partRep.Find(partNode.PartID);
                                if (part.Descr.Contains("COA"))
                                {
                                    COAStatus status = coaRep.Find(partNode.PartID);
                                    if (partNode.PartID != status.IECPN)
                                    {
                                        errFlag = true;
                                    }
                                }
                            }
                        }
                        if (errFlag)
                        {
                            erpara.Add(sessionKey);
                            ex = new FisException("PAK075", erpara);//COA not matches!
                            throw ex;
                        }
                    }
                    //========================================================
                    curSession.Exception = null;

                    //Release The XXX: 2012.04.19 LiuDong
                    //try
                    //{
                        curSession.SwitchToWorkFlow();
                    //}
                    //finally
                    //{
                    //    IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                    //    productRep.ReleaseLockByTransThread("Ucc", (Guid)curSession.GetValue<Guid>(Session.SessionKeys.lockToken_Ucc));
                    //    productRep.ReleaseLockByTransThread("Box", (Guid)curSession.GetValue<Guid>(Session.SessionKeys.lockToken_Box));
                    //    productRep.ReleaseLockByTransThread("Loc", (Guid)curSession.GetValue<Guid>(Session.SessionKeys.lockToken_Loc));
                    //    productRep.ReleaseLockByTransThread("Pallet", (Guid)curSession.GetValue<Guid>(Session.SessionKeys.lockToken_Pallet));
                    //    productRep.ReleaseLockByTransThread("Delivery", (Guid)curSession.GetValue<Guid>(Session.SessionKeys.lockToken_DN));
                    //}
                    //Release The XXX: 2012.04.19 LiuDong

                    if (curSession.Exception != null)
                    {
                        if (curSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            curSession.ResumeWorkFlow();
                        }

                        throw curSession.Exception;
                    }
                    //========================================================

                    ArrayList retList = new ArrayList();
                    ProductModel curModel = new ProductModel();
                    IList<WipBufferDef> wipBufferList = (IList<WipBufferDef>)curSession.GetValue("WipBuffer");

                    //CmdGeneratePdf(DeliveryNo,Pallet,Box,SN)
                    //'DeliveryNo – Product 结合的Delivery
                    //'Pallet – Product 结合的Pallet
                    //'Box – Product 结合的Box Id 或者UCC
                    //'SN – Product Id
                    //' CmbPL.value – UI 上选择的PdLine对应的IMES_GetData..Line.Line
                    string boxid = (string)curProduct.GetExtendedProperty("BoxId");
                    if (string.IsNullOrEmpty(boxid))
                    {
                        boxid = (string)curProduct.GetExtendedProperty("UCC");
                        if (string.IsNullOrEmpty(boxid))
                        {
                            boxid = "";
                        }
                    }

                    string pdf = (string)curSession.GetValue("CreatePDF");

                    // pdf
                    IPizzaRepository repPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();

                    string templatename = "";
                    //select @doc_set_number = DOC_SET_NUMBER  from [PAK.PAKComn] where left(InternalID,10) = @InternalID的前10位
                    if (!string.IsNullOrEmpty(pdf))
                    {
                        IList<string> docnumList = repPizza.GetDocSetNumListFromPakDashPakComnByLikeInternalID(curProduct.DeliveryNo.Substring(0, 10));
                        //SELECT @templatename = XSL_TEMPLATE_NAME 	FROM [PAK.PAKRT] WHERE DOC_CAT = @doctpye AND DOC_SET_NUMBER = @doc_set_number
                        if (docnumList.Count > 0)
                        {
                            IList<string> tempList = repPizza.GetXslTemplateNameListFromPakDashPakComnByDocCatAndDocSetNumer("Box Ship Label", docnumList[0]);
                            if (tempList.Count > 0)
                                templatename = tempList[0];
                        }
                    }
                    retList.Add(wipBufferList);
                    retList.Add(curProduct.DeliveryNo);
                    retList.Add(curProduct.PalletNo);
                    retList.Add(boxid);
                    retList.Add(pdf);
                    retList.Add(templatename);

                    //========================================================
                    return retList;

                }
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(PDPALabel02)InputWWANSN end,"
                   + " [prodId]: " + prodId);
            }

        }
Example #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="editor"></param>
        /// <param name="line"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        public ArrayList InputKey(string key, string editor, string line, string station, string customer)
        {
            logger.Debug(" InputKey start, key:" + key);
            try
            {
                Session currentSession = SessionManager.GetInstance.GetSession(key, currentSessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(key, currentSessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", key);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", currentSessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "KBEsop.xoml", "", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + key + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(key);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(key);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }


                ArrayList result = new ArrayList();
                Product currentProdct = currentSession.GetValue(Session.SessionKeys.Product) as Product;
                ProductModel resultModel = new ProductModel();
                resultModel.CustSN = currentProdct.CUSTSN;
                resultModel.ProductID = currentProdct.ProId;
                resultModel.Model = currentProdct.Model;

                result.Add(resultModel);
                result.Add(currentSession.GetValue(Session.SessionKeys.PicPositionName));
                return result;

            }
            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(" InputKey end, key:" + key);
            }
        }
Example #8
0
        /// <summary>
        /// 刷custSn,启动工作流,检查输入的custSn,卡站,获取ProductModel
        /// </summary>
        /// <param name="queryflag"></param>
        /// <param name="custSN"></param>
        /// <param name="line"></param>
        /// <param name="code"></param>
        /// <param name="floor"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ArrayList InputSN(Boolean queryflag, string custSN, string line, string code, string floor,
                                                    string editor, string station, string customer)
        {
            logger.Debug("(PDPALabel01)InputSN start, custSn:" + custSN);

            try
            {
                var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", SessionType);

                    //wfArguments.Add("Floor", floor);
                    //wfArguments.Add("Code", code);

                    string wfName, rlName;

                    string xmlname = "";
                    if (!queryflag)
                    {
                        xmlname = "PDPALabel01.xoml";
                    }
                    else
                    {
                        xmlname = "PDPALabel01Query.xoml";
                    }
                    RouteManagementUtils.GetWorkflow(station, xmlname, "", out wfName, out rlName);//PDPLabel01.rules
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.Floor, floor);
                    currentSession.AddValue(Session.SessionKeys.MBCode, code);
                    currentSession.AddValue(Session.SessionKeys.IsPalletChange, queryflag);

                    if (!queryflag)
                    {
                        currentSession.AddValue(Session.SessionKeys.IsComplete, false);

                    }
                    else
                    {
                        currentSession.AddValue(Session.SessionKeys.IsComplete, true);

                    }
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }

                //========================================================
                ArrayList retList = new ArrayList();
                Product curProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product);
                ProductModel curModel = new ProductModel();
                IList<WipBufferDef> wipBufferList = (IList<WipBufferDef>)currentSession.GetValue("WipBuffer");

                /*IList<WipBuffer> wipBufferList = new List<WipBuffer>();
                for (int i = 1; i < 14; i++)
                {
                    WipBuffer item = new WipBuffer();
                    item.PartNo = "PartNo"+Convert.ToString(i);
                    item.Tp = "TP"+Convert.ToString(i);
                    item.Qty = i;
                    wipBufferList.Add(item);
                }
                */

                string wlabel = (string)currentSession.GetValue("WLabel");
                string clabel = (string)currentSession.GetValue("LanguageLabel");
                string cmessage = (string)currentSession.GetValue("LanguageMessage");
                string llabel = (string)currentSession.GetValue("LANOMLabel");

                curModel.ProductID = curProduct.ProId;
                curModel.CustSN = curProduct.CUSTSN;
                curModel.Model = curProduct.Model;
                retList.Add(curModel);
                retList.Add(wipBufferList);

                retList.Add(wlabel);
                retList.Add(clabel);
                retList.Add(cmessage);
                retList.Add(llabel);
                //========================================================

                return retList;

            }
            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("(PDPALabel01)InputSN end, uutSn:" + custSN);
            }
        }
Example #9
0
        /// <summary>
        /// Change Model Save
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            var moList = CurrentSession.GetValue(Session.SessionKeys.VirtualMOList) as IList<string>;
            string VirtualMO = moList[0];
            string model1 = CurrentSession.GetValue(Session.SessionKeys.Model1) as string;
            string model2 = CurrentSession.GetValue(Session.SessionKeys.Model2) as string;
            string SelectStation = CurrentSession.GetValue(Session.SessionKeys.SelectStation) as string;
            int changeQty = (int)CurrentSession.GetValue(Session.SessionKeys.Qty);
            string productIDStr = CurrentSession.GetValue(Session.SessionKeys.ProductIDListStr) as string;

            SqlParameter[] paramsArray = new SqlParameter[7];
            paramsArray[0] = new SqlParameter("Model1", model1);
            paramsArray[1] = new SqlParameter("Model2", model2);
            paramsArray[2] = new SqlParameter("VirtualMO", VirtualMO);
            paramsArray[3] = new SqlParameter("ChangeQty", changeQty);
            paramsArray[4] = new SqlParameter("ProductIDStr", productIDStr);
            paramsArray[5] = new SqlParameter("Editor", Editor);
            paramsArray[6] = new SqlParameter("Station", SelectStation);


            IProductRepository CurrentProductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            DataTable ProductIDCustSNTable = CurrentProductRepository.ExecSpForQuery(SqlHelper.ConnectionString_FA, "IMES_ChangeModelSave", paramsArray);
            if (ProductIDCustSNTable != null && ProductIDCustSNTable.Rows.Count > 0)
            {
                List<ProductModel> ProductList = new List<ProductModel>();
                int maxNum = ProductIDCustSNTable.Rows.Count;
                for (int i = 0; i < maxNum; i++)
                {
                    ProductModel temp = new ProductModel();
                    temp.ProductID = ProductIDCustSNTable.Rows[i][0] as string;
                    temp.CustSN = ProductIDCustSNTable.Rows[i][1] as string;
                    ProductList.Add(temp);
                }
                CurrentSession.AddValue(Session.SessionKeys.ProductIDListStr, ProductList);
            }

            return base.DoExecute(executionContext);
        }
Example #10
0
        /// <summary>
        /// 重印标签
        /// </summary>

        IList<PrintItem> IMacPrint.ReprintLabel(string prodOrsn, string line, string editor, string station, string customer, string reason, IList<PrintItem> printItems, out string model, out string curProductID)
        {
            logger.Debug("(MacPrintImpl)ReprintLabel start, ProductIDOrCustSN:" + prodOrsn + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer + "reason:" + reason);
            try
            {
                /// ProductIDOrCustSN类型的InputType
                /// 为了确保一个Product不会同时被两个操作员刷入,需要用ProductID做主键启动工作流
                /// 此站若输入的是SN,需要先根据SN获取Product调用CommonImpl.GetProductByInput(),将获得的Product放到Session.Product,再用ProductID启动工作流

                var currentProduct = CommonImpl.GetProductByInput(prodOrsn, CommonImpl.InputTypeEnum.ProductIDOrCustSN);
                string sessionKey = currentProduct.ProId;
                curProductID = sessionKey;

                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, ProductSessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station",station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", ProductSessionType);

                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow("046MacRePrint.xoml", "", wfArguments);

                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.PrintItems, printItems);
                    currentSession.AddValue(Session.SessionKeys.Reason, reason);
                    currentSession.AddValue(Session.SessionKeys.PrintLogBegNo, sessionKey);
                    currentSession.AddValue(Session.SessionKeys.PrintLogEndNo, sessionKey);
                    currentSession.AddValue(Session.SessionKeys.PrintLogDescr, "Mac");

                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(prodOrsn);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(prodOrsn);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }

                IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();

                currentModel.ProductID = currentProduct.ProId;
                currentModel.CustSN = currentProduct.CUSTSN;
                currentModel.Model = currentProduct.Model;

                model = currentModel.Model;
               
                return (IList<PrintItem>)currentSession.GetValue(Session.SessionKeys.PrintItems);
              
            }
            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("(MacPrintImpl)ReprintLabel end, ProductIDOrCustSN:" + prodOrsn + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer + "reason:" + reason);
            }
        }
Example #11
0
        /// <summary>
        /// 启动工作流,根据输入productID获取Model,成功后调用CheckSN
        /// </summary>
        /// <param name="productID">product id</param>
        /// <param name="line">product line</param>
        /// <param name="editor">editor</param>
        /// <param name="station">station</param>
        /// <param name="customer">customer</param>
        /// <returns>返回ProductModel</returns>
        public ProductModel InputUUT(string prodId, string pdLine, string editor, string stationId, string customerId)
        {
            logger.Debug("(_FGShippingLabelTRO)InputUUT start, pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);

            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = prodId;
            try
            {
                Session Session = SessionManager.GetInstance.GetSession(sessionKey, TheType);

                if (Session == null)
                {
                    Session = new Session(sessionKey, TheType, editor, stationId, pdLine, customerId);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    //一个MB_SNo对应一个workflow
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", stationId);
                    wfArguments.Add("CurrentFlowSession", Session);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", pdLine);
                    wfArguments.Add("Customer", customerId);
                    wfArguments.Add("SessionType", TheType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(stationId, "050FGShippingLabelTRO.xoml", "050FGShippingLabelTRO.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    Session.AddValue(Session.SessionKeys.IsComplete, false);
                    Session.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(Session))
                    {
                        Session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }
                    Session.WorkflowInstance.Start();
                    Session.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                //check workflow exception
                if (Session.Exception != null)
                {
                    if (Session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        Session.ResumeWorkFlow();
                    }
                    throw Session.Exception;
                }
                IProduct product = (IProduct)Session.GetValue(Session.SessionKeys.Product);
                ProductModel currentModel = new ProductModel();
                if (product != null)
                {
                    currentModel.CustSN = product.CUSTSN;
                    currentModel.ProductID = product.ProId;
                    currentModel.Model = product.Model;
                }
                return currentModel;

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(_FGShippingLabelTRO)InputUUT end, pdLine:" + pdLine + " prodId:" + prodId + " editor:" + editor + " stationId:" + stationId + " customerId:" + customerId);

            }
        }
        private void DoWfGenerateCustomerSNForDocking(string pdLine, string prodId, string editor, string stationId, string customer,
                                out IMES.DataModel.ProductModel curProduct, string newmodel)
		{
			FisException ex;
            List<string> erpara = new List<string>();
			string sessionKey = prodId;
			Session session = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);

			if (session == null)
			{
                if (!string.IsNullOrEmpty(newmodel))
                {
                    IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
                    Model newModel = modelRep.Find(newmodel);
                    if (null == newModel)
                    {
                        erpara.Add(newmodel);
                        ex = new FisException("CHK038", erpara);
                        throw ex;
                    }
                    string family = newModel.FamilyName;

                    var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                    IProduct currentProduct = productRepository.Find(prodId);
                    if (null == currentProduct)
                    {
                        erpara.Add(prodId);
                        ex = new FisException("CHK079", erpara);
                        throw ex;
                    }

                    Model curModel = modelRep.Find(currentProduct.Model);
                    if (null == curModel)
                    {
                        erpara.Add(currentProduct.Model);
                        ex = new FisException("CHK038", erpara);
                        throw ex;
                    }

                    if (!family.Equals(curModel.FamilyName))
                    {
                        ex = new FisException("DCK001", erpara); //Family不同,不能转换
                        throw ex;
                    }

                }

				// begin wf
				session = new Session(sessionKey, ProductSessionType, editor, stationId, pdLine, customer);

				Dictionary<string, object> wfArguments = new Dictionary<string, object>();
				//一个MB_SNo对应一个workflow
				wfArguments.Add("Key", sessionKey);
				wfArguments.Add("Station", stationId);
				wfArguments.Add("CurrentFlowSession", session);
				wfArguments.Add("Editor", editor);
				wfArguments.Add("PdLine", pdLine);
				wfArguments.Add("Customer", customer);
				wfArguments.Add("SessionType", ProductSessionType);
				string wfName, rlName;
				RouteManagementUtils.GetWorkflow(stationId, "GenerateCustomerSNForDocking.xoml", "GenerateCustomerSNForDocking.rules", out wfName, out rlName);
				WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                session.AddValue("ChangeToModel", newmodel);
				session.AddValue(Session.SessionKeys.IsComplete, false);
				session.SetInstance(instance);

				if (!SessionManager.GetInstance.AddSession(session))
				{
					session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
					erpara.Add(sessionKey);
					ex = new FisException("CHK020", erpara);
					throw ex;
				}

				session.WorkflowInstance.Start();
				session.SetHostWaitOne();
			}
			else
			{
				erpara.Add(sessionKey);
				ex = new FisException("CHK020", erpara);
				throw ex;
			}

			//session.SwitchToWorkFlow();

			//check workflow exception
			if (session.Exception != null)
			{
				if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
				{
					session.ResumeWorkFlow();
				}

				throw session.Exception;
			}

			Product tempProduct = (Product)session.GetValue(Session.SessionKeys.Product);
			//IMES.DataModel.ProductModel 
			curProduct = new IMES.DataModel.ProductModel();

			curProduct.CustSN = tempProduct.CUSTSN;
			curProduct.ProductID = tempProduct.ProId;
			curProduct.Model = tempProduct.Model;
		}
Example #13
0
        public ProductModel StartWorkFlow(string firstSN, string line, string editor, string station, string customer, out string CustPN)
        {
            logger.Debug("(_052VirtualPallet)StartWorkFlow start, line:" + line + " firstSN:" + firstSN + " editor:" + editor + " station:" + station + " customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = firstSN;
            try
            {
                Session Session = SessionManager.GetInstance.GetSession(sessionKey, TheType);

                if (Session == null)
                {
                    Session = new Session(sessionKey, TheType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();

                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", Session);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", TheType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, WFName, WFRule, out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    Session.AddValue(Session.SessionKeys.CustSN, firstSN);
                    Session.AddValue(Session.SessionKeys.IsComplete, false);
                    Session.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(Session))
                    {
                        Session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }
                    Session.WorkflowInstance.Start();
                    Session.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }

                //check workflow exception
                if (Session.Exception != null)
                {
                    if (Session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        Session.ResumeWorkFlow();
                    }
                    throw Session.Exception;
                }

                IProduct prod = (Product)(Session.GetValue(Session.SessionKeys.Product));
                Session.AddValue(Session.SessionKeys.FirstProductModel, prod.Model);

                ProductModel ProductModel = new ProductModel();

                ProductModel.CustSN = prod.CUSTSN;
                ProductModel.Model = prod.Model;
                ProductModel.ProductID = prod.ProId;


                CustPN = prod.ModelObj.CustPN;
                return ProductModel;

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(_052VirtualPallet)StartWorkFlow end, line:" + line + " firstSN:" + firstSN + " editor:" + editor + " station:" + station + " customer:" + customer);
            }
        }
Example #14
0
        public ArrayList InputSN_subFunc_isNotBT(string inputSN, string deliveryNo, string model, string firstProID, string line, string editor, string station, string customer, string isBT, bool newflag, ref IProduct curProduct)
        {
            ArrayList retList = new ArrayList();

            if ("Y".Equals(isBT))
            {
                FisException ex;
                List<string> erpara = new List<string>();
                ex = new FisException("DCK003", erpara);//非BT机器
                throw ex;
            }

            //g.	如果Product 尚未结合Delivery(Product.DeliveryNo),则报告错误:“Not found delivery for ” + @CustomerSN
            //b)	如果Product 尚未结合Delivery(Product.DeliveryNo),则报告错误:“Not found delivery for ” + @CustomerSN;
            //报告错误后,清空页面[Model] 内容
            if (string.IsNullOrEmpty(curProduct.DeliveryNo))
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.CUSTSN);
                ex = new FisException("PAK129", erpara);//Not found delivery for + @CustomerSN
                throw ex;
            }
            if (deliveryNo == "")
            {
                deliveryNo = curProduct.DeliveryNo;
            }

            if (model == "")
            {
                model = curProduct.Model;
            }

            if (firstProID == "")
            {
                firstProID = curProduct.ProId;
            }
            //g.	如果Product 结合的Delivery 与页面上[Delivery] 中的不同,则报告错误:“Delivery is not match!”
            if (curProduct.DeliveryNo != deliveryNo)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.CUSTSN);
                ex = new FisException("PAK130", erpara);//Delivery is not match!
                throw ex;
            }

            //检查Product Model (Product.Model) 是否与页面上的[Model] 相同,如果不同,则报告错误:“Model is not match!”
            if (curProduct.Model != model)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.Model);
                ex = new FisException("PAK131", erpara);//Model is not match!
                throw ex;
            }

            //c)如果Product 结合的Delivery 在数据库中不存在或者ShipDate 已经是5天以前了,则报告错误:“Not found Delivery for ”+ @Model
            DateTime beginCdt = DateTime.Now.AddDays(-5);
            Delivery curDev = deliveryRep.Find(curProduct.DeliveryNo);
            if (curDev == null || curDev.ShipDate < beginCdt)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.Model);
                ex = new FisException("PAK129", erpara);
                throw ex;
            }

            //h.	如果用户刷入的Product Id (可能是直接刷入的,也可能是基于Customer S/N查询到的)已经刷过,则报告错误:“Duplicate data!”
            if (!string.IsNullOrEmpty(curProduct.CartonSN))
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.Model);
                ex = new FisException("PAK134", erpara);//Duplicate data!
                throw ex;
            }


            string sessionKey = firstProID;
            Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

            if (currentSession == null)
            {
                if (!newflag)
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    ex = new FisException("PAK157", erpara);
                    retList.Add("Error");
                    retList.Add(ex);
                    return retList;
                }
                currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                wfArguments.Add("Key", sessionKey);
                wfArguments.Add("Station", station);
                wfArguments.Add("CurrentFlowSession", currentSession);
                wfArguments.Add("Editor", editor);
                wfArguments.Add("PdLine", line);
                wfArguments.Add("Customer", customer);
                wfArguments.Add("SessionType", SessionType);

                string wfName, rlName;

                RouteManagementUtils.GetWorkflow(station, "CombinePoInCarton.xoml", "CombinePoInCarton.rules", out wfName, out rlName);
                WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                currentSession.AddValue(Session.SessionKeys.Product, curProduct);
                IList<IProduct> productList = new List<IProduct>();
                currentSession.AddValue(Session.SessionKeys.ProdList, productList);
                IList<string> productIDList = new List<string>();
                currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, productIDList);

                currentSession.SetInstance(instance);

                if (!SessionManager.GetInstance.AddSession(currentSession))
                {
                    currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }

                currentSession.WorkflowInstance.Start();
                currentSession.SetHostWaitOne();
            }
            else
            {
                if (newflag)
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }
                currentSession.AddValue(Session.SessionKeys.Product, curProduct);

                currentSession.Exception = null;
                currentSession.SwitchToWorkFlow();
                /*FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(sessionKey);
                ex = new FisException("CHK020", erpara);
                throw ex;*/
            }
            if (currentSession.Exception != null)
            {
                if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                {
                    currentSession.ResumeWorkFlow();
                }
                IList<IProduct> productList = (List<IProduct>)currentSession.GetValue(Session.SessionKeys.ProdList);
                if (productList.Count == 0)
                {
                    SessionManager.GetInstance.RemoveSession(currentSession);
                }
                throw currentSession.Exception;
            }
            //========================================================                
            //SELECT Qty as [Total Qty] FROM Delivery NOLOCK WHERE DeliveryNo = @Delivery
            //SELECT InfoValue as [PCs in Carton] FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @Delivery AND InfoType = ‘CQty’
            //SELECT COUNT(ProductID) as [Packed Qty] FROM Product NOLOCK WHERE DeliveryNo = @Delivery

            ProductModel curModel = new ProductModel();

            curModel.ProductID = curProduct.ProId;
            curModel.CustSN = curProduct.CUSTSN;
            curModel.Model = curProduct.Model;

            IList<IProduct> proList = (List<IProduct>)currentSession.GetValue(Session.SessionKeys.ProdList);
            IList<string> idList = (List<string>)currentSession.GetValue(Session.SessionKeys.NewScanedProductIDList);
            proList.Add(curProduct);
            idList.Add(curProduct.ProId);

            currentSession.AddValue(Session.SessionKeys.ProdList, proList);
            currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, idList);

            string cQtyStr = (string)curDev.GetExtendedProperty("CQty");
            int cQty = 0;
            if (string.IsNullOrEmpty(cQtyStr))
            {
                cQty = 5;
            }
            else
            {
                decimal tmp = Convert.ToDecimal(cQtyStr);
                cQty = Convert.ToInt32(tmp);
            }
            int packedqty = 0;
            var tmpList = productRep.GetProductListByDeliveryNo(curDev.DeliveryNo);
            foreach (var prod in tmpList)
            {
                if (!string.IsNullOrEmpty(prod.CartonSN))
                {
                    packedqty++;
                }
            }

            //RTRIM(DeliveryNo) + ‘_’ + CONVERT(varchar, ShipDate, 111) + ‘_’ + CONVERT(varchar, Qty) 
            //就是UI 中[Delivery] List 中Item 的显示格式,正确取得Product 结合的Qty 后,要在[Delivery] 中选中该Delivery
            string devStr = curDev.DeliveryNo + "_" + curDev.ShipDate.Year.ToString("d4") + "/"
                + curDev.ShipDate.Month.ToString("d2") + "/" + curDev.ShipDate.Day.ToString("d2") + "_" + curDev.Qty.ToString();

            retList.Add("SUCCESS");
            retList.Add(curModel);
            retList.Add(curProduct.DeliveryNo);
            retList.Add(curDev.Qty);//Total Qty
            retList.Add(cQty);//PCs in Carton
            retList.Add(packedqty);//Packed Qty
            retList.Add(devStr);//Delivery Item
            retList.Add("N"); // isNotBT ; mantis 1696
            //========================================================
            return retList;
        }
        /// <summary>
        /// 除首次外,每次刷SN都调用该方法,进行SFC,判断DN是否和但前选定DN相同,刷SN返回ProductModel
        /// 将SN放到Session.CustSN里
        /// </summary>
        /// <param name="dn"></param>
        /// <param name="palletNo"></param>
        /// <param name="uutSN"></param>
        /// <returns>返回ProductModel</returns>
        public IMES.DataModel.ProductModel ScanSN(string dn, string palletNo, string uutSN)
        {
            logger.Debug("(PalletDataCollectionTROImpl)ScanSN start,"
                + " [dn]: " + dn
                + " [palletNo]:" + palletNo
                + " [uutSN]:" + uutSN);
            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = palletNo;

            try
            {
                Session session = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (session == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    //ex.logErr("", "", "", "", "83");
                    //logger.Error(ex);
                    throw ex;
                }
                else
                {
                    session.AddValue(Session.SessionKeys.CustSN, uutSN);
                    session.Exception = null;
                    session.SwitchToWorkFlow();

                    //check workflow exception
                    if (session.Exception != null)
                    {
                        if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            session.ResumeWorkFlow();
                        }

                        throw session.Exception;
                    }
                }

                IProduct currentProduct = (IProduct)session.GetValue(Session.SessionKeys.Product);
                IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();

                currentModel.CustSN = currentProduct.CUSTSN;
                currentModel.ProductID = currentProduct.ProId;
                currentModel.Model = currentProduct.Model;
                return currentModel;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(PalletDataCollectionTROImpl)ScanSN start,"
                    + " [dn]: " + dn
                    + " [palletNo]:" + palletNo
                    + " [uutSN]:" + uutSN);
            }
        }
Example #16
0
 /// <summary>
 /// 获取product表相关信息 GetProductListByDeliveryNoAndPalletNo
 /// </summary>
 /// <param name="PalletNo">PalletNo</param>
 /// <param name="DN">DN</param>
 public IList<ProductModel> GetProductList(string PalletNo, string DN)
 {
     logger.Debug("(_CombineDNPalletforBT)GetProductList start.");
     try
     {
         //IList<ProductModel> ret = new List<ProductModel>();
         IList<ProductModel> retValue = new List<ProductModel>();
         //ret = productRepository.GetProductListByPalletNo(PalletNo);
         if (DN == "------------")
         {
             retValue = productRepository.GetProductListByPalletNo(PalletNo); 
         }
         else
         {
             IList<IProduct> ret = new List<IProduct>();
             ret = productRepository.GetProductListByDeliveryNoAndPalletNo(DN, PalletNo);
             foreach (IProduct tmp in ret)
             {
                 ProductModel ele = new ProductModel();
                 ele.CustSN = tmp.CUSTSN;
                 ele.ProductID = tmp.ProId;
                 ele.Model = tmp.Model;
                 retValue.Add(ele);
             }
         }
         return retValue;
     }
     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("(_CombineDNPalletforBT)GetProductList end.");
     }
 }
        /// <summary>
        /// 刷第一个SN时,调用该方法启动工作流,根据输入CustSN获取ProductModel,
        /// 将SN放到Session.CustSN里
        /// </summary>
        /// <param name="dn"></param>
        /// <param name="palletNo"></param>
        /// <param name="firstSN"></param>
        /// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        public IMES.DataModel.ProductModel StartWorkFlow(string dn, string palletNo, string firstSN, string line, string editor, string station, string customer)
        {
            logger.Debug("(PalletDataCollectionTROImpl)StartWorkFlow start, [dn]:" + dn
                + "[palletNo]: " + palletNo
                + "[firstSN]: " + firstSN
                + "[line]: " + line
                + "[editor]: " + editor
                + "[station]: " + station
                + "[customer]: " + customer);

            try
            {
                string sessionKey = palletNo;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
                //Delivery delivery = null;

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", SessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "054PalletDataCollectionTRO.xoml", "054PalletDataCollectionTRO.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);


                    currentSession.AddValue(Session.SessionKeys.DeliveryNo, dn);
                    currentSession.AddValue(Session.SessionKeys.PalletNo, palletNo);
                    currentSession.AddValue(Session.SessionKeys.CustSN, firstSN);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }

                IProduct currentProduct = (IProduct)currentSession.GetValue(Session.SessionKeys.Product);
                IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();

                currentModel.CustSN = currentProduct.CUSTSN;
                currentModel.ProductID = currentProduct.ProId;
                currentModel.Model = currentProduct.Model;
                return currentModel;
            }
            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("(PalletDataCollectionTROImpl)StartWorkFlow end, [dn]:" + dn
                    + "[palletNo]: " + palletNo
                    + "[firstSN]: " + firstSN
                    + "[line]: " + line
                    + "[editor]: " + editor
                    + "[station]: " + station
                    + "[customer]: " + customer);
            }
        }
Example #18
0
        /// <summary>
        /// Box Id / UCC 分配原则
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            List<string> errpara = new List<string>();
            Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            Delivery curDelivery = (Delivery)CurrentSession.GetValue(Session.SessionKeys.Delivery);
            Pallet curPallet = (Pallet)CurrentSession.GetValue(Session.SessionKeys.Pallet);

            IList<string> ProductIDList = new List<string>();

            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();

            CurrentSession.AddValue("CreatePDF", "");
            IList<ProductBTInfo> btList = productRep.GetProductBT(curProduct.ProId);
            if (btList.Count > 0 && Station.Trim() == "92")
            {
                return base.DoExecute(executionContext);
            }

            string proBoxId = (string)curProduct.GetExtendedProperty("BoxId");
            string proUCC = (string)curProduct.GetExtendedProperty("UCC");

            //a.	取Delivery 的下列属性并保存到对应的变量中:
            string BoxId = "";
            string shipment = curDelivery.ShipmentNo;
            string model = curDelivery.ModelName;
            int qut = curDelivery.Qty;
            DateTime shipDate = curDelivery.ShipDate;
            string emea = (string)curDelivery.GetExtendedProperty("EmeaCarrier");
            string carrier = (string)curDelivery.GetExtendedProperty("Carrier");
            string regId = (string)curDelivery.GetExtendedProperty("RegId");
            string deport = (string)curDelivery.GetExtendedProperty("Deport");
            string flag = (string)curDelivery.GetExtendedProperty("Flag");
            string boxId = (string)curDelivery.GetExtendedProperty("BoxId");
            string boxReg = (string)curDelivery.GetExtendedProperty("BoxReg");
            string shipWay = (string)curDelivery.GetExtendedProperty("ShipWay");
            string palletLayer = (string)curDelivery.GetExtendedProperty("PalletLayer");

             string locWC="";

            if (regId != null && regId.Length == 3)
            { 
                regId = regId.Substring(1, 2); 
            }  
            else
            { 
                regId = ""; 
            }
            //b.	取Pallet 的UCC 属性(IMES_PAK..Pallet.UCC),并保存到变量@ucc 中
            //IF EXISTS (SELECT *FROM ShipBoxDet NOLOCK WHERE DeliveryNo=@dn and PLT<>@plt and SnoId=@id)
            //BEGIN
	        //UPDATE ShipBoxDet SET SnoId='' ,Udt=GETDATE() WHERE DeliveryNo=@dn and SnoId=@id
            //END
            string ucc = curPallet.UCC;

            //c.如果Product 曾经结合过其它栈板,需要先解除与其他栈板的结合
            Boolean bindflag = deliveryRep.CheckExistShipBoxDetExceptPlt(curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
            if (bindflag)
            {
                deliveryRep.UpdateShipBoxDetForClearSnoidDefered(CurrentSession.UnitOfWork, curProduct.ProId, curDelivery.DeliveryNo);
            }

            IList<ShipBoxDetInfo> shipList;
            IList<string> boxIdList;
            ShipBoxDetInfo shipInfo;
            //d.当@Flag='N' or @ucc<>'' 时(所谓自动单情况),按照如下方法分配Box Id
            if ( (flag == "N")|| !string.IsNullOrEmpty(ucc))
            {
                //a)使用DeliveryNo=@dn and PLT=@plt and SnoId=@id 查询ShipBoxDet 表存在记录时,
                shipList = deliveryRep.GetShipBoxDetList(curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
                
                if (shipList.Count != 0)
                {
                    //取查询到的记录的BoxId 字段值保存到变量@BoxId 中,并更新该记录的Udt 字段值为当前时间
                   
                    shipInfo = shipList[0];
                    BoxId = shipInfo.boxId;

                    ShipBoxDetInfo setvalue = new ShipBoxDetInfo();
                    ShipBoxDetInfo conf = new ShipBoxDetInfo();
                    conf.deliveryNo = curDelivery.DeliveryNo;
                    conf.plt = curPallet.PalletNo;
                    conf.snoId = curProduct.ProId;

                    setvalue.udt = DateTime.Now;
                    deliveryRep.UpdateShipBoxDetInfoDefered(CurrentSession.UnitOfWork, setvalue, conf);

                    //i.如果Product 已经结合过Box Id / UCC (两者只会结合一个)
                    if (!string.IsNullOrEmpty(proBoxId) || !string.IsNullOrEmpty(proUCC))
                    {
                        //则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();
                        if (!string.IsNullOrEmpty(proBoxId))
                        {
                            curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                        }
                        else
                        {
                            curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                        }
                    }
                    else
                    {
                        //如果尚未结合过,则结合@BoxId,记录到IMES_FA..ProductInfo (InfoValue = @BoxId, 
                        //InfoType 当@ucc<>''and LEN(@BoxId)=20 时,记录为'UCC',否则记录为'BoxId')
                        if (!string.IsNullOrEmpty(ucc) && (BoxId.Length == 20))
                        {
                            curProduct.SetExtendedProperty("UCC",BoxId,CurrentSession.Editor);
                        }
                        else
                        {
                            curProduct.SetExtendedProperty("BoxId",BoxId,CurrentSession.Editor);
                        }
                    }
                    
                    //ii.	更新Product结合的Pallet (IMES_FA..Product.PalletNo) 为@plt
                    ProductIDList.Add(curProduct.ProId);
                    productRep.BindPalletDefered(CurrentSession.UnitOfWork, curProduct.PalletNo, ProductIDList);
                }
                else
                {
                    //b)使用DeliveryNo=@dn and PLT=@plt and SnoId=@id 查询ShipBoxDet 表不存在记录时,
                    //使用DeliveryNo=@dn and PLT=@plt and SnoId='' 查询ShipBoxDet 表,
                    //取查询到的记录的BoxId 字段值保存到变量@BoxId 中

                    //shipList = deliveryRep.GetShipBoxDetList(curDelivery.DeliveryNo, curPallet.PalletNo, "");
                    boxIdList = deliveryRep.GetAndUpdateShipBoxDet(curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
                    //if (shipList.Count == 0)
                    if(boxIdList.Count==0)
                    {
                        errpara.Add(this.Key);//无可用Box Id,请联系FIS!
                        throw new FisException("PAK102", errpara);
                    }

                    //shipInfo = shipList[0];
                    //BoxId = shipInfo.boxId;
                    BoxId = boxIdList[0];

                    //i.	如果ISNULL(@BoxId, '') = '',则报告错误:“无可用Box Id,请联系FIS!”
                    if (string.IsNullOrEmpty(BoxId))
                    {
                        errpara.Add(this.Key);//无可用Box Id,请联系FIS!
                        throw new FisException("PAK102", errpara);

                    }
                    else
                    {
                        //ii.	如果ISNULL(@BoxId, '') <> '', 
                        //A.	Update ShipBoxDet 记录结合Product 信息
                        //Condition: DeliveryNo=@dn and PLT=@plt and BoxId=@BoxId SET:SnoId=@id,Udt=GETDATE()

                        //deliveryRep.UpdateShipBoxDetForSetSnoIdDefered(CurrentSession.UnitOfWork,curProduct.ProId,curDelivery.DeliveryNo,curPallet.PalletNo, BoxId);
                        
                        //B.	如果Product 已经结合过Box Id / UCC (两者只会结合一个,Box Id / UCC 存放在IMES_FA..ProductInfo.Value,
                        //Condition: InfoType = 'BoxId' 或者 'UCC'),则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();
                        deliveryRep.UpdateAssignBoxIdEditorDefered(CurrentSession.UnitOfWork, curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
                        if (!string.IsNullOrEmpty(proBoxId) || !string.IsNullOrEmpty(proUCC))
                        {
                            if (!string.IsNullOrEmpty(proBoxId))
                            {
                                curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                            }
                            else
                            {
                                curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                            }
                            curProduct.Udt = DateTime.Now;
                        }
                        else
                        {
                            //如果尚未结合过,则结合@BoxId,记录到IMES_FA..ProductInfo 
                            //(InfoValue = @BoxId,InfoType 当@ucc<>'' and LEN(@BoxId)=20 时,记录为'UCC',否则记录为'BoxId')
                            if (!string.IsNullOrEmpty(ucc) && (BoxId.Length == 20))
                            {
                                curProduct.SetExtendedProperty("UCC",BoxId,CurrentSession.Editor);
                            }
                            else
                            {
                                curProduct.SetExtendedProperty("BoxId",BoxId,CurrentSession.Editor);
                            }
                        }
                        
                        //C.	更新Product结合的Pallet (IMES_FA..Product.PalletNo) 为@plt
                        //ProductIDList.Add(curProduct.ProId);
                        //productRep.BindPalletDefered(CurrentSession.UnitOfWork, curProduct.PalletNo, ProductIDList);
                        curProduct.Udt = DateTime.Now;
                        curProduct.PalletNo = curPallet.PalletNo;
                        productRep.Update(curProduct, CurrentSession.UnitOfWork);
                    }
                }
            }
            else  //e	当@Flag<>'N' and @ucc='' 时(所谓手动单情况),按照如下方法分配Box Id
            {
                //a)	使用DeliveryNo=@dn and PLT=@plt and SnoId=@id 查询ShipBoxDet 表存在记录时,取查询到的记录的BoxId 字段值保存到变量@BoxId 中,
                //并更新该记录的Udt 字段值为当前时间
                //i.	如果Product 已经结合过Box Id / UCC (两者只会结合一个,Box Id / UCC 存放在IMES_FA..ProductInfo.Value,Condition: InfoType = 'BoxId' 或者 'UCC'),
                //则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();如果尚未结合过,则结合@BoxId,记录到IMES_FA..ProductInfo (InfoValue = @BoxId,InfoType 当@ucc<>'' and LEN(@BoxId)=20 时,记录为'UCC',否则记录为'BoxId')
                //ii.	更新Product结合的Pallet (IMES_FA..Product.PalletNo) 为@plt
                shipList = deliveryRep.GetShipBoxDetList(curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
                if (shipList.Count > 0)
                {
                    shipInfo = shipList[0];
                    BoxId = shipInfo.boxId;

                    ShipBoxDetInfo setvalue= new ShipBoxDetInfo();
                    ShipBoxDetInfo conf = new ShipBoxDetInfo();
                    conf.deliveryNo = curDelivery.DeliveryNo;
                    conf.plt = curPallet.PalletNo;
                    conf.snoId = curProduct.ProId;
                    
                    setvalue.udt = DateTime.Now;
                    deliveryRep.UpdateShipBoxDetInfoDefered(CurrentSession.UnitOfWork,setvalue,conf);

                    if (!string.IsNullOrEmpty(proBoxId) || !string.IsNullOrEmpty(proUCC))
                    {
                        //则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();
                        if (!string.IsNullOrEmpty(proBoxId))
                        {
                            curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                        }
                        else
                        {
                            curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(ucc) && (BoxId.Length == 20))
                        {
                            curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                        }
                        else
                        {
                            curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                        }
                    }
                    curProduct.Udt = DateTime.Now;
                    curProduct.PalletNo = curPallet.PalletNo;
                    productRep.Update(curProduct, CurrentSession.UnitOfWork);
                }
                else
                {   //Mantis #0000954   
                    // a)	如果使用DeliveryNo=@dn and PLT=@plt and SnoId='' 查询ShipBoxDet 表存在记录时,按照下列方法,分配Box Id
                    //i.	使用DeliveryNo=@dn and PLT=@plt and SnoId='' 查询ShipBoxDet 表,取记录的BoxId 字段值保存到@BoxId 变量中
                    //ii.	Update ShipBoxDet 记录结合Product 信息 Condition: DeliveryNo=@dn and PLT=@plt and BoxId=@BoxId SET:SnoId=@id,Udt=GETDATE()
                    //iii.	如果Product 已经结合过Box Id / UCC (两者只会结合一个,Box Id / UCC 存放在IMES_FA..ProductInfo.Value,Condition: InfoType = 'BoxId' 或者 'UCC'),
                    //      则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();如果尚未结合过,则结合@BoxId,记录到IMES_FA..ProductInfo 
                    //      (InfoValue = @BoxId,InfoType 当@ucc<>'' and LEN(@BoxId)=20 时,记录为'UCC',否则记录为'BoxId')
                    //iv.	更新Product结合的Pallet (IMES_FA..Product.PalletNo) 为@plt
                    //shipList = deliveryRep.GetShipBoxDetList(curDelivery.DeliveryNo, curPallet.PalletNo, "");
                    boxIdList = deliveryRep.GetAndUpdateShipBoxDet(curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
                    //if (shipList.Count != 0)
                    if (boxIdList.Count !=0)
                    {
                        //shipInfo = shipList[0];
                        //BoxId = shipInfo.boxId;
                        //deliveryRep.UpdateShipBoxDetForSetSnoIdDefered(CurrentSession.UnitOfWork, curProduct.ProId, curDelivery.DeliveryNo, curPallet.PalletNo, BoxId);
                        deliveryRep.UpdateAssignBoxIdEditorDefered(CurrentSession.UnitOfWork, curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
                        BoxId = boxIdList[0];
                        if (!string.IsNullOrEmpty(proBoxId) || !string.IsNullOrEmpty(proUCC))
                        {
                            //则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();
                            if (!string.IsNullOrEmpty(proBoxId))
                            {
                                curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                            }
                            else
                            {
                                curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(ucc) && (BoxId.Length == 20))
                            {
                                curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                            }
                            else
                            {
                                curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                            }
                        }
                        curProduct.Udt = DateTime.Now;
                        curProduct.PalletNo = curPallet.PalletNo;
                        productRep.Update(curProduct, CurrentSession.UnitOfWork);
                    }
                    else
                    {
                        //b)	如果使用DeliveryNo=@dn and PLT=@plt and SnoId='' 查询ShipBoxDet 表不存在记录时,按照下列方法,分配Box Id
                        //i.	使用DeliveryNo=@dn and SnoId='' 查询ShipBoxDet 表,按照PLT, BoxId 升序排序,取TOP 1 记录的PLT / BoxId 字段值保存到@plt / @BoxId 变量中
                        //ii.	如果ISNULL(@BoxId, '') = '',则报告错误:“无可用Box Id,请联系FIS!”
                        //iii.	Update ShipBoxDet 记录结合Product 信息   Condition: DeliveryNo=@dn and PLT=@plt and BoxId=@BoxId SET:SnoId=@id,Udt=GETDATE()
                        //iv.   如果Product 已经结合过Box Id / UCC (两者只会结合一个,Box Id / UCC 存放在IMES_FA..ProductInfo.Value,Condition: InfoType = 'BoxId' 或者 'UCC'),
                        //      则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();如果尚未结合过,则结合@BoxId,记录到IMES_FA..ProductInfo 
                        //      (InfoValue = @BoxId,InfoType 当@ucc<>'' and LEN(@BoxId)=20 时,记录为'UCC',否则记录为'BoxId')
                        //v.	更新Product结合的Pallet (IMES_FA..Product.PalletNo) 为@plt
                        //shipList = deliveryRep.GetShipBoxDetList(curDelivery.DeliveryNo, curPallet.PalletNo, "");//??
                        boxIdList = deliveryRep.GetAndUpdateShipBoxDet(curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);
                        //if (shipList.Count == 0)
                        if (boxIdList.Count == 0)
                        {
                            errpara.Add(this.Key);//无可用Box Id,请联系FIS!
                            throw new FisException("PAK102", errpara);
                        }

                        //shipInfo = shipList[0];
                        //BoxId = shipInfo.boxId;
                        BoxId = boxIdList[0];
                        if (string.IsNullOrEmpty(BoxId))
                        {
                            errpara.Add(this.Key);//无可用Box Id,请联系FIS!
                            throw new FisException("PAK102", errpara);
                        }
                        else
                        {
                            //deliveryRep.UpdateShipBoxDetForSetSnoIdDefered(CurrentSession.UnitOfWork, curProduct.ProId, curDelivery.DeliveryNo, curPallet.PalletNo, BoxId);
                            // ProductIDList.Add(curProduct.ProId);
                            //productRep.BindPalletDefered(CurrentSession.UnitOfWork, curProduct.PalletNo, ProductIDList);
                            deliveryRep.UpdateAssignBoxIdEditorDefered(CurrentSession.UnitOfWork, curDelivery.DeliveryNo, curPallet.PalletNo, curProduct.ProId);

                            if (!string.IsNullOrEmpty(proBoxId) || !string.IsNullOrEmpty(proUCC))
                            {
                                //则需要更新该记录的InfoValue = @BoxId, Editor, Udt = Getdate();
                                if (!string.IsNullOrEmpty(proBoxId))
                                {
                                    curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                                }
                                else
                                {
                                    curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(ucc) && (BoxId.Length == 20))
                                {
                                    curProduct.SetExtendedProperty("UCC", BoxId, CurrentSession.Editor);
                                }
                                else
                                {
                                    curProduct.SetExtendedProperty("BoxId", BoxId, CurrentSession.Editor);
                                }
                            }
                            curProduct.Udt = DateTime.Now; 
                            curProduct.PalletNo = curPallet.PalletNo;
                            productRep.Update(curProduct, CurrentSession.UnitOfWork);
                        }
                    }
                }
            }

            //f.	当与分配的Delivery (@dn)结合的所有Product (IMES_FA..Product.DeliveryNo)数量与Delivery 定义数量(IMES_PAK..Delivery.Qty)相等,
            //并都已经结合了Pallet(IMES_FA..Product.PalletNo)时,更新Delivery 的状态为'88'
            //curDelivery.IsDNFull()

            //2012-01-10 Vincent Change caculate combine pallet logical
            //int dvQty = productRep.GetCombinedQtyByDN(curDelivery.DeliveryNo);
            
            //string oldDnFlag = (string)CurrentSession.GetValue("HasDN");
            //if (oldDnFlag != "Y")
            //{
            //    dvQty++;
            //}

            int combinePLTQty = (CurrentSession.GetValue("HasAssignPLTQrty")==null?0:(int)CurrentSession.GetValue("HasAssignPLTQrty")) ;
            int dvQty = productRep.GetCombinedPalletQtyByDN(curDelivery.DeliveryNo) + combinePLTQty;
            if (dvQty == curDelivery.Qty)
            {
                curDelivery.Status = "88";
                curDelivery.Editor = CurrentSession.Editor;
                curDelivery.Udt = DateTime.Now;
                deliveryRep.Update(curDelivery, CurrentSession.UnitOfWork);
            }
            
            // g.下文描述的是针对不同的情况,如何获取需要提示用户的信息 
            //a)	取Delivery 的PalletQty (IMES_PAK..DeliveryInfo.InfoValue,Condition: InfoType = 'PalletQty')属性值,
            //并取其整数部分保存到@paletqty 变量中;如果该属性不存在,则令@paletqty = 60
            string paletqty = (string)curDelivery.GetExtendedProperty("PalletQty");
            
            if (string.IsNullOrEmpty(paletqty))
            {
                paletqty = "60";
            }
           
            //b)	使用如下方法,取得变量@pqty
            //SELECT @pqty = sum(DeliveryQty) FROM Delivery_Pallet NOLOCK WHERE PalletNo = @Plt
            int pqty = deliveryRep.GetSumDeliveryQtyOfACertainPallet(curPallet.PalletNo);

            //c)	使用如下方法,取得变量@pqty2
            //SELECT @pqty2=TierQty FROM PalletStandard WHERE FullQty=@paletqty
            int pqty2 = palletRep.GetTierQtyFromPalletQtyInfo(paletqty);

            //d)	如果@pqty>=@pqty2,则令@emeastr='海运,满一层请使用大的木头栈板'
            string emeastr = string.Empty;
            string pclor = string.Empty;

            //*********** Add by Benson for CQ Begin  ***********
            
       
            IList<PalletType> lstPalletType = IMES.Infrastructure.Utility.Common.CommonUti.GetPalletType(curPallet.PalletNo, curDelivery.DeliveryNo);
        //    IList<PalletType> lstPalletType = palletTypeRepository.GetPalletType(ShipWay, RegId, StdPltFullQty, pltDeliveryQty);
            if (lstPalletType.Count == 0)
            {
                 pclor="";
                 emeastr="Other";
            }
            else
            { 
                pclor=lstPalletType[0].Code.Trim();
                emeastr=lstPalletType[0].Type.Trim();
            }


            //*********** Add by Benson for CQ End  ***********


            //  *********** Marked by Benson Begin ***********
            /* 
            if (pqty > pqty2 )
            {
                emeastr = "海运,满一层请使用大的木头栈板";
            }
            //e)	如果(@Region='SNE' or @Region='SCE' ) and @shipway<>'T002'时
            //i.	如果@pqty>=@pqty2 and @pqty2>0,则令@emeastr='满一层请使用chep栈板';@pclor=' H';
            //否则令@emeastr=' ';@pclor=''
            if(( regId=="NE" || regId=="CE")&&(shipWay != "T002" ))
            {
                if (pqty > pqty2 && pqty2 > 0)
                {
                    emeastr= "满一层请使用chep栈板";
                    pclor = " H";
                }
                else
                {
                    emeastr= "";
                    pclor = "";
                }
            }
            else if(( regId=="NL" )&&(shipWay != "T002" ))
            {   //f)	不满足上一步的条件时,如果@Region='SNL' and @shipway<>'T002' 时
                //i.	如果@pqty>=@pqty2 and @pqty2>0,则令@emeastr='请使用绿色塑料栈板';@pclor=' P';
                //否则令@emeastr=' ';@pclor=''
                if (pqty > pqty2 && pqty2 > 0 )
                {
                    emeastr = "请使用蓝色塑料栈板";
                    pclor = " A";
                }
                else
                {
                    emeastr= "";
                    pclor = "";
                }

            }
            else if(( regId=="NU" || regId == "CU" ) && (shipWay != "T002" ))
            {    //g)	不满足前面的条件时,如果(@Region='SNU' or @Region='SCU' ) and @shipway<>'T002' 时
                 //i.	如果@pqty>=@pqty2 and @pqty2>0,则令@emeastr='请使用蓝色塑料栈板';@pclor=' A';
                 //否则令@emeastr=' ';@pclor=''
                if (pqty > pqty2 && pqty2 > 0 )
                {
                    emeastr= "请使用蓝色塑料栈板";
                    pclor = " A";
                }
                else
                {
                    emeastr= "";
                    pclor = "";
                }
            }
            else if(( regId=="NE" || regId == "CE" ) && (shipWay == "T002" ))
            {
                //h)	不满足前面的条件时,如果(@Region='SNE' or @Region='SCE' ) and @shipway='T002' 时,
                //      则令@emeastr='EMEA海运,请使用E1栈板';@pclor=' K'
                emeastr= "EMEA海运,请使用E1栈板";
                pclor = " K";
            }
            else if(( regId=="AF" ) && (shipWay == "T001" ))
            {
                //i)	不满足前面的条件时,如果@shipway='T001' and @Region='SAF' 时,
                //i.	如果@pqty>=@pqty2 and @pqty2>0,则令@emeastr='請使用綠色塑料棧板';@pclor=' P';
                //否则令@emeastr=' ';@pclor=''
                if (pqty > pqty2 && pqty2 > 0 )
                {
                    emeastr= "请使用绿色塑料栈板";
                    pclor = " P";
                }
                else
                {
                    emeastr= "";
                    pclor = "";
                }

            }
            else if ((regId == "CN") && (shipWay == "T001"))
            {
                // j)	不满足前面的条件时,如果@shipway='T001' and @Region='SCN' 时,
                //i.	如果@pqty>=@pqty2 and @pqty2>0,则令@emeastr='满一层请使用大的木头栈板';@pclor=' ';
                //否则令@emeastr=' ';@pclor=''
                if (pqty > pqty2 && pqty2 > 0 )
                {
                    emeastr= "满一层请使用大的木头栈板";
                    pclor = " ";
                }
                else
                {
                    emeastr= "";
                    pclor = "";
                }

            }
            else
            {
                emeastr= "";
                pclor = "";
            }
             */
            //  *********** Marked by Benson End ***********
            
            //h.下文描述的是分配库位
            //Model 的第10,11码是”29” 或者”39” 的产品是出货日本的产品;否则,是非出货日本的产品
            //PAK_LocMas.WC = ‘JP’ 的为日本专用库位
            //出货日本的Pallet优先分配出货日本专用库位,当出货日本专用库位用完时,出货日本的Pallet 方可使用普通库位

            if (pqty <= 6)
            { locWC = "Virtual"; }
            
            string jpmodel =curProduct.Model.Substring(9,2);
            //bool jpflag = false;
            if (jpmodel == "29" || jpmodel == "39")
            {
                locWC="JP";
                //jpflag = true;
            }

            //a)	当LEFT(@plt,2)<>'NA' and LEFT(@plt,2)<>'BA' 时,按照如下方法分配库位
            string floor = (string)CurrentSession.GetValue(Session.SessionKeys.Floor);
            string loc="";
            Boolean addflag = true;
            if (curPallet.PalletNo.Substring(0,2) !="NA" && curPallet.PalletNo.Substring(0,2) !="BA")
            {
                 //Vincent add Check NBO包裝方式               
                int palletLayerQty=0;
                if (!string.IsNullOrEmpty(palletLayer) &&
                     int.TryParse(palletLayer, out palletLayerQty) &&
                    palletLayerQty > this.OverPalletLayer )
                {                   
                     locWC="NBO";
                }               
               
                //i.	取与@plt 结合的Product 数量,如果数量为1,则按照如下方法分配库位
                IList<ProductModel> modelList = productRep.GetProductListByPalletNo(curPallet.PalletNo);
                IList<PakLocMasInfo> macList;
                string pdline;
                ProductModel newModel = new ProductModel();
                if (!string.IsNullOrEmpty(curProduct.PalletNo))
                {
                    foreach (ProductModel pmodel in modelList)
                    {
                        if (pmodel.ProductID == curProduct.ProId)
                        {
                            addflag = false;
                            break;
                        }
                    }
                    if (addflag)
                    {
                        newModel.ProductID = curProduct.ProId;
                        newModel.Model = curProduct.Model;
                        newModel.CustSN = curProduct.CUSTSN;
                        modelList.Add(newModel);
                    }
                }

                if (modelList.Count == 1 )
                {
                    // 1.	当使用Pno=@plt and Tp='PakLoc' and FL=@floor (@floor 来自页面用户的选择)查询PAK_LocMas表存在记录时,
                    //则取该记录的SnoId 字段值保存到变量@loc 中,并更新PAK_LocMas表中满足Pno=@plt and Tp='PakLoc' 条件的
                    //记录的PdLine 字段值为Product Id 的第一位字符,Udt 为当前时间
                    //bool chkmas = palletRep.CheckExistPakLocMas(curPallet.PalletNo, "PakLoc", floor);
            
                    PakLocMasInfo normalconf = new PakLocMasInfo();
                    normalconf.pno = curPallet.PalletNo;
                    normalconf.tp = "PakLoc";
                    normalconf.fl = floor;
                    normalconf.wc = locWC;
                    macList = palletRep.GetPakLocMasList(normalconf);
                    if (macList.Count==0 &&  !string.IsNullOrEmpty(locWC))
                    {
                        normalconf.wc = "";
                        macList = palletRep.GetPakLocMasList(normalconf);
                    }

                     if (macList.Count>0)
                    {                        
                        loc = macList[0].snoId;
                        pdline = curProduct.ProId.Substring(0,1);
                        palletRep.UpdatePakLocMasByIdDefered(CurrentSession.UnitOfWork,
                                                                                       macList[0].id,
                                                                                       curPallet.PalletNo,
                                                                                       pdline,
                                                                                       this.Editor);
                        //palletRep.UpdatePakLocMasForPdLineDefered(CurrentSession.UnitOfWork,pdline,curPallet.PalletNo,"PakLoc");
                    }
                     else
                     {
                         normalconf.pno = "";
                         normalconf.tp = "PakLoc";
                         normalconf.fl = floor;
                         normalconf.wc = locWC;
                         
                         macList = palletRep.GetPakLocMasList(normalconf);
                         if (macList.Count==0 &&  !string.IsNullOrEmpty(locWC))
                         {
                            normalconf.wc = "";
                            macList = palletRep.GetPakLocMasList(normalconf);
                          }

                          if (macList.Count >0)//(palletRep.CheckExistPakLocMas("", "PakLoc", floor))
                         {                          
                            loc = macList[macList.Count-1].snoId;
                            pdline = curProduct.ProId.Substring(0,1);
                            palletRep.UpdatePakLocMasByIdDefered(CurrentSession.UnitOfWork,
                                                                                     macList[macList.Count - 1].id,
                                                                                     curPallet.PalletNo,
                                                                                     pdline,
                                                                                     this.Editor);
                            //palletRep.UpdatePakLocMasForPdLineAndPnoDefered(CurrentSession.UnitOfWork,pdline,curPallet.PalletNo,"","PakLoc",loc);                            
                        }
                        else
                        {
                            //3.当不满足前面条件时,令@loc = 'Others'
                            loc = "Others";
                        }

                     }
                        #region Vincent disable below code
                    //PakLocMasInfo neqconf = new PakLocMasInfo();
                    //neqconf.wc = "JP";
                    //if (jpflag)
                    //{
                    //    PakLocMasInfo conf = new PakLocMasInfo();
                    //    conf.pno = curPallet.PalletNo;
                    //    conf.tp = "PakLoc";
                    //    conf.fl= floor;
                    //    conf.wc = "JP";
                    //    macList = palletRep.GetPakLocMasList(conf);
                    //    if (macList.Count == 0)
                    //    {
                    //        //macList = palletRep.GetPakLocMasList(normalconf, neqconf);//(curPallet.PalletNo, "PakLoc", floor);
                    //        macList = palletRep.GetPakLocMasList(normalconf);
                    //    }
                    //}                 
                    //else
                    //{
                    //    //macList = palletRep.GetPakLocMasList(normalconf, neqconf);//(curPallet.PalletNo, "PakLoc", floor);
                    //    macList = palletRep.GetPakLocMasList(normalconf);

                    //}
                    //if (macList.Count>0)
                    //{                        
                    //    loc = macList[0].snoId;
                    //    pdline = curProduct.ProId.Substring(0,1);
                    //    palletRep.UpdatePakLocMasForPdLineDefered(CurrentSession.UnitOfWork,pdline,curPallet.PalletNo,"PakLoc");
                    //}
                    //else
                    //{
                    //    //2.当使用Pno=@plt and Tp='PakLoc' and FL=@floor (@floor 来自页面用户的选择)查询PAK_LocMas表不存在记录时,
                    //    //如果使用Pno='' and Tp='PakLoc' and FL=@floor (@floor 来自页面用户的选择)查询PAK_LocMas表存在记录时,
                    //    //按照SnoId 字段转为整型排序,取第一条记录的SnoId 字段值保存到变量@loc 中,
                    //    //并更新PAK_LocMas 表中满足SnoId=@loc and Tp='PakLoc' and Pno='' 条件的记录的Pno 字段值为@plt,
                    //    //PdLine 字段值为Product Id 的第一位字符,Udt 为当前时间
                    //    //分配库位时优先选择空的,再选择库位号小的
                       
                    //    normalconf.pno = "";
                        
                    //    if (jpflag)
                    //    {
                    //        PakLocMasInfo conf = new PakLocMasInfo();
                    //        conf.pno = "";
                    //        conf.tp = "PakLoc";
                    //        conf.fl = floor;
                    //        conf.wc = "JP";
                    //        macList = palletRep.GetPakLocMasList(conf);
                    //        if (macList.Count == 0)
                    //        {
                    //            macList = palletRep.GetPakLocMasList(normalconf, neqconf);//("", "PakLoc", floor);
                    //        }
                    //    }
                    //    else
                    //    {
                    //        macList = palletRep.GetPakLocMasList(normalconf, neqconf);//("", "PakLoc", floor);
                    //    }
                    //    if (macList.Count >0)//(palletRep.CheckExistPakLocMas("", "PakLoc", floor))
                    //    {                          
                    //        loc = macList[macList.Count-1].snoId;
                    //        pdline = curProduct.ProId.Substring(0,1);
                    //        palletRep.UpdatePakLocMasForPdLineAndPnoDefered(CurrentSession.UnitOfWork,pdline,curPallet.PalletNo,"","PakLoc",loc);
                    //    }
                    //    else
                    //    {
                    //        //3.当不满足前面条件时,令@loc = 'Others'
                    //        loc = "Others";
                    //    }
                    //}
#endregion
                }
                else //ii.	如果数量不为1,则按照如下方法分配库位
                {
                    //1.查询PAK_LocMas 表,取满足条件Tp='PakLoc' and Pno=@plt 记录的SnoId 字段值保存到变量@loc 中,
                    //如果ISNULL(@loc, '') = '',则令@loc = 'Others'
                 
                    PakLocMasInfo normalconf = new PakLocMasInfo();
                    normalconf.pno = curPallet.PalletNo;
                    normalconf.tp = "PakLoc";
                    normalconf.wc = locWC;
                    macList = palletRep.GetPakLocMasList(normalconf);
                    if (macList.Count == 0 && !string.IsNullOrEmpty(locWC))
                    {
                        normalconf.wc = "";
                        macList = palletRep.GetPakLocMasList(normalconf);
                    }

                    if (macList.Count == 0)
                    {
                        loc = "";
                    }
                    else
                    {
                        loc = macList[0].snoId;
                    }
                    if (loc == "")
                    {
                        loc = "Others";
                    }

                    #region Vincent disable Code
                //    PakLocMasInfo neqconf = new PakLocMasInfo();
                //    neqconf.wc = "JP";

                //    if (jpflag)
                //    {
                //        PakLocMasInfo conf = new PakLocMasInfo();
                //        conf.pno = curPallet.PalletNo;
                //        conf.tp = "PakLoc";
                //        conf.wc = "JP";
                //        macList = palletRep.GetPakLocMasList(conf);
                //        if (macList.Count == 0)
                //        {
                //            macList = palletRep.GetPakLocMasList(normalconf, neqconf);//(curPallet.PalletNo, "PakLoc");
                //        }
                //    }
                //    else
                //    {
                //        macList = palletRep.GetPakLocMasList(normalconf, neqconf);//(curPallet.PalletNo, "PakLoc");
                //    }
                //    if (macList.Count == 0)
                //    {
                //        loc = "";
                //    }
                //    else
                //    {
                //        loc = macList[0].snoId;
                //    }
                //    if (loc == "")
                //    {
                //        loc = "Others";
                //    }
                #endregion
                } 
            }
            else if (curPallet.PalletNo.Substring(0, 2) == "NA")
            {   //b)	当LEFT(@plt,2)='NA'时,令@loc = 'OT'
                loc = "OT";
            }
            else if (curPallet.PalletNo.Substring(0, 2) == "BA")
            {   //c)当LEFT(@plt,2)='BA'时,令@loc=RTRIM(@carrier)
                loc = carrier.TrimEnd();
            }

            //i.如果LEFT(@plt,2)<>'NA' and LEFT(@plt,2)<>'BA'
            /*
            if (curPallet.PalletNo.Substring(0, 2) != "NA" && curPallet.PalletNo.Substring(0, 2) != "BA")
            {
                //a)如果@pqty <= 6,则令@loc='',并更新PAK_LocMas 表中满足条件Pno=@plt and Tp='PakLoc' 记录的Pno 字段值为''
                if (pqty <= 6)
                {
                    loc ="";
                    palletRep.UpdatePakLocMasForPnoDefered(CurrentSession.UnitOfWork, "", curPallet.PalletNo,"PakLoc");
                }
            }*/

            //j.	如果@emeastr<>'',则令@loc=RTRIM(@loc)+RTRIM(@pclor)
            if (!string.IsNullOrEmpty(emeastr))
            {
                loc = loc.TrimEnd() + pclor.TrimEnd();
            }

            //k.	准备HP EDI 数据,调用存储过程op_PackingData 实现
            //snoid char(9), --Product Id
            //@model char(12), --Product Model
            //@dn char(16), --Delivery
            //@plt char(12), --Pallet
            //@loc varchar(10),--Location
            //@pltqty int --Select Sum(DeliveryQty) from Delivery_Pallet where PalletNo = @plt
            //.CallOp_PackingData(string snoid, string model, string dn, string plt, string loc, int pltqty);
            //palletRep.CallOp_PackingData(curProduct.ProId, curProduct.Model, curDelivery.DeliveryNo, curPallet.PalletNo, loc, pqty);

            /*SqlParameter[] paramsArray = new SqlParameter[8];

            paramsArray[0] = new SqlParameter("@snoID", SqlDbType.Char);
            paramsArray[0].Value = curProduct.ProId;
            paramsArray[1] = new SqlParameter("@Model", SqlDbType.Char);
            paramsArray[1].Value = curProduct.Model;
            paramsArray[2] = new SqlParameter("@Delivery", SqlDbType.Char);
            paramsArray[2].Value = curDelivery.DeliveryNo;
            paramsArray[3] = new SqlParameter("@Pallet", SqlDbType.Char);
            paramsArray[3].Value = curPallet.PalletNo;
            paramsArray[4] = new SqlParameter("@Location", SqlDbType.VarChar);
            paramsArray[4].Value = loc;
            paramsArray[5] = new SqlParameter("@pltqty", SqlDbType.Int);
            paramsArray[5].Value = pqty;
            paramsArray[6] = new SqlParameter("@BoxId", SqlDbType.VarChar);
            paramsArray[6].Value = boxId;
            paramsArray[7] = new SqlParameter("@UCC", SqlDbType.VarChar);
            paramsArray[7].Value = ucc;

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString_PAK, CommandType.StoredProcedure, "op_PackingData", paramsArray);*/

            ////Lock The XXX: 2012.04.20 LiuDong
            //if (!string.IsNullOrEmpty(loc))
            //{
            //    Guid gUiD = Guid.Empty;
            //    var identity = new ConcurrentLocksInfo();
            //    identity.clientAddr = "N/A";
            //    identity.customer = CurrentSession.Customer;
            //    identity.descr = string.Format("ThreadID: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
            //    identity.editor = CurrentSession.Editor;
            //    identity.line = CurrentSession.Line;
            //    identity.station = CurrentSession.Station;
            //    identity.timeoutSpan4Hold = new TimeSpan(0, 0, 3).Ticks;
            //    identity.timeoutSpan4Wait = new TimeSpan(0, 0, 5).Ticks;
            //    gUiD = productRep.GrabLockByTransThread("Loc", loc, identity);
            //    CurrentSession.AddValue(Session.SessionKeys.lockToken_Loc, gUiD);
            //}
            ////Lock The XXX: 2012.04.20 LiuDong

            ////Lock The XXX: 2012.04.20 LiuDong
            //if (!string.IsNullOrEmpty(boxId))
            //{
            //    Guid gUiD = Guid.Empty;
            //    var identity = new ConcurrentLocksInfo();
            //    identity.clientAddr = "N/A";
            //    identity.customer = CurrentSession.Customer;
            //    identity.descr = string.Format("ThreadID: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
            //    identity.editor = CurrentSession.Editor;
            //    identity.line = CurrentSession.Line;
            //    identity.station = CurrentSession.Station;
            //    identity.timeoutSpan4Hold = new TimeSpan(0, 0, 3).Ticks;
            //    identity.timeoutSpan4Wait = new TimeSpan(0, 0, 5).Ticks;
            //    gUiD = productRep.GrabLockByTransThread("Box", boxId, identity);
            //    CurrentSession.AddValue(Session.SessionKeys.lockToken_Box, gUiD);
            //}
            ////Lock The XXX: 2012.04.20 LiuDong


            ////Lock The XXX: 2012.04.20 LiuDong
            //if (!string.IsNullOrEmpty(ucc))
            //{
            //    Guid gUiD = Guid.Empty;
            //    var identity = new ConcurrentLocksInfo();
            //    identity.clientAddr = "N/A";
            //    identity.customer = CurrentSession.Customer;
            //    identity.descr = string.Format("ThreadID: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
            //    identity.editor = CurrentSession.Editor;
            //    identity.line = CurrentSession.Line;
            //    identity.station = CurrentSession.Station;
            //    identity.timeoutSpan4Hold = new TimeSpan(0, 0, 3).Ticks;
            //    identity.timeoutSpan4Wait = new TimeSpan(0, 0, 5).Ticks;
            //    gUiD = productRep.GrabLockByTransThread("Ucc", ucc, identity);
            //    CurrentSession.AddValue(Session.SessionKeys.lockToken_Ucc, gUiD);
            //}
            ////Lock The XXX: 2012.04.20 LiuDong


            palletRep.CallOp_PackingDataDefered(CurrentSession.UnitOfWork, curProduct.ProId, curProduct.Model, curDelivery.DeliveryNo,
                                            curPallet.PalletNo, loc, pqty, BoxId, ucc);

            //如果Product 结合的Delivery 的Flag IMES_PAK..DeliveryInfo.InfoValue,Condition: InfoType = 'Flag' 属性为'N',
            //RegId IMES_PAK..DeliveryInfo.InfoValue,Condition: InfoType = 'RegId'属性不等于'SCN' 时,需要生成Box Ship Label Pdf Document
            //if ((flag == "N") && (regId != "SCN"))
            //UC Update 2012/03/28 不再限制RegId <> ‘SCN’ 才需要产生PDF
            if (flag == "N") 
            {
                CurrentSession.AddValue("CreatePDF", "pdf");
            }
            else
            {
                CurrentSession.AddValue("CreatePDF", "");
            }

            return base.DoExecute(executionContext);
        }
        /// <summary>
        /// 除第一个SN外,每次刷SN都调用该方法,进行SFC,判断Model是否和第一个相同,刷SN返回ProductID
        /// 将uutSN放到Session.CustSN里
        /// </summary>
        public IMES.DataModel.ProductModel ScanSN(string productID, string uutSN,string deliveryNo)     //接口改为productID
        {
            logger.Debug("(CombinePOInCartonImpl)ScanSN start, productID:" + productID + "uutSN:" + uutSN);
            logger.Error("------------------ScanSN-----------------uutSN=" + uutSN);
            FisException ex;
            List<string> erpara = new List<string>();

            try
            {
                string sessionKey = productID;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);

                if (currentSession == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {
                    //Add by Benson at 20110915
                    IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                    Delivery currentDelivery = DeliveryRepository.Find(deliveryNo);
                    currentSession.AddValue(Session.SessionKeys.DeliveryNo, deliveryNo);
                    currentSession.AddValue(Session.SessionKeys.Delivery, currentDelivery);
                    
                    //Add by Benson at 20110915
              
                    currentSession.AddValue(Session.SessionKeys.CustSN, uutSN);
                    currentSession.Exception = null;
                    currentSession.SwitchToWorkFlow();

               

                    if (currentSession.Exception != null)
                    {
                        if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            currentSession.ResumeWorkFlow();
                        }
                        throw currentSession.Exception;
                    }



                    IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();

                    var uutProduct = CommonImpl.GetProductByInput(uutSN, CommonImpl.InputTypeEnum.CustSN);
                    currentModel.CustSN = uutProduct.CUSTSN;
                    currentModel.ProductID = uutProduct.ProId;
                    currentModel.Model = uutProduct.Model;

                    return currentModel;
                }
            }
            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("(CombinePOInCartonImpl)ScanSN end, productID:" + productID + "uutSN:" + uutSN);
            }
        }
Example #20
0
        /// <summary>
        /// 输入Product Id和相关信息
        /// </summary>
        /// <param name="pdLine">Pd Line</param>
        /// <param name="prodId">Product Id</param>
        /// <param name="editor">operator</param>
        public ArrayList InputProdId(string pdLine, string prodId, string editor, string stationId, string PrintLogName, string customer, IList<PrintItem> printItems)
        {
            logger.Debug("(EEPLabelPrint)InputProdId start, [pdLine]:" + pdLine
                + " [prodId]: " + prodId
                + " [editor]:" + editor
                + " [station]:" + stationId
                + " [customer]:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = prodId;

            try
            {
                Session session = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);

                if (session == null)
                {
                    session = new Session(sessionKey, ProductSessionType, editor, stationId, pdLine, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    //一个MB_SNo对应一个workflow
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", stationId);
                    wfArguments.Add("CurrentFlowSession", session);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", pdLine);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", ProductSessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(stationId, "EEPLabelPrint.xoml", "EEPLabelPrint.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    session.AddValue(Session.SessionKeys.PrintLogName, printItems[0].LabelType);
                    session.AddValue(Session.SessionKeys.PrintLogBegNo, prodId);
                    session.AddValue(Session.SessionKeys.PrintLogEndNo, prodId);
                    session.AddValue(Session.SessionKeys.PrintLogDescr, "");
                    session.AddValue(Session.SessionKeys.PrintItems, printItems);

                    session.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(session))
                    {
                        session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    session.WorkflowInstance.Start();
                    session.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }

                //session.SwitchToWorkFlow();

                //check workflow exception
                if (session.Exception != null)
                {
                    if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        session.ResumeWorkFlow();
                    }

                    throw session.Exception;
                }
                UnitOfWork uow = new UnitOfWork();
                ArrayList retList = new ArrayList();
                IProductRepository iProductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();
                Product tempProduct = (Product)session.GetValue(Session.SessionKeys.Product);
                ProductModel curProduct = new ProductModel();
                if (string.IsNullOrEmpty(tempProduct.CUSTSN))
                {
                    tempProduct.CUSTSN = tempProduct.ProId;
                }
                iProductRepository.Update(tempProduct, uow);
                uow.Commit();
                curProduct.CustSN = tempProduct.CUSTSN;
                curProduct.ProductID = tempProduct.ProId;
                curProduct.Model = tempProduct.Model;
                IList<PrintItem> retprintitem = (IList<PrintItem>)session.GetValue(Session.SessionKeys.PrintItems);
                retList.Add(curProduct);
                retList.Add(retprintitem);
                return retList;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(EEPLabelPrint)InputProdId end, [pdLine]:" + pdLine
                    + " [prodId]: " + prodId
                    + " [editor]:" + editor
                    + " [station]:" + stationId
                    + " [customer]:" + customer);
            }
        }
        /// <summary>
        /// 刷第一个SN时,调用该方法启动工作流053CombinePOInCarton.xoml,根据输入CustSN获取Model,
        /// 将SN放到Session.CustSN里
        /// 成功后将ProductModel.Model放到Session.FirstProductModel中
        /// 调用getDNList
        /// </summary>
      //  public IMES.DataModel.ProductModel ScanFirstSN(string firstSN, string line, string editor, string station, string customer)
     
        public IMES.DataModel.ProductModel ScanFirstSN(string firstSN, string line, string editor, string station, string customer)
        
    {
        
            logger.Debug("(CombinePOInCartonImpl)ScanFirstSN start, firstSN:" + firstSN + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            logger.Error("------------------ScanFirstSN-----------------firstSN=" + firstSN);
            FisException ex;
            List<string> erpara = new List<string>();

            try
            {

                var currentProduct = CommonImpl.GetProductByInput(firstSN, CommonImpl.InputTypeEnum.CustSN);
                if(!CheckIsFRU(currentProduct.Model))
                {
                    erpara.Add(currentProduct.Model);
                    FisException fe = new FisException("CHK177", erpara);
                    throw fe;
                }

                if (!string.IsNullOrEmpty(currentProduct.CartonSN))
                {
                    //需要保证Product的CartonSN无值
                    FisException fe = new FisException("CHK151", new string[] { firstSN });
                    throw fe;
                }
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);
              //  station = "82";

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, ProductSessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", ProductSessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "126CombinePOInCartonForFRU.xoml", "126CombinePOInCartonForFRU.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.CustSN, firstSN);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.AddValue(Session.SessionKeys.isDNFull, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }


                IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();
                currentModel.CustSN = currentProduct.CUSTSN;
                currentModel.ProductID = currentProduct.ProId;
                currentModel.Model = currentProduct.Model;
           //      isFRU=CheckIsFRU( currentModel.Model);
                currentSession.AddValue(Session.SessionKeys.FirstProductModel, currentProduct.Model);

                return currentModel;

            }
            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("(CombinePOInCartonImpl)ScanFirstSN end, firstSN:" + firstSN + "line:" + line + "editor:" + editor + "station:" + station + "customer" + customer);
            }
        }
Example #22
0
        public ArrayList checkCOAQuery(string prodId)
        {
            logger.Debug("(PDPALabel02)checkCOA start,"
                + " [prodId]: " + prodId);

            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = prodId;

            try
            {

                Session curSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (curSession == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    //ex.logErr("", "", "", "", "83");
                    //logger.Error(ex);
                    throw ex;
                }
                else
                {

                    //========================================================
                    curSession.Exception = null;
                    curSession.SwitchToWorkFlow();

                    if (curSession.Exception != null)
                    {
                        if (curSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            curSession.ResumeWorkFlow();
                        }

                        throw curSession.Exception;
                     }
                   
                    //========================================================

                    ArrayList retList = new ArrayList();
                    ProductModel curModel = new ProductModel();
                    Product curProduct = (Product)curSession.GetValue(Session.SessionKeys.Product);
                    IList<WipBufferDef> wipBufferList = (IList<WipBufferDef>)curSession.GetValue("WipBuffer");
                                        
                    retList.Add(wipBufferList);
                    retList.Add(curProduct.DeliveryNo);
                    retList.Add(curProduct.PalletNo);
                    
                    //========================================================
                    return retList;

                }
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(PDPALabel02)InputWWANSN end,"
                   + " [prodId]: " + prodId);
            }

        }
Example #23
0
        /// <summary>
        /// 启动工作流,根据输入productID获取ProductModel,成功后调用CheckSN
        /// </summary>
        /// <param name="sessionKey"></param>
        /// <returns>返回Model</returns>

         ProductModel IJapaneseLabelPrint.InputUUT(string productID, string line, string editor, string station, string customer)
        {
            logger.Debug("(JapaneseLabelPrintImpl)InputUUT start, productID:" + productID + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            string sessionKey = productID;
            try
            {
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, ProductSessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", ProductSessionType);

                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "047JapaneseLabelPrint.xoml", "047JapaneseLabelPrint.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.Product, sessionKey);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }

                ProductModel modelInfo = new ProductModel();
                Product tempProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product);
                modelInfo.ProductID = tempProduct.ProId;
                modelInfo.Model = tempProduct.Model;
                modelInfo.CustSN = tempProduct.CUSTSN;

                return modelInfo;


            }
            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("(JapaneseLabelPrintImpl)InputUUT end, productID:" + productID + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Example #24
0
        /// <summary>
        /// 重新列印Customer SN
        /// </summary>
        /// <param name="prodId">Product Id</param>
        /// <param name="editor">operator</param>
        /// <returns>Print Items</returns>
        public ArrayList Reprint(string prodId, string editor, string stationId, string customer, IList<PrintItem> printItems, string reason, out string customerSN)
        {
            logger.Debug("(GenerateCustomerSNImpl)Reprint start,"
                + " [prodId]: " + prodId
                + " [editor]:" + editor
                + " [station]:" + stationId
                + " [customer]:" + customer);
            FisException ex;
            List<string> erpara = new List<string>();
            //string sessionKey = prodId;
            IMES.FisObject.FA.Product.IProduct product = null;

            try
            {
                //修改为输入custSN
                var currentProduct = CommonImpl.GetProductByInput(prodId, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;

                ArrayList retList = new ArrayList();
                Session session = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);

                if (session == null)
                {
                    session = new Session(sessionKey, ProductSessionType, editor, stationId, string.Empty, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    //一个MB_SNo对应一个workflow
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", stationId);
                    wfArguments.Add("CurrentFlowSession", session);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", ProductSessionType);

                    //session.AddValue(Session.SessionKeys.PrintLogBegNo, prodId);
                    //session.AddValue(Session.SessionKeys.PrintLogEndNo, prodId);
                    session.AddValue(Session.SessionKeys.Reason, reason);
                    session.AddValue(Session.SessionKeys.PrintItems, printItems);

                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow("022ReprintServiceTag.xoml", null, wfArguments);

                    session.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(session))
                    {
                        session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    session.WorkflowInstance.Start();
                    session.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }

                //session.SwitchToWorkFlow();

                //check workflow exception
                if (session.Exception != null)
                {
                    if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        session.ResumeWorkFlow();
                    }

                    throw session.Exception;
                }

                product = (IMES.FisObject.FA.Product.IProduct)session.GetValue(Session.SessionKeys.Product);

                customerSN = (product == null ? string.Empty : product.CUSTSN);
                IList<PrintItem> printList = this.getPrintList(session);

                ProductModel curproc = new ProductModel();
                curproc.CustSN = product.CUSTSN;
                curproc.ProductID = product.ProId;
                curproc.Model = product.Model;

                string labelType = "";
                if (product.Family.ToUpper().IndexOf("AKASHI") < 0)
                {
                    labelType = "SN Label";
                }
                else
                {
                    labelType = "SN_AKASHI_Label";
                }

                retList.Add(printList);
                retList.Add(curproc);
                retList.Add(labelType);

                return retList;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(GenerateCustomerSNImpl)Reprint end,"
                    + " [prodId]: " + prodId
                    + " [editor]:" + editor
                    + " [station]:" + stationId
                    + " [customer]:" + customer);
            }
        }
Example #25
0
        /// <summary>
        /// 根据刷入的Customer S/N,SFC,获得 Product ID,Customer P/N 信息
        /// Product ID: Product.ProductID;
        /// Customer P/N: Product.Model对应的Model.CustPN
        /// </summary>
        ProductModel IPodLabelCheck.InputCustSnOnCooLabel(string custsn, string pdLine, string editor, string station, string customer, out string custpn , out MRPLabelDef MRP,out string BoxID)
        {
            logger.Debug("(PodLabelCheckImpl)InputCustSNOnCooLabel start, custsn:" + custsn + "pdLine:" + pdLine + "editor:" + editor + "station:" + station + "customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();

            try
            {
                       
                var currentProduct = CommonImpl.GetProductByInput (custsn, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                CommonImpl2 cm2 = new CommonImpl2();
                string label = "";
                label = cm2.CheckPodLabel(custsn);
                if (label == "")
                { label = cm2.CheckConfigLabel(custsn); }
                if (string.IsNullOrEmpty(label))
                {
                    throw new FisException("SFC013", new string[] { });
                }

                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, editor, station, pdLine, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", pdLine);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Product);
                    
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "PodLabelCheck.xoml", "PodLabelCheck.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.CustSN, custsn);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }


                ProductModel currentProductModel = new ProductModel();

                currentProductModel.CustSN = currentProduct.CUSTSN;
                currentProductModel.Model = currentProduct.Model;
                currentProductModel.ProductID = currentProduct.ProId;

                custpn = string.Empty;
                //custpn = currentProduct.ModelObj.CustPN;
                //if (String.IsNullOrEmpty(custpn))
                //{
                //    erpara.Add(custsn);
                //    ex = new FisException("CHK043", erpara);
                //    throw ex;
                //} //UC Revision: 7294: CustPN 修改为Model
                //Revision: 9810:	修改列印Config Label 的条件为非BT
                currentSession.AddValue(Session.SessionKeys.ifElseBranch, ""); 
                IDeliveryRepository iDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                
                string printlabeltype1 = string.Empty; // Config Label
                string printlabeltype2 = string.Empty; // POD Label
                string delievery = string.Empty;    // currentDeliveryNo
                string pno = string.Empty;      // currentModel
                delievery = currentProduct.DeliveryNo;
                if (!currentProduct.IsBT)
                {
                    string BTRegId =(string) iDeliveryRepository.GetDeliveryInfoValue(delievery, "RegId");
                    if (BTRegId != null && BTRegId.Length == 3)
                    { BTRegId = BTRegId.Substring(1, 2); }
                    else
                    { BTRegId = ""; }
                    string BTShipTp = iDeliveryRepository.GetDeliveryInfoValue(delievery, "ShipTp");
                    string BTCountry = iDeliveryRepository.GetDeliveryInfoValue(delievery, "Country");

                    if (!string.IsNullOrEmpty(BTRegId) && !string.IsNullOrEmpty(BTShipTp) && !string.IsNullOrEmpty(BTCountry))
                    {
                        //ITC-1360-1527:RegId 为'SNE'时,未能打印CONFIG LABEL                       
                        //if ((BTRegId == "CN" || BTRegId == "AF" || BTRegId == "NE" || BTRegId == "CE") && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                        if ((ActivityCommonImpl.Instance.CheckDomesticDN(BTRegId) || BTRegId == "AF" || BTRegId == "NE" || BTRegId == "CE") && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                        {
                            printlabeltype1 = "ConfigLabel";
                            currentSession.AddValue(Session.SessionKeys.ifElseBranch, printlabeltype1);
                            currentProductModel.CustSN = printlabeltype1;
                        }
                    }
                }
               
               
                //  Print =====如果IMES_PAK..PODLabelPart中有维护PartNo等于Model的前几位字符的记录 and (Model的第7位不是数字),则需要列印POD Label====
                pno = currentProduct.Model;
                IList<PODLabelPartDef> podLabelPartLst = new List<PODLabelPartDef>();
                podLabelPartLst = ipartRepository.GetPODLabelPartListByPartNo(pno);
                if (podLabelPartLst.Count > 0)
                {
                    string number = "0123456789";
                    string modelbit = currentProduct.Model.Substring(6, 1);
                    if (!number.Contains(modelbit)) //Model的第7位不是数字
                    {
                        printlabeltype2 = "PODLabel";
                        currentSession.AddValue(Session.SessionKeys.ifElseBranch, printlabeltype2);  //如果列印PodLabel,则需要再记录一次ProductLog (Station = 'PD',Line = 'POD Label Print')
                        currentProductModel.CustSN = printlabeltype2;
                    }
                }
                MRP = new MRPLabelDef();
                MRP = iDeliveryRepository.GetMRPLabel(delievery);
                if (MRP == null)
                {
                    MRP = new MRPLabelDef();
                    MRP.IndiaPrice = "";
                    MRP.IndiaPriceDescr = "";
                    MRP.IndiaPriceID = "";
                }
                BoxID = iProductRepository.GetProductInfoValue(currentProduct.ProId, "BoxId");
                if (BoxID == null)
                {
                    BoxID = "";
                }
                return currentProductModel;
            }
            catch (FisException e)
            {
                //logger.Error(e.mErrmsg, e);
                //throw new Exception(e.mErrmsg);
                logger.Error(e.mErrmsg, e);
                if (e.mErrcode == "CHK020") //序號已被刷入
                {
                    throw e;
                }
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PodLabelCheckImpl)InputCustSNOnCooLabel end, custsn:" + custsn + "pdLine:" + pdLine + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Example #26
0
        /// <summary>
        /// 刷uutSn,启动工作流,检查输入的uutSn,卡站,获取ProductModel
        /// </summary>
        /// <param name="uutSn"></param>
        /// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <returns>ProductModel</returns>
        public ArrayList InputSN(string uutSn, string line, string editor, string station, string customer)
        {
            logger.Debug("(PAQCOutputImpl)InputSN start, uutSn:" + uutSn);

            try
            {
                var currentProduct = CommonImpl.GetProductByInput(uutSn, CommonImpl.InputTypeEnum.CustSN);
                //****** add by Benson at 2013/05/10 for Unit Weight当Non BT 产品时,只能由Pass Ship to Station(95) 进入
                /* Move the logic form SP [IMES_SFC_Product] to here
                 * else if (@CurrentStation ='PO'and @PreStation ='85')
                     begin
                         if (@NeedPODLabel ='Y' OR @NeedConfigLabel ='Y')
                         begin
                             select 'SFC014',@Key
                             return
                         end
                     end */
                string site = IMES.Infrastructure.Utility.Common.CommonUti.GetSite();
                if (site != "ICC")
                {
                    IList<ProductLog> lstLog = currentProduct.ProductLogs.OrderByDescending(x => x.Cdt).ToList();
                    string preStation = lstLog[0].Station;
                    string label = "";
                    if (station == "PO" && preStation == "85")
                    {
                        CommonImpl2 cm2 = new CommonImpl2();
                        label = cm2.CheckPodLabel(uutSn);
                        if (label == "")
                        { label = cm2.CheckConfigLabel(uutSn); }
                        if (string.IsNullOrEmpty(label))
                        {
                            throw new FisException("SFC014", new string[] { });
                        }
                    }
                }
              


                //****** add by Benson at 2013/05/10

                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", SessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "043PAQCOutput.xoml", "043PAQCOutput.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }
                //==============================================================================
                ArrayList retList = new ArrayList();
                //Get infomation
                Product curProduct = (Product)currentSession.GetValue(Session.SessionKeys.Product);
                IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();

                //a.	如果Product 在QCStatus 中不存在记录,则报告错误:“此Product 在QCStatus 中不存在记录,请联系相关人员”

                if (curProduct.QCStatus.Count == 0)
                {
                    SessionManager.GetInstance.RemoveSession(currentSession);
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("PAK110", erpara);//此Product 在QCStatus 中不存在记录,请联系相关人员
                    throw ex;

                }

                currentModel.CustSN = curProduct.CUSTSN;
                currentModel.ProductID = curProduct.ProId;
                currentModel.Model = curProduct.Model;

                retList.Add(currentModel);


                //select b.Line + ' ' + b.Descr from ProductStatus a (nolock), Line b (nolock)
                //WHERE a.ProductID = @ProductId
                //AND a.Line = b.Line
                ILineRepository lineRepository = RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
                Line pdline = lineRepository.Find(curProduct.Status.Line);

                string strline = "";
                strline = pdline.Id + " " + pdline.Descr;
                retList.Add(strline);
                //===============================================================================

                return retList;

            }
            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("(PAQCOutputImpl)InputSN end, uutSn:" + uutSn);
            }
        }
Example #27
0
        public ArrayList InputSN_subFunc_isBT(string inputSN, string deliveryNo, string model, string firstProID, string line, string editor, string station, string customer, string isBT, bool newflag, ref IProduct curProduct)
        {
            ArrayList retList = new ArrayList();

            string strSQL = "";
            SqlParameter paraName = null;
            DataTable tb = null;

            if ("N".Equals(isBT))
            {
                FisException ex;
                List<string> erpara = new List<string>();
                ex = new FisException("DCK004", erpara);//BT机器
                throw ex;
            }

            if ("".Equals(isBT))
            {
                if ("".Equals(deliveryNo))
                {
                    // RTRIM(DeliveryNo) + '_' + CONVERT(varchar, ShipDate, 111) + '_' + CONVERT(varchar, Qty) as DeliveryListItem
                    strSQL = @"SELECT RTRIM(DeliveryNo) + '_' + CONVERT(varchar, ShipDate, 111) + '_' + CONVERT(varchar, Qty) as DeliveryListItem
	FROM Delivery d WHERE Status ='00' And Model = @Model And ShipDate >= CONVERT(char(10),GETDATE() - 5,111)  
    and Qty>(select COUNT(1) from Product where DeliveryNo=d.DeliveryNo) ORDER BY ShipDate";
                    // 
                    paraName = new SqlParameter("@Model", SqlDbType.VarChar, 32);
                    paraName.Direction = ParameterDirection.Input;
                    paraName.Value = curProduct.Model;
                    tb = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, System.Data.CommandType.Text, strSQL, paraName);
                    if (tb == null || tb.Rows.Count == 0)
                    {
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(curProduct.Model);
                        ex = new FisException("DCK002", erpara);//Not Found PoData for ' + @Model
                        throw ex;
                    }

                    ArrayList lstDNs = new ArrayList();
                    for (int i = 0; i < tb.Rows.Count; i++)
                    {
                        lstDNs.Add(tb.Rows[i]["DeliveryListItem"].ToString());
                    }

                    retList.Add("SUCCESS");
                    retList.Add(lstDNs);
                    retList.Add("");
                    retList.Add("");//Total Qty
                    retList.Add("");//PCs in Carton
                    retList.Add("");//Packed Qty
                    retList.Add("");//Delivery Item
                    retList.Add("NeedDN"); // isBT, Need choose dn ; mantis 1696
                    //========================================================
                    return retList;
                }
                isBT = "Y";
            }

            if (!string.IsNullOrEmpty(curProduct.DeliveryNo))
            {
            }
            curProduct.DeliveryNo = deliveryNo;

            if (model == "")
            {
                model = curProduct.Model;
            }

            if (firstProID == "")
            {
                firstProID = curProduct.ProId;
            }
            //g.	如果Product 结合的Delivery 与页面上[Delivery] 中的不同,则报告错误:“Delivery is not match!”
            if (curProduct.DeliveryNo != deliveryNo)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.CUSTSN);
                ex = new FisException("PAK130", erpara);//Delivery is not match!
                throw ex;
            }

            //检查Product Model (Product.Model) 是否与页面上的[Model] 相同,如果不同,则报告错误:“Model is not match!”
            if (curProduct.Model != model)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.Model);
                ex = new FisException("PAK131", erpara);//Model is not match!
                throw ex;
            }

            //c)如果Product 结合的Delivery 在数据库中不存在或者ShipDate 已经是5天以前了,则报告错误:“Not found Delivery for ”+ @Model
            DateTime beginCdt = DateTime.Now.AddDays(-5);
            Delivery curDev = deliveryRep.Find(curProduct.DeliveryNo);
            if (curDev == null || curDev.ShipDate < beginCdt)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.Model);
                ex = new FisException("PAK129", erpara);
                throw ex;
            }

            //h.	如果用户刷入的Product Id (可能是直接刷入的,也可能是基于Customer S/N查询到的)已经刷过,则报告错误:“Duplicate data!”
            if (!string.IsNullOrEmpty(curProduct.CartonSN))
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(curProduct.Model);
                ex = new FisException("PAK134", erpara);//Duplicate data!
                throw ex;
            }


            string sessionKey = firstProID;
            Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

            if (currentSession == null)
            {
                if (!newflag)
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    ex = new FisException("PAK157", erpara);
                    retList.Add("Error");
                    retList.Add(ex);
                    return retList;
                }
                currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                wfArguments.Add("Key", sessionKey);
                wfArguments.Add("Station", station);
                wfArguments.Add("CurrentFlowSession", currentSession);
                wfArguments.Add("Editor", editor);
                wfArguments.Add("PdLine", line);
                wfArguments.Add("Customer", customer);
                wfArguments.Add("SessionType", SessionType);

                string wfName, rlName;

                RouteManagementUtils.GetWorkflow(station, "CombinePoInCarton.xoml", "CombinePoInCarton.rules", out wfName, out rlName);
                WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                currentSession.AddValue(Session.SessionKeys.Product, curProduct);
                IList<IProduct> productList = new List<IProduct>();
                currentSession.AddValue(Session.SessionKeys.ProdList, productList);
                IList<string> productIDList = new List<string>();
                currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, productIDList);

                currentSession.SetInstance(instance);

                if (!SessionManager.GetInstance.AddSession(currentSession))
                {
                    currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }

                currentSession.WorkflowInstance.Start();
                currentSession.SetHostWaitOne();
            }
            else
            {
                if (newflag)
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }
                currentSession.AddValue(Session.SessionKeys.Product, curProduct);

                currentSession.Exception = null;
                currentSession.SwitchToWorkFlow();
                /*FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(sessionKey);
                ex = new FisException("CHK020", erpara);
                throw ex;*/
            }
            if (currentSession.Exception != null)
            {
                if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                {
                    currentSession.ResumeWorkFlow();
                }
                IList<IProduct> productList = (List<IProduct>)currentSession.GetValue(Session.SessionKeys.ProdList);
                if (productList.Count == 0)
                {
                    SessionManager.GetInstance.RemoveSession(currentSession);
                }
                throw currentSession.Exception;
            }
            //========================================================                
            //SELECT Qty as [Total Qty] FROM Delivery NOLOCK WHERE DeliveryNo = @Delivery
            //SELECT InfoValue as [PCs in Carton] FROM DeliveryInfo NOLOCK WHERE DeliveryNo = @Delivery AND InfoType = ‘CQty’
            //SELECT COUNT(ProductID) as [Packed Qty] FROM Product NOLOCK WHERE DeliveryNo = @Delivery

            ProductModel curModel = new ProductModel();

            curModel.ProductID = curProduct.ProId;
            curModel.CustSN = curProduct.CUSTSN;
            curModel.Model = curProduct.Model;

            IList<IProduct> proList = (List<IProduct>)currentSession.GetValue(Session.SessionKeys.ProdList);
            IList<string> idList = (List<string>)currentSession.GetValue(Session.SessionKeys.NewScanedProductIDList);
            proList.Add(curProduct);
            idList.Add(curProduct.ProId);

            currentSession.AddValue(Session.SessionKeys.ProdList, proList);
            currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, idList);

            string keysessionDNForBT = "ChangeToDN";
            string sessionDNForBT = currentSession.GetValue(keysessionDNForBT) as string;
            if (string.IsNullOrEmpty(sessionDNForBT))
            {
                currentSession.AddValue(keysessionDNForBT, deliveryNo);
            }
            else if (!deliveryNo.Equals(sessionDNForBT))
            {
            }

            string keysessionProIdsForBT = "prodsToChangeToDN";
            ArrayList sessionProIdsForBT = currentSession.GetValue(keysessionProIdsForBT) as ArrayList;
            if (sessionProIdsForBT == null)
            {
                sessionProIdsForBT = new ArrayList();
            }
            sessionProIdsForBT.Add(curProduct);
            currentSession.AddValue(keysessionProIdsForBT, sessionProIdsForBT);

            currentSession.AddValue("isBT", isBT);

            string cQtyStr = (string)curDev.GetExtendedProperty("CQty");
            int cQty = 0;
            if (string.IsNullOrEmpty(cQtyStr))
            {
                cQty = 5;
            }
            else
            {
                decimal tmp = Convert.ToDecimal(cQtyStr);
                cQty = Convert.ToInt32(tmp);
            }
            int packedqty = 0;
            var tmpList = productRep.GetProductListByDeliveryNo(curDev.DeliveryNo);
            foreach (var prod in tmpList)
            {
                if (!string.IsNullOrEmpty(prod.CartonSN))
                {
                    packedqty++;
                }
            }

            //RTRIM(DeliveryNo) + ‘_’ + CONVERT(varchar, ShipDate, 111) + ‘_’ + CONVERT(varchar, Qty) 
            //就是UI 中[Delivery] List 中Item 的显示格式,正确取得Product 结合的Qty 后,要在[Delivery] 中选中该Delivery
            string devStr = curDev.DeliveryNo + "_" + curDev.ShipDate.Year.ToString("d4") + "/"
                + curDev.ShipDate.Month.ToString("d2") + "/" + curDev.ShipDate.Day.ToString("d2") + "_" + curDev.Qty.ToString();

            retList.Add("SUCCESS");
            retList.Add(curModel);
            retList.Add(curProduct.DeliveryNo);
            retList.Add(curDev.Qty);//Total Qty
            retList.Add(cQty);//PCs in Carton
            retList.Add(packedqty);//Packed Qty
            retList.Add(devStr);//Delivery Item
            retList.Add("Y"); // isBT ; mantis 1696
            //========================================================
            return retList;
        }
Example #28
0
        /// <summary>
        /// 启动工作流,根据输入productID获取ProductModel,成功后调用getExplicitCheckItem
        /// 如果有需要刷料检查的CheckItem,调用checkExplicitCheckItem,否则调用Save
        /// </summary>
        ProductModel IJPNPVS.InputUUT(string custSN, string line, string editor, string station, string customer)
        {
            logger.Debug("(JPNPVSImpl)InputUUT start, custSN:" + custSN + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();

            try
            {
                var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, currentSessionType);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, currentSessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", currentSessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "048JPNPVS.xoml", "048JPNPVS.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(custSN);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }

                IMES.DataModel.ProductModel currentModel = new IMES.DataModel.ProductModel();

                currentModel.CustSN = currentProduct.CUSTSN;
                currentModel.ProductID = currentProduct.ProId;
                currentModel.Model = currentProduct.Model;

                return currentModel;

            }
            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("(JPNPVSImpl)InputUUT end, custSN:" + custSN + "line:" + line + "editor:" + editor + "station:" + station + "customer" + customer);
            }
        }
Example #29
0
        /// <summary>
        /// 记录过站Log,更新机器状态,返回打印重量标签的PrintItem,结束工作流。
        /// 将Session.IsComplete设为True
        /// </summary>
        /// <param name="productID">production id</param>
        /// <param name="printItems">打印列表</param> 
        /// <param name="cust sn">cust sn</param> 
        /// <returns>打印列表</returns>
        public IList<PrintItem> Save(string prodId, IList<PrintItem> printItems, out string custSn)
        {
            logger.Debug("(_FGShippingLabel)Save start, prodId:" + prodId);

            FisException ex;
            string sessionKey = prodId;
            List<string> erpara = new List<string>();
            Session Session = SessionManager.GetInstance.GetSession(sessionKey, TheType);
            string sn = "";
            if (Session == null)
            {
                erpara.Add(sessionKey);
                ex = new FisException("CHK021", erpara);
                throw ex;
            }
            try
            {

                Session.Exception = null;
                Session.AddValue(Session.SessionKeys.IsComplete, true);
                Session.AddValue(Session.SessionKeys.PrintItems, printItems);
                
                Session.SwitchToWorkFlow();

                if (Session.Exception != null)
                {
                    if (Session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        Session.ResumeWorkFlow();
                    }

                    throw Session.Exception;
                }


                IList<PrintItem> returnList = this.getPrintList(Session);
                IProduct product = (IProduct)Session.GetValue(Session.SessionKeys.Product);
                ProductModel currentModel = new ProductModel();
                if (product != null)
                {
                    sn = product.CUSTSN;
                }
                custSn = sn;
                return returnList;
            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(_FGShippingLabel)Save end, prodId:" + prodId);
            }
        }