Пример #1
0
        /// <summary>
        /// GetValue
        /// </summary>
        /// <param name="session"></param>
        /// <param name="product"></param>
        /// <param name="mb"></param>
        /// <param name="delivery"></param>
        /// <param name="part"></param>
        /// <param name="testLog"></param>
        /// <param name="name"></param>
        /// <param name="spliter"></param>
        /// <returns></returns>
        public static string GetValue(Session session, IProduct product, IMB mb, Delivery delivery, IPart part,
                                                    TestLog testLog, string name, char spliter)
        {
            string ret = null;
            int index = name.IndexOf(spliter);
            if (index < 1)
            {
                throw new Exception("wrong method name : " + name);
            }

            string objName = name.Substring(0, index);
            string objMethod = name.Substring(index + 1).Trim();

            if (resolveTestLog(testLog, objName, objMethod, true, out ret))
            {
                return ret;
            }

            return getValueInner(session, product, mb, delivery, part, name, spliter, true); 
        }
Пример #2
0
 /// <summary>
 /// 填充TestLogDefects
 /// </summary>
 /// <param name="tstlg"></param>
 public static void FillingTestLogDefects(TestLog tstlg)
 {
     MbRepository.FillTestLogDefectInfo(tstlg);
 }
Пример #3
0
        /// <summary>
        /// 添加测试记录
        /// </summary>
        /// <param name="testLog">测试记录</param>
        public void AddTestLog(TestLog testLog)
        {
            if (testLog == null)
                return;

            lock (_syncObj_testLogs)
            {
                if (this._testLogs == null)
                {
                    this._testLogs = new List<TestLog>();
                }

                //object naught = this.TestLogs;
                if (this._testLogs.Contains(testLog))
                    return;

                testLog.Tracker = this._tracker.Merge(testLog.Tracker);
                this._testLogs.Add(testLog);
                testLog.FillingTestLogDefects += new FillTestLog(FillingTestLogDefects);
                this._tracker.MarkAsAdded(testLog);
                this._tracker.MarkAsModified(this);
            }
        }
Пример #4
0
        /// <summary>
        /// 檢查QTime 及設定QTime Action
        /// </summary>        
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IQTimeRepository qTimeRep = RepositoryFactory.GetInstance().GetRepository<IQTimeRepository, QTime>();
            ILineRepository lineRep = RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
            DateTime now = DateTime.MinValue;

            #region 檢查 Product ,QTime及LineEx 設置資料,若無,則不做
            string pdline = this.Line;
            var prod = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);

            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 (prod == null ||
                line == null ||
                line.LineEx == null ||
                string.IsNullOrEmpty(line.LineEx.AliasLine))
            {
                //throw new FisException();
                return base.DoExecute(executionContext);
            }

            string aliasLine = line.LineEx.AliasLine;
            //QTime qTime = qTimeRep.Find(new string[] { aliasLine, this.Station, prod.ProId });

            QTime qTime = qTimeRep.GetPriorityQTime(aliasLine, this.Station, prod.ProId, prod.Model, prod.Family);
            if (qTime == null)
            {
                return base.DoExecute(executionContext);
            }

            #endregion


            #region 檢查QTime.StopTime,計算是否紀錄停線,不做DB事務
            if (qTime != null && qTime.StopTime > 0)
            {
                LineStationLastProcessTime processTime = qTimeRep.GetLastProcessTime(aliasLine, this.Station);
                if (processTime != null)
                {
                    now = processTime.Now;
                    if (processTime.SpeedTime >= qTime.StopTime)
                    {
                        LineStationStopPeriodLog periodLog = new LineStationStopPeriodLog
                        {
                            Line = aliasLine,
                            Station = this.Station,
                            StartTime = processTime.ProcessTime,
                            EndTime = now,
                            Editor = this.Editor
                        };
                        qTimeRep.AddLineStationStopPeriodLog(periodLog);
                    }
                }
                // 沒有最後一次Process Time 不考慮Check TimeOut
                else
                {
                    now = SqlHelper.GetDateTime();
                }

                processTime = new LineStationLastProcessTime
                {
                    Line = aliasLine,
                    Station = this.Station,
                    ProductID = prod.ProId,
                    ProcessTime = now,
                    Editor = this.Editor
                };
                qTimeRep.UpdateLineStationLastProcessTime(processTime);

                //刪除過時的停線紀錄
                qTimeRep.RemoveStationStopPeriodLog(aliasLine, this.Station, this.RemainLogDay);
            }
            #endregion

            #region 檢查TimeOut ,計算是否QTime逾時並執行QTime Action
            IUnitOfWork uow = new UnitOfWork();
            bool isDoDefect = false;
            bool isDoHoldStation = false;
            string defectStation = this.Station;
            int timeOut = 0;
            //int stopTime = 0;
            bool isCheckTimeOutStation = true;
            bool isTimeOut = false;
            string preStation = prod.Status.StationId.Trim();
            TestLog.TestLogStatus defectStatus = TestLog.TestLogStatus.Fail;
            //檢查TimeOut例外站點
            if (!string.IsNullOrEmpty(qTime.ExceptStation))
            {
                string[] exceptStations = qTime.ExceptStation.Split(new char[] { ',', ';', '~' });
                isCheckTimeOutStation = !exceptStations.Contains(preStation);
            }

            if (qTime != null && qTime.TimeOut > 0 &&
                isCheckTimeOutStation)
            {
                if (now == DateTime.MinValue)
                {
                    now = SqlHelper.GetDateTime();
                }
                //計算TimeOut
                //IList<int> timeOutList = qTimeRep.CalLineStopTime(aliasLine, "69", prod.Status.Udt, now);
                //stopTime = timeOutList[0];
                //timeOut = (timeOutList[1] - timeOutList[0]) ;

                IList<LineStopLogInfo> logs = qTimeRep.CalLineStopMillionSecond(aliasLine, this.Station, prod.Status.Udt, now);
                double stopMillionSecond = 0;
                foreach (LineStopLogInfo item in logs)
                {
                    stopMillionSecond = stopMillionSecond + (item.EndTime - item.StartTime).TotalMilliseconds;
                }

                timeOut = (int)(((now - prod.Status.Udt).TotalMilliseconds - stopMillionSecond) / 1000);

                // 判別有沒有TimeOut 
                if ((qTime.Category == QTimeCategoryEnum.Max && timeOut >= qTime.TimeOut) ||
                    (qTime.Category == QTimeCategoryEnum.Min && timeOut <= qTime.TimeOut))
                {
                    isTimeOut = true;
                    if (!string.IsNullOrEmpty(qTime.DefectCode))
                    {
                        isDoDefect = true;
                    }
                    if (!string.IsNullOrEmpty(qTime.HoldStation))
                    {
                        defectStation = qTime.HoldStation;
                        defectStatus = (qTime.HoldStatus == QTimeStationStatusEnum.Fail ?
                                                 TestLog.TestLogStatus.Fail : TestLog.TestLogStatus.Pass);
                        isDoHoldStation = true;
                    }
                }

                //執行QTime Action
                if (isDoDefect || isDoHoldStation)
                {
                    #region record previous product Status
                    //System.Data.DataTable preStatus = CreateDataTable.CreateProductStatusTb();
                    //preStatus.Rows.Add(prod.ProId,
                    //                                   prod.Status.StationId,
                    //                                   prod.Status.Status == StationStatus.Pass ? 1 : 0,
                    //                                   prod.Status.ReworkCode,
                    //                                   prod.Status.Line,
                    //                                   prod.Status.TestFailCount,
                    //                                   prod.Status.Editor,                            
                    //                                   prod.Status.Udt
                    //                                   );



                    //System.Data.DataTable curStatus = CreateDataTable.CreateProductStatusTb();
                    prod.UpdateStatus(new IMES.FisObject.FA.Product.ProductStatus()
                    {
                        Line = pdline,
                        ProId = prod.ProId,
                        TestFailCount = 0,
                        ReworkCode = "",
                        StationId = defectStation,
                        Status = (defectStatus == TestLog.TestLogStatus.Fail ?
                                                       StationStatus.Fail : StationStatus.Pass),
                        Editor = this.Editor,
                        Udt = now
                    });

                    //prod.Status.Line = pdline;
                    //prod.Status.StationId = defectStation;
                    //prod.Status.Status = (defectStatus == TestLog.TestLogStatus.Fail ?
                    //                                   StationStatus.Fail : StationStatus.Pass);
                    //prod.Status.Editor = this.Editor;
                    //prod.Status.Udt = now;

                    //curStatus.Rows.Add(prod.ProId,
                    //                                   defectStation,
                    //                                  (defectStatus == TestLog.TestLogStatus.Fail ?
                    //                                   0 : 1),
                    //                                   prod.Status.ReworkCode,
                    //                                   this.Line,
                    //                                   prod.Status.TestFailCount,
                    //                                   this.Editor,
                    //                                   prod.Status.Udt
                    //                                   );

                    //SqlParameter para1 = new SqlParameter("PreStatus", System.Data.SqlDbType.Structured);
                    //para1.Direction = System.Data.ParameterDirection.Input;
                    //para1.Value = preStatus;

                    //SqlParameter para2 = new SqlParameter("Status", System.Data.SqlDbType.Structured);
                    //para2.Direction = System.Data.ParameterDirection.Input;
                    //para2.Value = curStatus;

                    //prodRep.ExecSpForNonQueryDefered(uow,
                    //                                                                 IMES.Infrastructure.Repository._Schema.SqlHelper.ConnectionString_FA,
                    //                                                                 "IMES_UpdateProductStatus",
                    //                                                                 para1,
                    //                                                                 para2);

                    IList<IMES.DataModel.TbProductStatus> stationList = prodRep.GetProductStatus(new List<string> { prod.ProId });
                    prodRep.UpdateProductPreStationDefered(uow, stationList);

                    #endregion

                    #region write Productlog

                    ProductLog productLog = new ProductLog
                    {
                        Model = prod.Model,
                        Status = (defectStatus == TestLog.TestLogStatus.Fail ?
                                                       StationStatus.Fail : StationStatus.Pass),
                        Editor = this.Editor,
                        Line = pdline,
                        Station = defectStation,
                        Cdt = now
                    };

                    prod.AddLog(productLog);

                    #endregion
                }

                //unpack Pizza part
                if (isDoHoldStation && defectStation == "UnPizza")
                {
                    ActivityCommonImpl utl = ActivityCommonImpl.Instance;
                    utl.UnPack.unPackPizzaPart(CurrentSession, uow, this.Editor);
                    utl.UnPack.unPackPAKProductPart(CurrentSession, uow, this.Editor);

                    prodRep.DeleteProductPartByProductIDAndStationDefered(uow,
                                                                                                             new List<string>() { prod.ProId },
                                                                                                             new List<string>() { "68", "8C", "PK01", "PK02", "PK03", "PK04", "PK05", "PKOK" },
                                                                                                             this.Editor);
                }

                if (isDoDefect)
                {
                    #region add test log
                    string actionName = qTime.Category.ToString() + "QTime";
                    string errorCode = "";
                    string descr = "PreStation:" + preStation + "~CurStation:" + this.Station + "~TimeOut:" + timeOut.ToString();

                    //TestLog testLog = new TestLog(0, prod.ProId, this.Line, "", defectStation, defectStatus, "", this.Editor, "PRD", DateTime.Now);
                    TestLog testLog = new TestLog(0, prod.ProId, pdline, "", defectStation, defectStatus, "",
                                                                        actionName, errorCode, descr, this.Editor, "PRD", now);

                    prod.AddTestLog(testLog);
                    //add defect
                    TestLogDefect defectItem = new TestLogDefect(0, 0, qTime.DefectCode, this.Editor, now);
                    testLog.AddTestLogDefect(defectItem);
                    #endregion
                }

                if (isDoDefect || isDoHoldStation)
                {
                    prodRep.Update(prod, uow);
                    uow.Commit();
                    if (qTime.Category == QTimeCategoryEnum.Min)
                    {
                        int diffTime = (timeOut - qTime.TimeOut) / 60;
                        throw new FisException("CHK093", new string[] { diffTime.ToString() });
                    }
                    else
                    {
                        throw new FisException("QTM001", new string[] { prod.ProId, qTime.Category.ToString() + "QTime", timeOut.ToString() });
                    }
                }


                //Min QTime Warning message nothing to do
                if (isTimeOut && qTime.Category == QTimeCategoryEnum.Min)
                {
                    int diffTime = (timeOut - qTime.TimeOut) / 60;
                    throw new FisException("CHK093", new string[] { diffTime.ToString() });
                }
            }
            #endregion

            return base.DoExecute(executionContext);
        }
Пример #5
0
        public void SaveModelWeightItemAndHold(ModelWeightDef item, IList<string> lstPrdID, string holdStation, string defectCode)
        {
            try
            {

                IModelWeightRepository itemRepositoryModelWeight = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository>();
                //看取得的数据是否有, 防止update的是空记录,但[PAK_SkuMasterWeight_FIS]中加入了记录
                DataTable modelWeight = itemRepositoryModelWeight.GetModelWeightItem(item.Model);
                //if (modelWeight == null || modelWeight.Rows.Count == 0)
                //{
                //    //该Model尚无标准重量,请先去称重。
                //    List<string> erpara = new List<string>();
                //    erpara.Add(item.Model);
                //    FisException ex;
                //    ex = new FisException("PAK123", erpara);
                //    throw ex;
                //}
                if (modelWeight == null || modelWeight.Rows.Count == 0)
                {
                    item.UnitWeight = "0.00";
                }
                else
                {
                    item.UnitWeight = modelWeight.Rows[0][1].ToString();
                }

                IPizzaRepository itemRepositoryPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository>();

                ModelWeightInfo setValue = new ModelWeightInfo();
                setValue.unitWeight = Decimal.Parse(item.UnitWeight);
                setValue.sendStatus = "";
                setValue.remark = "";
                setValue.editor = item.Editor;

                setValue.udt = DateTime.Now;

                ModelWeightInfo condition = new ModelWeightInfo();
                condition.model = item.Model;

                PakSkuMasterWeightFisInfo pakSkuMasterWeight = new PakSkuMasterWeightFisInfo();
                pakSkuMasterWeight.model = item.Model;
                pakSkuMasterWeight.weight = setValue.unitWeight;                
                pakSkuMasterWeight.cdt = setValue.udt;

                UnitOfWork uow = new UnitOfWork();
                itemRepositoryModelWeight.UpdateModelWeightDefered(uow, setValue, condition);
                itemRepositoryPizza.DeletetPakSkuMasterWeightFisByModelDefered(uow, item.Model);
                itemRepositoryPizza.InsertPakSkuMasterWeightFisDefered(uow, pakSkuMasterWeight);
                HoldProductByProductList(lstPrdID, item, uow,holdStation);
             
             //void WriteHoldCodeDefered(IUnitOfWork uow, IList<string> productIDList, TestLog log, IList<string> defectList);
                TestLog testLog = new TestLog(0, "", "", "", "HOLD", TestLog.TestLogStatus.Fail, "", "HOLD", "", "", item.Editor, "HOLD", DateTime.Now);
                IProductRepository prodyctRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                IList<string> defectLst = new List<string>();
                defectLst.Add(defectCode);
                prodyctRep.WriteHoldCodeDefered(uow, lstPrdID, testLog, defectLst);
                uow.Commit();

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
        
        }
Пример #6
0
        /// <summary>
        /// insert into pcbtestlog
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            var mb = (IMB)CurrentSession.GetValue(Session.SessionKeys.MB);
            IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            IList<string> defectList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.DefectList);

            IList<TestLogDefect> defects = new List<TestLogDefect>();

            if (defectList != null)
            {
                foreach (string item in defectList)
                {
                    //add defect
                    TestLogDefect defectItem = new TestLogDefect(0, 0, item, this.Editor, DateTime.Now);
                    defects.Add(defectItem);
                }
            }

            //get 111 type
            string type = "MB";// mb.ModelObj.Type;

            string line = this.Line;
            if (string.IsNullOrEmpty(line))
            {
                line = mb.MBStatus.Line;
            }

            string fixid = (string)CurrentSession.GetValue(Session.SessionKeys.FixtureID);
            if (string.IsNullOrEmpty(fixid))
            {
                fixid = string.Empty;
            }

            string actionName = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.TestLogActionName);
            if (string.IsNullOrEmpty(actionName))
            {
                actionName = string.Empty;
            }

            string errorCode = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.TestLogErrorCode);
            if (string.IsNullOrEmpty(errorCode))
            {
                errorCode = string.Empty;
            }

            string descr = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.TestLogDescr);
            if (string.IsNullOrEmpty(descr))
            {
                descr = string.Empty;
            }

            string remark = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.TestLogRemark);
            if (string.IsNullOrEmpty(remark))
            {
                remark = string.Empty;
            }


            TestLog tItem;

            string AllowPass = "";
            string DefectStation = "";
            if (CurrentSession.GetValue(ExtendSession.SessionKeys.AllowPass) != null)
            {
                AllowPass = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.AllowPass);
            }

            if (CurrentSession.GetValue(ExtendSession.SessionKeys.DefectStation) != null)
            {
                DefectStation = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.DefectStation);
            }

            if (defectList == null || defectList.Count == 0)
            {
                tItem = new TestLog(0, mb.Sn, line, fixid, this.Station, new List<TestLogDefect>(), TestLog.TestLogStatus.Pass, "",
                                               actionName, errorCode, descr, this.Editor, type, DateTime.Now);
            }
            else
            {
                if (AllowPass == "N")//Check AllowPass =N  Dean 20110625
                {
                    tItem = new TestLog(0, mb.Sn, line, fixid, DefectStation, defects, TestLog.TestLogStatus.Fail, "",
                        actionName, errorCode, descr, this.Editor, type, DateTime.Now);
                }
                else //Normal Flow
                {
                    tItem = new TestLog(0, mb.Sn, line, fixid, this.Station, defects, TestLog.TestLogStatus.Fail, "",
                                                   actionName, errorCode, descr, this.Editor, type, DateTime.Now);
                }
            }

            tItem.Remark = remark;

            mb.AddTestLog(tItem);
            mbRepository.Update(mb, CurrentSession.UnitOfWork);

            return base.DoExecute(executionContext);
        }
Пример #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IQTimeRepository qTimeRep = RepositoryFactory.GetInstance().GetRepository<IQTimeRepository, QTime>();
            ILineRepository lineRep = RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
            DateTime now = DateTime.MinValue;
          
            var prod = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            string pdline = prod.Status.Line;
            IUnitOfWork uow = new UnitOfWork();
            string defectStation = this.Station;
            string preStation = prod.Status.StationId.Trim();
            string defctcode=  (string)CurrentSession.GetValue(Session.SessionKeys.DefectList);
            TestLog.TestLogStatus defectStatus = TestLog.TestLogStatus.Fail;
            prod.UpdateStatus(new IMES.FisObject.FA.Product.ProductStatus()
                    {
                        Line = pdline,
                        ProId = prod.ProId,
                        TestFailCount = 0,
                        ReworkCode = "",
                        StationId = this.Station,
                        Status = StationStatus.Fail ,
                        Editor = this.Editor,
                        Udt = now
                    });
           IList<IMES.DataModel.TbProductStatus> stationList = prodRep.GetProductStatus(new List<string> { prod.ProId });
           prodRep.UpdateProductPreStationDefered(uow, stationList);

                  

           #region write Productlog

            ProductLog productLog = new ProductLog
                    {
                        Model = prod.Model,
                        Status =StationStatus.Fail ,
                        Editor = this.Editor,
                        Line = pdline,
                        Station = defectStation,
                        Cdt = now
                    };
             prod.AddLog(productLog);

           #endregion
              
           #region add test log
                    string actionName =  "OfflineQTime";
                    string errorCode = "";
                    string descr = "PreStation:" + preStation + "~CurStation:" + this.Station + "~TimeOut:" ;

                    //TestLog testLog = new TestLog(0, prod.ProId, this.Line, "", defectStation, defectStatus, "", this.Editor, "PRD", DateTime.Now);
                    TestLog testLog = new TestLog(0, prod.ProId, pdline, "", defectStation, defectStatus, "",
                                                                        actionName, errorCode, descr, this.Editor, "PRD", now);

                    prod.AddTestLog(testLog);
                    //add defect
                    TestLogDefect defectItem = new TestLogDefect(0, 0, defctcode, this.Editor, now);
                    testLog.AddTestLogDefect(defectItem);
              #endregion   
           prodRep.Update(prod, uow);
           uow.Commit();

            return base.DoExecute(executionContext);
        }
Пример #8
0
        /// <summary>
        /// Update Lot
        /// Update Lot.Qty=Qty+1 where LotNo = (Select LotNo from PCBLot where PCBNo=@MBSN and Status=1)
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            //string mbsno = (string)CurrentSession.GetValue(Session.SessionKeys.MBSN);
            var mb = (IMB)CurrentSession.GetValue(Session.SessionKeys.MB);
            //FisException ex;
            List<string> erpara = new List<string>();

            string mbsno = mb.Sn;
            string SelectLotNo =(string)CurrentSession.GetValue(Session.SessionKeys.LotNo);

            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
           
            

            LotInfo conLotInfo = new LotInfo();
            conLotInfo.lotNo = SelectLotNo;

            LotInfo setLotInfo = new LotInfo();
            setLotInfo.qty = 1; // Qty赋要加的值
            setLotInfo.editor = Editor;
            setLotInfo.udt = DateTime.Now;

            iMBRepository.UpdateLotInfoForIncQtyDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);

            PcblotInfo checkInfo = new PcblotInfo();
            checkInfo.lotNo = SelectLotNo;
            checkInfo.pcbno = mbsno;
            checkInfo.status = "1";
            checkInfo.editor = Editor;
            //iMBRepository.InsertPcblotcheckInfoDefered(CurrentSession.UnitOfWork, checkInfo);
            iMBRepository.InsertPCBLotInfoDefered(CurrentSession.UnitOfWork, checkInfo);
            TestLog tItem;
            tItem = new TestLog(0, mbsno, this.Line, null, "15", new List<TestLogDefect>(), TestLog.TestLogStatus.Pass,"" , null,null,"Combine PCB In Lot",this.Editor, "MB", DateTime.Now);
            mb.AddTestLog(tItem);
            iMBRepository.Update(mb, CurrentSession.UnitOfWork);
            return base.DoExecute(executionContext);
        }
        /// <summary>
        /// PCA Test Station 检查MBSNO,处理15种异常情况
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IMBRepository currentMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
            Product currentProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            IBOMRepository bomRepository = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();

            bool mbHave = false;
            IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
            IHierarchicalBOM curBOM = bomRep.GetHierarchicalBOMByModel(currentProduct.Model);
            IList<IBOMNode> bomNodeLst = curBOM.FirstLevelNodes;

            if (bomNodeLst != null && bomNodeLst.Count > 0)
            {
                foreach (IBOMNode item in bomNodeLst)
                {
                    if (!string.IsNullOrEmpty(item.Part.BOMNodeType) &&
                          item.Part.BOMNodeType.ToUpper() == "MB")
                    {
                        mbHave = true;
                        break;
                    }
                }
            }

            if (!mbHave)
            {
                return base.DoExecute(executionContext);
            }

            if (String.IsNullOrEmpty(currentProduct.PCBID) )
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(currentProduct.ProId);
                ex = new FisException("CHK400", erpara);
                throw ex;
            }
            string MBSN = currentProduct.PCBID;
            string strMBCode = MBSN.Substring(0, 2);
            //Vincent Mark this logical 
           // string strMBCode = "";  
            //if (MBSN.Substring(5, 1) == "M")
            //{
            //    strMBCode = MBSN.Substring(0, 3);
            //    if (MBSN.Substring(4, 1) == "M" && MBSN.Length == 10)
            //    {
            //        strMBCode = MBSN.Substring(0, 2);
            //    }
            //}
            //else if (MBSN.Substring(4, 1) == "M")
            //{
            //    strMBCode = MBSN.Substring(0, 2);
            //}
            //else
            //{
            //    strMBCode = MBSN.Substring(0, 2);
            //}

            //Get latest move out datetime
            DateTime lastMoveOutTime = currentProduct.Status.Udt;

            FaItCnDefectCheckInfo con = new FaItCnDefectCheckInfo();
            con.code = strMBCode;
            IList<FaItCnDefectCheckInfo> listDefectCheck = productRep.GetFaItCnDefectCheckInfoList(con);
            foreach (FaItCnDefectCheckInfo temp in listDefectCheck)
            {
                string MAC = temp.mac;
                string MBCT = temp.mbct;
                string HDDV = temp.hddv;
                string BIOS = temp.bios;


                TestLog eqCondition = new TestLog();
                TestLog notNullCondition = new TestLog();
                IList<TestLog> listTestLog = null;
                string mac15 = "";
                string mac32 = "";
                string mbct15 = "";
                string mbct32 = "";

                eqCondition.Status = TestLog.TestLogStatus.Pass;
                eqCondition.Sn = MBSN;//add
                eqCondition.Station = "15";
                notNullCondition.Remark = "";
                listTestLog = currentMBRepository.GetPCBTestLogInfo(eqCondition, notNullCondition);               
                //MAC:E4115B3D46FB~MBCT:PCCKB001X2A4X7~V:CT11-IU2.03~BIOS:68SCF Ver. F.22~ 
                foreach (TestLog tmp in listTestLog)
                {
                    if (tmp.Sn != currentProduct.PCBID)
                    {
                        continue;
                    }
                    string strgetremark = tmp.Remark.ToUpper();
                    if (MAC == "Y")
                    {
                        var strMACremark = "";
                        var ilocMAC = strgetremark.IndexOf("MAC");
                        if (ilocMAC != -1)
                        {
                            ilocMAC = ilocMAC + 4;
                            string strremarkMAC = strgetremark.Substring(ilocMAC);
                            var ilenMAC = strremarkMAC.IndexOf("~");
                            if (ilenMAC == -1)
                                strMACremark = strremarkMAC;
                            else
                                strMACremark = strremarkMAC.Substring(0, ilenMAC);
                        }
                        if ("" == strMACremark)
                        {
                            //SA未上传MAC
                            throw new FisException("CHK550", new string[] { });
                        }
                        else
                        {
                            if (mac15 == "")
                            {
                                mac15 = strMACremark;
                            }
                        }
                    }
                    if (MBCT == "Y")
                    {
                        var strMBCTremark = "";
                        var ilocMBCT = strgetremark.IndexOf("MBCT");
                        if (ilocMBCT != -1)
                        {
                            ilocMBCT = ilocMBCT + 5;
                            string strremarkMBCT = strgetremark.Substring(ilocMBCT);
                            var ilenMBCT = strremarkMBCT.IndexOf("~");

                            if (ilenMBCT == -1)
                            {
                                strMBCTremark = strremarkMBCT;
                            }
                            else
                            {
                                strMBCTremark = strremarkMBCT.Substring(0, ilenMBCT);
                            }
                        }
                        if ("" == strMBCTremark)
                        {
                            //SA未上传MBCT
                            throw new FisException("CHK551", new string[] { });
                        }
                        else
                        {
                            if (mbct15 == "")
                            {
                                mbct15 = strMBCTremark;
                            }
                        }
                    }
                    break;
                }
                if (MAC == "Y")
                {
                    if (mac15 == "")
                    {
                        //SA未上传MAC
                        throw new FisException("CHK550", new string[] { });
                    }
                }
                if (MBCT == "Y")
                {
                    if (mbct15 == "")
                    {
                        //SA未上传MBCT
                        throw new FisException("CHK551", new string[] { });
                    }
                }

                //eqCondition.Status = TestLog.TestLogStatus.Pass;
                //eqCondition.Sn = MBSN;//add
                //eqCondition.Station = "32";
                //notNullCondition.Remark = "";
                //listTestLog = currentMBRepository.GetPCBTestLogInfo(eqCondition, notNullCondition);

                //mantis 1902: RCTO..Function Test For RCTO页面check 测试记录逻辑修改
                listTestLog = currentMBRepository.GetPCBTestLogListFromPCBTestLog(MBSN, 1, "32", lastMoveOutTime);
                bool no1 = true;
                bool no2 = true;
                foreach (TestLog tmp in listTestLog)
                {
                    if (tmp.Sn != currentProduct.PCBID)
                    {
                        continue;
                    }
                    string strgetremark = tmp.Remark.ToUpper();
                    var strMACremark = "";
                    if (MAC == "Y")
                    {
                        var ilocMAC = strgetremark.IndexOf("MAC");
                        if (ilocMAC != -1)
                        {
                            ilocMAC = ilocMAC + 4;
                            string strremarkMAC = strgetremark.Substring(ilocMAC);
                            var ilenMAC = strremarkMAC.IndexOf("~");
                            if (ilenMAC == -1)
                                strMACremark = strremarkMAC;
                            else
                                strMACremark = strremarkMAC.Substring(0, ilenMAC);
                        }
                        if ("" == strMACremark)
                        {
                            //FA未上传MAC
                            throw new FisException("CHK552", new string[] { });
                        }
                        else
                        {
                            if (mac32 == "")
                            {
                                mac32 = strMACremark;
                            }
                        }
                    }
                    if (MBCT == "Y")
                    {
                        var strMBCTremark = "";
                        var ilocMBCT = strgetremark.IndexOf("MBCT");
                        if (ilocMBCT != -1)
                        {
                            ilocMBCT = ilocMBCT + 5;
                            string strremarkMBCT = strgetremark.Substring(ilocMBCT);
                            var ilenMBCT = strremarkMBCT.IndexOf("~");

                            if (ilenMBCT == -1)
                            {
                                strMBCTremark = strremarkMBCT;
                            }
                            else
                            {
                                strMBCTremark = strremarkMBCT.Substring(0, ilenMBCT);
                            }
                        }
                        if ("" == strMBCTremark)
                        {
                            //FA未上传MBCT
                            throw new FisException("CHK553", new string[] { });
                        }
                        else
                        {
                            if (mbct32 == "")
                            {
                                mbct32 = strMBCTremark;
                            }
                        }
                    }
                    if (HDDV != "N" && HDDV != "")
                    {
                        var strHDDVremark = "";
                        var ilocHDDV = strgetremark.IndexOf("HDD");
                        if (ilocHDDV != -1)
                        {
                            ilocHDDV = ilocHDDV + 4;
                            string strremarkHDDV = strgetremark.Substring(ilocHDDV);
                            var ilenHDDV = strremarkHDDV.IndexOf("~");

                            if (ilenHDDV == -1)
                            {
                                strHDDVremark = strremarkHDDV;
                            }
                            else
                            {
                                strHDDVremark = strremarkHDDV.Substring(0, ilenHDDV);
                            }
                        }
                        if ("" == strHDDVremark)
                        {
                            //FA未上传V
                            throw new FisException("CHK554", new string[] { });
                        }
                        no1 = false;
                        if (strHDDVremark != HDDV)
                        {
                            //FA上传的V与Maintain值不一致
                            throw new FisException("CHK555", new string[] { });
                        }
                    }
                    if (BIOS != "N" && BIOS != "")
                    {
                        var strBIOSremark = "";
                        var ilocBIOS = strgetremark.IndexOf("BIOS");
                        if (ilocBIOS != -1)
                        {
                            ilocBIOS = ilocBIOS + 5;
                            string strremarkBIOS = strgetremark.Substring(ilocBIOS);
                            var ilenBIOS = strremarkBIOS.IndexOf("~");

                            if (ilenBIOS == -1)
                            {
                                strBIOSremark = strremarkBIOS;
                            }
                            else
                            {
                                strBIOSremark = strremarkBIOS.Substring(0, ilenBIOS);
                            }
                        }
                        if ("" == strBIOSremark)
                        {
                            //FA未上传BIOS
                            throw new FisException("CHK556", new string[] { });
                        }
                        no2 = false;
                        if (strBIOSremark != BIOS)
                        {
                            //FA上传的BIOS与Maintain值不一致
                            throw new FisException("CHK557", new string[] { });
                        }
                    }
                    break;
                }
                if (MAC == "Y")
                {
                    if (mac32 == "")
                    {
                        //FA未上传MAC
                        throw new FisException("CHK552", new string[] { });
                    }
                }
                if (MBCT == "Y")
                {
                    if (mbct32 == "")
                    {
                        //FA未上传MBCT
                        throw new FisException("CHK553", new string[] { });
                    }
                }
                if (HDDV != "N" && HDDV != "")
                {
                    if (no1)
                    {
                        //FA未上传V
                        throw new FisException("CHK554", new string[] { });
                    }
                }
                if (BIOS != "N" && BIOS != "")
                {
                    if (no2)
                    {
                        //FA未上传BIOS
                        throw new FisException("CHK556", new string[] { });
                    }
                }
                if (MAC == "Y")
                {
                    if (mac15 != mac32)
                    {
                        //SA和FA上传的MAC不一致
                        throw new FisException("CHK558", new string[] { });
                    }
                }
                if (MBCT == "Y")
                {
                    if (mbct15 != mbct32)
                    {
                        //SA和FA上传的MBCT不一致
                        throw new FisException("CHK559", new string[] { });
                    }
                }
            }

           

            return base.DoExecute(executionContext);
        }
Пример #10
0
 private static bool resolveTestLog(TestLog testLog, string objName, string objMethod, bool isThrowError,  out string value)
 {
     value = null;
     if (string.Compare(objName, GlobalConstName.ResolveValue.TESTLOG, true) == 0)
     {
         if (testLog == null)
         {
             throw new FisException("CQCHK0006", new List<string> { "TestLog" });
         }
         object retValue = testLog.GetProperty(objMethod);
         if (retValue == null)
         {
             if (isThrowError)
             {
                 throw new FisException(string.Format("{0} not exists property name {1}", objName, objMethod));
             }
             else
             {                        
                 return true;
             }
         }
         value = retValue.ToString();
         return true;
     }
     return false;
 }
Пример #11
0
        /// <summary>
        /// Wrint Product Log
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IProduct currentProduct = null;
            RepairDefect defect = null;
            var newStatus = new ProductStatus();
            string ProductID = "";
            
            defect = (RepairDefect)CurrentSession.GetValue(Session.SessionKeys.CurrentRepairdefect);
            if (defect == null)
            {
                List<string> errpara = new List<string>();

                errpara.Add("CurrentRepairdefect");
                FisException e = new FisException("CHK194", errpara);
                e.stopWF = this.IsStopWF;
                throw e; 
            }

            if (IsNewProID) 
            {
                ProductID = defect.NewPartSno;//NEW
            }
            else 
            {
                ProductID = defect.OldPartSno;//OLD
            }
            //Vincent modify this for CQ CleanRoom trace maijor id is CT
            //currentProduct = productRepository.Find(ProductID);
            currentProduct = productRepository.GetProductByIdOrSn(ProductID);
            if (currentProduct==null)
            {
                List<string> errpara = new List<string>();

                errpara.Add(ProductID);
                FisException e = new FisException("SFC002", errpara);
                e.stopWF=this.IsStopWF;
                throw e; 
            }

            ProductID = currentProduct.ProId;
            //UnpackCarton
            if (!IsNewProID)
            {
                //var currentProductObject = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
                //String cartonSN = currentProduct.CartonSN;
                //String palletNo = currentProduct.PalletNo;
                //String dn = currentProduct.DeliveryNo;
                //if (currentProduct != null)
                //{
                //    productId = currentProduct.ProId;
                //}
                productRepository.BackUpProduct(ProductID, this.Editor);
                //productRepository.CopyProductToUnpackDefered(CurrentSession.UnitOfWork, cartonSN, palletNo, dn, productId, this.Editor);
                currentProduct.CartonSN = "";
            }

            //write ProductStatusEx
            IList<IMES.DataModel.TbProductStatus> stationList = productRepository.GetProductStatus(new List<string> { currentProduct.ProId });
            productRepository.UpdateProductPreStationDefered(CurrentSession.UnitOfWork, stationList);
            
            //write ProductStatus
            newStatus.ProId = currentProduct.ProId;
            newStatus.Status = Status;
            newStatus.StationId = Station;
            newStatus.Editor = Editor;
            newStatus.Line =  currentProduct.Status.Line ;
            newStatus.TestFailCount = 0;
            newStatus.ReworkCode = "";
            currentProduct.UpdateStatus(newStatus);

           //write productLog
            var productLog = new ProductLog
            {
                Model = currentProduct.Model,
                Status = Status,
                Editor = Editor,
                Line = currentProduct.Status.Line,
                Station = Station,
                Cdt = DateTime.Now
            };
            currentProduct.AddLog(productLog);

            //write ProductTestLog
            if (this.IsWriteTestLog)
            {

            TestLog.TestLogStatus status = (Status== StationStatus.Pass? TestLog.TestLogStatus.Pass: TestLog.TestLogStatus.Fail);

            TestLogDefect defectItem = new TestLogDefect(0, 0,defect.DefectCodeID, this.Editor, DateTime.Now);
            //TestLog item = new TestLog(0, currentProduct.ProId, string.IsNullOrEmpty(Line) ? currentProduct.Status.Line : Line,
            //                                            "", Station, status, "", this.TestLogAction, "", "", this.Editor, "PRD", DateTime.Now);
            IList<TestLogDefect> defectItemList = new List<TestLogDefect>();
            defectItemList.Add(defectItem);

            TestLog item = new TestLog(0, currentProduct.ProId, currentProduct.Status.Line ,
                                               "", Station, defectItemList, status, "", this.TestLogAction, "", "", this.Editor, "PRD", DateTime.Now);
                       
                
            //item.AddTestLogDefect(defectItem);

            currentProduct.AddTestLog(item);
            }
            
            productRepository.Update(currentProduct, CurrentSession.UnitOfWork);
                

            return base.DoExecute(executionContext);
        }
Пример #12
0
        /// <summary>
        /// 记录到ProductTestLog,ProductTestLog_DefectInfo表
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Session session = CurrentSession;
            var prod = (IProduct)session.GetValue(Session.SessionKeys.Product);
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IList<string> defectList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.DefectList);

            //Dean 20110625
            string AllowPass = "";
            string DefectStation = "";
            string InsertStation = "";
          //  string logDescr=(string)CurrentSession.GetValue("ProductTestLogDescr")??"";
          //  string logAction = (string)CurrentSession.GetValue("ProductTestLogAction") ?? "";
            //Benson

            string fixid = (string)session.GetValue(Session.SessionKeys.FixtureID);
            if (string.IsNullOrEmpty(fixid))
            {
                fixid = string.Empty;
            }

            string actionName = (string)session.GetValue(ExtendSession.SessionKeys.TestLogActionName);
            if (string.IsNullOrEmpty(actionName))
            {
                actionName = string.Empty;
            }

            string errorCode = (string)session.GetValue(ExtendSession.SessionKeys.TestLogErrorCode);
            if (string.IsNullOrEmpty(errorCode))
            {
                errorCode = string.Empty;
            }

            string descr = (string)session.GetValue(ExtendSession.SessionKeys.TestLogDescr);
            if (string.IsNullOrEmpty(descr))
            {
                descr = string.Empty;
            }

            string remark = (string)session.GetValue(ExtendSession.SessionKeys.TestLogRemark);
            if (string.IsNullOrEmpty(remark))
            {
                remark = string.Empty;
            }

            string testLogJoinId = (string)session.GetValue(ExtendSession.SessionKeys.TestLogJoinId) ?? string.Empty;
            //Benson


            if (session.GetValue(ExtendSession.SessionKeys.AllowPass) != null)
            {
                AllowPass = (string)session.GetValue(ExtendSession.SessionKeys.AllowPass);
            }

            if (session.GetValue(ExtendSession.SessionKeys.DefectStation) != null)
            {
                DefectStation = (string)session.GetValue(ExtendSession.SessionKeys.DefectStation);
            }
            //Dean 20110625

            string line = this.Line;
            if (string.IsNullOrEmpty(line))
            {
                line = prod.Status.Line;
            }

            TestLog.TestLogStatus status = TestLog.TestLogStatus.Fail;
            if (IsPass)
            {
                status = TestLog.TestLogStatus.Pass;
            }

            if (AllowPass == "N")//Check AllowPass =N  Dean 20110625
            {
                InsertStation = DefectStation;
            }
            else //Normal Flow
            {
                InsertStation = this.Station;
            }
            TestLog tItem;
            /*
            if (string.IsNullOrEmpty(logDescr) && string.IsNullOrEmpty(logAction))
            {
                 tItem = new TestLog(0, prod.ProId, line, "", InsertStation, status, "", this.Editor, "PRD", DateTime.Now);//Dean 20110625 this.Station==>InsertStation

            }
            else
            {
                 tItem = new TestLog(0, prod.ProId, line, "", InsertStation, status, "",logAction,"",logDescr, this.Editor, "PRD", DateTime.Now);//Dean 20110625 this.Station==>InsertStation
            
            }*/
            string type = "PRD";
            if (defectList == null || defectList.Count == 0)
            {
                tItem = new TestLog(0, prod.ProId, line, fixid, InsertStation, new List<TestLogDefect>(), status, testLogJoinId,
                                               actionName, errorCode, descr, this.Editor, type, DateTime.Now);
            }
            else
            {
                IList<TestLogDefect> defects = new List<TestLogDefect>();
                if (defectList != null)
                {
                    foreach (string item in defectList)
                    {
                        //add defect
                        TestLogDefect defectItem = new TestLogDefect(0, 0, item, this.Editor, DateTime.Now);
                        defects.Add(defectItem);
                    }
                }

                if (AllowPass == "N")//Check AllowPass =N  Dean 20110625
                {
                    tItem = new TestLog(0, prod.ProId, line, fixid, InsertStation, defects, status, testLogJoinId,
                        actionName, errorCode, descr, this.Editor, type, DateTime.Now);
                }
                else //Normal Flow
                {
                    tItem = new TestLog(0, prod.ProId, line, fixid, InsertStation, defects, status, testLogJoinId,
                                                   actionName, errorCode, descr, this.Editor, type, DateTime.Now);
                }
            }

            tItem.Remark = remark;         


            prod.AddTestLog(tItem);

            productRepository.Update(prod, session.UnitOfWork);
            return base.DoExecute(executionContext);
        }
Пример #13
0
        /// <summary>
        /// 檢查QTime 及設定QTime Action
        /// </summary>        
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Session session = CurrentSession;
            ActivityCommonImpl utl = ActivityCommonImpl.Instance;
            IProductRepository prodRep = utl.prodRep; //RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IMBRepository mbRep = utl.mbRep;            
            IQTimeRepository qTimeRep = RepositoryFactory.GetInstance().GetRepository<IQTimeRepository, QTime>();
            ILineRepository lineRep = utl.lineRep;  //RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
            DateTime now=DateTime.MinValue;
           
            #region 檢查 Product ,QTime及LineEx 設置資料,若無,則不做
            string pdline = this.Line;
            IProduct prod =null;
            IMB mb =null;
            string SN = null;
            string modelName = null;
            string familyName = null;
            DateTime udt = DateTime.Now;
            string preStation = null;

            if (this.ProcessType == ProcessTypeEnum.Product)
            {
                prod = utl.IsNull<IProduct>(session,Session.SessionKeys.Product);
                modelName = prod.Model;
                SN = prod.ProductID;
                familyName = prod.Family;
                udt = prod.Status.Udt;
                preStation = prod.Status.StationId.Trim();
                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;
                        }
                    }
                }
            }
            else
            {
                mb = utl.IsNull<IMB>(session, Session.SessionKeys.MB);
                modelName = mb.Model;
                SN = mb.Sn;
                familyName = mb.Family;
                udt = mb.MBStatus.Udt;
                preStation = mb.MBStatus.Station;

                if (string.IsNullOrEmpty(pdline))
                {
                    pdline = mb.MBStatus.Line;
                    if (string.IsNullOrEmpty(pdline))
                    {
                        IList<PCBStatusExInfo> preStatusList = mbRep.GetPCBPreStation(new List<string> { mb.Sn });
                        if (preStatusList.Count > 0)
                        {
                            pdline = preStatusList[0].PreLine;
                        }
                    }
                }
            }

         

            Line line = lineRep.Find(pdline);
            if (prod==null  || 
                line == null || 
                line.LineEx == null || 
                string.IsNullOrEmpty(line.LineEx.AliasLine))
            {
                //throw new FisException();
                return base.DoExecute(executionContext);
            }

            string aliasLine = line.LineEx.AliasLine;
            //QTime qTime = qTimeRep.Find(new string[] { aliasLine, this.Station, prod.ProId });

            QTime qTime = qTimeRep.GetPriorityQTime(aliasLine, this.Station, SN,modelName, familyName);
            if (qTime == null )
            {
                return base.DoExecute(executionContext);
            }
  
            #endregion
                      

            #region 檢查QTime.StopTime,計算是否紀錄停線,不做DB事務
            if (qTime != null && qTime.StopTime > 0)
            {
                 LineStationLastProcessTime processTime= qTimeRep.GetLastProcessTime(aliasLine, this.Station);
                 if (processTime != null)
                 {
                     now = processTime.Now;
                     if (processTime.SpeedTime >= qTime.StopTime)
                     {
                         LineStationStopPeriodLog periodLog = new LineStationStopPeriodLog
                         {
                             Line = aliasLine,
                             Station = this.Station,
                             StartTime = processTime.ProcessTime,
                             EndTime = now,
                             Editor = this.Editor
                         };
                         qTimeRep.AddLineStationStopPeriodLog(periodLog);
                     }
                 }
                 // 沒有最後一次Process Time 不考慮Check TimeOut
                 else
                 {
                     now = SqlHelper.GetDateTime();
                 }

                processTime = new LineStationLastProcessTime
                 {
                     Line = aliasLine,
                     Station = this.Station,
                     ProductID = SN,
                     ProcessTime = now,
                     Editor = this.Editor
                 };
                 qTimeRep.UpdateLineStationLastProcessTime(processTime);

                //刪除過時的停線紀錄
                 qTimeRep.RemoveStationStopPeriodLog(aliasLine, this.Station, this.RemainLogDay);
            }
           #endregion

           #region 檢查TimeOut ,計算是否QTime逾時並執行QTime Action
            IUnitOfWork uow = new UnitOfWork();
            bool isDoDefect = false;
            bool isDoHoldStation = false;
            string defectStation = this.Station;
            int timeOut = 0;
            //int stopTime = 0;
            bool isCheckTimeOutStation = true;
            bool isTimeOut = false;
            //string preStation = prod.Status.StationId.Trim();
            TestLog.TestLogStatus defectStatus = TestLog.TestLogStatus.Fail;
            //檢查TimeOut例外站點
            if (!string.IsNullOrEmpty(qTime.ExceptStation))
            {
                string[] exceptStations = qTime.ExceptStation.Split(Delimiter);
                isCheckTimeOutStation = !exceptStations.Contains(preStation);
            }

            if (qTime != null && qTime.TimeOut > 0 &&
                isCheckTimeOutStation)
            {
                if (now == DateTime.MinValue)
                {
                    now = SqlHelper.GetDateTime();
                }
                    //計算TimeOut
                    //IList<int> timeOutList = qTimeRep.CalLineStopTime(aliasLine, "69", prod.Status.Udt, now);
                    //stopTime = timeOutList[0];
                    //timeOut = (timeOutList[1] - timeOutList[0]) ;

                    IList<LineStopLogInfo> logs = qTimeRep.CalLineStopMillionSecond(aliasLine, this.Station, udt, now);
                    double stopMillionSecond = 0;
                    foreach( LineStopLogInfo item in logs)
                    {
                        stopMillionSecond = stopMillionSecond + (item.EndTime - item.StartTime).TotalMilliseconds;
                    }

                    timeOut = (int)(((now - udt).TotalMilliseconds - stopMillionSecond) / 1000); 

                    // 判別有沒有TimeOut 
                    if ((qTime.Category == QTimeCategoryEnum.Max && timeOut >= qTime.TimeOut) ||
                        (qTime.Category == QTimeCategoryEnum.Min && timeOut <= qTime.TimeOut))
                    {
                        isTimeOut = true;
                        if (!string.IsNullOrEmpty(qTime.DefectCode))
                        {
                            isDoDefect = true;
                        }
                        if (!string.IsNullOrEmpty(qTime.HoldStation))
                        {
                            defectStation = qTime.HoldStation;
                            defectStatus = (qTime.HoldStatus == QTimeStationStatusEnum.Fail ?
                                                     TestLog.TestLogStatus.Fail : TestLog.TestLogStatus.Pass);
                            isDoHoldStation = true;
                        }
                    }
                    
                    //執行QTime Action
                    if (isDoDefect || isDoHoldStation)
                    {
                       
                        if (this.ProcessType == ProcessTypeEnum.Product)
                        {
                            prod.UpdateStatus(new IMES.FisObject.FA.Product.ProductStatus()
                            {
                                Line = pdline,
                                ProId = SN,
                                TestFailCount = 0,
                                ReworkCode = string.Empty,
                                StationId = defectStation,
                                Status = (defectStatus == TestLog.TestLogStatus.Fail ?
                                                               StationStatus.Fail : StationStatus.Pass),
                                Editor = this.Editor,
                                Udt = now
                            });

                            IList<IMES.DataModel.TbProductStatus> stationList = prodRep.GetProductStatus(new List<string> { prod.ProId });
                            prodRep.UpdateProductPreStationDefered(uow, stationList);

                            #region write Productlog

                            ProductLog productLog = new ProductLog
                            {
                                Model = prod.Model,
                                Status = (defectStatus == TestLog.TestLogStatus.Fail ?
                                                               StationStatus.Fail : StationStatus.Pass),
                                Editor = this.Editor,
                                Line = pdline,
                                Station = defectStation,
                                Cdt = now
                            };

                            prod.AddLog(productLog);
                        }
                        else
                        {
                            MBStatus mbStatus= new MBStatus(SN, defectStation, (defectStatus == TestLog.TestLogStatus.Fail ?
                                                               MBStatusEnum.Fail : MBStatusEnum.Pass), this.Editor, pdline, now, now);
                            mb.MBStatus = mbStatus;

                            IList<TbProductStatus> preStatusList = mbRep.GetMBStatus(new List<string>() { SN });
                            mbRep.UpdatePCBPreStationDefered(uow,
                                                                                       preStatusList);
                            #region Write MBlog
                            var mbLog = new MBLog(
                                                0,
                                                mb.Sn,
                                                mb.Model,
                                                 defectStation,
                                                 (defectStatus == TestLog.TestLogStatus.Fail ?
                                                               0 : 1),
                                                pdline,
                                                this.Editor,
                                                now);

                            mb.AddLog(mbLog);
                           
                            #endregion
                        }

                        #endregion
                    }

                    //unpack Pizza part
                    if (this.ProcessType == ProcessTypeEnum.Product && 
                        isDoHoldStation &&
                        defectStation == UnPizzaDefectStation)
                    {                        
                        utl.UnPack.unPackPizzaPart(session, uow, this.Editor);
                        utl.UnPack.unPackPAKProductPart(session, uow, this.Editor);

                        prodRep.DeleteProductPartByProductIDAndStationDefered(uow, 
                                                                                                                 new List<string>() { SN },
                                                                                                                 UnpackPizzaStationList, 
                                                                                                                 this.Editor);
                    }

                    if (isDoDefect)
                    {
                        #region add test log
                        string actionName = qTime.Category.ToString() + QTIMEName;
                        string errorCode = string.Empty;
                        string descr = string.Format(DefectDescrFormat, preStation, this.Station, timeOut.ToString()); //"PreStation:"+preStation+ "~CurStation:"+this.Station +"~TimeOut:"+ timeOut.ToString();
                         
                        //TestLog testLog = new TestLog(0, prod.ProId, this.Line, "", defectStation, defectStatus, "", this.Editor, "PRD", DateTime.Now);
                        TestLog testLog = new TestLog(0, SN, pdline, string.Empty, defectStation, defectStatus, string.Empty,
                                                                            actionName, errorCode, descr, this.Editor, DefectType, now);
                        if (this.ProcessType == ProcessTypeEnum.Product)
                        {
                            prod.AddTestLog(testLog);
                            //add defect
                            TestLogDefect defectItem = new TestLogDefect(0, 0, qTime.DefectCode, this.Editor, now);
                            testLog.AddTestLogDefect(defectItem);
                        }
                        else
                        {
                            mb.AddTestLog(testLog);
                            TestLogDefect defectItem = new TestLogDefect(0, 0, qTime.DefectCode, this.Editor, now);
                            testLog.AddTestLogDefect(defectItem);
                        }
                        #endregion
                    } 
                
                     if (isDoDefect || isDoHoldStation)
                     {
                         if (this.ProcessType == ProcessTypeEnum.Product)
                         {
                             prodRep.Update(prod, uow);
                         }
                         else
                         {
                             mbRep.Update(mb, uow);
                         }
                        uow.Commit();
                        if (qTime.Category == QTimeCategoryEnum.Min)
                        {
                            int diffTime = (timeOut - qTime.TimeOut) / 60;
                            throw new FisException("CHK093", new string[] { diffTime.ToString() });
                        }
                        else
                        {
                            throw new FisException("QTM001", new string[] { SN, qTime.Category.ToString() + QTIMEName, timeOut.ToString() });
                        }
                     }
                    
                     
                     //Min QTime Warning message nothing to do
                     if (isTimeOut && qTime.Category == QTimeCategoryEnum.Min)
                     {
                         int diffTime = (timeOut - qTime.TimeOut) / 60;
                         throw new FisException("CHK093", new string[]{diffTime.ToString()});
                     }
                }  
            #endregion

            return base.DoExecute(executionContext);
        }
Пример #14
0
        /// <summary>
        /// 记录到ProductTestLog,ProductTestLog_DefectInfo表
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            var prod = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IList<string> defectList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.DefectList);

            //Dean 20110625
            string AllowPass = "";
            string DefectStation = "";
            string InsertStation = "";
            if (CurrentSession.GetValue(ExtendSession.SessionKeys.AllowPass) != null)
            {
                AllowPass = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.AllowPass);
            }

            if (CurrentSession.GetValue(ExtendSession.SessionKeys.DefectStation) != null)
            {
                DefectStation = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.DefectStation);
            }
            //Dean 20110625

            string line = this.Line;
            if (string.IsNullOrEmpty(line))
            {
                line = prod.Status.Line;
            }

            TestLog.TestLogStatus status = TestLog.TestLogStatus.Fail;
            if (IsPass)
            {
                status = TestLog.TestLogStatus.Pass;
            }

            if (AllowPass == "N")//Check AllowPass =N  Dean 20110625
            {
                InsertStation = DefectStation;
            }
            else //Normal Flow
            {
                InsertStation = this.Station;
            }

            TestLog tItem = new TestLog(0, prod.ProId, line, "", InsertStation, status, "", this.Editor, "PRD", DateTime.Now);//Dean 20110625 this.Station==>InsertStation
            prod.AddTestLog(tItem);

            if (defectList != null)
            {
                foreach (string item in defectList)
                {
                    //add defect
                    TestLogDefect defectItem = new TestLogDefect(0, 0, item, this.Editor, DateTime.Now);
                    tItem.AddTestLogDefect(defectItem);
                }
            }


            productRepository.Update(prod, CurrentSession.UnitOfWork);
            return base.DoExecute(executionContext);
        }