Example #1
0
        ///<summary>
        /// 根据指定的DeliveryNo解除绑定
        /// 使用工作流070UnpackDNByDN.xoml
        /// </summary>
        public void UnpackDNByDN(string deliveryNo, bool bSuperUI, string line, string editor, string station, string customer)
        {
            if (bSuperUI)
            {
                logger.Debug("(UnpackDNByDN[Super])Unpack start, deliveryNo:" + deliveryNo + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
            else
            {
                logger.Debug("(UnpackDNByDN)Unpack start, deliveryNo:" + deliveryNo + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }

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



            try
            {
                var currentDelivery = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, IMES.FisObject.PAK.DN.Delivery>().Find(deliveryNo);
                
                if (null == currentDelivery)
                {
                    throw new FisException("CHK190", new string[] { deliveryNo });//DN不存在
                }

                if (!bSuperUI && "98" == currentDelivery.Status)
                {
                    throw new FisException("CHK191", new string[] { deliveryNo });//DN已上传
                }

                string sessionKey = currentDelivery.DeliveryNo;


                station = "80";

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


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

                    currentSession.AddValue(Session.SessionKeys.DeliveryNo, currentDelivery.DeliveryNo);
                    currentSession.AddValue(Session.SessionKeys.Delivery, currentDelivery);

                    //Add by Benson for Mantis 0001555
                    string isSuper = "";
                    if (bSuperUI)
                    {
                        isSuper = "Y";
                        CommonImpl cmi = new CommonImpl();
                        IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType("SAP", "Name").Where(x => x.value.Trim() != "").ToList(); ;
                        string isExcuteDeleteSAPsn = "";
                        string allowUnpackCode = "";
                        foreach (ConstValueInfo constV in lstConst)
                        {
                            if (constV.name == "ExcuteDeleteSNonSAP")
                            {
                                isExcuteDeleteSAPsn = constV.value;
                            }
                            if (constV.name == "AllowUnpackCode")
                            {
                                allowUnpackCode = constV.value;
                            }
                        }
                        string plant = System.Configuration.ConfigurationManager.AppSettings["PlantCode"];
                        currentSession.AddValue("IsSuper", isSuper);
                        currentSession.AddValue("ExcuteDeleteSNonSAP", isExcuteDeleteSAPsn);
                        currentSession.AddValue("AllowUnpackCode", allowUnpackCode);
                        currentSession.AddValue("PlantCode", plant);
                        currentSession.AddValue("DNStatus", currentDelivery.Status);
                         
                    }
                    //Add by Benson


                    
                    
                    currentSession.SetInstance(instance);




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

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


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

                    throw currentSession.Exception;
                }

            }
            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
            {
                if (bSuperUI)
                {
                    logger.Debug("(UnpackDNByDN[Super])Unpack end,  deliveryNo:" + deliveryNo + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
                }
                else
                {
                    logger.Debug("(UnpackDNByDN)Unpack end,  deliveryNo:" + deliveryNo + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
                }
            }
        }
Example #2
0
        ///<summary>
        /// 根据指定的Custom Sn解除绑定
        /// 使用工作流070UnpackDNBySN.xoml
        /// </summary>
        public void UnpackDNbySNCheck(string prodSn, string pdline, string editor, string station, string customer)
        {
            logger.Debug("(UnpackDNbySNCheck)UnpackDNbySNCheck start, prodSn:" + prodSn + "line:" + pdline + "editor:" + editor + "station:" + station + "customer:" + customer);

            string currentSessionKey = prodSn;
            try
            {
               


                /*if (station == "91")
                {
                    station = "9U";
                }
                else
                {
                    station = "9P";
                }*/
                //Session currentCommonSession = SessionManager.GetInstance.GetSession(currentSessionKey, ProductSessionType);
                Session currentCommonSession = SessionManager.GetInstance.GetSession(currentSessionKey, ProductSessionType);


                if (currentCommonSession == null)
                {
                    //currentCommonSession = new Session(currentSessionKey, Session.SessionType.Common, editor, station, pdline, customer);
                    currentCommonSession = new Session(currentSessionKey, ProductSessionType, editor, station, pdline, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", currentSessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentCommonSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", pdline);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Product);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow("070UnpackDNBySN.xoml", "", wfArguments);

                    currentCommonSession.AddValue(Session.SessionKeys.CN, "DN");
                    currentCommonSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentCommonSession.SetInstance(instance);
                    //Add for Call SAP service
                

                    CommonImpl cmi = new CommonImpl();
                    IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType("SAP", "Name");
                    string isExcuteDeleteSAPsn = "";
                    string allowUnpackCode = "";
                    foreach (ConstValueInfo constV in lstConst)
                    {
                        if (constV.name == "ExcuteDeleteSNonSAP")
                        {
                            isExcuteDeleteSAPsn = constV.value;
                        }
                        if (constV.name == "AllowUnpackCode")
                        {
                            allowUnpackCode = constV.value;
                        }
                    }
                    string plant = System.Configuration.ConfigurationManager.AppSettings["PlantCode"];
                
                    currentCommonSession.AddValue("ExcuteDeleteSNonSAP", isExcuteDeleteSAPsn);
                    currentCommonSession.AddValue("AllowUnpackCode", allowUnpackCode);
                    currentCommonSession.AddValue("PlantCode", plant);
                   

                    //Add for Call SAP service



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

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

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

                    throw currentCommonSession.Exception;
                }
            /*    
                Product newProduct = (Product)currentCommonSession.GetValue(Session.SessionKeys.Product);
                if (newProduct.PalletNo == null)
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add("此机器尚未结合栈板,不能进行Unpack!");
                    ex = new FisException("CHK292", erpara);
                    throw ex;
                }
                currentCommonSession.AddValue(Session.SessionKeys.DeliveryNo, newProduct.DeliveryNo);
                */
               

                return ;
            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(UnpackDNbySN)UnpackDNbySNCheck end,  cartonNo:" + prodSn + "line:" + pdline + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Example #3
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);
            }
        
        
        
        }
Example #4
0
 private bool CheckPODLabel(IMES.FisObject.FA.Product.IProduct product)
 {
    // string qc=product.GetAttributeValue("PAQC_QCStatus");
     //if (qc == null ) { return true; }
     bool IsOK = true;
     CommonImpl cmi = new CommonImpl();
     IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType("CTO Check", "Name").Where(x => x.value.Trim() != "").ToList(); 
     if (lstConst.Count==0)
     {
         throw new FisException("PAK181", new string[]{"CTO Check"});   
       
     }
     if (lstConst[0].name == "CheckStation")
         {
             string[] stArr = lstConst[0].value.Split(',');
             return stArr.Contains(product.Status.StationId);
         }
    return IsOK;
  
         //if (lstConst.(product.Status.StationId) > -1)
         //{ IsOK = true; }
    
 }
Example #5
0
        string IPodLabelCheck.InputCustPnOnPodLabel(string productIdValue, string custSnOnCooValue, string custPnOnPodValue, string pdLine, string editor, string station, string customer, out string Loc)
        {
            logger.Debug("(PodLabelCheckImpl)Save start, productIdValue:" + productIdValue + "custSnOnCooValue:" + custSnOnCooValue + "custPnOnPodValue" + custPnOnPodValue + "pdLine" + pdLine + "editor:" + editor + "station:" + station + "customer" + customer);
            string ret = "";
            Loc = "";
            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = "";
            try
            {
                var currentProduct = CommonImpl.GetProductByInput(productIdValue, CommonImpl.InputTypeEnum.ProductIDOrCustSN);
                CommonImpl cmloc = new CommonImpl();
                IList<ConstValueInfo> lstloc = cmloc.GetConstValueListByType("TabletPODCheckLoc", "Name");
                var list = (from x in lstloc where x.name ==currentProduct.Model  select x.value).ToList();
                if (list != null && list.Count > 0)
                {
                    Loc = list[0];
                }
                      
                
                sessionKey = productIdValue;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);

                
                if (currentSession == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;

                }

               else
                {
                    if (custSnOnCooValue == "")
                    {
                        currentSession.AddValue(Session.SessionKeys.IsComplete, true);
                        currentSession.Exception = null;
                        currentSession.SwitchToWorkFlow();

                        if (currentSession.Exception != null)
                        {
                            if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                            {
                                currentSession.ResumeWorkFlow();
                            }
                            throw currentSession.Exception;
                        }
                    }
                    else
                    {
                        bool check = false;
                        IPartRepository iPartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository>();
                        IList<ConstValueTypeInfo> familyList = iPartRepository.GetConstValueTypeList("CheckWMFamilyInPOD");
                        if (familyList != null && familyList.Count > 0 && Regex.IsMatch(currentProduct.Family, familyList[0].value))
                        {
                            string pf = currentProduct.ProductInfoes.Where(x => x.InfoType == "WM").Select(x => x.InfoValue).FirstOrDefault();
                            if (!string.IsNullOrEmpty(pf) && custSnOnCooValue.Replace(":", "").Trim() == pf.Replace(":", "").Trim())
                            {
                                ret = "mac";
                                check = true;
                            }
                        }
                        else if (custSnOnCooValue == currentProduct.MAC)
                        {
                            ret = "mac";
                            check = true;
                        }
                        if (check == false)
                        {
                            // IMES_FA..Product_Part 表中与当前Product 绑定的Parts 
                            IList<IProductPart> productParts = new List<IProductPart>();
                            productParts = currentProduct.ProductParts;
                            if (productParts == null || productParts.Count <= 0)
                            {
                                //List<string> errpara = new List<string>();
                                //errpara.Add(productIdValue);
                                //throw new FisException("PAK038", errpara);  //该Product尚未绑定Part!
                            }
                            else
                            {
                                foreach (ProductPart iprodpart in productParts)
                                {
                                    if (iprodpart.BomNodeType == "AT")
                                    {
                                        IPart curPart = ipartRepository.GetPartByPartNo(iprodpart.PartID);
                                        if (curPart.BOMNodeType == "AT")
                                        {
                                            if (custSnOnCooValue == iprodpart.PartSn)
                                            {
                                                ret = "tag";
                                                check = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (check == false)
                        {
                            //throw new FisException("CHK888", new string[] { });
                            return "checkwrong";
                        }
                        currentSession.AddValue(Session.SessionKeys.IsComplete, true);
                        currentSession.Exception = null;
                        currentSession.SwitchToWorkFlow();

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

                }
                return ret;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PodLabelCheckImpl)Save end,productIdValue:" + productIdValue + "custSnOnCooValue:" + custSnOnCooValue + "custPnOnPodValue" + custPnOnPodValue + "pdLine" + pdLine + "editor:" + editor + "station:" + station + "customer" + customer);
                /*Session sessionDelete = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product); ;
                if (sessionDelete != null)
                {
                    SessionManager.GetInstance.RemoveSession(sessionDelete);
                }*/
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ArrayList InputMBSN(string mbsn, bool isGetDn, string shipMode, string line, string editor, string station, string customer)
        {
            logger.Debug("(CombineCartonDNfor146MB)Inputmbsn start, shipMode:" + shipMode + " mbsn:" + mbsn + " line:" + line + " editor:" + editor + " station:" + station + " customer:" + customer);
            List<string> errpara = new List<string>();
            ArrayList retList = new ArrayList();
            string usedModel = "";
            
            try
            {
                bool shipModeIs146 = "RCTO".Equals(shipMode);
                bool shipModeIsFru = "FRU".Equals(shipMode);
                
                IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                IMB mb = mbRepository.Find(mbsn);
                if (mb == null || mb.MBStatus == null)
                {
                    throw new FisException("SFC001", new string[] { mbsn });
                }

                if (!shipMode.Equals(mb.ShipMode))
                {
                    // 此MBSN:%1 非 %2 板子
                    throw new FisException("CQCHK0038", new string[] { mbsn, shipMode });
                }
                
                string mbcode = mbsn.Substring(0, 2);

                if (!(string.IsNullOrEmpty(mb.CartonSN) && string.IsNullOrEmpty(mb.DeliveryNo)))
                {
                    // PCB的 CartonSN & DeliveryNo 須為空
                    throw new FisException("CQCHK0022", new string[] { });
                }

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

                if (shipModeIs146)
                {
                    //string strSQL = "select Model from ModelInfo where Name='Infor' and Value=@MBCode";
                     string strSQL =@"select distinct a.Material as Model from ModelBOM a, PartInfo b 
                                    where a.Component = b.PartNo and b.InfoType='MB' and a.Material like'146%' 
                                    and b.InfoValue =@MBCode";
                    SqlParameter paraName = new SqlParameter("@MBCode", SqlDbType.VarChar, 10);
                    paraName.Direction = ParameterDirection.Input;
                    paraName.Value = mbcode;
                    DataTable tb = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, System.Data.CommandType.Text,
                        strSQL, paraName);
                    if (tb != null)
                    {
                        foreach (DataRow dr in tb.Rows)
                        {
                            string s = dr["Model"].ToString();
                            if (s.IndexOf("146") == 0)
                            {
                                lstUsedModel.Add(s);
                            }
                        }
                    }
                    if (lstUsedModel.Count == 0)
                    {
                        // MBCode帶出的Model 不是146XXXXXX機型
                        throw new FisException("CQCHK0041", new string[] { });
                    }

                    string biosConstType = "RCTOMBBIOSVer";
                    CommonImpl cmi = new CommonImpl();
                    IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType(biosConstType, "Name").Where(x => x.value.Trim() != "" && x.name == mbcode).ToList();
       
                    if (lstConst == null || lstConst.Count == 0)
                    {
                        // ConstValue 未设定 %1,请联系IE设定
                        throw new FisException("CQCHK0026", new string[] { biosConstType });
                    }

                    string mbrTestLog = "";
                    foreach (IMES.FisObject.Common.TestLog.TestLog tl in mb.TestLogs)
                    {
                        if ("MBR".Equals(tl.Type))
                        {
                            mbrTestLog = tl.Remark;
                            break;
                        }
                    }

                    if (mbrTestLog.IndexOf(lstConst[0].value) < 0)
                    {
                        // BIOS 匹配不對
                        throw new FisException("CQCHK0023", new string[] { });
                    }

                    bool isMatchMBCT = false;
                    foreach (IMES.FisObject.PCA.MB.MBInfo mbi in mb.MBInfos)
                    {
                        if ("MBCT".Equals(mbi.InfoType))
                        {
                            if (mbrTestLog.IndexOf(mbi.InfoValue) >= 0)
                            {
                                isMatchMBCT = true;
                            }
                            break;
                        }
                    }
                    if (!isMatchMBCT)
                    {
                        // MBCT 不相同
                        throw new FisException("CQCHK0024", new string[] { });
                    }
                }
                else if (shipModeIsFru)
                {
                    bool isFru = false;
                    string strSQL = @"select distinct a.Material as Model from ModelBOM a, PartInfo b 
where a.Component = b.PartNo and b.InfoType='MB' and a.Material not like 'PC%' 
and b.InfoValue =@MBCode";

                    SqlParameter paraName = new SqlParameter("@MBCode", SqlDbType.VarChar, 10);
                    paraName.Direction = ParameterDirection.Input;
                    paraName.Value = mbcode;
                    DataTable tb = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, System.Data.CommandType.Text,
                        strSQL, paraName);
                    if (tb != null)
                    {
                        foreach (DataRow dr in tb.Rows)
                        {
                            //usedModel = dr["Model"].ToString();
                            lstUsedModel.Add(dr["Model"].ToString());
                            isFru = true;
                       }
                    }
                    if (!isFru)
                    {
                        throw new FisException("CQCHK0038", new string[] { mbsn, shipMode });
                    }

                }
                
                // 检查Process卡站
				CommonImpl.GetInstance().CheckProductBlockStation((MB)mb, line, editor, station, customer);

                IList<string> deliveryNos = new List<string>();
                IList<string> shipDatesOfDn = new List<string>();
                IList<string> modelsOfDn = new List<string>();
                IList<string> qtysOfDn = new List<string>();
                IList<string> shipwayOfDn = new List<string>();

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

				if (isGetDn)
                {
                    foreach (string m in lstUsedModel)
                    {
                        GetDeliveryNoList(m, line, editor, station, customer, ref deliveryNos, ref shipDatesOfDn, ref modelsOfDn, ref qtysOfDn, ref shipwayOfDn);
                    }
					
					if (deliveryNos == null || deliveryNos.Count == 0)
					{
						// DN %1 不存在!
						throw new FisException("CHK190", new string[] { "" });
					}

                    if (shipModeIsFru)
                    {
                        // 此機型下的所有MBCode清單
                        foreach (string m in lstUsedModel)
                        {
                            string strSQL = @"SELECT c.InfoValue as MBCode
FROM dbo.ModelBOM a, 
     Part b,
     PartInfo c 
WHERE a.Material=@Model and 
      a.Component = b.PartNo and
      b.PartNo =c.PartNo and
      b.Flag=1 and
      c.InfoType ='MB' and
      b.BomNodeType='MB'";
                            SqlParameter paraName = new SqlParameter("@Model", SqlDbType.VarChar, 255);
                            paraName.Direction = ParameterDirection.Input;
                            paraName.Value = m;
                            DataTable tb = SqlHelper.ExecuteDataFill(SqlHelper.ConnectionString_GetData, System.Data.CommandType.Text,
                                strSQL, paraName);
                            if (tb != null)
                            {
                                foreach (DataRow dr in tb.Rows)
                                {
                                    if (!lstMbsn.Contains(dr["MBCode"].ToString()))
                                        lstMbsn.Add(dr["MBCode"].ToString());
                                }
                            }
                        }
                    }
                }

                retList.Add(mbsn);
                retList.Add(""); // usedModel
                retList.Add(deliveryNos);
                retList.Add(shipDatesOfDn);
                retList.Add(modelsOfDn);
                retList.Add(qtysOfDn);
                retList.Add(lstMbsn);
                retList.Add(shipwayOfDn);
                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("(CombineCartonDNfor146MB)Inputmbsn end, shipMode:" + shipMode + " mbsn:" + mbsn + " line:" + line + " editor:" + editor + " station:" + station + " customer:" + customer);
            }
        }
Example #7
0
        public  ArrayList RePrintCartonLabel(string sn, string editor, string station,string customer, string reason,IList<PrintItem> printItems)
        {
            logger.Debug("(CombineCartonInDN)RePrintCartonLabel Start,Key:" + sn);
            List<string> erpara = new List<string>();
            ArrayList retLst = new ArrayList();
             FisException ex;
            try
            {
                CommonImpl cmi = new CommonImpl();
                IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType("CTO Check", "Name").Where(x => x.value.Trim() != "").ToList(); 
                string line = "";
                string custsn = "";
                string dn = "";
                string flag = "";
                string descr = "";
                IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IFAPrd.IProduct>();
                IDeliveryRepository deliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                ICartonRepository cartonRep = RepositoryFactory.GetInstance().GetRepository<ICartonRepository, Carton>();
                Carton objCarton=cartonRep.Find(sn);
                 if (objCarton == null)
                {
                    objCarton = cartonRep.GetCartonByBoxId(sn);
                    if (objCarton == null) // input = CUSTSN
                    {
                        IFAPrd.IProduct objPrd = productRep.GetProductByCustomSn(sn);
                        custsn = sn;
                        if (objPrd != null)
                        {
                            objCarton = cartonRep.Find(objPrd.CartonSN);
                        }

                    }

                }
           
                if (objCarton == null)
                {
                    throw new FisException("PAK084", new string[] { });
                }
                if (custsn == "")
                {
                    IList<CartonProduct> lstCartonPrd = objCarton.CartonProducts;
                    if (lstCartonPrd != null && lstCartonPrd.Count > 0)
                    {
                        string prdId = lstCartonPrd[0].ProductID;
                        IFAPrd.IProduct objPrd = productRep.Find(prdId);
                        line = objPrd.Status.Line.Substring(0, 1);
                        custsn = objPrd.CUSTSN;
                        dn = objPrd.DeliveryNo;
                     }
                }
                else
                {
                    IFAPrd.IProduct objPrd = productRep.GetProductByCustomSn(custsn);
                    line = objPrd.Status.Line.Substring(0, 1);
                    dn = objPrd.DeliveryNo;
                }
                Delivery dnObj = deliveryRepository.Find(dn);
                if (dnObj == null)
                { throw new FisException("CHK190", new string[] { dn }); }
                flag = (string)dnObj.GetExtendedProperty("Flag");
            
                //IList<CartonInfo> lstCartonInfo=objCarton.CartonInfos;
                //if (lstCartonInfo != null && lstCartonInfo.Count > 0)
                //{
                //    var infoList = (from p in lstCartonInfo
                //                    where p.InfoType == "PdfFileName"
                //                    select p.InfoValue).ToList();
                //    if (infoList .Count>0)
                //    {
                //        pdfFileName = infoList[0].ToString();
                //    }
                //}
                
             
         
                //Start Workflow
                string sessionKey = custsn;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);
                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, editor, station, "", 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", "");
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Product);
                    currentSession.AddValue(Session.SessionKeys.DeliveryNo,dn);
                    currentSession.AddValue(Session.SessionKeys.Reason, reason);
                    currentSession.AddValue(Session.SessionKeys.PrintItems, printItems);
                    currentSession.AddValue(Session.SessionKeys.PrintLogName, "Carton Label");
                    currentSession.AddValue(Session.SessionKeys.PrintLogBegNo, sn);
                    currentSession.AddValue(Session.SessionKeys.PrintLogEndNo, sn);
                    currentSession.AddValue(Session.SessionKeys.PrintLogDescr, descr);        
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "ReprintCartonLabel.xoml", "", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + 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 templatename = "";
                if (flag == "N")
                {
                    IPizzaRepository repPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
                    IList<string> docnumList = repPizza.GetDocSetNumListFromPakDashPakComnByLikeInternalID(dn.Substring(0, 10));
                    //SELECT @templatename = XSL_TEMPLATE_NAME 	FROM [PAK.PAKRT] WHERE DOC_CAT = @doctpye AND DOC_SET_NUMBER = @doc_set_number
                    if (docnumList.Count > 0)
                    {
                        IList<string> tempList = repPizza.GetXslTemplateNameListFromPakDashPakComnByDocCatAndDocSetNumer("Box Ship Label", docnumList[0]);
                        if (tempList.Count > 0)
                            templatename = tempList[0];
                    }
                
                }
             
                retLst.Add(custsn);
                retLst.Add(dn);
                retLst.Add(objCarton.CartonSN);
                retLst.Add(templatename);
                retLst.Add(line);
                retLst.Add(flag);
                retLst.Add((IList<PrintItem>)currentSession.GetValue(Session.SessionKeys.PrintItems));
                return retLst;
                           
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(CombineCartonInDN)RePrintCartonLabel end, key:" + sn);
            }
        }
Example #8
0
 private string GetAOI_Addr(string line)
 {
     //    各線別的AOI機台IP 請抓取 ConstValue Type='AOIServerIP' and Name='LineAlias' 
     CommonImpl cmi = new CommonImpl();
     IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType("AOIServerIP", "Name").Where(y => y.name == line).ToList();
     return lstConst.Count == 0 ? "" : lstConst[0].value.Trim();
 }
Example #9
0
        public void Unpack(string proid, string line, string editor, string station, string customer)
        {

            logger.Debug("(UnpackDNByCarton)Unpack start, ProdID:" + proid + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            FisException ex;
            List<string> erpara = new List<string>();
            try
            {
                string sessionKey = proid;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, ProductSessionType);
                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, ProductSessionType, editor, station, line, customer);


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

                    // ********** Add by Benson at 2013/10/09
                    CommonImpl cmi = new CommonImpl();
                    IList<ConstValueInfo> lstConst = cmi.GetConstValueListByType("SAP", "Name").Where(x => x.value.Trim() != "").ToList(); ;
                    string isExcuteDeleteSAPsn = "";
                    string allowUnpackCode = "";
                    foreach (ConstValueInfo constV in lstConst)
                    {
                        if (constV.name == "ExcuteDeleteSNonSAP")
                        {
                            isExcuteDeleteSAPsn = constV.value;
                        }
                        if (constV.name == "AllowUnpackCode")
                        {
                            allowUnpackCode = constV.value;
                        }
                    }
                    string plant = System.Configuration.ConfigurationManager.AppSettings["PlantCode"];
                    currentSession.AddValue("ExcuteDeleteSNonSAP", isExcuteDeleteSAPsn);
                    currentSession.AddValue("AllowUnpackCode", allowUnpackCode);
                    currentSession.AddValue("PlantCode", plant);
                    // ********** Add by Benson at 2013/10/09

                    
                    currentSession.SetInstance(instance);

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

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


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

                    throw currentSession.Exception;
                }

            }
            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("(UnpackAllByDN)Unpack end, ProdID:" + proid + "line:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }