Exemplo n.º 1
0
        /// <summary>
        /// 刷第一个SN时,调用该方法启动工作流,根据输入CustSN获取PalletInfo,成功后调用InputCustSn
        /// 将custSN放到Session.CustSN中(string)
        /// 返回ArrayList
        /// </summary>
        public ArrayList InputFirstCustSn(string firstSn, string line, string editor, string station, string customer, out int index)
        {
            logger.Debug("(PalletVerifyOnlyImpl)InputCustSNOnCooLabel start, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);

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

            try
            {
                //根据输入的Customer S/N, 获得对应的Product
                var currentProduct = CommonImpl.GetProductByInput(firstSn, CommonImpl.InputTypeEnum.CustSN);
                if (string.IsNullOrEmpty(currentProduct.ProId))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                    throw ex;

                }
                

                //取得Customer S/N 绑定的Delivery No :IMES_FA..Product.DeliveryNo
                if (string.IsNullOrEmpty(currentProduct.DeliveryNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK020", erpara);    //该Customer S/N还未与DN绑定!
                    throw ex;
                }
                string curDn = currentProduct.DeliveryNo;

                //获取Pallet No : IMES_FA..Product.PalletNo
                if (string.IsNullOrEmpty(currentProduct.PalletNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK021", erpara);     //该Customer S/N还未与Pallet绑定!
                    throw ex;
                }
                string currentPalletNo = currentProduct.PalletNo;
                
     

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

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, 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", Session.SessionType.Product);

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

                    currentSession.AddValue(Session.SessionKeys.CustSN, firstSn);
                    currentSession.AddValue(Session.SessionKeys.PalletNo, currentPalletNo);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.DeliveryNo, curDn);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);

                    //For Check OA3
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IList<ConstValueInfo> cvInfo = new List<ConstValueInfo>();
           
                    //ConstValueInfo cvCond = new ConstValueInfo();
                    //cvCond.type = "CheckOA3State";
                    //cvCond.name = "OA3UpSAP";
                    //bool bNeedCheckEOA = partRepository.GetConstValueInfoList(cvCond).Any(x => x.value == "Y");
    
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA=false;
                    GetAndCheckOA3Setting(currentProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);

                    //string fkiPath = System.Configuration.ConfigurationManager.AppSettings["FKIServicePath"].Trim();
                    //string fkiUser = System.Configuration.ConfigurationManager.AppSettings["FKIAuthUser"].Trim();
                    //string fkiPwd = System.Configuration.ConfigurationManager.AppSettings["FKIAuthPassword"].Trim();
                    currentSession.AddValue("FKIServicePath", fkiPath);
                    currentSession.AddValue("FKIAuthUser", fkiUser);
                    currentSession.AddValue("FKIAuthPassword", fkiPwd);
                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }
                    IMES.FisObject.FA.Product.IProduct prd = (IMES.FisObject.FA.Product.IProduct)currentProduct;
                    IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                   // bool bNoNeedCheckEOA = partRepository.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                                                             //  Any(x => x == "Y");
                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRep.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == currentProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                         IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currentProduct.Model);
                        if (!cmm2.CheckOA3Key(bom, prd, fkiPath, FKICredentialCache, editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                            throw new FisException("PAK158", new string[] { currentProduct.CUSTSN, currentProduct.DeliveryNo });
                        }
                    }

                    //For Check OA3

                    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;
                }
               

                // 获取该Pallet 上的SKU 列表
                // 该Pallet 上的SKU 列表:IMES_FA..Product.PalletNo = @PalletNo的所有记录
                // SKU 列表显示如下信息:Product ID | Customer S/N | PAQC | POD | WC | Collection Data
                // 按照Customer S/N 升序排序
                IList<string> productNoList = new List<string>();
                IList<string> custSnList = new List<string>();
                
                // retLst[0]-[2]
                string dummyPalletNo = string.Empty;
                dummyPalletNo = (string)currentSession.GetValue(Session.SessionKeys.DummyPalletNo);
                productNoList = (IList<string>) currentSession.GetValue(Session.SessionKeys.ProdNoList);
                custSnList = (IList<string>) currentSession.GetValue(Session.SessionKeys.CustomSnList);
                retLst.Add(dummyPalletNo);
                retLst.Add(productNoList);
                retLst.Add(custSnList);

                IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>();
                
                // Mantis Bug :http://10.99.183.26/Mantis/view.php?id=627 (改为前台页面收集scanProductNoList)
                // Update IMES_FA..ProductStatus ( 更新Pallet 上已收集的PRODUCT 的状态)
                //IList<string> scanProductNoList = new List<string>();
                //scanProductNoList.Add(currentProduct.ProId);
                //currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, scanProductNoList);
                
                int i = 0;
                index = 0;
                foreach (string iprod in productNoList)
                {
                  
                  if (iprod== currentProduct.ProId && custSnList[i] == firstSn)
                    {
                        index = i+1;
                        break;
                    }
                  else i++;
                }
               
                // PAQC –retLst[3]: 使用ProductID = @ProductId and Tp = 'PAQC' 查询IMES_FA..QCStatus 表取Udt 最新的记录,如果该记录的Status = '8',则PAQC 栏位显示'PAQC';Status = '9',则PAQC 栏位显示'Pass';Status = 'A',则PAQC 栏位显示'Fail';Status = '1',则PAQC 栏位显示'No Check';
                IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                IList<string> PAQCStatusLst = new List<string>();
                foreach (string iprod in productNoList)
                {
                    ProductQCStatus qcsStatus = ideliveryRepository.GetQCStatus(iprod, "PAQC");
                    if (qcsStatus == null || string.IsNullOrEmpty(qcsStatus.Status))
                    {
                        erpara.Add(iprod);
                        erpara.Add("PAQC");
                        ex = new FisException("PAK051", erpara);    //QCStatus 中Product%1 的参数 %2 不存在!
                        throw ex;
                    }
                    switch (qcsStatus.Status)
                    {
                        case "8":
                        case "B":
                        case "C":
                            PAQCStatusLst.Add("PAQC");
                            break;
                        case "9":
                            // ITC-1360-1235 : 小写
                            // PAQCStatusLst.Add("PASS");
                            PAQCStatusLst.Add("Pass");
                            break;
                        case "A":
                            PAQCStatusLst.Add("Fail");
                            break;
                        case "1":
                            PAQCStatusLst.Add("No Check");
                            break;
                        default:
                            PAQCStatusLst.Add("");
                            break;
                    }

                }

                retLst.Add(PAQCStatusLst);      


                // POD –retLst[4]: 检查IMES_FA..ProductLog,如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';如果存在Station = '86' 的记录,则POD 栏位显示'86';
                // WC –retLst[5]: IMES_ProductStatus.Station
                // UC Revision: 7422:检查IMES_FA..ProductLog,如果存在Station = ’86' 的记录,则POD 栏位显示'86';否则如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';两者都不存在时,显示为空
                IList<string> PODLst = new List<string>();
                IList<string> WCLst = new List<string>();
                foreach (string prodid in productNoList)
                {
                    IList<ProductLog> prodLogLst = new List<ProductLog>();
                    prodLogLst = iproductRepository.GetProductLogs(prodid, "86");
                    if (prodLogLst.Count> 0)
                    {
                        PODLst.Add("86");
                    }
                    else
                    {
                        prodLogLst = iproductRepository.GetProductLogs(prodid, "PD");
                        if (prodLogLst.Count > 0)
                        {
                            PODLst.Add("PD");
                        }
                        else
                        {
                            PODLst.Add("");
                        }
                    }

                    ProductStatusInfo productStatus = iproductRepository.GetProductStatusInfo(prodid);
                    if (productStatus.station != null)
                    {
                        WCLst.Add(productStatus.station);
                    }
                    else
                    {
                        erpara.Add(prodid);
                        ex = new FisException("PAK026", erpara);    //没有Product Status 站数据!
                        throw ex;
                    }

                }
                retLst.Add(PODLst);
                retLst.Add(WCLst);
                
                // Collection Data 为空 - retLst[6]
                retLst.Add("");

                // Pallet Qty -retLst[7]: (Sum(IMES_PAK..Delivery_Pallet.DeliveryQty))
                //int palletQty =0;
                //IList<DeliveryPallet> dnpltlist = new List<DeliveryPallet>();
                //IPalletRepository iPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                //dnpltlist= iPalletRepository.GetDeliveryPallet(currentPalletNo);
                //if (dnpltlist != null && dnpltlist.Count > 0)
                //{
                //   foreach (DeliveryPallet dp in dnpltlist)
                //   {
                //       palletQty += dp.DeliveryQty;
                //   }
                //}
                //else
                //{
                //    erpara.Add(currentPalletNo);
                //    ex = new FisException("PAK027", erpara);    //没有获得当前Pallet的DeliveryQty!
                //    throw ex;
                //}

               string palletQty = (string)currentSession.GetValue(Session.SessionKeys.PalletQty);
               retLst.Add(palletQty);

               // Scan Qty - retLst[8]: 
               string scanQty = (string)currentSession.GetValue(Session.SessionKeys.ScanQty);
               retLst.Add(scanQty);
               
               // DPC - retLst[9]: 
               string DPC = (string)currentSession.GetValue(Session.SessionKeys.DummyPalletCase);
               retLst.Add(DPC);
               
               // total Qty - retLst[10]:
               string totalQty = (string)currentSession.GetValue(Session.SessionKeys.Qty);
               retLst.Add(totalQty);

               return retLst;             

            }
            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("(PalletVerifyOnlyImpl)InputCustSNOnCooLabel end, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 刷第一个SN时,调用该方法启动工作流,根据输入CustSN获取PalletInfo,成功后调用InputCustSn
        /// 将custSN放到Session.CustSN中(string)
        /// 在获取了Pallet No 后,要进行Delivery Download Check,以保证并板情况下,该Pallet 所对应的Delivery 资料Download 完毕。
        /// 检查方法如下:
        ///     取得Customer S/N 绑定的Delivery No (IMES_FA..Product.DeliveryNo)
        ///     取得该Delivery No 的Consolidated 属性(IMES_PAK.DeliveryInfo)
        ///     如果Consolidated 属性存在,则解析Consolidated 属性(Consolidated 属性以'/' 为分隔符,分为两部分,前面的为Consolidate No,后面为Delivery数量),得到并板的Consolidate No 和Delivery 数量
        ///     使用Consolidate No 检索IMES_PAK.DeliveryInfo 表,取得相关记录,统计这些记录共有多少个不同的LEFT(DeliveryNo,10),该数据如果小于前面查询到的Delivery 的Consolidated 属性中定义的并板的Delivery 数量,则报告错误:“Delivery No 未完全Download!”
        ///     SELECT COUNT(DISTINCT LEFT(DeliveryNo,10)) AS Expr1
        ///     FROM IMES_PAK.dbo.DeliveryInfo
        ///     where InfoValue like @ConsolidateNo and InfoType = 'Consolidated'
        /// 返回ArrayList
        /// </summary>
        public ArrayList InputFirstCustSn(string sCheckBoxId,string firstSn, string line, string editor, string station, string customer, out int index, out string labeltypeBranch)
        {
            logger.Debug("(PalletVerifyImpl)InputCustSNOnCooLabel start, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);

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

            try
            {
                //根据输入的Customer S/N, 获得对应的Product
                var currentProduct = CommonImpl.GetProductByInput(firstSn, CommonImpl.InputTypeEnum.CustSN);
                if (string.IsNullOrEmpty(currentProduct.ProId))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                    throw ex;

                }
                else
                {
                    if (CheckCTObyDN(currentProduct.DeliveryNo))
                    {
                        if (!CheckPODLabel(currentProduct))
                        {
                            throw new FisException("PAK172", erpara);
                        }
                    }
                
                }
            
                //取得Customer S/N 绑定的Delivery No :IMES_FA..Product.DeliveryNo
                if (string.IsNullOrEmpty(currentProduct.DeliveryNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK020", erpara);    //该Customer S/N还未与DN绑定!
                    throw ex;
                }
                string curDn = currentProduct.DeliveryNo;

                //获取Pallet No : IMES_FA..Product.PalletNo
                if (string.IsNullOrEmpty(currentProduct.PalletNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK021", erpara);     //该Customer S/N还未与Pallet绑定!
                    throw ex;
                }
                string currentPalletNo = currentProduct.PalletNo;

                if (currentPalletNo.Substring(0, 2) == "BA" || currentPalletNo.Substring(0, 2) == "NA")
                {
                    erpara.Add(currentPalletNo);
                    ex = new FisException("PAK044", erpara);     //散装Pallet,不能使用此功能!
                    throw ex;
                }

                //获取Pallet Info
                IPalletRepository iPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                Pallet CurrentPallet = null;
                CurrentPallet = iPalletRepository.Find(currentPalletNo);
                if (CurrentPallet == null)
                {
                    erpara.Add(currentProduct.PalletNo);
                    ex = new FisException("CHK106", erpara);    // Pallet不存在!
                    throw ex;
                }
                IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>();
                IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();

                //2012/10/18	如果Pallet 结合的Delivery 为自动单(Pallet 结合的Delivery 的Flag 属性=’N’)时,如果Pallet 上所有Product 结合的BoxId有重复,则报告错误:“此Pallet 上的Product 结合的Box Id 有重复,请检查!”
                //IProductRepository::IList<ProductInfo> GetProductInfoListByPalletNo(ProductInfo condition, string palletNo);
                //----------------------------------------------------------------------
                //UC Update: 2012/10/25  BoxId 加:UCC
                //string Autoflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Flag");
                //如果Pallet 结合的Delivery 为自动单(Pallet 结合的Delivery 的Flag 属性=’N’)时,如果Pallet 上所有Product 结合的BoxId or UCC数量和Pallet 上所有Product数量不同,则报告错误:“此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查!”
                //if ((Autoflag == "N") && (sCheckBoxId =="Y"))
                //{
                    //IList<IMES.FisObject.FA.Product.ProductInfo> ProductsInfolst = new List<IMES.FisObject.FA.Product.ProductInfo>();
                    //var conProductInfo = new IMES.FisObject.FA.Product.ProductInfo();
                    //conProductInfo.InfoType = "BoxId";
                    //ProductsInfolst = iproductRepository.GetProductInfoListByPalletNo(conProductInfo,currentProduct.PalletNo);
                    //if ((ProductsInfolst==null)||(ProductsInfolst.Count ==0))
                    //{
                    //    //获取失败,这种情况应该不存在
                    //    erpara.Add(currentProduct.PalletNo);
                    //    ex = new FisException("PAK098", erpara);    // Pallet不存在!
                    //    throw ex;
                    //}
                    //else
                    //{
                    //   var boxidquery =
                    //       from q in ProductsInfolst
                    //       group q by q.InfoValue into gboxid
                    //       where gboxid.Count() >= 2
                    //       select new
                    //      {
                    //          _Boxid = gboxid.Key,
                    //          _Count = gboxid.Count()
                    //      };
                    //    if (boxidquery.Count() != 0)
                    //    {
                    //        //Product 结合的Box Id 有重复
                    //        var dupBoxid = "";
                    //        foreach (var vq in boxidquery)
                    //        {
                    //            dupBoxid = vq._Boxid;
                    //            break;
                    //        }
                    //        var prodidquery =
                    //            from qq in ProductsInfolst
                    //            where qq.InfoValue == dupBoxid
                    //            select qq;
                    //        var errProdidstring = "";
                    //        foreach (var vp in prodidquery)
                    //        {
                    //            if (errProdidstring == "")
                    //                errProdidstring = vp.ProductID;
                    //            else
                    //                errProdidstring = errProdidstring + ", " + vp.ProductID;
                    //        }

                    //        erpara.Add(currentProduct.PalletNo);
                    //        erpara.Add(errProdidstring);
                    //        erpara.Add(dupBoxid);
                    //        ex = new FisException("CHK963", erpara);    // 此Pallet 上的Product 结合的Box Id 有重复,请检查!!
                    //        throw ex;
                    //    }
                    //  }
                    //}
                //----------------------------------------------------------------------

                //if (!CurrentPallet.IsPalletFull(string.Empty))
                //{
                //    FisException fe = new FisException("CHK122", new string[] { currentProduct.PalletNo });
                //    throw fe;
                //}
                

                // 获取该Pallet 上的SKU 列表
                // 该Pallet 上的SKU 列表:IMES_FA..Product.PalletNo = @PalletNo的所有记录
                // SKU 列表显示如下信息:Product ID | Customer S/N | PAQC | POD | WC | Collection Data
                // 按照Customer S/N 升序排序
             
                IList<ProductModel> prodModelLst = new List<ProductModel>();
                prodModelLst = iproductRepository.GetProductListByPalletNoOrderByCustSN(currentPalletNo);
                int countInPallet = prodModelLst.Count;
            
                bool isBsamOrTablet = false; 
                if (prodModelLst == null || prodModelLst.Count <= 0)
                {
                    erpara.Add(firstSn);
                    ex = new FisException("CHK079", erpara);    //找不到与此序号 %1 匹配的Product! 
                    throw ex;
                }
                IBSamRepository bsamRepository = RepositoryFactory.GetInstance().GetRepository<IBSamRepository, BSamLocation>();
                BSamModel bsamModel = bsamRepository.GetBSamModel(currentProduct.Model);
                if (bsamModel != null || checkIsTablet(currentProduct))
                { isBsamOrTablet = true; }
             
                //UC Update: 2012/10/25  BoxId 加:UCC
                //如果Pallet 结合的Delivery 为自动单(Pallet 结合的Delivery 的Flag 属性=’N’)时,如果Pallet 上所有Product 结合的BoxId or UCC数量和Pallet 上所有Product数量不同,则报告错误:“此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查!”
                //----------------------------------------------------------------------------------------------------------------------
                string Autoflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Flag");
                if ((Autoflag == "N") && (sCheckBoxId == "Y"))
                {
                  
                    //For BSAM
                //    if (bsamModel != null || checkIsTablet(currentProduct))
                    if (isBsamOrTablet)
                    {
                      //  ICartonRepository cartonRep = RepositoryFactory.GetInstance().GetRepository<ICartonRepository, Carton>();
                      //  int cartonQty=  cartonRep.GetAssignedPalletCartonQty(currentProduct.PalletNo);
                      ////  int sumDnQty = iPalletRepository.GetDeliveryPallet(currentPalletNo).Sum(x => x.DeliveryQty);

                      // //Vincent 2013-10-07:併Carton case造成從Delivery_Pallet table計算carton 樹有問題,須重DeliveryInfo.PalletQty來計算Carton 總數
                      //  // int sumDnQty = ideliveryRepository.GetSumDeliveryQtyOfACertainPallet(currentProduct.PalletNo);
                      //  int sumDnQty = ideliveryRepository.GetFullPalletCartonQtyByDeliveryPallet(currentProduct.DeliveryNo, currentProduct.PalletNo);
                      //  if (sumDnQty != cartonQty)
                      //  {
                      //      erpara.Add(currentProduct.PalletNo);
                      //      ex = new FisException("CHK963", erpara);    //此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查! 
                      //      throw ex;
                      //  }

                       CommonUtl.CheckDeliveryPalletCartonQty(currentProduct.PalletNo);

                    }
                    else
                    {
                        //NEW Interface:2012/12/25
                        //IProductRepository::int GetCountOfInfoValueInProductInfo(string palletNo, string[] infoTypes);
                        string[] param = { "BoxId ", "UCC" };
                        int productsInfolstcount = iproductRepository.GetCountOfInfoValueInProductInfo(currentProduct.PalletNo, param);
                        if (productsInfolstcount != prodModelLst.Count)
                        {
                            erpara.Add(currentProduct.PalletNo);
                            ex = new FisException("CHK963", erpara);    //此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查! 
                            throw ex;
                        }
                    }
                }
                //----------------------------------------------------------------------------------------------------------------------
                IList<string> productNoList = new List<string>();
                IList<string> custSnList = new List<string>();
                int i = 0;
                index = 0;
                string curInfoBoxID = "";
                string curShipBoxDetID = "";

                foreach (ProductModel prod in prodModelLst)
                {
                    productNoList.Add(prod.ProductID);
                    custSnList.Add(prod.CustSN);
                    
                    if (prod.ProductID == currentProduct.ProId && prod.CustSN == firstSn)
                    {
                       //2012/10/25 取消检查每个Product 结合的Box Id 或UCC 的正确性
                       //--------------------------------------------------------------------------------------
                        ////Productinfo
                        //curInfoBoxID = iproductRepository.GetProductInfoValue(prod.ProductID, "BoxId");

                        ////ShipBoxDet
                        //IList<ShipBoxDetInfo> shipList;
                        //ShipBoxDetInfo shipInfo;
                        ////shipList = ideliveryRepository.GetShipBoxDetList(curDn, currentPalletNo, prod.ProductID);
                        //var conshipdet = new ShipBoxDetInfo();
                        //conshipdet.snoId = prod.ProductID;
                        //shipList = ideliveryRepository.GetShipBoxDetInfoListByCondition(conshipdet);

                        //if (shipList.Count != 0)
                        //{
                        //    shipInfo = shipList[0];
                        //    curShipBoxDetID=shipInfo.boxId;
                        //}
                        //--------------------------------------------------------------------------------------
                        index = i+1;
                       // break;
                    }
                    else i++;
                }

                // retLst[0]-[2]
                retLst.Add(currentPalletNo);
                retLst.Add(productNoList);
                retLst.Add(custSnList);
     

                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);
                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, 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", Session.SessionType.Product);

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

                    currentSession.AddValue(Session.SessionKeys.CustSN, firstSn);
                    currentSession.AddValue(Session.SessionKeys.PalletNo, currentPalletNo);
                    currentSession.AddValue(Session.SessionKeys.Pallet, CurrentPallet);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.ProdNoList, productNoList); 
                    currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, productNoList); // UpdateProductListStatusByProdID (Update IMES_FA..ProductStatus – 更新Pallet 上所有PRODUCT 的状态)
                    currentSession.AddValue(Session.SessionKeys.CustomSnList, custSnList);
                    currentSession.AddValue(Session.SessionKeys.DeliveryNo, curDn);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);

                    // ***************** For Check OA3 *****************
                  
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA = false;
                    GetAndCheckOA3Setting(currentProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);
                    currentSession.AddValue("FKIServicePath", fkiPath);
                    currentSession.AddValue("FKIAuthUser", fkiUser);
                    currentSession.AddValue("FKIAuthPassword", fkiPwd);
                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }
                    IMES.FisObject.FA.Product.IProduct prd= (IMES.FisObject.FA.Product.IProduct)currentProduct;
                
                    // bNoNeedCheckEOA = partRepository.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                                                            // Any(x => x == "Y");

                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRepository.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == currentProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                        IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currentProduct.Model);
                        if (!cmm2.CheckOA3Key(bom, currentProduct, fkiPath, FKICredentialCache, editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                          throw new FisException("PAK158", new string[] { currentProduct.CUSTSN, currentProduct.DeliveryNo });
                        }
                    }

                    // ***************** For Check OA3 *****************
                 

                    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;
                }
                
                               
                
                //Delivery Download Check,以保证并板情况下,该Pallet 所对应的Delivery 资料Download 完毕。
                //取得该Delivery No 的Consolidated 属性(IMES_PAK.DeliveryInfo)
                //如果Consolidated 属性存在,则解析Consolidated 属性(Consolidated 属性以'/' 为分隔符,分为两部分,前面的为Consolidate No,后面为Delivery数量),得到并板的Consolidate No 和Delivery 数量
                //IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                string Consolidated = string.Empty;
                Consolidated = ideliveryRepository.GetDeliveryInfoValue(curDn, "Consolidated");
                // SVN 2569: 如果Consolidated 属性不存在或者为空,则不用进行Delivery Download Check
                if (!string.IsNullOrEmpty(Consolidated))
                {
                    string[] pattern = Consolidated.Split('/');
                    string ConsolidateNo = string.Empty;
                    int dnQty = 0;
                    if (pattern.Length.ToString() != "2" || string.IsNullOrEmpty(pattern[0]) || string.IsNullOrEmpty(pattern[1]))
                    {
                        erpara.Add(curDn);
                        ex = new FisException("PAK024", erpara);  //找不到该Delivery No 的Consolidated 属性
                        throw ex;
                    }
                    ConsolidateNo = pattern[0];
                    dnQty = Int32.Parse(pattern[1]);

                    //使用Consolidate No 检索IMES_PAK.DeliveryInfo 表,取得相关记录,统计这些记录共有多少个不同的LEFT(DeliveryNo,10),该数据如果小于前面查询到的Delivery 的Consolidated 属性中定义的并板的Delivery 数量,则报告错误:“Delivery No 未完全Download!”
                    int DistinctDNQty = 0;
                    DistinctDNQty = ideliveryRepository.GetDistinctDeliveryNo(ConsolidateNo);
                    if (DistinctDNQty < dnQty)
                    {
                        erpara.Add(curDn);
                        ex = new FisException("PAK018", erpara);    //Delivery No 未完全Download!
                        throw ex;
                    }

                    int SumCartonQty = 0;
                    int SumDnPallletQty = 0;
                    IList<Delivery> dnList = ideliveryRepository.GetDeliveryListByInfoTypeAndValue("Consolidated", Consolidated);
                    foreach (Delivery dn in dnList)
                    {

                        SumCartonQty += dn.Qty;
                        int DnPallletQty = ideliveryRepository.GetSumDeliveryQtyOfACertainDN(dn.DeliveryNo);
                        SumDnPallletQty += DnPallletQty;
                    }
                    //临时注释掉,保出货
                    //if (SumCartonQty != SumDnPallletQty)
                    //{
                    //    //从整机库get
                    //    {
                    //        erpara.Add(currentProduct.PalletNo);
                    //        ex = new FisException("CHK903", erpara);    //PALLET  未完全Download!
                    //        throw ex;
                    //    }
                    //}
                }
                // PAQC –retLst[3]: 使用ProductID = @ProductId and Tp = 'PAQC' 查询IMES_FA..QCStatus 表取Udt 最新的记录,如果该记录的Status = '8',则PAQC 栏位显示'PAQC';Status = '9',则PAQC 栏位显示'Pass';Status = 'A',则PAQC 栏位显示'Fail';Status = '1',则PAQC 栏位显示'No Check';
                IList<string> PAQCStatusLst = new List<string>();
                foreach ( string iprod in productNoList)
                {
                    ProductQCStatus qcsStatus = ideliveryRepository.GetQCStatus(iprod, "PAQC");
                    if (qcsStatus ==null || string.IsNullOrEmpty(qcsStatus.Status))
                    {
                        erpara.Add(iprod);
                        erpara.Add("PAQC");
                        ex = new FisException("PAK051", erpara);    //QCStatus 中Product%1 的参数 %2 不存在!
                        throw ex;
                    }
                    switch (qcsStatus.Status)
                    {
                        case "8":
                        case "B":
                        case "C":
                            PAQCStatusLst.Add("PAQC");
                            break;
                        case "9":
                           // ITC-1360-1235 : 小写
                           // PAQCStatusLst.Add("PASS");
                            PAQCStatusLst.Add("Pass");
                            break;
                        case "A":
                            PAQCStatusLst.Add("Fail");
                            break;
                        case "1":
                            PAQCStatusLst.Add("No Check");
                            break;
                        default:
                            PAQCStatusLst.Add("");
                            break;
                    }

                }
                
                retLst.Add(PAQCStatusLst);    


                // POD –retLst[4]: 检查IMES_FA..ProductLog,如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';如果存在Station = '86' 的记录,则POD 栏位显示'86';
                // WC –retLst[5]: IMES_ProductStatus.Station
                // UC Revision: 7366:修正POD 栏位数据的获取方法 :检查IMES_FA..ProductLog,如果存在Station = 'PD' 的记录,但不存在Station = '86' 的记录时,则POD 栏位显示'PD';如果存在Station = '86' 的记录,则POD 栏位显示'86';两者都不存在时,显示为空
                // UC Revision: 7422:检查IMES_FA..ProductLog,如果存在Station = ’86' 的记录,则POD 栏位显示'86';否则如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';两者都不存在时,显示为空
                IList<string> PODLst = new List<string>();
                IList<string> WCLst = new List<string>();
              
                foreach (string prodid in productNoList)
                {
                    IList<ProductLog> prodLogLst = new List<ProductLog>();
                    prodLogLst = iproductRepository.GetProductLogs(prodid, "86");
                    if (prodLogLst.Count> 0)
                    {
                        PODLst.Add("86");
                    }
                    else
                    {
                        prodLogLst = iproductRepository.GetProductLogs(prodid, "PD");
                        if (prodLogLst.Count > 0)
                        {
                            PODLst.Add("PD");
                        }
                        else
                        {
                            PODLst.Add("");
                        }
                    }

                    ProductStatusInfo productStatus = iproductRepository.GetProductStatusInfo(prodid);
                    if (productStatus.station != null)
                    {
                        WCLst.Add(productStatus.station);
                    }
                    else
                    {
                        erpara.Add(prodid);
                        ex = new FisException("PAK026", erpara);    //没有Product Status 站数据!
                        throw ex;
                    }

                }
                retLst.Add(PODLst);
                retLst.Add(WCLst);
                
                // Collection Data 为空 - retLst[6]
                retLst.Add("");

                // Pallet Qty -retLst[7]: (Sum(IMES_PAK..Delivery_Pallet.DeliveryQty))
                int palletQty =0;
                int sumDeviceQty = 0;
                IList<DeliveryPallet> dnpltlist = new List<DeliveryPallet>();
                IList<string> DeliveryPerPalletList = new List<string>();
                IList<string> modelList = new List<string>();
            
                dnpltlist= iPalletRepository.GetDeliveryPallet(currentPalletNo);
                if (dnpltlist != null && dnpltlist.Count > 0)
                {
                   foreach (DeliveryPallet dp in dnpltlist)
                   {
                       palletQty += dp.DeliveryQty;
                       sumDeviceQty += dp.DeviceQty;
                       DeliveryPerPalletList.Add(dp.DeliveryID);
                       Delivery currentDelivery = ideliveryRepository.Find(dp.DeliveryID);
                       modelList.Add(currentDelivery.ModelName);
                   }
                }
                else
                {
                    erpara.Add(currentPalletNo);
                    ex = new FisException("PAK027", erpara);    //没有获得当前Pallet的DeliveryQty!
                    throw ex;
                }

              // retLst.Add(palletQty.ToString());

                if (isBsamOrTablet)
                {
                    //retLst.Add(countInPallet.ToString()); For Mantis 0001035]: PalletVerify界面针对平板和BSam的页面显示PalletQty需要防止资料异常
                    retLst.Add(sumDeviceQty.ToString());
                }
                else
                {
                    retLst.Add(palletQty.ToString());
                }


               // retLst[8]: SVN 2569: 9.	Scan '9999' or 'EMEA':当前Delivery 的RegId (IMES_PAK..DeliveryInfo.InfoValue, Condition: InfoType = 'RegId')属性
               string infoValue = string.Empty;
               infoValue = ideliveryRepository.GetDeliveryInfoValue(curDn, "RegId");
               if (String.IsNullOrEmpty(infoValue))
               {
                   //erpara.Add("RegId");
                   //ex = new FisException("PAK047", erpara);    //没有InfoType为 %1 的DeliveryInfo!
                   //throw ex;
                   infoValue = string.Empty;
               }
               retLst.Add(infoValue);

               //string PLEditsURL = string.Empty;
               //string PLEditsTemplate = string.Empty;
               //string PLEditsXML = string.Empty;
               //string PLEditsPDF = string.Empty;
               //string PLEditsImage = string.Empty;
               //string FOPFullFileName = string.Empty;
               
               IList<string> PDFPLLst = new List<string>();

               //当EDI_RegId = 'SNE' or 'SCE'时, Emea = 1;否则, Emea = 0
               decimal emea =0;

               //  SVN 2569: 自动单和手动单列印 (printflag =="C",表示手动单;否则表示自动单)
               labeltypeBranch = string.Empty;
               string printflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Flag");
               if (printflag == "SNE" || printflag == "SCE")
               {
                   emea = 1;
               }
               else emea = 0;
              
                if (printflag == "C")
               {
                   string cpmoflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Carrier");
                   if (cpmoflag == "XJ")
                   {
                       labeltypeBranch = "X";   //手动单:Pallet Label + CPMO Label
                   }
                   else labeltypeBranch = "C";   // 手动单:Pallet Label 
               }
               else
               {
                   labeltypeBranch = "A"; // 自动单:Pallet Label 

                   //UC Revision: 7636:要求Edits 文档所在的网络路径可配置:
                   // (\\hp-iis\OUT\)需要查询SysSetting 表获取, 参考方法:select Value from SysSetting nolock where Name = 'EditsFISAddr'
                   IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                   IList<string> PLEditsURLLst = partRepository.GetValueFromSysSettingByName("PLEditsURL");
                   if (PLEditsURLLst != null && PLEditsURLLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsURLLst[0]); //PDFPLLst[0]
                   }

                   IList<string> PLEditsTemplateLst = partRepository.GetValueFromSysSettingByName("PLEditsTemplate");
                   if (PLEditsTemplateLst != null && PLEditsTemplateLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsTemplateLst[0]);//PDFPLLst[1]
                   }

                   IList<string> PLEditsXMLLst = partRepository.GetValueFromSysSettingByName("PLEditsXML");
                   if (PLEditsXMLLst != null && PLEditsXMLLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsXMLLst[0]);//PDFPLLst[2]
                   }

                   IList<string> PLEditsPDFLst = partRepository.GetValueFromSysSettingByName("PLEditsPDF");
                   if (PLEditsPDFLst != null && PLEditsPDFLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsPDFLst[0]); //PDFPLLst[3]
                   }
                   IList<string> PLEditsImageLst = partRepository.GetValueFromSysSettingByName("PLEditsImage");
                   if (PLEditsImageLst != null && PLEditsImageLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsImageLst[0]); //PDFPLLst[4]
                   }

                   IList<string> FOPFullFileNameLst = partRepository.GetValueFromSysSettingByName("FOPFullFileName");
                   if (FOPFullFileNameLst != null && FOPFullFileNameLst.Count > 0)
                   {
                       PDFPLLst.Add(FOPFullFileNameLst[0]); //PDFPLLst[5]

                   }
                   IList<string> printexepathLst = partRepository.GetValueFromSysSettingByName("PDFPrintPath");
                   if (printexepathLst != null && printexepathLst.Count > 0)
                   {
                       PDFPLLst.Add(printexepathLst[0]); //PDFPLLst[6]
                   }


               }
               currentSession.AddValue(Session.SessionKeys.labelBranch,labeltypeBranch);
               // retList[9]: PLEditsPDF
               // retLst.Add(PLEditsPDF);
               retLst.Add(PDFPLLst);

                //retList[10]:DeliveryPerPalletList: 获取与当前Pallet 结合的Delivery
                retLst.Add(DeliveryPerPalletList);

                // retList[11]:'This Customer S/N's Delivery No – Product.DeliveryNo
                retLst.Add(currentProduct.DeliveryNo);

                //retList[12]: emea
                retLst.Add(emea);

                //retList[13]: modelList
                retLst.Add(modelList);

               // WriteProductLog (Insert IMES_FA..ProductLog – 记录Pallet 上所有PRODUCT 的Log)
               //IList<IMES.FisObject.FA.Product.IProduct> prodLst = iproductRepository.GetProductListByIdList(productNoList);
             //  currentSession.AddValue(Session.SessionKeys.ProdList, prodLst);
               //2012/10/18 
               //如果Product 结合的Delivery 为自动单,但Product 没有结合Box Id(ProductInfo.InfoValue; Condition: InfoType =’BoxId’)则报告错误:“此Product 尚未结合Box Id!”
               //如果Product 结合的Delivery 为自动单,但其结合的BoxId 在ProductInfo 和ShipBoxDet (ShipBoxDet.BoxId)中记录的不同,则报告错误:“Box Id 异常! 请检查ProductInfo 及ShipBoxDet 中的相关数据。”;
               //string curInfoBoxID = "";
               //string curShipBoxDetID = "";
               retLst.Add(curInfoBoxID);
               retLst.Add(curShipBoxDetID);

               return retLst;             

            }
            catch (FisException e)
            {
                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("(PalletVerifyImpl)InputCustSNOnCooLabel end, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 每次刷SN都调用该方法,SFC
        /// 将custSN放到Session.CustSN中(string)
        /// 如果匹配到SKU List 中的某条记录,如果该记录的Collection Data为空,(页面处理): 如果该记录的PAQC 栏位等于'PAQC',则报告错误:“该机器尚未完成PAQC!”;
        ///                                                                                如果该记录的PAQC 栏位等于'Fail',则报告错误:“该机器PAQC Fail!”;
        ///                                                                                如果该记录的PD 栏位等于'PD',则报告错误:“该机器尚未完成POD Label Check!”;
        ///                                                                                如果上述错误均未发生,则该记录的Collection Data 栏位显示刷入的Customer S/N,并且Scan Qty + 1;
        ///                                  如果该记录的Collection Data 不为空,则报告错误:“You had duplicate scan.”。(页面处理)
        /// 如果没有匹配到SKU List 中的任何记录,则报告错误:“非法数据!”(service处理)
        /// </summary>
        /// <param name="firstSn">firstSn</param>
        /// <param name="custSn">custSn</param>
        /// <returns></returns>
        public int InputCustSn(string firstSn, string custSn)
        {
            logger.Debug("(PalletVerifyOnlyImpl)ScanSN start, firstSn:" + firstSn + " custSn:" + custSn);

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

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


                if (currentSession == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {
                    currentSession.AddValue(Session.SessionKeys.CustSN, custSn);
                    //SFC : 根据刷入的 Another Customer S/N (custSn), 获得其对应的Product
                    var newProduct = CommonImpl.GetProductByInput(custSn, CommonImpl.InputTypeEnum.CustSN);
                    if (string.IsNullOrEmpty(newProduct.ProId))
                    {
                        erpara.Add(custSn);
                        ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                        throw ex;

                    }
       
                    IList<string> productNoList = (List<string>)(currentSession.GetValue(Session.SessionKeys.ProdNoList));
                    IList<string> custSnList = (List<string>)(currentSession.GetValue(Session.SessionKeys.CustomSnList));
                    int index = 0;
                    Boolean flag =false;
                    foreach (string sn in custSnList)
                    {
                        if (sn == custSn)
                        {
                            flag = true;
                            break;
                        }
                        index++;
                    }
                    if (!flag)
                    {
                        erpara.Add(custSn);
                        ex = new FisException("PAK022", erpara);    //非法数据!
                        throw ex;
                    }

                    if ((string.IsNullOrEmpty(newProduct.ProId)) || (newProduct.ProId != productNoList[index]))
                    {
                        erpara.Add(custSn);
                        ex = new FisException("PAK022", erpara);    //非法数据!
                        throw ex;
                    }


                    //For Check OA3
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IList<ConstValueInfo> cvInfo = new List<ConstValueInfo>();
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA = false;
                    GetAndCheckOA3Setting(newProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);

                    //string fkiPath = System.Configuration.ConfigurationManager.AppSettings["FKIServicePath"].Trim();
                    //string fkiUser = System.Configuration.ConfigurationManager.AppSettings["FKIAuthUser"].Trim();
                    //string fkiPwd = System.Configuration.ConfigurationManager.AppSettings["FKIAuthPassword"].Trim();

                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }
                    IMES.FisObject.FA.Product.IProduct prd = (IMES.FisObject.FA.Product.IProduct)currentProduct;
                    IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                   // bool bNoNeedCheckEOA = partRepository.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                                                              // Any(x => x == "Y");
                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRep.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == newProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                        IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(newProduct.Model);
                        if (!cmm2.CheckOA3Key(bom, newProduct, fkiPath, FKICredentialCache, currentSession.Editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                            throw new FisException("PAK158", new string[] { newProduct.CUSTSN, newProduct.DeliveryNo });
                        }
                    }

                    //For Check OA3

                    currentSession.AddValue(Session.SessionKeys.Product, newProduct);
                    currentSession.Exception = null;
                    currentSession.SwitchToWorkFlow();

                    if (currentSession.Exception != null)
                    {
                        if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            currentSession.ResumeWorkFlow();
                        }
                        throw currentSession.Exception;
                    }
                    
                    //string currentPalletNo = (string)(currentSession.GetValue(Session.SessionKeys.PalletNo));
                    
                    //ITC-1360-1277:
                    //if ((string.IsNullOrEmpty(newProduct.ProId)) || (newProduct.PalletNo != currentPalletNo) || (newProduct.ProId != productNoList[index]))
                    //{
                    //    erpara.Add(custSn);
                    //    ex = new FisException("PAK022", erpara);    //非法数据!
                    //    throw ex;
                    //}

                   

                    //Mantis Bug :http://10.99.183.26/Mantis/view.php?id=627 (改为前台页面收集scanProductNoList)
                    //IList<string> scanProductNoList = (IList<string>)currentSession.GetValue(Session.SessionKeys.NewScanedProductIDList);
                    //Boolean exitFlag = false;
                    //foreach (string iprodid in scanProductNoList)
                    //{
                    //    if (iprodid == newProduct.ProId)
                    //    {
                    //        exitFlag = true;
                    //        break;
                    //    }
                    //}
                    //if (!exitFlag)
                    //{
                    //    scanProductNoList.Add(newProduct.ProId);
                    //    currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, scanProductNoList);
                    //}

                    return index;

                }
            }

            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PalletVerifyOnlyImpl)ScanSN end, firstSn:" + firstSn + " custSn:" + custSn);
            }
        }
Exemplo n.º 5
0
        public ArrayList InputCustSnForCQ(string custsn, string pdLine, string editor, string station, string customer)
        {
            logger.Debug("(PodLabelCheckImpl)InputCustSnForCQ start, custsn:" + custsn + "pdLine:" + pdLine + "editor:" + editor + "station:" + station + "customer:" + customer);
            FisException ex;
            List<string> erpara = new List<string>();
            ArrayList retArr = new ArrayList();
            string label = "";
            try
            {
               
                var currentProduct = CommonImpl.GetProductByInput(custsn, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);
                CommonImpl2 cm2 = new CommonImpl2();
                label = cm2.CheckPodLabel(custsn);
                if (label == "")
                { label = cm2.CheckConfigLabel(custsn); }
                 if (string.IsNullOrEmpty(label))
                 {
                     throw new FisException("SFC013", new string[] { });
                 }

                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;
                }
                CommonImpl cmi = new CommonImpl();
                IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType("PODModel", "Name").Where(y => y.value != "").ToList();
                string countryCode = currentProduct.Model.Substring(9, 2);
                var s = lstConst.Where(x => x.name == countryCode).Select(x => x.value).ToList();
                IList<string> codeLst = null;
                List<string> modelLst = new List<string>();

                if (s.Count > 0)
                {
                    string code = s[0];
                    codeLst = code.Split('~').Where(x=>x.Trim()!="").ToList();
                    foreach (string m in codeLst)
                    { modelLst.Add(currentProduct.Model+m.Trim()); }
                }
                string NoNeedScanMAC = "";
                IList<ConstValueTypeInfo> typeinfo = cmi.GetConstValueTypeListByType("ConfigNoCheckMAC").ToList();
                if (typeinfo.Where(x => x.value == currentProduct.Family).Any())
                {
                    NoNeedScanMAC = "NoNeed";
                }
                   
             
          
                currentSession.AddValue(Session.SessionKeys.ifElseBranch, label);
                retArr.Add(currentProduct.ProId);
                retArr.Add(currentProduct.Model);
                retArr.Add(label);
                retArr.Add(modelLst);
                retArr.Add(NoNeedScanMAC);//0001583: 86站POD Label check修改
                return retArr;
            }
            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)InputCustSnForCQ end, custsn:" + custsn + "pdLine:" + pdLine + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        
        
        
        }
Exemplo n.º 6
0
        /// <summary>
        /// 每次刷SN都调用该方法,SFC
        /// 将custSN放到Session.CustSN中(string)
        /// 如果匹配到SKU List 中的某条记录,如果该记录的Collection Data为空,(页面处理): 如果该记录的PAQC 栏位等于'PAQC',则报告错误:“该机器尚未完成PAQC!”;
        ///                                                                                如果该记录的PAQC 栏位等于'Fail',则报告错误:“该机器PAQC Fail!”;
        ///                                                                                如果该记录的PD 栏位等于'PD',则报告错误:“该机器尚未完成POD Label Check!”;
        ///                                                                                如果上述错误均未发生,则该记录的Collection Data 栏位显示刷入的Customer S/N,并且Scan Qty + 1;
        ///                                  如果该记录的Collection Data 不为空,则报告错误:“You had duplicate scan.”。(页面处理)
        /// 如果没有匹配到SKU List 中的任何记录,则报告错误:“非法数据!”(service处理)
        /// </summary>
        /// <param name="firstSn">firstSn</param>
        /// <param name="custSn">custSn</param>
        /// <param name="curInfoBoxId">custSn</param>
        /// <param name="curShipBoxDetId">custSn</param>
        /// <returns></returns>
        public int InputCustSn(string firstSn, string custSn, out string curInfoBoxId, out string curShipBoxDetId)
        {
            logger.Debug("(PalletVerifyImpl)ScanSN start, firstSn:" + firstSn + " custSn:" + custSn);

            try
            {
                FisException ex;
                List<string> erpara = new List<string>();
                var currentProduct = CommonImpl.GetProductByInput(firstSn, CommonImpl.InputTypeEnum.CustSN);
             
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);


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

                    //SFC : 根据刷入的 Another Customer S/N (custSn), 获得其对应的Product
                    var newProduct = CommonImpl.GetProductByInput(custSn, CommonImpl.InputTypeEnum.CustSN);
                    if (string.IsNullOrEmpty(newProduct.ProId))
                    {
                        erpara.Add(custSn);
                        ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                        throw ex;

                    }
                    else
                    {
                        if (CheckCTObyDN(newProduct.DeliveryNo))
                        {
                            if (!CheckPODLabel(newProduct))
                            {
                                throw new FisException("PAK172", erpara);
                            }
                        }

                    }

                


                    IList<string> productNoList = (List<string>)(currentSession.GetValue(Session.SessionKeys.ProdNoList));
                    IList<string> custSnList = (List<string>)(currentSession.GetValue(Session.SessionKeys.CustomSnList));
                    int index = 0;
                    Boolean flag = false;
                    string currentPalletNo = (string)(currentSession.GetValue(Session.SessionKeys.PalletNo));
                    string currentDN = (string)(currentSession.GetValue(Session.SessionKeys.DeliveryNo));
                    foreach (string sn in custSnList)
                    {
                        if (sn == custSn)
                        {
                            flag = true;
                            break;
                        }
                        index++;
                    }
                    if (!flag)
                    {
                        erpara.Add(currentPalletNo);
                        erpara.Add(custSn);
                        ex = new FisException("PAK144", erpara);    //非法数据!
                        throw ex;
                    }

                   // string currentPalletNo = (string)(currentSession.GetValue(Session.SessionKeys.PalletNo));
                    if ((string.IsNullOrEmpty(newProduct.ProId)) || (newProduct.PalletNo != currentPalletNo) || (newProduct.ProId != productNoList[index]))
                    {
                        erpara.Add(currentPalletNo);
                        erpara.Add(custSn);
                        
                        ex = new FisException("PAK144", erpara);    //非法数据!
                        throw ex;
                    }
                 //For Check OA3
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                    IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA = false;
                    GetAndCheckOA3Setting(newProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);
                    //string fkiPath = System.Configuration.ConfigurationManager.AppSettings["FKIServicePath"].Trim();
                    //string fkiUser = System.Configuration.ConfigurationManager.AppSettings["FKIAuthUser"].Trim();
                    //string fkiPwd = System.Configuration.ConfigurationManager.AppSettings["FKIAuthPassword"].Trim();

                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }


                    //bool bNoNeedCheckEOA = partRep.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                    //                                                         Any(x => x == "Y");
                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRep.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == newProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                        IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(newProduct.Model);
                        if ( !cmm2.CheckOA3Key(bom, newProduct, fkiPath, FKICredentialCache, currentSession.Editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                            throw new FisException("PAK158", new string[] { newProduct.CUSTSN, newProduct.DeliveryNo });
                        }
                    }

                    //For Check OA3



                    currentSession.AddValue(Session.SessionKeys.Product, newProduct);
                    currentSession.Exception = null;
                    currentSession.SwitchToWorkFlow();

                    if (currentSession.Exception != null)
                    {
                        if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            currentSession.ResumeWorkFlow();
                        }
                        throw currentSession.Exception;
                    }
                    //--------------------------------------------------------------------------------------
                    curInfoBoxId = "";
                    curShipBoxDetId = "";
                    //2012/10/25.	取消检查每个Product 结合的Box Id 或UCC 的正确性
                    //IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>();
                    //IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();

                    ////Productinfo
                    //curInfoBoxId = iproductRepository.GetProductInfoValue(newProduct.ProId, "BoxId");
                    ////ShipBoxDet
                    //IList<ShipBoxDetInfo> shipList;
                    //ShipBoxDetInfo shipInfo;
                    ////shipList = ideliveryRepository.GetShipBoxDetList(currentDN, currentPalletNo, newProduct.ProId);
                    //var conshipdet = new ShipBoxDetInfo();
                    //conshipdet.snoId = newProduct.ProId;
                    //shipList = ideliveryRepository.GetShipBoxDetInfoListByCondition(conshipdet);
                    //if (shipList.Count != 0)
                    //{
                    //    shipInfo = shipList[0];
                    //    curShipBoxDetId = shipInfo.boxId;
                    //}
                    //--------------------------------------------------------------------------------------
                    return index;

                }
            }

            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PalletVerifyImpl)ScanSN end, firstSn:" + firstSn + " custSn:" + custSn);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 取ModelBOM 中Model 直接下阶中有BomNodeType 为'P1' 的Part
 /// </summary>
 /// <param name="custSN">custSN</param>
 public string CheckBOM(string custSN)
 {
     string ret = "NotFind";
     try 
     {
         IProduct product = productRepository.GetProductByCustomSn(custSN);
         if (product == null)
         {
             return ret;
         }
         string model = product.Model;
         // 取ModelBOM 中Model 直接下阶中有BomNodeType 为'P1' 的Part
         IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>();
         IHierarchicalBOM sessionBOM = null;
         sessionBOM = ibomRepository.GetHierarchicalBOMByModel(product.Model);
         CommonImpl2 cm2 = new CommonImpl2();
         string site = cm2.GetSite();
         if (site == "ICC" && cm2.CheckIsWIN8(sessionBOM))
         {
             return ret;
         }
         IList<IBOMNode> bomNodeLst = new List<IBOMNode>();
         bomNodeLst = sessionBOM.FirstLevelNodes;
         if (bomNodeLst != null && bomNodeLst.Count > 0)
         {
             foreach (IBOMNode ibomnode in bomNodeLst)
             {
                 IPart currentPart = ibomnode.Part;
                 if (currentPart.BOMNodeType == "P1" && currentPart.Descr.IndexOf("COA") == 0)
                 {
                     return currentPart.PN;
                 }
             }
         }
         return ret;
     }
     catch (Exception ee)
     {
         throw ee;
     }
 }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
0
        public string GetCqPodLabelColor(string model)
        {
           
            IMES.FisObject.Common.FisBOM.IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>();
            IHierarchicalBOM sessionBOM = null;
            sessionBOM = ibomRepository.GetHierarchicalBOMByModel(model);
            IList<IBOMNode> bomNodeLst = new List<IBOMNode>();
            bomNodeLst = sessionBOM.FirstLevelNodes;
            CommonImpl2 cm2 = new CommonImpl2();
            string color = "Black";
            IList<string> lstValue
                     = cm2.GetConstValueTypeByType("POD_White_Lable_PN").Where(x => x.value != "").Select(x => x.value).ToList();
                if (lstValue != null && lstValue.Count > 0)
                {
                    foreach (IBOMNode ibomnode in bomNodeLst)
                    {
                        if (lstValue.Contains(ibomnode.Part.PN))
                        { color = "White"; ; break; }

                    }
                }
                return color;
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取Product表相关信息
        /// </summary>
        /// <param name="line">line</param>
        /// <param name="editor">editor</param>
        /// <param name="station">station</param>
        /// <param name="customer">customer</param>
        /// <param name="customerSN">customer SN</param>
        public S_RowData_Product GetProduct(string line, string editor, string station, string customer,string customerSN)
        {
            logger.Debug("(_CombineCOAandDN)GetProduct start.customerSN:" + customerSN);
           
            string keyStr = "";
            try
            {
                var currentProduct = CommonImpl.GetProductByInput(customerSN, CommonImpl.InputTypeEnum.CustSN);
                if (null == currentProduct)
                {
                    List<string> errpara = new List<string>();
                    errpara.Add(customerSN);
                    throw new FisException("SFC002", errpara);
                }
                if (!string.IsNullOrEmpty(currentProduct.CartonSN))
                {
                    string temp = "CartonSN:" + currentProduct.CartonSN.ToString();
                    List<string> errpara = new List<string>();

                    errpara.Add(temp);
                    throw new FisException("CHK858", errpara);
                }
                if (!string.IsNullOrEmpty(currentProduct.DeliveryNo))
                {
                    string temp = "DeliveryNo:" + currentProduct.DeliveryNo.ToString();
                    List<string> errpara = new List<string>();

                    errpara.Add(temp);
                    throw new FisException("CHK858", errpara);
                }
                if (!string.IsNullOrEmpty(currentProduct.PalletNo))
                {
                    string temp = "PalletNo:" + currentProduct.PalletNo.ToString();
                    List<string> errpara = new List<string>();

                    errpara.Add(temp);
                    throw new FisException("CHK858", errpara);
                }
                if (!string.IsNullOrEmpty(currentProduct.PizzaID))
                {
                    string temp = "PizzaID:" + currentProduct.PizzaID.ToString();
                    List<string> errpara = new List<string>();

                    errpara.Add(temp);
                    throw new FisException("CHK858", errpara);
                }
                if ( currentProduct.CartonWeight == (decimal)0.00)
                {
                }
                else
                {
                    string temp = "CartonWeight:" + currentProduct.CartonWeight.ToString();
                    List<string> errpara = new List<string>();

                    errpara.Add(temp);
                    throw new FisException("CHK858", errpara);
                }
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            try
            {
                string sessionKey = customerSN;
                keyStr = sessionKey;
                Session 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, "CombineCOAandDNBlock.xoml", "", out wfName, out rlName);
                WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);
                currentSession.AddValue(Session.SessionKeys.CustSN, customerSN);
                currentSession.SetInstance(instance);
                if (!SessionManager.GetInstance.AddSession(currentSession))
                {
                    currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");

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

                    throw currentSession.Exception;
                }
                
				string isBSaM = currentSession.GetValue(ExtendSession.SessionKeys.IsBSamModel) as string;
                S_RowData_Product ret = new S_RowData_Product();
                ret.DN = "";
                ret.Model = "";
                ret.isBSaM = "";
                ret.ProductID = "";
                ret.isBT = "false";
                ret.isCDSI = "";
                ret.isFactoryPo = "";
                ret.isWin8 = "";
                IProduct temp = productRepository.GetProductByCustomSn(customerSN);
                if (null != temp)
                {
                    ret.ProductID = temp.ProId;
                    ret.isBT = temp.IsBT.ToString();
                    ret.Model = temp.Model;
                    
                    IList<IMES.FisObject.Common.Model.ModelInfo> isPO = modelRep.GetModelInfoByModelAndName(temp.Model, "PO");
                    foreach (IMES.FisObject.Common.Model.ModelInfo tmpPO in isPO)
                    {
                        if (tmpPO.Value == "Y")
                        {
                            ret.isCDSI = "true";
                        }
                        else
                        {
                            IList<IMES.FisObject.Common.Model.ModelInfo> isATSNAV = modelRep.GetModelInfoByModelAndName(temp.Model, "ATSNAV");
                            foreach (IMES.FisObject.Common.Model.ModelInfo tmpATSNAV in isATSNAV)
                            {
                                if (tmpATSNAV.Value == null)
                                { 
                                }
                                else if (tmpATSNAV.Value != "")
                                {
                                    ret.isCDSI = "true";
                                }
                                break;
                            }
                        }
                        break;
                    }
                    if (ret.isCDSI == "true")
                    {
                        CdsiastInfo condition = new CdsiastInfo();
                        condition.snoId = temp.ProId;
                        condition.tp = "FactoryPO";
                        IList<CdsiastInfo> isCdsiastInfo = productRepository.GetCdsiastInfoList(condition);
                        ret.isFactoryPo = "";
                        foreach (CdsiastInfo tmpCdsiastInfo in isCdsiastInfo)
                        {
                            ret.isFactoryPo = tmpCdsiastInfo.sno;
                            break;
                        }
                        if (ret.isBT == "true" || ret.isBT == "True")
                        {
                        }
                        else
                        {
                            if (ret.isFactoryPo == "" || ret.isFactoryPo == null)
                            {
                                throw new FisException("CHK882", new string[] { });
                            }
                        }
                    }
                    //Vincent 2015-02-26 Mo 綁訂PoNo
                    else if (temp.IsBindedPo)
                    {
                            ret.isCDSI = "true";
                            ret.isFactoryPo = temp.BindPoNo;
                     }
                    

                    //Marked by Benson at 20130517 For CQ Mantis 24
                 //   IList<MoBOMInfo>  win8list = bomRepository.GetPnListByModelAndBomNodeTypeAndDescr(temp.Model, "P1", "ECOA");
                   // if (win8list != null && win8list.Count > 0)
                    //Marked by Benson at 20130517 For CQ Mantis 24
                    bool bWIN8 = false;
                    CommonImpl2 cm2 = new CommonImpl2();
                    IHierarchicalBOM bom = bomRepository.GetHierarchicalBOMByModel(temp.Model);
                    bWIN8=cm2.CheckIsWIN8(bom);
                    if(bWIN8)
                   {
                        // mantis 1574
                       IList<string> valueList = ipartRepository.GetValueFromSysSettingByName("Site");
                       if (valueList.Count == 0)
                       {
                           throw new Exception("Error:尚未設定Site...");
                       }
                        string errMsg = "";
                        IList<string> typeList = new List<string>();
                        typeList.Add("P/N");
                        typeList.Add("Key");
                        if (valueList[0] == "ICC")
                        {
                            typeList.Add("COA");
                        }
                        else
                        {
                            typeList.Add("Hash");
                        }
                        IList<IMES.FisObject.FA.Product.ProductInfo> infoList = productRepository.GetProductInfoList(temp.ProId, typeList);
                        if (infoList != null)
                        {
                            StringBuilder infoTypes = new StringBuilder();
                            foreach (var v in infoList)
                            {
                                if ((null != v.InfoValue) && !string.IsNullOrEmpty(v.InfoValue.Trim()))
                                    infoTypes.Append(v.InfoType).Append(",");
                            }
                            string win8Type = infoTypes.ToString();
                            foreach (string s in typeList) {
                                if (!(win8Type.Contains(s)))
                                    errMsg += s+ "缺少 ";
                            }
                        }
                        else
                        {
                            foreach (string s in typeList)
                                errMsg += s + "缺少 ";
                        }
                        if (!string.IsNullOrEmpty(errMsg))
                        {
                            throw new FisException("CHK969", new string[] { errMsg });
                        }
                        ret.isWin8 = "true";
                    }
					if (!"Y".Equals(isBSaM))
					{
						if (ret.isCDSI == "true")
						{
							DNQueryCondition conditionDN = new DNQueryCondition();
							DateTime aTime = DateTime.Now;
							aTime = aTime.AddDays(-3);
							conditionDN.ShipDateFrom = new DateTime(aTime.Year, aTime.Month, aTime.Day, 0, 0, 0, 0);
							conditionDN.Model = ret.Model;
							if (conditionDN.Model != "")
							{
								IList<Srd4CoaAndDn> dnList = currentRepository.GetDNListByConditionForPerformanceWithSorting(conditionDN);
								foreach (Srd4CoaAndDn tmp in dnList)
								{
									if (ret.isFactoryPo != "")
									{
										if (ret.isFactoryPo != tmp.PoNo)
										{
											continue;
										}
									}
									ret.DN = tmp.DeliveryNO;
									break;
								}
							}
						}
						else
						{ 
							Delivery assignDelivery = null;
							int assignQty = 0;

                            // modify for other model, ex: Jamestown in mantis 1945
							//IList<Delivery> deliveryList = currentRepository.GetDeliveryListByModel(ret.Model,"PC",12,"00");
                            IList<Delivery> deliveryList = getDnByModel(ret.Model);
                            //Vincent 2015-02-27 過濾綁訂PoDN
                            IList<string> bindPoNoList = moRep.GetBindPoNoByModel(ret.Model);
                            if (bindPoNoList != null && bindPoNoList.Count > 0)
                            {
                                deliveryList = deliveryList.Where(x => !bindPoNoList.Contains(x.PoNo)).ToList();
                            }

							if (deliveryList.Count == 0)
							{

								if (temp.IsBT)
								{
								}
								else
								{
									List<string> errpara = new List<string>();
									errpara.Add(customerSN);
									throw new FisException("PAK101", errpara);//无此机型Delivery!
								}
							}

							//a)	ShipDate 越早,越优先
							//b)	散装优先于非散装
							//c)	剩余未包装Product数量越少的越优先

							bool assignNA = false;
							foreach (Delivery dvNode in deliveryList)
							{
								int curqty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo);
								int tmpqty = dvNode.Qty - curqty;
								int curQty = productRepository.GetCombinedQtyByDN(dvNode.DeliveryNo);
								if (tmpqty > 0 )
								{
									bool naflag = false;
									foreach (DeliveryPallet dpNode in dvNode.DnPalletList)
									{
										if (dpNode.PalletID.Substring(0, 2) == "NA")
										{
											naflag = true;
											break;
										}
									}
									if (assignDelivery == null)
									{
										assignDelivery = dvNode;
										assignQty = tmpqty;
										assignNA = naflag;
										continue;
									}
									if (DateTime.Compare(assignDelivery.ShipDate, dvNode.ShipDate) < 0)
									{
										continue;
									}
									if (!assignNA && naflag)
									{
										assignDelivery = dvNode;
										assignQty = tmpqty;
										assignNA = naflag;
									}
									else if (assignNA == naflag)
									{
										if (tmpqty < assignQty)
										{
											assignDelivery = dvNode;
											assignQty = tmpqty;
											assignNA = naflag;
										}
									}
								}
							}
							if (assignDelivery == null)
							{
								if (temp.IsBT)
								{
								}
								else
								{
									FisException fe = new FisException("PAK103", new string[] { });   //没找到可分配的delivery
									throw fe;
								}
							}
							else
							{
								ret.DN = assignDelivery.DeliveryNo;
							}
						}
					}
					else // isBSaM
					{
                        //if (! ChkInDelivery(ret.Model))
                        //{
                        //    List<string> errpara = new List<string>();
                        //    errpara.Add(ret.Model);
                        //    throw new FisException("PAK174", errpara);
                        //}
                        if (ChkInCartonLoc(ret.ProductID))
                        {
                            List<string> errpara = new List<string>();
                            errpara.Add(ret.ProductID);
                            throw new FisException("PAK175", errpara);
                        }
                        ret.isBSaM = isBSaM; //Y
					}
				}

                return ret;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                Session sessionDelete = SessionManager.GetInstance.GetSession(keyStr, SessionType); ;
                if (sessionDelete != null)
                {
                    SessionManager.GetInstance.RemoveSession(sessionDelete);
                }
                logger.Debug("(_CombineCOAandDN)GetProduct end, customerSN:" + customerSN);
            }          
        }
Exemplo n.º 11
0
 public ArrayList GetPODLabelPathAndSite()
 {
    ArrayList arr = new ArrayList();
    string path = "";
    CommonImpl2 cm2 = new CommonImpl2();
     path = cm2.GetValueFromSysSetting("PODLabelPath"); 
    arr.Add(path);
    return arr;
 }
Exemplo n.º 12
0
        /// <summary>
        /// 此站输入的是SN,需要在BLL中先根据SN获取Product调用CommonImpl.GetProductByInput()
        /// 如果获取不到,报CHK079!
        /// 用ProductID启动工作流
        /// 将获得的Product放到Session.Product中
        /// 获取Model和标准重量和ProductID
        /// </summary>
        /// <param name="custSN"></param>
        /// <param name="actualWeight"></param>
        /// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <param name="configParams"></param>
        /// <returns>ArrayList对象</returns>
        public ArrayList InputCustsn(string custSN, decimal actualWeight, string line, string editor, string station, string customer, out List<string> configParams)
        {
            logger.Debug("(PakUnitWeightNew)InputCustsn Start,"
                + " [custSN]:" + custSN
                + " [line]:" + line
                + " [editor]:" + editor
                + " [station]:" + station
                 + " [actualWeight]:" + actualWeight.ToString()
                + " [customer]:" + customer);
            FisException ex;
            List<string> erpara = new List<string>();
            try
            {
                ArrayList retLst = new ArrayList();
                var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN);
                if (currentProduct == null)
                {
                    FisException fe = new FisException("CHK079", new string[] { custSN });
                    throw fe;
                }
                string productID = currentProduct.ProId;
                string sessionKey = productID;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);
                //Mantis 961
                //获取Pallet No : IMES_FA..Product.PalletNo
                if (!currentProduct.IsBT && string.IsNullOrEmpty(currentProduct.PalletNo))
                {
                    erpara.Add(custSN);
                    ex = new FisException("PAK021", erpara);     //该Customer S/N还未与Pallet绑定!
                    throw ex;
                }
                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, 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", Session.SessionType.Product);

                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "PakUnitWeightNew.xoml", "PakUnitWeightNew.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.ActuralWeight, actualWeight);
                    currentSession.AddValue(Session.SessionKeys.PalletNo, currentProduct.PalletNo);
                    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;
                }

                string modelTolerance = currentSession.GetValue(Session.SessionKeys.Tolerance).ToString();
                decimal standardWeight = -1;
                if (currentSession.GetValue(Session.SessionKeys.StandardWeight) != null)
                {
                    standardWeight = (decimal)currentSession.GetValue(Session.SessionKeys.StandardWeight);
                }
              

                //PAQC 抽检: 查询IMES_FA..QCStatus 取Udt 最新的记录,如果该记录的Status = ‘8’,则在UI 上显示'PAQC 抽检',否则该位置显示' '
                string labelType1 = string.Empty;

                IDeliveryRepository iDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                ProductQCStatus qcStatus = iDeliveryRepository.GetQCStatus(productID, "PAQC");
                //Vincent for ICC special PAQC/PAQC
                if (qcStatus != null && (qcStatus.Status == "8" || qcStatus.Status == "B" || qcStatus.Status == "C"))
                {
                    labelType1 = "P" + qcStatus.Status;
                }

                //1.判断是否为BT Product, 2.于非BT Product
                string delievery = currentProduct.DeliveryNo;
                string model = string.IsNullOrEmpty(currentProduct.Model) ? "" : currentProduct.Model.Trim();
                string country = string.Empty;
                string printlabeltype1 = string.Empty; // Config Label
                string printlabeltype2 = string.Empty; // POD Label

                if (!currentProduct.IsBT)
                {
                    //获取与Customer S/N 绑定的Delivery No :IMES_FA..Product.DeliveryNo
                    if (string.IsNullOrEmpty(delievery))
                    {
                        erpara.Add(custSN);
                        ex = new FisException("PAK020", erpara);    //该Customer S/N还未与DN绑定!
                        throw ex;
                    }
                }
                else
                {
                    //获取Model : IMES_FA..Product.Model
                    if (string.IsNullOrEmpty(model))
                    {
                        erpara.Add(custSN);
                        ex = new FisException("PAK028", erpara);     //该Customer S/N还未与Model绑定!
                        throw ex;
                    }
                }
               
                IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
             
                // 4. Adaptor Label / India Label 判定
                string labelType2 = string.Empty;
                if (model.Length >= 11 && (model.Substring(9, 2) == "16" || model.Substring(9, 2) == "DM" || model.Substring(9, 2) == "D0"))
                {
                    labelType2 = "A";
                }
                else if (country == "INDIA")
                {
                    labelType2 = "I";
                }
      
                IPartRepository ipartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                IMES.FisObject.Common.FisBOM.IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>();
                IHierarchicalBOM sessionBOM = null;
                sessionBOM = ibomRepository.GetHierarchicalBOMByModel(currentProduct.Model);
                IList<IBOMNode> bomNodeLst = new List<IBOMNode>();
                bomNodeLst = sessionBOM.FirstLevelNodes;
                CommonImpl2 cm2 = new CommonImpl2();
                string site = cm2.GetValueFromSysSetting("Site");
                currentSession.AddValue("Site", "ICC");
                currentSession.AddValue("BlackLabel",true);
                IList<string> lstValue
                         =cm2.GetConstValueTypeByType("POD_White_Lable_PN").Where(x=>x.value!="").Select(x=>x.value).ToList();
                    if (lstValue != null && lstValue.Count > 0 )
                    {
                        foreach (IBOMNode ibomnode in bomNodeLst)
                        {
                            if (lstValue.Contains(ibomnode.Part.PN))
                            { currentSession.AddValue("BlackLabel", false); break; }

                        }
                    }
                
                if (bomNodeLst == null || bomNodeLst.Count <= 0)
                {
                    erpara.Add(currentProduct.Model);
                    ex = new FisException("PAK039", erpara);
                    throw ex;
                }
                IModelRepository iModelRepository = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
                string type = string.Empty;
        //       Model modelObject = iModelRepository.Find(currentProduct.Model);
                string family = currentProduct.Family;
                
              // Print =====如果为BT 产品,当满足如下条件时,需要列印Config Label=====

                currentSession.AddValue(Session.SessionKeys.labelBranch, "");
     //           delievery = currentProduct.DeliveryNo;
                configParams = new List<string>();
               
                //Revision: 9810:	修改列印Config Label 的条件为非BT
                if (!currentProduct.IsBT)
                {
                    string BTRegId = iDeliveryRepository.GetDeliveryInfoValue(delievery, "RegId");
                    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
                        IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository>();
                         //bool bRegId = new[] { "SCN", "SAF", "SNE", "SCE", "QCN", "QAF", "QNE", "QCE" }.Any(BTRegId.Trim().Equals);
                       
                        IList<ConstValueTypeInfo> constValueTypeList = partRep.GetConstValueTypeList("ConfigLabelRegionId", BTRegId.Trim());
                        bool bRegId = (constValueTypeList != null && constValueTypeList.Count > 0);
                        
                       // if ((BTRegId == "SCN" || BTRegId == "SAF" || BTRegId == "SNE" || BTRegId == "SCE") && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                        if (bRegId && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                         {
                            printlabeltype1 = "ConfigLabel";
                            currentSession.AddValue(Session.SessionKeys.labelBranch, printlabeltype1);
                        }
                    }
                }

                //  Print =====如果IMES_PAK..PODLabelPart中有维护PartNo等于Model的前几位字符的记录 and (Model的第7位不是数字),则需要列印POD Label====

                IList<PODLabelPartDef> podLabelPartLst = new List<PODLabelPartDef>();
                podLabelPartLst = ipartRepository.GetPODLabelPartListByPartNo(model);
                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.labelBranch, printlabeltype2);  //如果列印PodLabel,则需要再记录一次ProductLog (Station = 'PD',Line = 'POD Label Print')
                    }
                }
                IList<string> EditsFISAddrLst = new List<string>();
                string EditsFISAddr = string.Empty;
                EditsFISAddrLst = ipartRepository.GetValueFromSysSettingByName("EditsFISAddr");
                if (EditsFISAddrLst != null && EditsFISAddrLst.Count > 0)
                {
                    EditsFISAddr = EditsFISAddrLst[0];
                } 
               
                IList<BomItemInfo> bomItemList = PartCollection.GeBOM(sessionKey, Session.SessionType.Product);
                S_UnitWeightNew sUnitWeightNew = new S_UnitWeightNew
                                                                       {
                                                                           ProductID = productID,
                                                                           Model = model,
                                                                           StandardWeight = standardWeight,
                                                                           PAQC = labelType1,
                                                                           FAI=CheckFAI(model).Replace(currentProduct.CUSTSN,"").Replace("[","").Replace("]",""),
                                                                           IndiaLabel = labelType2,
                                                                           ConfigLabel = printlabeltype1,
                                                                           PODLabel = printlabeltype2,
                                                                           EditsFISAddr = EditsFISAddr,
                                                                           BomItemList = bomItemList
                                                                       };
                      
                retLst.Add(sUnitWeightNew);  
                return retLst;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                if (e.mErrcode == "CHK020") //序號已被刷入
                {
                    throw e;
                }
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PakUnitWeightNew)InputCustsn End,"
                    + " [custSN]:" + custSN
                    + " [line]:" + line
                    + " [editor]:" + editor
                    + " [station]:" + station
                    + " [customer]:" + customer);
            }

        }
Exemplo n.º 13
0
        /// <summary>
        /// 此站输入的是SN,需要在BLL中先根据SN获取Product调用CommonImpl.GetProductByInput()
        /// 如果获取不到,报CHK079!
        /// 用ProductID启动工作流
        /// 将获得的Product放到Session.Product中
        /// 获取Model和标准重量和ProductID
        /// </summary>
        /// <param name="custSN"></param>
        /// <param name="actualWeight"></param>
        /// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <param name="configParams"></param>
        /// <returns>ArrayList对象</returns>
        public ArrayList InputUUT(string custSN, decimal actualWeight, string line, string editor, string station, string customer, out List<string> configParams)
        {
            logger.Debug("(UnitWeight)InputUUT Start,"
                + " [custSN]:" + custSN
                + " [line]:" + line
                + " [editor]:" + editor
                + " [station]:" + station
                 + " [actualWeight]:" + actualWeight.ToString()
                + " [customer]:" + customer);
            FisException ex;
            List<string> erpara = new List<string>();
            try
            {
                ArrayList retLst = new ArrayList();
                var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN);
                if (currentProduct == null)
                {
                    FisException fe = new FisException("CHK079", new string[] { custSN });
                    throw fe;
                }
                string productID = currentProduct.ProId;
                string sessionKey = productID;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);

                //Mantis 961
                //获取Pallet No : IMES_FA..Product.PalletNo
                if (!currentProduct.IsBT && string.IsNullOrEmpty(currentProduct.PalletNo) && currentProduct.Model.Substring(0, 3) != "146")
                {
                    erpara.Add(custSN);
                    ex = new FisException("PAK021", erpara);     //该Customer S/N还未与Pallet绑定!
                    throw ex;
                }


                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, 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", Session.SessionType.Product);

                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "PakUnitWeight.xoml", "PakUnitWeight.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.ActuralWeight, actualWeight);
                    currentSession.AddValue(Session.SessionKeys.PalletNo, currentProduct.PalletNo);
                    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;
                }

                string modelTolerance = currentSession.GetValue(Session.SessionKeys.Tolerance).ToString();
                decimal standardWeight = -1;
                if (currentSession.GetValue(Session.SessionKeys.StandardWeight) == null)
                {
                    standardWeight = -1;
                }
                else
                {
                    standardWeight = (decimal)currentSession.GetValue(Session.SessionKeys.StandardWeight);
                }

                //PAQC 抽检: 查询IMES_FA..QCStatus 取Udt 最新的记录,如果该记录的Status = ‘8’,则在UI 上显示'PAQC 抽检',否则该位置显示' '
                string labelType1 = string.Empty;

                IDeliveryRepository iDeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                ProductQCStatus qcStatus = iDeliveryRepository.GetQCStatus(productID, "PAQC");
                //Vincent for ICC special PAQC/PAQC
                if (qcStatus != null && (qcStatus.Status == "8" || qcStatus.Status == "B" || qcStatus.Status == "C"))
                {
                    labelType1 = "P" + qcStatus.Status;
                }

                //1.判断是否为BT Product, 2.于非BT Product
                string delievery = string.Empty;    // currentDeliveryNo
                string plt = string.Empty;      // currentPalletNo
                string pno = string.Empty;      // currentModel
                string country = string.Empty;
                string jcid = string.Empty;     //configID
                string flg = string.Empty;    // Flag
                string printlabeltype1 = string.Empty; // Config Label
                string printlabeltype2 = string.Empty; // POD Label

                if (!currentProduct.IsBT)
                {
                    //获取与Customer S/N 绑定的Delivery No :IMES_FA..Product.DeliveryNo
                    if (string.IsNullOrEmpty(currentProduct.DeliveryNo))
                    {
                        erpara.Add(custSN);
                        ex = new FisException("PAK020", erpara);    //该Customer S/N还未与DN绑定!
                        throw ex;
                    }
                    delievery = currentProduct.DeliveryNo;

                    //获取Pallet No : IMES_FA..Product.PalletNo
                    //if (string.IsNullOrEmpty(currentProduct.PalletNo))
                    //{
                    //    erpara.Add(custSN);
                    //    ex = new FisException("PAK021", erpara);     //该Customer S/N还未与Pallet绑定!
                    //    throw ex;
                    //}
                    plt = currentProduct.PalletNo;

                    //获取Model : IMES_FA..Product.Model
                    //if (string.IsNullOrEmpty(currentProduct.Model))
                    //{
                    //    erpara.Add(custSN);
                    //    ex = new FisException("PAK028", erpara);     //该Customer S/N还未与Model绑定!
                    //    throw ex;
                    //}
                    // pno = currentProduct.Model;

                    if (string.IsNullOrEmpty(currentProduct.Model))
                    {
                        pno = "";
                    }
                    else
                    {
                        pno = currentProduct.Model.Trim();
                    }

                    //获取Delivery 的Country / configID / Flag 
                    country = iDeliveryRepository.GetDeliveryInfoValue(delievery, "Country");
                    if (string.IsNullOrEmpty(country))
                    {
                        //List<string> errpara = new List<string>();
                        //errpara.Add(delievery);
                        //errpara.Add("Country");
                        //throw new FisException("PAK029", errpara);

                        country = "";
                    }
                    jcid = iDeliveryRepository.GetDeliveryInfoValue(delievery, "ConfigID");
                    if (string.IsNullOrEmpty(jcid))   //ITC-1360-1222 取消报错!
                    {
                        //List<string> errpara = new List<string>();
                        //errpara.Add(delievery);
                        //errpara.Add("configID");
                        //throw new FisException("PAK029", errpara);

                        jcid = "";
                    }
                    flg = iDeliveryRepository.GetDeliveryInfoValue(delievery, "Flag");
                    if (string.IsNullOrEmpty(flg))
                    {
                        //List<string> errpara = new List<string>();
                        //errpara.Add(delievery);
                        //errpara.Add("Flag");
                        //throw new FisException("PAK029", errpara);

                        flg = "";
                    }
                }
                else
                {
                    //获取Model : IMES_FA..Product.Model
                    if (string.IsNullOrEmpty(currentProduct.Model))
                    {
                        erpara.Add(custSN);
                        ex = new FisException("PAK028", erpara);     //该Customer S/N还未与Model绑定!
                        throw ex;
                    }
                    pno = currentProduct.Model;

                }
               
                IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

                // 3. 是否有与当前Product 绑定的BoxID或UCC:(IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'BoxId')或UCC (IMES_FA..ProductInfo.InfoValue,Condition: InfoType = 'UCC')
                ////---- UC Update : SVN Revison: 11531 取消BoxId/UCC唯一性检查----
                //int bindQty1 = 0;
                //int bindQty2 = 0;
                ////bindQty1 = iproductRepository.GetProductInfoCountByInfoType("BoxId");
                ////bindQty2 = iproductRepository.GetProductInfoCountByInfoType("UCC");
                //string PrdInfo_BoxID_Value = iproductRepository.GetProductInfoValue(productID, "BoxId");
                //string PrdInfo_UCC_Value = iproductRepository.GetProductInfoValue(productID, "UCC");

                //if (!String.IsNullOrEmpty(PrdInfo_BoxID_Value))
                //{
                //    IProduct product = null;
                //    product = (IProduct)currentSession.GetValue(Session.SessionKeys.Product);
                //    IList<IMES.FisObject.FA.Product.ProductInfo> infos = new List<IMES.FisObject.FA.Product.ProductInfo>();
                //    infos = product.ProductInfoes;

                //    foreach (IMES.FisObject.FA.Product.ProductInfo iInfo in infos)
                //    {
                //        if (iInfo.InfoValue == PrdInfo_BoxID_Value)
                //        {
                //            bindQty1++;
                //        }
                //    }
                //    if (bindQty1 > 1)
                //    {
                //        erpara.Add("BoxId");
                //        ex = new FisException("PAK030", erpara);     //此机器BoxId与其他机器重复,请unpack后重流亮灯第二站!
                //        throw ex;
                //    }
                //}

                //if (!String.IsNullOrEmpty(PrdInfo_UCC_Value))
                //{
                //    IProduct product = null;
                //    product = (IProduct)currentSession.GetValue(Session.SessionKeys.Product);
                //    IList<IMES.FisObject.FA.Product.ProductInfo> infos = new List<IMES.FisObject.FA.Product.ProductInfo>();
                //    infos = product.ProductInfoes;

                //    foreach (IMES.FisObject.FA.Product.ProductInfo iInfo in infos)
                //    {
                //        if (iInfo.InfoValue == PrdInfo_UCC_Value)
                //        {
                //            bindQty2++;
                //        }
                //    }

                //    if (bindQty2 > 1)
                //    {
                //        erpara.Add("UCC");
                //        ex = new FisException("PAK030", erpara);     //此机器UCC与其他机器重复,请unpack后重流亮灯第二站!
                //        throw ex;
                //    }
                //}
                ////---- UC Update : SVN Revison: 11531 取消BoxId/UCC唯一性检查----


                // 4. Adaptor Label / India Label 判定
                string labelType2 = string.Empty;
                if (pno.Length >= 11 && (pno.Substring(9, 2) == "16" || pno.Substring(9, 2) == "DM" || pno.Substring(9, 2) == "D0"))
                {
                    labelType2 = "A";
                }
                else if (country == "INDIA")
                {
                    labelType2 = "I";
                }

                // 6. Get Asset Tag Item / Asset Tag Item Value 
                //  a) wc ="85";@ast=''(Asset Tag Item Value);@item='' (Asset Tag Item)
                // string wc = "85";
                string ast = string.Empty;  // Asset Tag Item Value
                string item = string.Empty; // Asset Tag Item
                string asttp = string.Empty;
                string astrm = string.Empty;
                string cust = string.Empty;

                //  b) 取ModelBOM 中Model 直接下阶中有BomNodeType 为'AT' 的Part 
                IPartRepository ipartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                IMES.FisObject.Common.FisBOM.IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>();
                IHierarchicalBOM sessionBOM = null;
                sessionBOM = ibomRepository.GetHierarchicalBOMByModel(currentProduct.Model);
                IList<IBOMNode> bomNodeLst = new List<IBOMNode>();
                
                bomNodeLst = sessionBOM.FirstLevelNodes;
                //For CQ
                CommonImpl2 cm2 = new CommonImpl2();
                string site = cm2.GetValueFromSysSetting("Site");
                if (site == "ICC")
                {
                    currentSession.AddValue("Site", "ICC");
                    currentSession.AddValue("BlackLabel",true);
                    IList<string> lstValue
                         =cm2.GetConstValueTypeByType("POD_White_Lable_PN").Where(x=>x.value!="").Select(x=>x.value).ToList();
                    if (lstValue != null && lstValue.Count > 0 )
                    {
                        foreach (IBOMNode ibomnode in bomNodeLst)
                        {
                            if (lstValue.Contains(ibomnode.Part.PN))
                            { currentSession.AddValue("BlackLabel", false); break; }

                        }
                    }
                }


                //For CQ



                if (bomNodeLst == null || bomNodeLst.Count <= 0)
                {
                    erpara.Add(currentProduct.Model);
                    ex = new FisException("PAK039", erpara);
                    throw ex;
                }
                IList<IPart> AT_PartList = new List<IPart>();
                foreach (IBOMNode ibomnode in bomNodeLst)
                {
                    //Revision: 9707:6. Get Asset Tag Item / Asset Tag Item Value 中b) “取AT Part 时需要按照Descr 逆序排取第一条”
                    IPart currentPart = ibomnode.Part;
                    if (currentPart.BOMNodeType == "AT")
                    {
                        //asttp = currentPart.Descr;  //IMES_GetData..Part.Descr
                        //astrm = currentPart.Remark; //IMES_GetData..Part.Remark
                        //break;
                        AT_PartList.Add(currentPart);
                    }
                }
                IPart BindCurrentPart;
               
            
                if (AT_PartList.Count > 0)
                {
                    asttp = AT_PartList[AT_PartList.Count - 1].Descr;  //逆序排取第一条 ==> 正序取最后一条
             
                    astrm = AT_PartList[AT_PartList.Count - 1].Remark; //逆序排取第一条 ==> 正序取最后一条
                    BindCurrentPart = AT_PartList[AT_PartList.Count - 1];
                }
                // ********************Begin New AST Check Rule ******************** Add by Benson
                string av="";
                IList<IPart> AST_Check = new List<IPart>();
                foreach (IPart iPart in AT_PartList)
                {
                 //    if (iPart.Descr == "ATSN1" || iPart.Descr == "ATSN4" || iPart.Descr == "ATS7" || iPart.Descr == "ATSN8")
                    if (iPart.Descr == "ATSN1" || iPart.Descr == "ATSN4")
                   
                    { AST_Check.Add(iPart); }
                }
                IList<IProductPart> productParts = new List<IProductPart>();
                productParts = currentProduct.ProductParts;
                if (AST_Check.Count > 0)
                {
                    if (productParts == null || productParts.Count <= 0)
                    {
                        List<string> errpara = new List<string>();
                        errpara.Add(productID);
                        throw new FisException("PAK038", errpara);  //该Product尚未绑定Part!
                    }
                    foreach (IPart iCheckPart in AST_Check)
                    {
                        asttp=iCheckPart.Descr;
                        if (asttp == "ATSN1")
                        { 
                           if(CheckHaveATS1(productParts,ipartRepository))
                           {
                               FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                               throw fe;
                           }
                        }
                        else if (asttp == "ATSN4")
                        { 
                              // Add by Benson for Mantis 0001723: weight站页面修改 at 2013/04/12
                              IList<ProductLog> logList=  iproductRepository.GetProductLogs(currentProduct.ProId, "PKAT");
                              if (logList == null || logList.Count == 0)
                              {
                                  throw new FisException("PAK180", new string[] { });
                              }
                              // Add by Benson for Mantis 0001723: weight站页面修改 at 2013/04/12
                             foreach (PartInfo ele in iCheckPart.Attributes)
                                {
                                    if (ele.InfoType == "AV")
                                    {
                                      av=ele.InfoValue;break;
                                    }
                                }
                              if(av=="")
                                {
                                    FisException fe = new FisException("PAK171", new string[] { iCheckPart.PN });  //请联系IE维护%1的AV值
                                    throw fe;
                                }
                          IList<AstRuleInfo> astrule = iproductRepository.GetAstRuleByCodeAndStationAndCust(asttp, station, av);

                          if (astrule != null && astrule.Count > 0 && !string.IsNullOrEmpty(astrule[0].checkItem))
                          {
                              item = astrule[0].checkItem;
                              switch (item)
                              {
                                  case "PoNo":
                                      Delivery CurrentDelivery = iDeliveryRepository.Find(delievery);
                                      if (CurrentDelivery != null && !string.IsNullOrEmpty(CurrentDelivery.PoNo))
                                      {
                                          ast = CurrentDelivery.PoNo;
                                      }
                                      break;
                                  case "CustPo":
                                      ast = iDeliveryRepository.GetDeliveryInfoValue(delievery, "CustPo");
                                      break;
                                  case "UUID":
                                      ast = iproductRepository.GetProductInfoValue(productID, "UUID");
                                      break;
                                  case "MAC":
                                      ast = currentProduct.MAC;
                                      break;
                                  //Add by Benson for Mantis: 0001539
                                  case "WM":
                                      ast = iproductRepository.GetProductInfoValue(productID, "WM");
                                      if (!string.IsNullOrEmpty(ast))
                                      {
                                          ast = ast.Replace(":", "");     //去掉字符':' 
                                      }
                                      break;
                                  //Add by Benson for Mantis: 0001539

                                  // Add by Benson for Mantis 0001723: weight站页面修改 at 2013/04/12
                                  case "SN":
                                      ast = custSN;
                                      break;
                                      //
                                  case "CHAR":
                                      IList<ConstValueInfo> valueList =
                                          ipartRepository.GetConstValueListByType("ASTCHAR").Where(x => x.value.Trim() != "" && x.name==av).ToList();
                                     if (valueList != null && valueList.Count > 0)
                                     {
                                         ast = valueList[0].value;
                                     }
                                     break;

                                  // Add by Benson for Mantis 0001723: weight站页面修改 at 2013/04/12

                                  case "AST":
                                      //IMES_FA..Product_Part 表中与当前Product 绑定的Parts 中存在BomNodeType为'AT'的Part记录的PartSn
                                      //Boolean exitPart = true;
                                      foreach (ProductPart iprodpart in productParts)
                                      {
                                          if (iprodpart.BomNodeType == "AT")
                                          {
                                              IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);

                                              //Modify by Benson at 2012/12/13
                                              //if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN4")
                                              if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN3")
                                              {
                                                  ast = iprodpart.PartSn;
                                                  //exitPart = false;
                                                  break;
                                              }
                                          }
                                      }
                                      // Add by Benson for Mantis 0001723: weight站页面修改 at 2013/04/12
                                      if (string.IsNullOrEmpty(ast))
                                      {
                                          foreach (ProductPart iprodpart in productParts)
                                          {
                                              if (iprodpart.BomNodeType == "AT")
                                              {
                                                  IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);

                                                  //Modify by Benson at 2012/12/13
                                                  //if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN4")
                                                  if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN1")
                                                  {
                                                      ast = iprodpart.PartSn;
                                                      //exitPart = false;
                                                      break;
                                                  }
                                              }
                                          }
                                      }

                                      // Add by Benson for Mantis 0001723: weight站页面修改 at 2013/04/12

                                      break;
                                  default:
                                      break;
                              }
                          }
                           
                              //  astrule = iproductRepository.GetAstRuleByCodeAndStationAndCust("ATSN4", station, cust);
                        }
                        else if (asttp == "ATSN7")
                        {

                              foreach (PartInfo ele in iCheckPart.Attributes)
                                {
                                    if (ele.InfoType == "AV")
                                    {
                                      av=ele.InfoValue;break;
                                    }
                                }
                              if(av=="")
                                {
                                    FisException fe = new FisException("PAK171", new string[] { iCheckPart.PN });  //请联系IE维护%1的AV值
                                    throw fe;
                                }
                          IList<AstRuleInfo> astrule = iproductRepository.GetAstRuleByCodeAndStationAndCust(asttp, station, av);
                            if (astrule != null && astrule.Count > 0 && !string.IsNullOrEmpty(astrule[0].checkItem))
                           {
                              item=astrule[0].checkItem;
                               switch (item)
                                    {
                                        case "PoNo":
                                            Delivery CurrentDelivery = iDeliveryRepository.Find(delievery);
                                             if (CurrentDelivery != null && !string.IsNullOrEmpty(CurrentDelivery.PoNo))
                                            {
                                                ast = CurrentDelivery.PoNo;
                                            }
                                            break;
                                        case "CustPo":
                                            ast = iDeliveryRepository.GetDeliveryInfoValue(delievery, "CustPo");
                                            break;
                                        case "UUID":
                                            ast = iproductRepository.GetProductInfoValue(productID, "UUID");
                                            break;
                                        case "MAC":
                                            ast = currentProduct.MAC;
                                            break;
                                        //Add by Benson for Mantis: 0001539
                                        case "WM":
                                            ast = iproductRepository.GetProductInfoValue(productID, "WM");
                                            if (!string.IsNullOrEmpty(ast))
                                            {
                                                ast = ast.Replace(":", "");     //去掉字符':' 
                                            }
                                            break;
                                        //Add by Benson for Mantis: 0001539
                                       
                                        case "AST":
                                            //IMES_FA..Product_Part 表中与当前Product 绑定的Parts 中存在BomNodeType为'AT'的Part记录的PartSn
                                            //Boolean exitPart = true;
                                            foreach (ProductPart iprodpart in productParts)
                                            {
                                                if (iprodpart.BomNodeType == "AT")
                                                {
                                                    IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                                                    if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN7")
                                                    {
                                                        ast = iprodpart.PartSn;
                                                        //exitPart = false;
                                                        break;
                                                    }
                                                }
                                            }
                                    
                                            break;
                                        default:
                                            break;
                                    }

                           }



                        }
                        else if (iCheckPart.Descr == "ATSN8")
                        {
                             foreach (PartInfo ele in iCheckPart.Attributes)
                                {
                                    if (ele.InfoType == "AV")
                                    {
                                      av=ele.InfoValue;break;
                                    }
                                }
                              if(av=="")
                                {
                                    FisException fe = new FisException("PAK171", new string[] { iCheckPart.PN });  //请联系IE维护%1的AV值
                                    throw fe;
                                }
                          IList<AstRuleInfo> astrule = iproductRepository.GetAstRuleByCodeAndStationAndCust(asttp, station, av);
                           if (astrule != null && astrule.Count > 0 && !string.IsNullOrEmpty(astrule[0].checkItem))
                           {
                              item=astrule[0].checkItem;
                               switch (item)
                                    {
                                        case "PoNo":
                                            Delivery CurrentDelivery = iDeliveryRepository.Find(delievery);
                                             if (CurrentDelivery != null && !string.IsNullOrEmpty(CurrentDelivery.PoNo))
                                            {
                                                ast = CurrentDelivery.PoNo;
                                            }
                                            break;
                                        case "CustPo":
                                            ast = iDeliveryRepository.GetDeliveryInfoValue(delievery, "CustPo");
                                            break;
                                        case "UUID":
                                            ast = iproductRepository.GetProductInfoValue(productID, "UUID");
                                            break;
                                        case "MAC":
                                            ast = currentProduct.MAC;
                                            break;
                                        //Add by Benson for Mantis: 0001539
                                        case "WM":
                                            ast = iproductRepository.GetProductInfoValue(productID, "WM");
                                            if (!string.IsNullOrEmpty(ast))
                                            {
                                                ast = ast.Replace(":", "");     //去掉字符':' 
                                            }
                                            break;
                                        //Add by Benson for Mantis: 0001539
                                       
                                        case "AST":
                                          
                                            foreach (ProductPart iprodpart in productParts)
                                            {
                                                if (iprodpart.BomNodeType == "AT")
                                                {
                                                    IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                                                    if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN3")
                                                    {
                                                        ast = iprodpart.PartSn;
                                                        //exitPart = false;
                                                        break;
                                                    }
                                                }
                                            }
                                    
                                            break;
                                        default:
                                            break;
                                    }

                           }
                        }
                        else
                        {
                            continue;
                        }
                    }

                }


          


                IModelRepository iModelRepository = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();

                //if (!string.IsNullOrEmpty(asttp))
                //{

                //    // IMES_FA..Product_Part 表中与当前Product 绑定的Parts 
                //    /* marked by Benson at 2013/01/18
                //       IList<IProductPart> productParts = new List<IProductPart>();
                //       productParts = currentProduct.ProductParts;
                //       if (productParts == null || productParts.Count <= 0)
                //       {
                //           List<string> errpara = new List<string>();
                //           errpara.Add(productID);
                //           throw new FisException("PAK038", errpara);  //该Product尚未绑定Part!
                //       }
                //     *  marked by Benson at 2013/01/18
                //     */





                //    //   i.	当@asttp='ATSN1'


                //    if (asttp == "ATSN1")
                //    {
                //        //使用[email protected] AND wc="85"AND [email protected] ,查询IMES_FA..AstRule 表存在记录时 
                //        IList<AstRuleInfo> astRuleInfoLst = new List<AstRuleInfo>();
                //        astRuleInfoLst = iproductRepository.GetAstRuleByCodeAndStationAndCheckTp(asttp, station, astrm);
                //        //if (astRuleInfoLst.Count <= 0)  // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //        //{
                //        //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //        //    throw fe;
                //        //}

                //        //IMES_FA..Product_Part 表中与当前Product 绑定的Parts 中存在BomNodeType (parttype)为'AT',Descr属性为 "ATSN1"的Part
                //        //string[] descr = new string[1];
                //        //descr[0] = "ATSN1";
                //        //IList<PartDef> partLst = ipartRepository.GetPartByBomNodeTypeAndDescr(productID, "AT", descr);
                //        //foreach (PartDef ipart in partLst)
                //        //{
                //        //    Boolean f = false;
                //        //    if (ipart.partNo == iprodpart.PartID)
                //        //    {
                //        //        ast = iprodpart.PartSn;
                //        //        f = true;
                //        //        break;
                //        //    }
                //        //    if (f)
                //        //    { break; }
                //        //} // 改用新方法如下:

                //        if (astRuleInfoLst != null && astRuleInfoLst.Count > 0)
                //        {
                //            Boolean exitPart = true;
                //            foreach (ProductPart iprodpart in productParts)
                //            {
                //                if (iprodpart.BomNodeType == "AT")
                //                {
                //                    IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                //                    if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN1")
                //                    {
                //                        ast = iprodpart.PartSn;
                //                        item = "AST";
                //                        exitPart = false;
                //                        break;
                //                    }
                //                }
                //            }
                //            if (exitPart)
                //            {
                //                FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                throw fe;
                //            }
                //        }
                //    }
                //    else  // ii. 当@asttp<>'ATSN1' 时
                //    {
                //        IList<ModelInfo> modelInfos2 = new List<ModelInfo>();
                //        IList<ModelInfo> modelInfos = new List<ModelInfo>();
                //        //Modify 2012/07/25 get "Cust2" ->Get "Cust"
                //        //-------------------------------------------
                //        modelInfos2 = iModelRepository.GetModelInfoByModelAndName(pno, "Cust2");
                //        if (modelInfos2 == null || modelInfos2.Count <= 0)
                //        {
                //            cust = "";
                //        }
                //        else
                //        {
                //            cust = modelInfos2[0].Value;
                //        }
                //        if (cust.Trim() =="")
                //        {
                //            modelInfos = iModelRepository.GetModelInfoByModelAndName(pno, "Cust");
                //            if (modelInfos == null || modelInfos.Count <= 0)
                //            {
                //                cust = "";
                //            }
                //            else
                //            {
                //                cust = modelInfos[0].Value;
                //            }
                //        }
                //        //-------------------------------------------
                //        //modelInfos = iModelRepository.GetModelInfoByModelAndName(pno, "Cust");
                //        //if (modelInfos == null || modelInfos.Count <= 0)
                //        //{
                //        //    cust = "";
                //        //}
                //        //else
                //        //{
                //        //    cust = modelInfos[0].Value;
                //        //}
                //        //  iii.使用[email protected] AND [email protected] AND [email protected] 查询IMES_FA..AstRule 表存在记录时
                //        IList<AstRuleInfo> astrule = iproductRepository.GetAstRuleByCodeAndStationAndCust(asttp, station, cust);
                //        if (astrule.Count > 0)
                //        {
                //            if (asttp == "ATSN4")
                //            {
                //                astrule = iproductRepository.GetAstRuleByCodeAndStationAndCust("ATSN4", station, cust);
                //                //if (astrule == null || astrule.Count <= 0 || string.IsNullOrEmpty(astrule[0].checkItem))  // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //                //{
                //                //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                //    throw fe;
                //                //}
                //                if (astrule != null && astrule.Count > 0 && !string.IsNullOrEmpty(astrule[0].checkItem))
                //                {
                //                    item = astrule[0].checkItem;
                //                    switch (item)
                //                    {
                //                        case "PoNo":
                //                            Delivery CurrentDelivery = iDeliveryRepository.Find(delievery);
                //                            //if (CurrentDelivery == null)
                //                            //{
                //                            //    List<string> errpara = new List<string>();
                //                            //    errpara.Add(delievery);
                //                            //    throw new FisException("CHK107", errpara);
                //                            //}
                //                            if (CurrentDelivery != null && !string.IsNullOrEmpty(CurrentDelivery.PoNo))
                //                            {
                //                                ast = CurrentDelivery.PoNo;
                //                            }
                //                            break;
                //                        case "CustPo":
                //                            ast = iDeliveryRepository.GetDeliveryInfoValue(delievery, "CustPo");
                //                            break;
                //                        case "UUID":
                //                            ast = iproductRepository.GetProductInfoValue(productID, "UUID");
                //                            break;
                //                        case "MAC":
                //                            ast = currentProduct.MAC;
                //                            break;
                //                        //Add by Benson for Mantis: 0001539
                //                        case "WM":
                //                            ast = iproductRepository.GetProductInfoValue(productID, "WM");
                //                            if (!string.IsNullOrEmpty(ast))
                //                            {
                //                                ast = ast.Replace(":", "");     //去掉字符':' 
                //                            }
                //                            break;
                //                        //Add by Benson for Mantis: 0001539
                                       
                //                        case "AST":
                //                            //IMES_FA..Product_Part 表中与当前Product 绑定的Parts 中存在BomNodeType为'AT'的Part记录的PartSn
                //                            //Boolean exitPart = true;
                //                            foreach (ProductPart iprodpart in productParts)
                //                            {
                //                                if (iprodpart.BomNodeType == "AT")
                //                                {
                //                                    IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                                                   
                //                                    //Modify by Benson at 2012/12/13
                //                                    //if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN4")
                //                                    if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN3")
                //                                    {
                //                                        ast = iprodpart.PartSn;
                //                                        //exitPart = false;
                //                                        break;
                //                                    }
                //                                }
                //                            }
                //                            //if (exitPart) // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //                            //{
                //                            //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                            //    throw fe;
                //                            //}
                //                            break;
                //                        default:
                //                            break;
                //                    }

                //                    //if (string.IsNullOrEmpty(ast)) // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //                    //{
                //                    //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                    //    throw fe;
                //                    //}
                //                }
                //            }

                //            else if (asttp == "ATSN7")
                //            {
                //                astrule = iproductRepository.GetAstRuleByCodeAndStationAndCust("ATSN7", station, cust);
                //                //if (astrule == null || astrule.Count <= 0 || string.IsNullOrEmpty(astrule[0].checkItem)) // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //                //{
                //                //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                //    throw fe;
                //                //}
                //                if (astrule != null && astrule.Count > 0 && !string.IsNullOrEmpty(astrule[0].checkItem))
                //                {
                //                    item = astrule[0].checkItem;
                //                    switch (item)
                //                    {
                //                        case "PoNo":
                //                            Delivery CurrentDelivery = iDeliveryRepository.Find(delievery);
                //                            //if (CurrentDelivery == null || string.IsNullOrEmpty(CurrentDelivery.PoNo))
                //                            //{
                //                            //    List<string> errpara = new List<string>();
                //                            //    errpara.Add(delievery);
                //                            //    throw new FisException("CHK107", errpara);
                //                            //}
                //                            if (CurrentDelivery != null && !string.IsNullOrEmpty(CurrentDelivery.PoNo))
                //                            {
                //                                ast = CurrentDelivery.PoNo;
                //                            }
                //                            break;
                //                        case "CustPo":
                //                            ast = iDeliveryRepository.GetDeliveryInfoValue(delievery, "CustPo");
                //                            break;
                //                        case "UUID":
                //                            //ast = currentProduct.UUID; // QA 发现item=UUID时,ATSN4与ATSN7的处理不一样,经UC确认,按ATSN4方式处理
                //                            ast = iproductRepository.GetProductInfoValue(productID, "UUID");
                //                            break;
                //                        case "WM":
                //                            ast = iproductRepository.GetProductInfoValue(productID, "WM");
                //                            if (!string.IsNullOrEmpty(ast))
                //                            {
                //                                ast = ast.Replace(":", "");     //去掉字符':' 
                //                            }
                //                            break;
                //                        case "MAC":
                //                            ast = currentProduct.MAC;
                //                            break;
                //                        case "AST":
                //                            //Boolean exitPart = true;
                //                            foreach (ProductPart iprodpart in productParts)
                //                            {
                //                                if (iprodpart.BomNodeType == "AT")
                //                                {
                //                                    IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                //                                    if (curPart.BOMNodeType == "AT" && curPart.Descr == "ATSN7")
                //                                    {
                //                                        ast = iprodpart.PartSn;
                //                                        //exitPart = false;
                //                                        break;
                //                                    }
                //                                }
                //                            }
                //                            //if (exitPart) // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //                            //{
                //                            //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                            //    throw fe;
                //                            //}
                //                            break;
                //                        default:
                //                            break;
                //                    }
                //                    //if (string.IsNullOrEmpty(ast))  // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //                    //{
                //                    //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                    //    throw fe;
                //                    //}
                //                }
                //            }

                //            else if (asttp != "ATSN7" && asttp != "ATSN4" && asttp != "ATSN1")
                //            {
                //                //Boolean exitPart = true;
                //                foreach (ProductPart iprodpart in productParts)
                //                {
                //                    if (iprodpart.BomNodeType == "AT")
                //                    {
                //                        IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                //                        if (curPart.BOMNodeType == "AT" && curPart.Descr == asttp)
                //                        {
                //                            ast = iprodpart.PartSn;
                //                            //exitPart = false;
                //                            break;
                //                        }
                //                    }
                //                }
                //                //if (exitPart) // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //                //{
                //                //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //                //    throw fe;
                //                //}

                //                item = "AST";
                //            }
                //        }

                //        //else    //astrule.Count<=0 // ITC-1360-1441: 确实有@ast=''的情况存在(Get Type中提及),因此只卡一处:AstRule 表存在记录时, ATSN1没有
                //        //{
                //        //    FisException fe = new FisException("PAK031", new string[] { });  //此机器未结合Asset Tag!
                //        //    throw fe;
                //        //}
                //    }
                //}

                // 7. Get Type
                string type = string.Empty;
                Model modelObject = iModelRepository.Find(currentProduct.Model);
                //if (modelObject == null || string.IsNullOrEmpty(modelObject.FamilyName))
                //{
                //    throw new FisException("CHK038", new string[] { currentProduct.Model});
                //}
                string family = string.Empty;
                if (modelObject != null && !string.IsNullOrEmpty(modelObject.FamilyName))
                {
                    family = modelObject.FamilyName;
                }
                //ITC-1360-1272 : BT产品没有plt,做个保护
                //if (plt!=""&& plt.Length>=2 && !string.IsNullOrEmpty(family))
                //if (plt!=""&& plt.Length>=2)
                //{
                if (plt != "" && plt.Length >= 2 && plt.Substring(0, 2) == "NA" && ast != "" && (family == "TAOS 2.0" || family == "DAVOS 3.0" || family == "TIANSHAN 1.0"))
                {
                    type = "YA";
                }
                else
                {
                    if (plt != "" && plt.Length >= 2 && plt.Substring(0, 2) == "NA" && ast == "" && (family == "TAOS 2.0" || family == "DAVOS 3.0" || family == "TIANSHAN 1.0"))
                    {
                        type = "N";
                    }
                    else
                    {
                        if (flg == "N" && jcid != "" && ast != "")
                        {
                            type = "YABJ";
                        }
                        else
                        {
                            if (flg == "N" && string.IsNullOrEmpty(jcid) && ast != "")
                            {
                                type = "YAB";
                            }
                            else
                            {
                                if (flg != "N" && jcid != "" && jcid != null && ast != "")
                                {
                                    type = "YAJ";
                                }
                                else
                                {
                                    // ITC-1360-1440 : @flg<>'N' AND ( @jcid='' OR @jcid is null ) AND @ast<>'' 
                                    if (flg != "N" && string.IsNullOrEmpty(jcid) && ast != "")
                                    {
                                        type = "YA";
                                    }
                                    else
                                    {
                                        if (flg == "N" && jcid != "" && ast == "")
                                        {
                                            type = "YBJ";
                                        }
                                        else
                                        {
                                            if (flg == "N" && string.IsNullOrEmpty(jcid) && ast == "")
                                            {
                                                type = "YB";
                                            }
                                            else
                                            {
                                                if (flg != "N" && jcid != "" && jcid != null && ast == "")
                                                {
                                                    type = "YJ";
                                                }
                                                else type = "N";
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                }
                //}
                // 8. Get RMN Flag
                //如果ModelBOM 中Model 直接下阶中有Part No 为'6060B0232501' 或者'6060B0487001'的Part 时,@rmnflag = '0';否则@rmnflag = '1'
                //如果ModelBOM 中Model 直接下阶存在Descr in ('China label','TAIWAN Label')的Part (两者不会同时存在),@rmnflag = '0';否则@rmnflag = '1'   (UC Update: SVN Revision: 11535)
                string rmnflag = "1";
                foreach (IBOMNode ibomnode in bomNodeLst)
                {
                    IPart currentPart = ibomnode.Part;
                    //if (currentPart.PN == "6060B0232501" || currentPart.PN == "6060B0487001")
                    if (currentPart.Descr == "China label" || currentPart.Descr == "TAIWAN Label")
                    {
                        rmnflag = "0";
                        break;
                    }
                }


                // Print =====如果为BT 产品,当满足如下条件时,需要列印Config Label=====

                currentSession.AddValue(Session.SessionKeys.labelBranch, "");
                delievery = currentProduct.DeliveryNo;
                configParams = new List<string>();
               
                //Revision: 9810:	修改列印Config Label 的条件为非BT
                if (!currentProduct.IsBT)
                {
                    string BTRegId = iDeliveryRepository.GetDeliveryInfoValue(delievery, "RegId");
                    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
                        IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository>();
                   
                        
                        //bool bRegId = new[] { "SCN", "SAF", "SNE", "SCE", "QCN", "QAF", "QNE", "QCE" }.Any(BTRegId.Trim().Equals);
                        bool bRegId = false;
                        IList<ConstValueTypeInfo> constValueTypeList = partRep.GetConstValueTypeList("ConfigLabelRegionId", BTRegId.Trim());
                        if (constValueTypeList != null && constValueTypeList.Count > 0)
                        {
                            bRegId = true;
                        }
                       // if ((BTRegId == "SCN" || BTRegId == "SAF" || BTRegId == "SNE" || BTRegId == "SCE") && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                        if (bRegId && (BTShipTp == "CTO") && (BTCountry != "JAPAN"))
                         {
                            printlabeltype1 = "ConfigLabel";
                            currentSession.AddValue(Session.SessionKeys.labelBranch, printlabeltype1);

                            //IList<ModelInfo> modelInfo = new List<ModelInfo>();
                            //modelInfo = iModelRepository.GetModelInfoByModelAndName(pno, "PN");
                            //string AV1= modelInfo[0].Value;
                            //configParams.Add(AV1); 

                            //string bu = string.Empty;
                            //foreach (IBOMNode ibomnode in bomNodeLst)
                            //{
                            //    IPart currentPart = ibomnode.Part;
                            //    if (currentPart.BOMNodeType == "AV" && currentPart.GetProperty("Descr").Substring(0,2)=="BU")
                            //    {
                            //      bu = currentPart.GetProperty("AV");
                            //      IList<string> CTOBomDescrLst = new List<string>();
                            //      CTOBomDescrLst = ibomRepository.GetCTOBomDescr(pno, bu);
                            //      if (CTOBomDescrLst == null || CTOBomDescrLst.Count <= 0)
                            //      {
                            //          List<string> errpara = new List<string>();
                            //          errpara.Add("Config");
                            //          errpara.Add("DESCR1");
                            //          throw new FisException("PAK040", errpara);
                            //      }
                            //      configParams.Add(CTOBomDescrLst[0]);  
                            //      break;
                            //    }
                            //}

                            //configParams.Add(currentProduct.CUSTSN);   
                            //configParams.Add(currentProduct.ModelObj.FamilyName);  
                            //configParams.Add(currentProduct.Model.Substring(0, 6));

                            ////AV / QTY / DESCR这三个变量对应的数据是查询IMES_GetData..CTOBom 的得到的满足条件的记录集的SPno / Qty / Descr 字段.对应记录数量,n 从1开始依次编号
                            //int AVn = 0;
                            //int QTYn =0;
                            //int DESCRn =0;
                            //IList<CtoBomInfo> CTOBomLst = new List<CtoBomInfo>();
                            //CTOBomLst = ibomRepository.GetCTOBomList(pno,bu);
                            //if (CTOBomLst == null || CTOBomLst.Count <= 0)
                            //{
                            //    List<string> errpara = new List<string>();
                            //    errpara.Add("Config");
                            //    errpara.Add("AV/QTY/DESCR");
                            //    throw new FisException("PAK040", errpara);
                            //}
                            //foreach (CtoBomInfo ctobom in CTOBomLst)
                            //{
                            //    if (string.IsNullOrEmpty(ctobom.spno))
                            //    {
                            //        AVn++;
                            //    }
                            //    if (ctobom.qty >0)
                            //    {
                            //        QTYn++;
                            //    }
                            //    if (string.IsNullOrEmpty(ctobom.descr))
                            //    {
                            //        DESCRn++;
                            //    }

                            //}
                            //configParams.Add(AVn.ToString());
                            //configParams.Add(QTYn.ToString());
                            //configParams.Add(DESCRn.ToString());

                        }
                    }
                }

                //  Print =====如果IMES_PAK..PODLabelPart中有维护PartNo等于Model的前几位字符的记录 and (Model的第7位不是数字),则需要列印POD Label====

                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.labelBranch, printlabeltype2);  //如果列印PodLabel,则需要再记录一次ProductLog (Station = 'PD',Line = 'POD Label Print')
                    }
                }

                // (\\hp-iis\OUT\)需要查询SysSetting 表获取, 参考方法:select Value from SysSetting nolock where Name = 'EditsFISAddr'
                IList<string> EditsFISAddrLst = new List<string>();
                string EditsFISAddr = string.Empty;
                EditsFISAddrLst = ipartRepository.GetValueFromSysSettingByName("EditsFISAddr");
                if (EditsFISAddrLst != null && EditsFISAddrLst.Count > 0)
                {
                    EditsFISAddr = EditsFISAddrLst[0];
                }

                retLst.Add(productID);              //  [0] IMES_FA..ProductID
                retLst.Add(pno);                    //  [1] IMES_FA..Product.Model
                retLst.Add(standardWeight);         //  [2] (decimal) IMES_GetData..ModelWeight.UnitWeight 
                retLst.Add(labelType1);             //  [3] PAQC 抽检
                retLst.Add(labelType2);             //  [4] Adaptor Label / India Label 判定
                retLst.Add(item);                   //  [5] AssetTagItem

                retLst.Add(rmnflag);                //  [6] RMN Flag
                retLst.Add(jcid);                   //  [7] ConfigID
                retLst.Add(ast);                    //  [8] AssetTagItemValue
                retLst.Add(type);                   //  [9] Type
                retLst.Add(modelTolerance);         //  [10] (string) modelTolerance

                retLst.Add(printlabeltype1);            //  [11] print Config Label
                retLst.Add(printlabeltype2);            //  [12] print POD Label

                retLst.Add(EditsFISAddr);           //  [13]  (\\hp-iis\OUT\)需要查询SysSetting 表获取, 参考方法:select Value from SysSetting nolock where Name = 'EditsFISAddr'

                string printexepath = string.Empty;
                IList<string> printexepathLst = ipartRepository.GetValueFromSysSettingByName("PDFPrintPath");
                if (printexepathLst != null && printexepathLst.Count > 0)
                {
                    printexepath = printexepathLst[0];
                }
                else printexepath = "C:\\FIS\\";

                retLst.Add(printexepath);
                IList<string> lstWin8PartNo = CheckIsWin8(bomNodeLst);
                retLst.Add(lstWin8PartNo);

                string faiCheck = CheckFAI(currentProduct.Model.Trim());
                retLst.Add(faiCheck);
                return retLst;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                if (e.mErrcode == "CHK020") //序號已被刷入
                {
                    throw e;
                }
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(UnitWeight)InputUUT End,"
                    + " [custSN]:" + custSN
                    + " [line]:" + line
                    + " [editor]:" + editor
                    + " [station]:" + station
                    + " [customer]:" + customer);
            }

        }
Exemplo n.º 14
0
        private bool CheckOA3Key(IHierarchicalBOM bom, IProduct p, string fkiPath, CredentialCache FKICredentialCache, string editor, UnitOfWork uow)
        {
            bool bWIN8 = false;
            IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
            //foreach (IBOMNode bomNode in P1BomNodeList)
            //{
            //    if (bomNode.Part.Descr.StartsWith("ECOA"))
            //    {
            //        bWIN8 = true;
            //        break;
            //    }
            //}
            CommonImpl2 cm2 = new CommonImpl2();
            bWIN8 = cm2.CheckIsWIN8(bom);


            if (!bWIN8) return true;

            if (fkiPath == "") return true; //Switch off checking by FKIServer.
            string thisURI = "";
            if (fkiPath.EndsWith("/"))
            {
                thisURI = fkiPath + "UnitStatus";
            }
            else
            {
                thisURI = fkiPath + "/UnitStatus";
            }

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(thisURI);
            req.AllowAutoRedirect = true;
            req.CookieContainer = new CookieContainer();
            req.ContentType = "application/plain; charset=utf-8";
            req.Accept = "*/*";
            req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
            req.KeepAlive = true;
            req.Method = "POST";
            req.Credentials = FKICredentialCache.GetCredential(new Uri(fkiPath), "NTLM");

            string XMLInputData = "<?xml version='1.0' encoding='utf-8' ?>";
            XMLInputData += "<UnitStatusRequest xmlns='http://HP.ITTS.OA30/digitaldistribution/2011/08'>";
            XMLInputData += "<HPSerialNumber>";
            XMLInputData += p.CUSTSN;
            XMLInputData += "</HPSerialNumber>";
            XMLInputData += "<ProductKeyID>";
            XMLInputData += "";
            XMLInputData += "</ProductKeyID>";
            XMLInputData += "</UnitStatusRequest>";
            Encoding encoding = Encoding.Default;
            byte[] buffer = encoding.GetBytes(XMLInputData);
            req.ContentLength = buffer.Length;
            req.GetRequestStream().Write(buffer, 0, buffer.Length);

            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            XmlTextReader xmlr = new XmlTextReader(res.GetResponseStream());
            string status = "";
            string rc = "";
            bool bError = false;
            bool bFound = false;
            StringBuilder str = new StringBuilder("Formatted Response:\n");

            while (xmlr.Read())
            {
                switch (xmlr.NodeType)
                {
                    case XmlNodeType.Element:
                        if (xmlr.IsEmptyElement)
                            str.AppendFormat("<{0}/>", xmlr.Name);
                        else
                            str.AppendFormat("<{0}>", xmlr.Name);
                        break;
                    case XmlNodeType.Text:
                        str.Append(xmlr.Value);
                        break;
                    case XmlNodeType.CDATA:
                        str.AppendFormat("<![CDATA[{0}]]>", xmlr.Value);
                        break;
                    case XmlNodeType.ProcessingInstruction:
                        str.AppendFormat("<?{0} {1}?>", xmlr.Name, xmlr.Value);
                        break;
                    case XmlNodeType.Comment:
                        str.AppendFormat("<!--{0}-->", xmlr.Value);
                        break;
                    case XmlNodeType.XmlDeclaration:
                        str.AppendFormat("<?xml version='1.0'?>");
                        break;
                    case XmlNodeType.DocumentType:
                        str.AppendFormat("<!DOCTYPE{0} [{1}]>", xmlr.Name, xmlr.Value);
                        break;
                    case XmlNodeType.EntityReference:
                        str.Append(xmlr.Name);
                        break;
                    case XmlNodeType.EndElement:
                        str.AppendFormat("</{0}>", xmlr.Name);
                        break;
                    case XmlNodeType.Whitespace:
                        str.Append("\n");
                        break;
                }

                if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnCode"))
                {
                    xmlr.Read();
                    str.Append(xmlr.Value);
                    rc = xmlr.Value.Trim();
                    if (rc != "000") bError = true;
                    continue;
                }

                if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnMessage"))
                {
                    if (bError)
                    {
                        xmlr.Read();
                        str.Append(xmlr.Value);
                        string msg = xmlr.Value;
                        xmlr.Close();
                        throw new Exception("[" + rc + "]:" + msg);
                    }
                }

                if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ProductKeyStateName"))
                {
                    xmlr.Read();
                    str.Append(xmlr.Value);
                    status = xmlr.Value;
                    // Marked this by Benson at 2013/3/8
                    //  if (status == "NotifiedBound")
                    if (status == "NotifiedBound" || status == "FKIErrorBound")
                    {
                        //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound" --OLD
                        //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound/FKIErrorBound" --NEW add by Benson at 2013/3/8

                        if (bFound)
                        {
                            xmlr.Close();
                            return false;
                        }
                        bFound = true;
                        continue;
                    }


                    if (status == "Bound" || status == "PendingBound")
                    {
                        //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound"
                        if (bFound)
                        {
                            xmlr.Close();
                            return false;
                        }
                        bFound = true;

                        //对于状态为Bound/PendingBound的Product需要记录到ProductInfo中
                        IMES.FisObject.FA.Product.ProductInfo item = new IMES.FisObject.FA.Product.ProductInfo();
                        item.ProductID = p.ProId;
                        item.InfoType = "Win8KeyState";
                        item.InfoValue = status;
                        item.Editor = editor;
                        if (productRepository.CheckExistProductInfo(p.ProId, "Win8KeyState"))
                        {
                            IMES.FisObject.FA.Product.ProductInfo cond = new IMES.FisObject.FA.Product.ProductInfo();
                            cond.ProductID = p.ProId;
                            cond.InfoType = "Win8KeyState";
                            productRepository.UpdateProductInfoDefered(uow, item, cond);
                        }
                        else
                        {
                            productRepository.InsertProductInfoDefered(uow, item);
                        }

                        continue;
                    }
                    //Returned 或PendingReturn或NotifiedReturned或FKIErrorReturn --Mantis0001691
                    // Marked this by Benson at 2013/3/8
                    //   if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn")
                    if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn" && status != "FKIErrorReturn")
                    {
                        xmlr.Close();
                        return false;
                    }
                }
            }
            xmlr.Close();
            Console.Write(str.ToString());
            return bFound;
        }
Exemplo n.º 15
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);
            CommonImpl2 cm2 = new CommonImpl2();
            string site = cm2.GetSite();
            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)
                    {
                        if (site == "ICC")
                        { xmlname = "PDPALabel01_CQ.xoml"; }
                        else
                        { 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("Site", site);
                    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);
                }
                */

                IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                IList<ConstValueInfo> cvInfo = new List<ConstValueInfo>();

                //ConstValueInfo cvCond = new ConstValueInfo();
                //cvCond.type = "PD PA Label 1";
                ////cvCond.name = product.Status.Line.Substring(0, 1);
                //cvInfo = partRepository.GetConstValueInfoList(cvCond);

                string wlabel = (string)currentSession.GetValue("WLabel");
                string clabel = (string)currentSession.GetValue("LanguageLabel");
                string cmessage = (string)currentSession.GetValue("LanguageMessage");
                string llabel = (string)currentSession.GetValue("LANOMLabel");
                string win8label = (string)currentSession.GetValue("Win8BoxLabel");
                List<string> label = new List<string>();
                //foreach (ConstValueInfo tmp in cvInfo)
                //{
                //    label.Add((string)currentSession.GetValue(tmp.name.ToString()));
                //}
                //string postellabel = (string)currentSession.GetValue("India Safety label");

                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);
                retList.Add(win8label);
                if (site == "ICC")
                { 
                   retList.Add((string)currentSession.GetValue("EnergyLabel")); 
                }

                if (currentSession.GetValue("PDPA1LabelType") == null)
                {
                    retList.Add(new List<string>());
                }
                else
                {
                    retList.Add((List<string>)(currentSession.GetValue("PDPA1LabelType")));
                }

                //retList.Add(postellabel);
                //========================================================
                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);
            }
        }