//private const Session.SessionType ProductSessionType = Session.SessionType.Product;

        #region SpecialModelForItcnd members

        /// <summary>
        /// 输入Model 相关信息并处理
        /// </summary>
        /// <param name="Family">Family</param>
        /// <param name="Model">Model</param>
        /// <param name="Type">Type</param>
        /// <returns>prestation</returns>
        /// 
        public ArrayList Query(string Family, string Model, string Type) 
        {
            logger.Debug("(SpecialModelForItcndImpl)Query start [Family]: " + Family
                + " [Model]:" + Model
                + " [SpecialType]:" + Type);

            ArrayList lstRet = new ArrayList();

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

            try
            {
                TsModelInfo item = new TsModelInfo();
                item.model = Model; //check
                item.mark = Type;
                IList<TsModelInfo> tmp = repProduct.GetTsModelList(item);
                /*IList<TsModelInfo> tmp = new List<TsModelInfo>();
                TsModelInfo t = new TsModelInfo();
                t.editor = "111";
                tmp.Add(t);


                if (tmp.Count != 0)  */
                    lstRet.Add(tmp);

              

                return lstRet; 
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(SpecialModelForItcndImpl)InputProdId end, [Family]: " + Family
                            + " [Model]:" + Model
                            + " [SpecialType]:" + Type);
            }
        }
        /// <summary>
        /// 檢查Image DL Station log
        /// </summary>        
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            ILineRepository lineRep = RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
            DateTime now = DateTime.MinValue;
            string checkStation = "";

            #region 檢查設置資料,若無,則不報錯
            string pdline = this.Line;
            var prod = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            CurrentSession.AddValue(ExtendSession.SessionKeys.DLCheckStation, "");

            if (string.IsNullOrEmpty(pdline))
            {
                pdline = prod.Status.Line;
                if (string.IsNullOrEmpty(pdline))
                {
                    IList<ProductStatusExInfo> preStatusList = prodRep.GetProductPreStation(new List<string> { prod.ProId });
                    if (preStatusList.Count > 0)
                    {
                        pdline = preStatusList[0].PreLine;
                    }
                }
            }

            Line line = lineRep.Find(pdline);
            if (line == null ||
                line.LineEx == null ||
                string.IsNullOrEmpty(line.LineEx.AliasLine))
            {
                //未設置 LineEx 
                //throw new FisException("IDL001", new string[] { });
                checkStation = "";
            }
            else
            {
                string aliasLine = line.LineEx.AliasLine;

                IList<ConstValueInfo> constValueInfoList = partRep.GetConstValueListByType(ConstType);

                if (constValueInfoList == null || constValueInfoList.Count == 0)
                {
                    //throw new FisException("IDL002", new string[] { ConstType });
                    checkStation = "";
                }
                else
                {
                    var lineCheckStationList = (from item in constValueInfoList
                                                where item.name == aliasLine
                                                select item).ToList();

                    if (lineCheckStationList == null ||
                        lineCheckStationList.Count == 0 ||
                        string.IsNullOrEmpty(lineCheckStationList[0].value))
                    {
                        //throw new FisException("IDL003", new string[] { ConstType, aliasLine });
                        checkStation = "";
                    }
                    else
                    {
                        checkStation = lineCheckStationList[0].value;
                       
                    }
                }
            }
            #endregion

            if (string.IsNullOrEmpty(checkStation))
            {
                checkStation = this.CheckDefaultDLStation;
            }

            CurrentSession.AddValue(ExtendSession.SessionKeys.DLCheckStation, checkStation);

            string[] CheckStation = checkStation.Split(new char[] { ',', ';', '~' });

            #region Check Image DL Station main logical
            //Check DL station log
            if (CheckStation.Contains(this.Station))
            {
                //Mantis 0000559: 【FA】針對特殊商业型机种down load 方式,在ITCND Check 66log不做檢查
                bool checkImgLog = (string)prod.GetExtendedProperty("NotCheckImgLog")=="Y"?false : true;
                string imgStation = (string)prod.GetExtendedProperty("ImgStation");

                imgStation = string.IsNullOrEmpty(imgStation) ||checkImgLog ? 
                                                this.ImageDownLoadStation.Trim() :
                                                imgStation;
               
                IList<TsModelInfo> tsInfo = null;

                //exception case No need download image for RCTO (No Image OS DownLoad) 
                TsModelInfo cond = new TsModelInfo();
                cond.model = prod.Model;
                cond.mark = "0";
                tsInfo = prodRep.GetTsModelList(cond);
                if (tsInfo != null && tsInfo.Count != 0)
                {
                    if (this.NoNeedOSImageThrowError)
                    {

                        throw new FisException("CHK805", new string[] { });
                    }
                    else
                    {
                        return base.DoExecute(executionContext);
                    }
                }


                cond.model = prod.Model;
                cond.mark = "1";
                tsInfo = prodRep.GetTsModelList(cond);
                if (tsInfo == null || tsInfo.Count == 0)  // if no redownload Image flag,Need Check EPIA download
                {
                    ProductLog epiaLog =  prodRep.GetLatestLogByWcAndStatus(prod.ProId, this.EAPIAOutStation.Trim(), 1);
                    if (epiaLog != null)
                    {
                        //ProductLog imageLog = prodRep.GetLatestLogByWcAndStatus(prod.ProId, this.ImageDownLoadStation.Trim(), 1);
                        ProductLog lastProdLog = null;
                        ProductLog lastStation = null;
                        if (!checkPreHoldStation(prod, out lastProdLog, out lastStation))
                        {
                            lastProdLog = prodRep.GetLatestLog(prod.ProId);
                        }
                        else
                        {
                            epiaLog = lastStation;
                        }


                        //ProductLog imageLog = prodRep.GetLatestLog(prod.ProId);
                        if (lastProdLog == null || epiaLog.Cdt >= lastProdLog.Cdt)
                        {
                            List<string> errpara = new List<string>();
                            throw new FisException("CHK807", new string[] { });
                        }
                       
                        //if (lastProdLog.Station != this.ImageDownLoadStation.Trim() ||
                        if (lastProdLog.Station != imgStation ||
                            lastProdLog.Status != IMES.FisObject.Common.Station.StationStatus.Pass)
                        {
                            throw new FisException("CQCHK1007", new string[] { });
                        }
                        
                    }
                }

                if (checkImgLog)   //正常機器 
                {
                    //Vincent add for CQ case
                    if (this.CheckLatestImageLog)
                    {

                        //ProductLog prodLog = prodRep.GetLatestLogByWc(prod.ProId, this.ImageDownLoadStation.Trim());
                        ProductLog lastProdLog = null;
                        ProductLog lastStation = null;
                        DateTime lastCheckOutTime = prod.Status.Udt;
                        if (checkPreHoldStation(prod, out lastProdLog, out lastStation))
                        {
                            lastCheckOutTime = lastStation == null ? lastCheckOutTime : lastStation.Cdt;
                        }
                        else
                        {
                            lastProdLog = prodRep.GetLatestLog(prod.ProId);
                        }

                        if (lastProdLog == null || lastCheckOutTime > lastProdLog.Cdt)
                        {
                            throw new FisException("CHK845", new string[] { });
                        }

                        if (lastProdLog.Station != this.ImageDownLoadStation.Trim() ||
                            lastProdLog.Status != IMES.FisObject.Common.Station.StationStatus.Pass)
                        {
                            throw new FisException("CHK806", new string[] { });
                        }
                    }
                    else
                    {
                        ProductLog failLog = prodRep.GetLatestLogByWcAndStatus(prod.ProId, this.ImageDownLoadStation.Trim(), 0);
                        if (failLog != null && prod.Status.Udt < failLog.Cdt)
                        {
                            throw new FisException("CHK806", new string[] { });
                        }

                        ProductLog passLog = prodRep.GetLatestLogByWcAndStatus(prod.ProId, this.ImageDownLoadStation.Trim(), 1);

                        if (passLog == null || prod.Status.Udt > passLog.Cdt)
                        {
                            throw new FisException("CHK845", new string[] { });
                        }
                    }
                }
                else if (this.EAPIAOutStation == this.Station)  //EPIA Out Station
                {
                    checkEPIAOutImageLog(prod, imgStation);
                }
            }
            #endregion
            if (!IsGetQCPIAStatus)
                return base.DoExecute(executionContext);

            #region Get QCStatus
            string[] tps = new string[2];
            tps[0] = "PIA";
            tps[1] = "PIA1";
            string status = "NA";
            string remark = "";
            IList<ProductQCStatus> QCStatusList = new List<ProductQCStatus>();
            QCStatusList = prodRep.GetQCStatusOrderByUdtDesc(prod.ProId, tps);
            if (QCStatusList != null && QCStatusList.Count > 0)
            {
                ProductQCStatus qcStatus = QCStatusList[0];
                status = qcStatus.Status.Trim();
                remark = qcStatus.Remark.Trim();
                if (status == "2")
                {
                    status = "PIA";
                    if (remark == "1")
                    {
                        status = "EPIA"; //epia
                    }
                }
                else if (status == "1")
                {
                    status = "NONE";
                }
                else if (remark == "1")
                {
                    status = "EPIAOut"; //epia
                }
                else if (status == "6" || status == "7")
                {
                    status = "PIAOut"; //pia
                }              
               
            }
            
            CurrentSession.AddValue(ExtendSession.SessionKeys.FAQCStatus, status);
            #endregion

            return base.DoExecute(executionContext);
        }
Beispiel #3
0
        /// <summary> 
        /// </summary>        
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            //TODO 1
            ProductLog testLog = new ProductLog();
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

            var product = CurrentSession.GetValue(Session.SessionKeys.Product) as IProduct;
            if (product == null)
            {
                throw new NullReferenceException("Product in session is null");
            }
            Model model = product.ModelObj;
            if (model == null)
            {
                List<string> errpara = new List<string>();
                errpara.Add(product.ProId);
                throw new FisException("CHK804", errpara);
            }
            if (model.Status == "0")
            {
                List<string> errpara = new List<string>();
                throw new FisException("CHK802", errpara);
            }
            if(product.State == "H")
            {
                List<string> errpara = new List<string>();
                throw new FisException("CHK802", errpara);
            }
            string value = (string)product.GetExtendedProperty("Exp");
            if (!String.IsNullOrEmpty(value))
            {
                List<string> errpara = new List<string>();                
                throw new FisException("CHK803", errpara);                         
            }

            IList<TsModelInfo> tsInfo = null;

            TsModelInfo cond = new TsModelInfo();
            cond.model = product.Model;
            cond.mark = "0";
            tsInfo = productRepository.GetTsModelList(cond);
            if(tsInfo != null && tsInfo.Count != 0)
            {
                List<string> errpara = new List<string>();                
                throw new FisException("CHK805", errpara);           
            }
            //
            
            IList<ProductLog> allLogs = new List<ProductLog>();


            cond.model = product.Model;
            cond.mark = "1";
            tsInfo = productRepository.GetTsModelList(cond);
            if(tsInfo == null || tsInfo.Count == 0)
            {
                allLogs = product.ProductLogs;
                IList<ProductLog> logs = new List<ProductLog>();
                ProductLog maxLog = new ProductLog();
                bool bExist = false;
                if(allLogs != null && allLogs.Count != 0)
                {
                    foreach(ProductLog temp in allLogs)
                    {
                        if(temp.Station == "66" && temp.Status == StationStatus.Pass)
                        {
                            bExist = true;
                            if(temp.Cdt.CompareTo(maxLog.Cdt) > 0)
                            {
                                maxLog = temp;
                            }
                        }
                        //else if(temp.Station == "73" || temp.Station == "74")
                        else if(temp.Station == "6A")
                        {
                            logs.Add(temp);
                        }
                    }
                    if (bExist == true)
                    {
                        foreach (ProductLog temp in logs)
                        {
                            if (temp.Cdt.CompareTo(maxLog.Cdt) > 0)
                            {
                                List<string> errpara = new List<string>();
                                throw new FisException("CHK807", errpara);
                            }
                        }
                    }
                }                
            }

            //UC 7
            allLogs = product.ProductLogs;
            if (allLogs != null && allLogs.Count > 0)
            {
                ProductLog maxLog = new ProductLog();
                foreach (ProductLog temp in allLogs)
                {
                    if (temp.Cdt.CompareTo(maxLog.Cdt) > 0)
                    {
                        maxLog = temp;
                    }
                }
                if (maxLog.Station == "66" && maxLog.Status == StationStatus.Fail)
                {
                    List<string> errpara = new List<string>();
                    throw new FisException("CHK806", errpara);
                }

                if (!(maxLog.Station == "66" && maxLog.Status == StationStatus.Pass))
                {
                    List<string> errpara = new List<string>();
                    throw new FisException("CHK845", errpara);
                }
            }

            //UC 8
            //ITC-1360-1787
            string[] code = new string[2];
            code[0] = product.Model;
            code[1] = product.CUSTSN;
            bool isHold = false;
            isHold = productRepository.CheckExistItcndCheckQcHold("1", code);
            if (isHold == true)
            {
                List<string> errpara = new List<string>();
                throw new FisException("CHK847", errpara);
            }

            //UC 9
            IBOMRepository bomRepository = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
            IList<MoBOMInfo> mbinfo = new List<MoBOMInfo>();
            mbinfo = bomRepository.GetPnListByModelAndBomNodeTypeAndDescr(product.Model, "P1", "ECOA");
            if (mbinfo != null && mbinfo.Count > 0)
            {
                DateTime win8Time;
                DateTime logTime;
                //('P/N','KEY','HASH')
                string[] infotypes = new string[3];
                infotypes[0] = "P/N";
                infotypes[1] = "KEY";
                infotypes[2] = "HASH";
                win8Time = productRepository.GetNewestCdtFromProductInfo(product.ProId, infotypes);
                logTime = productRepository.GetNewestCdtFromProductLog(product.ProId, "66", 1);

                if (win8Time == DateTime.MinValue || logTime == DateTime.MinValue)
                {
                    List<string> errpara = new List<string>();
                    throw new FisException("CHK900", errpara);
                }

                if (DateTime.Compare(win8Time, logTime.AddMinutes(1)) > 0 ||
                    DateTime.Compare(logTime, win8Time.AddMinutes(1)) > 0)
                {
                    List<string> errpara = new List<string>();
                    throw new FisException("CHK901", errpara);
                }




                //UC10
                //最新的P/N:@ImgPN 
                //(ProductInfo.InfoValue Condtion: Uppder(ProductInfo.InfoType) = ‘P/N’ and ProductID=[ProductID] order by Udt desc)
                IList<string> infoTypes = new List<string>();
                infoTypes.Add("P/N");
                IList<IMES.FisObject.FA.Product.ProductInfo> proInfos = new List<IMES.FisObject.FA.Product.ProductInfo>();
                proInfos = productRepository.GetProductInfoListUpperCaseItemType(product.ProId, infoTypes);

                //获取BOM的ECOA的PN:@BOMPN (select b.PartNo from ModelBOM a (nolock), Part b (nolock) 
                //where a.Material = @Model
                //and a.Component = b.PartNo
                //and b.BomNodeType = 'P1'
                //and b.Descr LIKE 'ECOA%')

                //若@ImgPN与@BOMPN不相等,则报错:“ImageDownload 失败,ECOA PN 错误
                bool bCompare = false;
                if (proInfos != null && proInfos.Count > 0)
                {
                    foreach (MoBOMInfo temp in mbinfo)
                    {
                        if (temp.component == proInfos[0].InfoValue)
                        {
                            bCompare = true;
                            break;
                        }
                    }
                }
                if (bCompare == false)
                {
                    List<string> errpara = new List<string>();
                    throw new FisException("CHK927", errpara);
                }
            }

            

            return base.DoExecute(executionContext);
        }
        public void Insert(string Family, string Model, string Type, string user,out string qcStatus )
        {
            logger.Debug("(SpecialModelForItcndImpl)Insert start [Family]: " + Family
               + " [Model]:" + Model
               + " [SpecialType]:" + Type);

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

            try
            {
                qcStatus = "";
                TsModelInfo item_select = new TsModelInfo();
                item_select.model = Model; //check
                //item_select.mark = Type;
                IList<TsModelInfo> tmp = repProduct.GetTsModelList(item_select);
                if (tmp.Count > 0) {
                    qcStatus = "false";
                   /* List<string> erpara = new List<string>();
                    erpara.Add("错误,此Model已设置,不能重复设置");
                    e = new FisException("CHK020", erpara);
                    throw e;*/
                    return ;
                }


                TsModelInfo item = new TsModelInfo();
                item.model = Model; ///check
                item.mark = Type;
                item.editor = user;
                repProduct.InsertTSModel(item);
                
            }
            catch (FisException ex)
            {
                logger.Error(ex.mErrmsg);
                throw ex;
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                throw ex;
            }
            finally
            {
                logger.Debug("(SpecialModelForItcndImpl)Insert end, [Family]: " + Family
                            + " [Model]:" + Model
                            + " [SpecialType]:" + Type);
            }
        }