Пример #1
0
        public void Save(object part_unit, object part_owner, string station, string key)
        {
            //Insert ProductInfo  InfoType='VGA'
            if (part_unit == null)
            {
                throw new ArgumentNullException();
            }
            if (part_owner == null)
            {
                throw new ArgumentNullException();
            }

            var product = (Product)part_owner;
            Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product);
            if (session == null)
            {
                throw new InstanceNotFoundException("Can not get Session instance from SessionManager!");
            }
            //var product_info = new ProductInfo();
            //product_info.InfoType = "VGA";
            //product.ProductInfoes.Add(product_info);
            product.SetExtendedProperty("VGA", ((PartUnit)part_unit).Sn.Trim(), session.Editor);
            IProductRepository product_repository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            product_repository.Update(product, session.UnitOfWork);


            var mb_repository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            IMB mb = mb_repository.Find(((PartUnit)part_unit).Sn.Trim());
            if (mb != null)
            {
                //PCA..PCBStatus.Station = 32
                mb.MBStatus.Station = "32";
                mb.MBStatus.Status = MBStatusEnum.Pass;
                //记录MB Log  Insert PCA..PCBLog   WC=32
                MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "32", (int) MBStatusEnum.Pass, session.Line, session.Editor,new DateTime());
                mb.AddLog(mb_log);
                mb_repository.Update(mb, session.UnitOfWork);
                //IProductRepository product_repository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                product_repository.Update(product, session.UnitOfWork);
//                if (product.IsCDSI)
//                {
//                    SpecialDetInfo item = new SpecialDetInfo{snoId = product.ProId,tp = "CDSI",sno1 = product.MAC,cdt = new DateTime(),id = 0,udt = new DateTime()};
//                    product_repository.InsertSpecialDet(item);
//                }
            }
        }
Пример #2
0
        /// <summary>
        /// 扫描9999,结束工作流
        /// 如果没有Defect,即defectCodeList为null或cout为0
        /// 将Session.AddValue(Session.SessionKeys.HasDefect,false)
        /// 否则Session.AddValue(Session.SessionKeys.HasDefect,true)
        /// </summary>
        /// <param name="mbsno">mbsno</param>
        /// <param name="defectCodeList">defectCodeList</param>
        public string save(string LotNo, String strCMD, string editor, string line, string customer)
        {
            logger.Debug("(PCAOQCInputImpl)save start,"
                + " LotNo: " + LotNo
                + " KeyCode:" + strCMD);
            FisException ex;
            List<string> erpara = new List<string>();
            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            string returnstring = "OK";
            try
            {
                if (strCMD == "LOCK") //Update Lot.Status=3
                {
                    LotInfo setLotInfo = new LotInfo();
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    setLotInfo.status = "3";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    iMBRepository.UpdateLotInfo(setLotInfo, conLotInfo);
                }
                else if (strCMD == "UNLOCK") //Update Lot.Status=2
                {
                    LotInfo setLotInfo = new LotInfo();
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    setLotInfo.status = "2";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    iMBRepository.UpdateLotInfo(setLotInfo, conLotInfo);
                }
                else if (strCMD == "UNDO")
                {
                    UnitOfWork uow = new UnitOfWork();
                    //	Update Lot.Status=4
                    LotInfo setLotInfo = new LotInfo();
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    setLotInfo.status = "4";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    iMBRepository.UpdateLotInfoDefered(uow,setLotInfo, conLotInfo);
                    //Update PCBStatus where PCBNo in PCBLot.PCBNo and PCBLot.Status=1 and LotNo=#LotNo Station=10 Status=1
                    PcblotInfo conupPcblot = new PcblotInfo();
                    conupPcblot.lotNo= LotNo;
                    conupPcblot.status = "1";
                    IList<PcblotInfo> upPcblotLst = new List<PcblotInfo>();
                    upPcblotLst = iMBRepository.GetPcblotInfoList(conupPcblot);
                    if ((upPcblotLst == null) || (upPcblotLst.Count == 0))
                    {

                    }
                    else
                    {
                        for (int i = 0; i < upPcblotLst.Count; i++)
                        {
                            IMB mb = iMBRepository.Find(upPcblotLst[i].pcbno);
                            if (mb != null)
                            {
                                mb.MBStatus.Station = "10";
                                mb.MBStatus.Status = MBStatusEnum.Pass;
                                mb.MBStatus.Editor = editor;
                                mb.MBStatus.Udt = DateTime.Now;
                                //记录MB Log 	Insert PCBLog  Station=’31A’ Status=’0’ PdLine=‘UNDO
                                MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "31A", (int)MBStatusEnum.Fail, "UNDO", editor, new DateTime());
                                mb.AddLog(mb_log);
                                iMBRepository.Update(mb, uow);
                            }
                        }
                    }
                    //	Update PCBLot.Status=0
                    PcblotInfo conPcblot = new PcblotInfo();
                    PcblotInfo setPcblot = new PcblotInfo();
                    conPcblot.lotNo = LotNo;
                    setPcblot.status = "0";
                    iMBRepository.UpdatePCBLotInfoDefered(uow, setPcblot, conPcblot);
                    uow.Commit();
                }
                else if (strCMD == "PASS")
                {
                    //	若当前Lot.Status=’3’,则报错:“该Lot已锁定,请解锁后再做放行”
                    LotInfo conLotInfo = new LotInfo();
                    conLotInfo.lotNo = LotNo;
                    IList<LotInfo> getLotInfo = iMBRepository.GetlotInfoList(conLotInfo);
                    if (getLotInfo[0].status == "3")
                    {
                        erpara.Add(LotNo);
                        ex = new FisException("CHK319", erpara); //该Lot已锁定,请解锁后再做放行!
                        throw ex;
                    }
                    //	获取LotSetting.FailQty(先用PdLine检索,若不存在,再用’ALL’检索,若不存在,则报错:“请IE维护LotSetting”)
                    LotSettingInfo conlotSetting = new LotSettingInfo();
                    int failQtyforLine = 0;
                    conlotSetting.line = getLotInfo[0].line;
                    conlotSetting.type = getLotInfo[0].type;
                    IList<LotSettingInfo> LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                    if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                    {
                        conlotSetting = new LotSettingInfo();
                        conlotSetting.line = "ALL";
                        conlotSetting.type = getLotInfo[0].type;
                        LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                        if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                        {
                            //报错:“请与IE联系,维护 Lot 相关设置”
                            List<string> errpara = new List<string>();
                            errpara.Add(LotNo);
                            ex = new FisException("CHK278", errpara);
                            throw ex;
                        }
                        else
                        {
                            failQtyforLine = LotSettinglst[0].failQty;
                        }
                    }
                    else
                    {
                        failQtyforLine = LotSettinglst[0].failQty;
                    }
                    //	获取当前Lot的PCBLot.Status=0的数量@CNT,
                    //若@CNT大于或者等于LotSetting.FailQty,则Update Lot.Status=3,并提示:“该Lot抽检失败的数量过多,已被锁定”;
                    PcblotInfo conpassPcblot = new PcblotInfo();
                    conpassPcblot.lotNo = LotNo;
                    conpassPcblot.status = "0";
                    IList<PcblotInfo> passPcblotLst = new List<PcblotInfo>();
                    int pcbfailCount = 0;
                    passPcblotLst = iMBRepository.GetPcblotInfoList(conpassPcblot);
                    if ((passPcblotLst == null) || (passPcblotLst.Count == 0))
                    {
                        pcbfailCount = 0;
                    }
                    else
                    {
                        pcbfailCount = passPcblotLst.Count;
                    }
                    //int pcbfailCount = passPcblotLst.Count;
                    if (pcbfailCount >= failQtyforLine)
                    {
                        LotInfo setfailLotInfo = new LotInfo();
                        LotInfo confailLotInfo = new LotInfo();
                        confailLotInfo.lotNo = LotNo;
                        setfailLotInfo.status = "3";
                        setfailLotInfo.editor = editor;
                        setfailLotInfo.udt = DateTime.Now;
                        iMBRepository.UpdateLotInfo(setfailLotInfo, confailLotInfo);
                        List<string> errpara = new List<string>();
                        errpara.Add(LotNo);
                        ex = new FisException("CHK318", errpara);//该Lot抽检失败的数量过多,已被锁定
                        throw ex;
                    }
                    else
                    {
                        //Update Lot.Status=9;
                        UnitOfWork uof = new UnitOfWork(); 
                        LotInfo setfailLotInfo = new LotInfo();
                        LotInfo confailLotInfo = new LotInfo();
                        confailLotInfo.lotNo = LotNo;
                        setfailLotInfo.status = "9";
                        setfailLotInfo.editor = editor;
                        setfailLotInfo.udt = DateTime.Now;
                        iMBRepository.UpdateLotInfoDefered(uof,setfailLotInfo, confailLotInfo);
                        // Update PCBStatus where PCBNo in PCBLot.PCBNo and PCBLot.Status=1 (Station=31 and Status=1);
                        // Insert PCBLog (Station=31 and Status=1)
                        //UpdatePCBStatus(PCBStatusInfo setValue, PCBStatusInfo condition)
                        PcblotInfo conupPcblot = new PcblotInfo();
                        conupPcblot.lotNo = LotNo;
                        conupPcblot.status = "1";
                        IList<PcblotInfo> upPcblotLst = new List<PcblotInfo>();
                        upPcblotLst = iMBRepository.GetPcblotInfoList(conupPcblot);
                        if ((upPcblotLst == null) || (upPcblotLst.Count == 0))
                        {

                        }
                        else
                        {
                             for (int i = 0; i < upPcblotLst.Count; i++)
                            {
                                IMB mb = iMBRepository.Find(upPcblotLst[i].pcbno);
                                if (mb != null)
                                {
                                    //UC Update  
                                    //Update PCBStatus where PCBNo in PCBLot.PCBNo and PCBLot.Status=1 and  
                                    //Station=31A and Status=1【2012-6-20】 (Station=31 and Status=1);
                                    if ((mb.MBStatus.Station == "31A") && (mb.MBStatus.Status == MBStatusEnum.Pass))
                                    {
                                        mb.MBStatus.Station = "31";
                                        mb.MBStatus.Status = MBStatusEnum.Pass;
                                        mb.MBStatus.Editor = editor;
                                        mb.MBStatus.Udt = DateTime.Now;
                                        //记录MB Log 	Insert PCBLog (Station=31 and Status=1)
                                        MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "31", (int)MBStatusEnum.Pass, line, editor, new DateTime());
                                        mb.AddLog(mb_log);
                                        iMBRepository.Update(mb, uof);
                                    }
                                }
                            }
                        }
                        uof.Commit();
                    }

                }
                return returnstring;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(PCAOQCInputImpl)save end,"
                   + " LotNo: " + LotNo
                   + " KeyCode:" + strCMD);
            }
        }
Пример #3
0
        /// <summary>
        /// 添加日志。
        /// </summary>
        /// <param name="log">日志对象</param>
        public void AddLog(MBLog log)
        {
            if (log == null)
                return;

            lock (_syncObj_logs)
            {
                if (this._logs == null)
                {
                    this._logs = new List<MBLog>();
                }

                object naught = this.MBLogs;
                if (this._logs.Contains(log))
                    return;

                log.Tracker = this._tracker.Merge(log.Tracker);
                this._logs.Add(log);
                this._tracker.MarkAsAdded(log);
                this._tracker.MarkAsModified(this);
            }
        }
Пример #4
0
        /// <summary>
        /// Save MB for RCTO MB Change
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            MB currentMB = CurrentSession.GetValue(Session.SessionKeys.MB) as MB;
            string currentNewMBSno = CurrentSession.GetValue(Session.SessionKeys.MBSN) as string;
            
            //2012-9-7, Jessica Liu
            string oldMBSno = currentMB.Sn;

            if (currentMB == null)
            {
                throw new NullReferenceException("MB in session is null");
            }

            bool isMatch = false;
            PCBStatusInfo tempPCBStatusInfo = new PCBStatusInfo();
            PCBStatusInfo tempCond = new PCBStatusInfo();
            IMBRepository CurrentRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            IList<MBLog> MBLogList = CurrentRepository.GetMBLog(currentMB.Sn, "1A", 1);
            if (MBLogList != null && MBLogList.Count > 0)
            {
                IList<Repair> tempRepairLst = CurrentRepository.GetPcbRepairList(currentMB.Sn, "15");
                if (tempRepairLst != null && tempRepairLst.Count > 0)
                {
                    isMatch = false;
                }
                else
                {
                    isMatch = true;

                    /* 2012-9-7, Jessica Liu, UC变更:Save时,满足条件I不再进行Station=10的设置
                    //update PCBStatus(PCBNo=@NewMBSN, Station=10, Editor, Udt; Condition: PCBNo=@MBSN)                   
                    tempPCBStatusInfo.station = "10";
                    */
                }

                IList<TestLog> lstalltestlog = CurrentRepository.GetPCBTestLogListFromPCBTestLogByType(currentMB.Sn, 1, "M/B");
                if (lstalltestlog != null && lstalltestlog.Count > 0)
                {
                    isMatch = true;
                }
                else
                {
                    isMatch = true;

                    //update PCBStatus(PCBNo=@NewMBSN, Station=10, Editor, Udt; Condition: PCBNo=@MBSN)                   
                    tempPCBStatusInfo.station = "10";
                }

            }
            else
            {
                if (currentMB.MBStatus.Station == "10" || currentMB.MBStatus.Station == "15" || currentMB.MBStatus.Station == "31")
                {
                    isMatch = true;

                    //update PCBStatus(PCBNo=@NewMBSN, Station=10, Editor, Udt; Condition: PCBNo=@MBSN)                   
                    tempPCBStatusInfo.station = "10";
                }
            }

            if (isMatch)
            {
                //update PCB(PCBNo=@NewMBSN, Udt; Codition: PCBNo=@MBSN)           
                PcbEntityInfo tempPcbInfo = new PcbEntityInfo();
                tempPcbInfo.pcbno = currentNewMBSno;
                PcbEntityInfo cond = new PcbEntityInfo();
                cond.pcbno = currentMB.Sn;
                CurrentRepository.UpdatePcb(tempPcbInfo, cond);
                
                //update PCBInfo(PCBNo=@NewMBSN, Editor, Udt; Condition: PCBNo=@MBSN)
                IMES.FisObject.PCA.MB.MBInfo tempMBInfo = new IMES.FisObject.PCA.MB.MBInfo();
                tempMBInfo.PCBID = currentNewMBSno;
                tempMBInfo.Editor = this.Editor;
                tempMBInfo.Udt = DateTime.Now;
                IMES.FisObject.PCA.MB.MBInfo MBCond = new IMES.FisObject.PCA.MB.MBInfo();
                MBCond.PCBID = currentMB.Sn;
                CurrentRepository.UpdatePcbInfo(tempMBInfo, MBCond);

                //update PCBStatus(PCBNo=@NewMBSN, Station=10, Editor, Udt; Condition: PCBNo=@MBSN)
                //或update PCBStatus(PCBNo=@NewMBSN, Editor, Udt; Condition: PCBNo=@MBSN)
                tempPCBStatusInfo.pcbno = currentNewMBSno;
                tempPCBStatusInfo.editor = this.Editor;
                tempPCBStatusInfo.udt = DateTime.Now;
                tempCond.pcbno = currentMB.Sn;
                CurrentRepository.UpdatePCBStatus(tempPCBStatusInfo, tempCond);    


                //Insert PCBInfo (PCBNo=@NewMBSN;InfoType=’RCTOChange’;InfoValue=@MBSN)
                IMES.FisObject.PCA.MB.MBInfo mbctInfo = new IMES.FisObject.PCA.MB.MBInfo(
                            0, 
                            currentNewMBSno, 
                            "RCTOChange", 
                            currentMB.Sn, 
                            this.Editor, 
                            DateTime.Now, 
                            DateTime.Now);
                //2012-9-7, Jessica Liu
                //currentMB.AddMBInfo(mbctInfo);
                CurrentRepository.AddMBInfoesDefered(CurrentSession.UnitOfWork, new IMES.FisObject.PCA.MB.MBInfo[] { mbctInfo });

                //Insert PCBLog(PCBNo=@NewMBSN; Station=PCBStatus.Station; Line=[Select Line]; Status=1)
                //line = string.IsNullOrEmpty(this.Line) ? currentMB.MBStatus.Line : this.Line;
                
                //ITC-1428-0027, Jessica Liu, 2012-9-12
                string currentStation = "";
                if (string.IsNullOrEmpty(tempPCBStatusInfo.station))
                {
                    currentStation = currentMB.MBStatus.Station;
                }
                else
                {
                    currentStation = tempPCBStatusInfo.station;
                }

                var mbLog = new MBLog(
                    0,
                    currentNewMBSno,
                    currentMB.Model,
                    //ITC-1428-0027, Jessica Liu, 2012-9-12
                    //currentMB.MBStatus.Station,
                    currentStation,
                    1,
                    this.Line,  //line,
                    this.Editor,
                    DateTime.Now);
                //2012-9-7, Jessica Liu
                //currentMB.AddLog(mbLog);
                CurrentRepository.AddMBLogsDefered(CurrentSession.UnitOfWork, new MBLog[] { mbLog });

                CurrentRepository.Update(currentMB, CurrentSession.UnitOfWork);
            }
            else
            {
                throw new FisException("CHK944", new string[] { }); //流程错误,请确定MB的状态!
            }

            //2012-9-7, Jessica Liu
            CurrentSession.AddValue(Session.SessionKeys.PrintLogName, "RCTO MB Label");
            CurrentSession.AddValue(Session.SessionKeys.PrintLogBegNo, currentNewMBSno);
            CurrentSession.AddValue(Session.SessionKeys.PrintLogEndNo, currentNewMBSno);
            CurrentSession.AddValue(Session.SessionKeys.PrintLogDescr, oldMBSno);

            return base.DoExecute(executionContext);
        }
Пример #5
0
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            try
            {
                IRepairTarget repairTarget = GetRepairTarget();
                RepairDefect defect;
                defect = (RepairDefect)CurrentSession.GetValue(Session.SessionKeys.CurrentRepairdefect);
                IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
                          
                //bool bSearch = false;
                bool bLCMType = false;
                
                //IList<IProductPart> productParts = product.ProductParts;
                IList<IProductPart> productParts = (IList<IProductPart>)CurrentSession.GetValue(ExtendSession.SessionKeys.ProductPart);
                bool isReleaseMB = (bool)CurrentSession.GetValue(ExtendSession.SessionKeys.ReleaseMB);
                bool isReleasePart = (bool)CurrentSession.GetValue(ExtendSession.SessionKeys.ReleasePart);
                CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, "");
                if (isReleaseMB) //MB
                {
                    CurrentSession.AddValue(Session.SessionKeys.OldMB, product.PCBID);

                    product.PCBID = "";
                    defect.PartType = "MB";
                    product.PCBModel = null;
                    product.MAC = null;
                    product.UUID = null;
                    product.MBECR = null;
                    product.CVSN = null;
                    //解綁MB要同時解綁 BATT
                    //20110615 只要有换MB/LCM/Battery三者中任意一个,都需要把机器原来结合的MB/LCM/Battery解掉,然后重BoardInput(40)站重流
                    foreach (ProductPart part in productParts)
                    {
                        //if (part.Value.Trim() == defect.OldPartSno.Trim())
                       // {
                            //CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, part.PartType);
                            /*if (part.PartType.Trim() == "BATT")
                            {
                                product.RemovePart(part.Value, part.PartID);
                                break;
                            }*/
                        //}
                        product.RemovePart(part.Value, part.PartID); // Dean 20110715 解綁MB要同時解綁 BATT/LCM1/LCM2
                    }
                    
                    CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, "MB");
                }
                else if (isReleasePart)
                {
                    // Dean 20110715 解綁LCM1/LCM2/BATT 要同時解綁MB,並且還是更新PCBStatus=30                    
                    var mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                    var mb = mbRepository.Find(product.PCBID);

                    if (mb == null)
                    {
                        var ex = new FisException("SFC001", new string[] { mb.Sn });
                        throw ex;
                    }

                    var PCBStatus = new MBStatus(mb.Sn, "30", MBStatusEnum.Pass, this.Editor, mb.MBStatus.Line, mb.MBStatus.Cdt, DateTime.Now);
                    mb.MBStatus = PCBStatus;
                    mbRepository.Update(mb, CurrentSession.UnitOfWork);
                    
                    var mbLog = new MBLog(
                        0,
                        mb.Sn,
                        mb.Model,
                        "30",
                        1,
                        mb.MBStatus.Line,
                        this.Editor,
                        DateTime.Now);

                    mb.AddLog(mbLog);
                    mbRepository.Update(mb, CurrentSession.UnitOfWork);

                    product.PCBID = "";                    
                    product.PCBModel = null;
                    product.MAC = null;
                    product.UUID = null;
                    product.MBECR = null;
                    product.CVSN = null;
                    
                    foreach (ProductPart part in productParts)
                    {
                      if (part.Value.Trim() == defect.OldPartSno.Trim())
                      {
                          CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, part.PartType);                          
                          //if (part.PartType != "MB" && part.PartType != "")
                          /*if (part.PartType.Trim() == "LCM1" || part.PartType.Trim() == "LCM2")
                          {
                             bLCMType = true; 
                          }
                          else if (part.PartType.Trim() == "BATT")//先解到BATT本身的
                          {
                              product.RemovePart(part.Value, part.PartID);
                          }
                          break;*/
                          foreach (ProductPart part1 in productParts)
                          {
                              product.RemovePart(part1.Value, part1.PartID);// Dean 20110715 解綁LCM1/LCM2要同時解綁 BATT/LCM1/LCM2
                          }
                          break;
                      }
                    }

                    //remove LCM1 & LCM2
                    /*if (bLCMType)
                    {
                        foreach (ProductPart part in productParts)
                        {
                            //if (part.PartType === "LCM1" || part.PartType == "LCM2")//若是LCM1/LCM2/BATT,要同時解綁
                            //解綁LCM1或LCM2要同時解綁LCM1/LCM2/BATT(若是LCM1/LCM2/BATT,要同時解綁)
                            if (part.PartType.Trim() != "MB" && part.PartType != "")
                            {
                                product.RemovePart(part.Value, part.PartID);
                            }                           
                        }
                    }*/
                }

                #region original 20110527
                //if (defect.OldPartSno.Trim() != "") //MB/LCM1/LCM2
                //{                    
                //    //MB 
                //    if (defect.OldPart.Trim() != "" && product.PCBModel.Trim() == defect.OldPart.Trim() ||
                //         defect.OldPartSno.Trim() != "" && product.PCBID.Trim() == defect.OldPartSno.Trim())
                //    {
                //        //Dean 20110516 即當Faulty Part NO ,Faulty Part Sn 和Product_Part中的數據不匹配
                //        if (defect.OldPart.Trim() != "" && defect.OldPartSno.Trim() != "")
                //        {
                //            if (product.PCBModel == defect.OldPart.Trim() &&
                //                    product.PCBID.Trim() == defect.OldPartSno.Trim())
                //            {
                //                CurrentSession.AddValue(Session.SessionKeys.OldMB, product.PCBID);

                //                product.PCBID = "";
                //                defect.PartType = "MB";
                //                product.PCBModel = null;
                //                product.MAC = null;
                //                product.UUID = null;
                //                product.MBECR = null;
                //                product.CVSN = null;
                //                CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, "MB");                                
                //                //bSearch = true;
                //            }
                //            else//兩個都有欄,但不匹配的ErrorMessage
                //            {
                //                List<string> errpara = new List<string>();

                //                errpara.Add(defect.OldPartSno);
                //                FisException e = new FisException("MAT010", errpara);
                //                e.stopWF = false;
                //                throw e;                                
                //            }
                //        }
                //        else //only sn check 
                //        {
                //            CurrentSession.AddValue(Session.SessionKeys.OldMB, product.PCBID);

                //            product.PCBID = "";
                //            defect.PartType = "MB";
                //            product.PCBModel = null;
                //            product.MAC = null;
                //            product.UUID = null;
                //            product.MBECR = null;
                //            product.CVSN = null;
                //            CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, "MB");
                //            //bSearch = true;
                //        }
                //    }                    
                //    else//LCM1/LCM2
                //    {                                                
                //        foreach (ProductPart part in productParts)
                //        {
                //            if (defect.OldPart.Trim() != "" && part.PartID.Trim() == defect.OldPart.Trim() ||
                //                defect.OldPartSno.Trim() != "" && part.Value.Trim() == defect.OldPartSno.Trim())
                //            {
                //                //Dean 20110516 即當Faulty Part NO ,Faulty Part Sn 和Product_Part中的數據不匹配
                //                if (defect.OldPart.Trim() != "" && defect.OldPartSno.Trim() != "")
                //                {                                    
                //                    if (part.PartID == defect.OldPart.Trim() &&
                //                        part.Value.Trim() == defect.OldPartSno.Trim())
                //                    {                                                                                                                    
                //                        //product.RemovePart(part.Value, part.PartID);
                //                        defect.PartType = part.PartType;
                //                        CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, part.PartType);

                //                        if (part.PartType == "LCM1" || part.PartType=="LCM2")
                //                        {
                //                            bLCMType = true; 
                //                        }
                //                        else
                //                        {
                //                            product.RemovePart(part.Value, part.PartID);
                //                        }
                //                        //if (!RemoveLCM1 && part.PartType == "LCM1") RemoveLCM1 = true;
                //                        //if (!RemoveLCM2 && part.PartType == "LCM2") RemoveLCM2 = true; 
                //                        bSearch = true;
                //                        break;
                //                    }
                //                    else //兩個都有欄,但不匹配的ErrorMessage
                //                    {
                //                        List<string> errpara = new List<string>();

                //                        errpara.Add(defect.OldPartSno);

                //                        FisException e = new FisException("MAT010", errpara);
                //                        e.stopWF = false;
                //                        throw e;
                //                    }
                //                }
                //                else //only sn check 
                //                {                                    
                //                    //product.RemovePart(part.Value, part.PartID);
                //                    defect.PartType = part.PartType;
                //                    CurrentSession.AddValue(ExtendSession.SessionKeys.PartType, part.PartType);
                //                    if (part.PartType == "LCM1" || part.PartType == "LCM2")
                //                    {
                //                        bLCMType = true;
                //                    }
                //                    else
                //                    {
                //                        product.RemovePart(part.Value, part.PartID);
                //                    }

                //                    bSearch = true;
                //                    //if (!RemoveLCM1 && part.PartType == "LCM1") RemoveLCM1 = true;
                //                    //if (!RemoveLCM2 && part.PartType == "LCM2") RemoveLCM2 = true; 
                //                    break;
                //                }
                //            }
                //        }

                //        if (!bSearch)
                //        {
                //            List<string> errpara = new List<string>();

                //            errpara.Add(defect.OldPart);


                //            FisException e = new FisException("CHK027", errpara);
                //            e.stopWF = false;
                //            throw e;
                //            //throw new FisException("CHK027", errpara);
                //        }
                //        else if (bLCMType)
                //        {
                //            foreach (ProductPart part in productParts)
                //            {                                
                //                if (part.PartType == "LCM1" || part.PartType == "LCM2")
                //                {
                //                    product.RemovePart(part.Value, part.PartID);
                //                }
                //                /*if (RemoveLCM1 || RemoveLCM2)
                //                {
                //                    if ((RemoveLCM1  && part.PartType == "LCM2") ||
                //                        (RemoveLCM2 & part.PartType == "LCM1"))
                //                    {
                //                        product.RemovePart(part.Value, part.PartID);
                //                    }
                //                }*/
                //            }
                //        }


                //    }
                //    #region Remark
                //    /*if (!bSearch)
                //    {
                //        List<string> errpara = new List<string>();

                //        errpara.Add(defect.OldPart);

                //        FisException e = new FisException("CHK027", errpara);
                //        e.stopWF = false;
                //        throw e;
                //        //throw new FisException("CHK027", errpara);
                //    }
                //   else
                //    {
                //        foreach (ProductPart part in productParts)
                //        {
                //            if (part.PartType == "LCM1" || part.PartType == "LCM2")
                //            {
                //                product.RemovePart(part.Value, part.PartID);
                //            }
                //        }
                //    }*/
                //#endregion
                //}
               
                //oldPart=partRep.GetPartByPartNo(defect.OldPartSno);                                                                         

                //if (oldPart == null)//Dean 20110427
                //{
                //    List<string> errpara = new List<string>();

                //    errpara.Add(defect.OldPart);

                //    throw new FisException("CHK027", errpara);

                //}

                //if (string.Compare(FaRepairStation, Station, true) == 0)
                //{
                //    if (string.Compare(oldPart.Type, "MB", true) == 0)
                //    {
                //        IMBRepository imr = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                //        IProduct tempProduct = ((IProduct)repairTarget);

                //        //update Product table
                //        tempProduct.PCBID = null;
                //        //PCBModel, MAC, UUID, MBECR, CVSN 2010-03
                //        tempProduct.PCBModel = null;
                //        tempProduct.MAC = null;
                //        tempProduct.UUID = null;
                //        tempProduct.MBECR = null;
                //        tempProduct.CVSN = null;
                //    }
                //    else if (string.Compare(oldPart.Type, "LCM1", true) == 0 || string.Compare(oldPart.Type, "LCM2", true) == 0)
                //    {
                //        List<string> partTypeList = new List<string> {"LCM1", "LCM2"};
                //        productRep.DeleteProductPartByPartTypeDefered(CurrentSession.UnitOfWork, ((IProduct)repairTarget).ProId, partTypeList);
                //    }
                //}
                #endregion original 20110527
                if (isReleaseMB ||isReleasePart)
                    productRep.Update(product, CurrentSession.UnitOfWork);
                return base.DoExecute(executionContext);
            }
            catch (FisException ex)
            {
                throw;
            }
        }
Пример #6
0
        /// <summary>
        /// 找到DISMANTLE Process,得到对应的Release Type,解除绑定关系
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            List<string> erpara = new List<string>();
            var currentProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
           
            //更新PCBStatus信息
            //bug:ITC-1268-0006
            //reason:先进行mb的处理
            //MB则通过Product.PCBID找到PCBNO
            var mbsn = currentProduct.PCBID.Trim();
            if (!string.IsNullOrEmpty(mbsn))
            {
                //MB状态修改为30 站
                IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                IMB mb = mbRepository.Find(mbsn);
                if (mb == null)
                {
                    var ex1 = new FisException("SFC001", new string[] { mbsn });
                    throw ex1;
                }
                string line = string.IsNullOrEmpty(this.Line) ? mb.MBStatus.Line : this.Line;
                //var mbLog = new MBLog(0, mb.Sn, mb.Model, "30", 1, line, this.Editor, DateTime.Now);
                var mbLog = new MBLog(0, mb.Sn, mb.Model, "DM", 1, line, this.Editor, DateTime.Now);
                mb.AddLog(mbLog);
                //2012/3/15	For MB :Update PCA..PCBStatus.Station=30->15
                //mb.MBStatus.Station = "30";
                mb.MBStatus.Station = "15";
                //DEBUG:ITC-1360-0105 update status =1
                mb.MBStatus.Status = MBStatusEnum.Pass;
                mb.MBStatus.Editor = this.Editor;
                
                //mb.MBStatus.Udt = DateTime.Now;

                mbRepository.Update(mb, CurrentSession.UnitOfWork);
               
            }
            //DEBUG ITC-1360-0403
            //	如果是VGA 则通过ProductInfo ProductID=PRDID# ValueType=’VGA’找到
            IList<IMES.FisObject.FA.Product.ProductInfo> infos = new List<IMES.FisObject.FA.Product.ProductInfo>();
            infos = currentProduct.ProductInfoes;
            var mbsnforVGA = "";
            foreach (IMES.FisObject.FA.Product.ProductInfo iInfo in infos)
            {
                if (iInfo.InfoType.Trim().ToUpper() == "VGA")
                {
                    mbsnforVGA = iInfo.InfoValue.Trim();
                    break;
                }
            }
            if (!string.IsNullOrEmpty(mbsnforVGA))
            {
                //MB状态修改为30 站
                IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                IMB mbVGA = mbRepository.Find(mbsnforVGA);
                if (mbVGA == null)
                {
                    var ex1 = new FisException("SFC001", new string[] { mbsnforVGA });
                    throw ex1;
                }
                string line = string.IsNullOrEmpty(this.Line) ? mbVGA.MBStatus.Line : this.Line;
                //var mbLog = new MBLog(0, mb.Sn, mb.Model, "30", 1, line, this.Editor, DateTime.Now);
                var mbLog = new MBLog(0, mbVGA.Sn, mbVGA.Model, "DM", 1, line, this.Editor, DateTime.Now);
                mbVGA.AddLog(mbLog);
                //2012/3/15	For VGA :Update PCA..PCBStatus.Station=30
                mbVGA.MBStatus.Station = "30";
                //DEBUG:ITC-1360-0105 update status =1
                mbVGA.MBStatus.Status = MBStatusEnum.Pass;
                mbVGA.MBStatus.Editor = this.Editor;

                //mb.MBStatus.Udt = DateTime.Now;

                mbRepository.Update(mbVGA, CurrentSession.UnitOfWork);

            }

            //更新Product表,将初始化Product表的剩余字段(供travel card用的)字段保留,其余都清空
            //MO,Model,ProductID,ECR字段不清空 
            //	Update set is null Product.PCBID/PCBModel/MBECR /MAC /CVSN
            currentProduct.PCBID = "";
            currentProduct.PCBModel = "";
            currentProduct.MBECR = "";
            currentProduct.MAC = "";
            //new del currentProduct.UUID = "";
            currentProduct.CVSN = "";
            currentProduct.CUSTSN = "";
            //currentProduct.BIOS = ""; why?
            //currentProduct.IMGVER = "";
            //currentProduct.WMAC = "";
            //currentProduct.IMEI = "";
            //currentProduct.MEID = "";
            //currentProduct.ICCID = "";
            //currentProduct.COAID = "";
            //new del currentProduct.PizzaID = "";
            //new del currentProduct.UnitWeight = 0.0M;
            //new del currentProduct.CartonSN = "";
            //new del currentProduct.CartonWeight = 0.0M;
            //new del currentProduct.DeliveryNo = "";
            //new del currentProduct.PalletNo = "";
            //currentProduct.HDVD = "";
            //currentProduct.BLMAC = "";
            //currentProduct.TVTuner = "";
            productRepository.Update(currentProduct, CurrentSession.UnitOfWork);
            //B.删除Product_Part表
            productRepository.DeleteProductPartByProIdDefered(CurrentSession.UnitOfWork,currentProduct.ProId);

            //C.删除ProductInfo表
            productRepository.DeleteProductInfoByProIdDefered(CurrentSession.UnitOfWork, currentProduct.ProId);

            return base.DoExecute(executionContext);
        }
Пример #7
0
        /// <summary>
        /// 找到DISMANTLE Process,得到对应的Release Type,解除绑定关系
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            List<string> erpara = new List<string>();
            var currentProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
          
			//若Product.PCBID不为空,则Update PCBStatus Set Station=’31’ where PCBNo = Product.PCBID 注意,不更新Line
			//Insert PCBLog 若Product.PCBID不为空,则插入PCBLog(Station=’38’ and Status=1 and Line = PCBStatus.Line)
            var mbsn = currentProduct.PCBID.Trim();
            if (!string.IsNullOrEmpty(mbsn))
            {
                IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                IMB mb = mbRepository.Find(mbsn);
                if (mb == null)
                {
                    var ex1 = new FisException("SFC001", new string[] { mbsn });
                    throw ex1;
                }
                string line = mb.MBStatus.Line;//string.IsNullOrEmpty(this.Line) ? mb.MBStatus.Line : this.Line;
                //var mbLog = new MBLog(0, mb.Sn, mb.Model, "30", 1, line, this.Editor, DateTime.Now);
                var mbLog = new MBLog(0, mb.Sn, mb.Model, "38", 1, line, this.Editor, DateTime.Now);
                mb.AddLog(mbLog);
                //2012/3/15	For MB :Update PCA..PCBStatus.Station=30->15
                //mb.MBStatus.Station = "30";
                mb.MBStatus.Station = "31";
                //DEBUG:ITC-1360-0105 update status =1  ???????UC??
                mb.MBStatus.Status = MBStatusEnum.Pass;
                mb.MBStatus.Editor = this.Editor;
                mb.MBStatus.Udt = DateTime.Now;  //update????
                mbRepository.Update(mb, CurrentSession.UnitOfWork);
               
            }
		    //Update Product Update PCBID, PCBModel, MAC, UUID, MBECR, CVSN, CUSTSN, ECR 为空
            currentProduct.PCBID = "";
            currentProduct.PCBModel = "";
            currentProduct.MAC = "";
			currentProduct.UUID ="";
			currentProduct.MBECR = "";
            //new del currentProduct.UUID = "";
            currentProduct.CVSN = "";
            currentProduct.CUSTSN = "";
			currentProduct.ECR = "";
			productRepository.Update(currentProduct, CurrentSession.UnitOfWork);
            //B.删除Product_Part表
            productRepository.DeleteProductPartByProIdDefered(CurrentSession.UnitOfWork,currentProduct.ProId);

            //C.删除ProductInfo表
            productRepository.DeleteProductInfoByProIdDefered(CurrentSession.UnitOfWork, currentProduct.ProId);

            return base.DoExecute(executionContext);
        }
Пример #8
0
        /// <summary>
        /// Bind pat to owner:
        /// A.Product.PCBID=mb sn#
        ///B.需要修改MB 的PCA..PCBStatus.Station = 32
        ///C.记录MB Log  Inert PCA..PCBLog
        ///D.将MB相关信息写入Product表:
        ///Product.PCBModel=PCA..PCB.PCBModelID
        ///Product. MAC =PCA..PCB. MAC
        ///Product. UUID =PCA..PCB. UUID
        ///Product. MBECR =PCA..PCB. ECR
        /// </summary>
        /// <param name="part">part</param>
        /// <param name="owner">owner</param>
        public override void BindTo(IProductPart part, IPartOwner owner)
        {
//            if (!part.ValueType.Equals(("SN")))
//            {
//                base.BindTo(part, owner);
//                return;
//            }

            var product = (IProduct)owner;
            Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product);
            var productRepoistory = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            var mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            var mb = mbRepository.Find(part.Value);

            string line = string.IsNullOrEmpty(session.Line) ? product.Status.Line : session.Line;

            //A
            product.PCBID = mb.Sn;

            //B
            var status = new MBStatus(mb.Key.ToString(), "32", MBStatusEnum.Pass , session.Editor, line, DateTime.Now, DateTime.Now);
            mb.MBStatus = status;

            //C
            var mbLog = new MBLog(
                0,
                mb.Sn,
                mb.Model,
                "32",
                1,
                line,
                session.Editor,
                DateTime.Now);

            mb.AddLog(mbLog);

            //D
            product.PCBModel = mb.Model;
            product.MAC = mb.MAC;
            product.UUID = mb.UUID;
            product.MBECR = mb.ECR;
            product.CVSN = mb.CVSN;

            mbRepository.Update(mb, session.UnitOfWork);
            productRepoistory.Update(product, session.UnitOfWork);
            
        }
Пример #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Session session = CurrentSession;
            ActivityCommonImpl utl = ActivityCommonImpl.Instance;
            IMB parentMB = utl.IsNull<IMB>(session, Session.SessionKeys.MB);
          
            IList<String> sbSNList = session.GetValue(ExtendSession.SessionKeys.SmallBoardSNList) as IList<string>;

            if (sbSNList == null || sbSNList.Count == 0)
            {
                return base.DoExecute(executionContext);
            }


            IList<String> smallBoardPartNoList = utl.IsNull <IList<String>>(session, ExtendSession.SessionKeys.SmallBoardPartNoList) as IList<string>;
            IList<String> smallBoardECRList = utl.IsNull <IList<String>>(session, ExtendSession.SessionKeys.SmallBoardECRList) as IList<string>;

            string moNo = parentMB.SMTMO;            
            string custSn = string.Empty;
            string custVer = string.Empty;
            string cvsn = parentMB.Sn;
            string uuid = string.Empty;
             string mac = string.Empty;
            string dateCode = session.GetValue(Session.SessionKeys.DCode) as string;
            //string ecr = session.GetValue(Session.SessionKeys.ECR) as string;
            //string iecVer = session.GetValue(Session.SessionKeys.IECVersion) as string;

            var sbMBList = new List<IMB>();
            session.AddValue(ExtendSession.SessionKeys.SmallBoardMBList, sbMBList);

            IMBRepository mbRep = utl.mbRep;

            IPrintLogRepository LogRep = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>();
            int index=0;    
            foreach (string sn in sbSNList)
            {
                string model = smallBoardPartNoList[index];
                string[] ecrList = smallBoardECRList[index].Split(GlobalConstName.SlashChar);
                string ecr = ecrList[0];
                string iecVer = ecrList[1];
                string[] sbSN = sn.Split(GlobalConstName.SlashChar);
                MB mb = new MB(sbSN[0], moNo, custSn, model, dateCode, mac, uuid, ecr, iecVer, custVer, cvsn, DateTime.Now, DateTime.Now);
                MBStatus mbStatus = new MBStatus(sbSN[0], this.Station, MBStatusEnum.Pass, this.Editor, this.Line, DateTime.Now, DateTime.Now);
                mb.MBStatus = mbStatus;   

                MBLog newLog = new MBLog(0, mb.Sn, mb.Model, Station, 1, Line, Editor, DateTime.Now);
                mb.AddLog(newLog);
                if (this.IsSplitMB)
                {
                    mb.SetExtendedProperty(ConstName.PCBInfo.ChildMBSN, sbSN[1], this.Editor);
                }
                else
                {
                    mb.SetExtendedProperty(ConstName.PCBInfo.ChildMBSN, parentMB.Sn, this.Editor);
                }
                mb.SetExtendedProperty(ConstName.PCBInfo.ParentMBSN, parentMB.Sn, this.Editor);
                mb.SetExtendedProperty(ConstName.PCBInfo.IsSmallBoard, ConstName.Letter.Y, this.Editor);
                mbRep.Add(mb, session.UnitOfWork);
                sbMBList.Add(mb);

                var item = new PrintLog
                {
                    Name = PrintLogName,
                    BeginNo = sn,
                    EndNo = sn,
                    Station = this.Station,
                    Cdt = DateTime.Now,
                    LabelTemplate = string.Empty,
                    Descr =string.Format(PrintLogDescr,mb.Sn, sbSN[1], sbSN[0])  ,
                    Editor = this.Editor
                };

                LogRep.Add(item, session.UnitOfWork);
                
                IMES.FisObject.PCA.MB.MBInfo items = new IMES.FisObject.PCA.MB.MBInfo();
                items.InfoType = ConstName.PCBInfo.ChildMBSN;
                items.InfoValue = mb.Sn;
                items.Editor = this.Editor;
                parentMB.AddMBInfo(items);
                index++;
            }

            return base.DoExecute(executionContext);
        }
Пример #10
0
        /// <summary>
        /// save for Docking MB
        /// </summary>
        /// <param name="partUnit">part Unit</param>
        /// <param name="partOwner">part owner</param>
        /// <param name="station">station</param>
        /// <param name="key">session key</param>
        public void Save(object partUnit, object partOwner, string station, string key)
        {

            if (partUnit == null)
            {
                throw new ArgumentNullException();
            }
            if (partOwner == null)
            {
                throw new ArgumentNullException();
            }

            var product = (Product)partOwner;
            product.PCBID = ((PartUnit)partUnit).Sn;
            Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product);
            if (session == null)
            {
                throw new InstanceNotFoundException("Can not get Session instance from SessionManager!");
            }
            var mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            IMB mb = mbRepository.Find(product.PCBID);
            if (mb != null)
            {
                //Product
                // PCBID: MBSN
                // PCBModel: PCB.PCBModelID
                // MAC: PCB.MAC
                // UUID: PCB.UUID
                // MBECR: PCB.ECR
                // CVSN: PCB.CVSN
                product.PCBModel = mb.PCBModelID;
                product.MAC = mb.MAC;
                product.MBECR = mb.ECR;
                if (!string.IsNullOrEmpty(mb.CVSN))
                {
                    product.CVSN = mb.CVSN;
                }
                product.UUID = mb.UUID;

/*
                //ProductInfo表
                //InfoType=‘IECECR’ 
                //InfoValue= PCB. IECECR
                product.SetExtendedProperty("IECECR", mb.IECVER, session.Editor);
                //ValueType=‘EEPROM’ 
                //InfoValue= PCBInfo.Value(ValueType=‘EEPROM’)
                object eeprom = mb.GetExtendedProperty("EEPROM");
                if (eeprom != null)
                {
                    product.SetExtendedProperty("EEPROM", eeprom, session.Editor);
                }
                //InfoType=’MBCT’
                //InfoValue= PCBInfo.Value(ValueType=‘MBCT’)
                object mbct = mb.GetExtendedProperty("MBCT");
                if (mbct != null)
                {
                    product.SetExtendedProperty("MBCT", mbct, session.Editor);
                }
*/


                ///PCBStatus
                /// PCBStatus.Station=’32’
                /// PCBStatus.Status=1
                /// 
                #region record previous PCB Status
                //IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                //System.Data.DataTable preStatus = CreateProductStatusTb();
                //preStatus.Rows.Add(mb.Sn,
                //                                   mb.MBStatus.Station,
                //                                    mb.MBStatus.Status == MBStatusEnum.Pass ? 1 : 0,
                //                                    "",
                //                                    mb.MBStatus.Line,
                //                                    mb.MBStatus.TestFailCount,
                //                                    mb.MBStatus.Editor,
                //    //mb.MBStatus.Udt.ToString("yyyy-MM-dd HH:mm:ss.fff")
                //                                    mb.MBStatus.Udt
                //                                    );

                //System.Data.DataTable curStatus = CreateProductStatusTb();
                //curStatus.Rows.Add(mb.Sn,
                //                                   "32",
                //                                    1,
                //                                   "",
                //                                   session.Line,
                //                                    mb.MBStatus.TestFailCount,
                //                                   session.Editor,
                //    //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
                //                                   DateTime.Now
                //                                   );

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


                //productRepository.ExecSpForNonQueryDefered(session.UnitOfWork,
                //                                                                                 IMES.Infrastructure.Repository._Schema.SqlHelper.ConnectionString_PCA,
                //                                                                                 "IMES_UpdatePCBStatus",
                //                                                                                para1,
                //                                                                                para2);
                #endregion


                #region recode PCBStatusEx for table structure

                //IMES.DataModel.TbProductStatus preStatus = new IMES.DataModel.TbProductStatus()
                //{
                //    ProductID = mb.Sn,
                //    Line = mb.MBStatus.Line,
                //    ReworkCode = string.Empty,
                //    TestFailCount = mb.MBStatus.TestFailCount,
                //    Station = mb.MBStatus.Station,
                //    Status = (int)mb.MBStatus.Status,
                //    Editor = mb.MBStatus.Editor,
                //    Udt = mb.MBStatus.Udt
                //};
                IList<TbProductStatus> preStatusList = mbRepository.GetMBStatus(new List<string>() { mb.Sn });
                mbRepository.UpdatePCBPreStationDefered(session.UnitOfWork,
                                                                                    preStatusList);
                #endregion

                mb.MBStatus.Station = "32";
                mb.MBStatus.Status = MBStatusEnum.Pass;
                var mbLog = new MBLog(0, mb.Sn, mb.Model, "32", (int)MBStatusEnum.Pass, mb.MBStatus.Line, session.Editor,
                                         new DateTime());
                mb.AddLog(mbLog);
                mbRepository.Update(mb, session.UnitOfWork);
                //IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                //productRepository.Update(product, session.UnitOfWork);

/*
                var setValue = new ProductPart();
                var condition = new ProductPart();
                if (!string.IsNullOrEmpty(mb.CVSN))
                {
                    setValue.PartSn = mb.CVSN;
                    condition.CheckItemType = "CPU";
                    condition.ProductID = product.ProId;
                    productRepository.UpdateProductPartDefered(session.UnitOfWork, setValue, condition);
                }
                if (product.IsCDSI)
                {
                    var item = new SpecialDetInfo { snoId = product.ProId, tp = "CDSI", sno1 = product.MAC, cdt = new DateTime(), id = 0, udt = new DateTime() };
                    productRepository.InsertSpecialDet(item);
                    //                    logger.Debug(" IMES.CheckItemModule.MB.Filter.SaveModule.Save  Time : " + new DateTime());
                }
*/
            }
        }
Пример #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            var CurrentMB = (MB)CurrentSession.GetValue(Session.SessionKeys.MB);

            string ecr = CurrentSession.GetValue(Session.SessionKeys.ECR) as string;
            string iecVer = CurrentSession.GetValue(Session.SessionKeys.IECVersion) as string;
            CurrentMB.ECR = ecr;
            CurrentMB.IECVER = iecVer;

            string mac = CurrentSession.GetValue(Session.SessionKeys.MAC) as string;
            if (!string.IsNullOrEmpty(mac))
            {
                CurrentMB.MAC = mac;
            }
            string dateCode = CurrentSession.GetValue(Session.SessionKeys.DCode) as string;
            if (!string.IsNullOrEmpty(dateCode))
            {
                CurrentMB.DateCode = dateCode;
            }

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

            string eep = CurrentSession.GetValue(Session.SessionKeys.EEP) as string;
            if (!string.IsNullOrEmpty(eep))
            {
                IMES.FisObject.PCA.MB.MBInfo eepInfo = new IMES.FisObject.PCA.MB.MBInfo(0, CurrentMB.Sn, "EEPROM", eep, Editor, DateTime.Now, DateTime.Now);
                CurrentMB.AddMBInfo(eepInfo);
            }

            string mbct = CurrentSession.GetValue(Session.SessionKeys.MBCT) as string;
            if (!string.IsNullOrEmpty(mbct))
            {
                IMES.FisObject.PCA.MB.MBInfo mbctInfo = new IMES.FisObject.PCA.MB.MBInfo(0, CurrentMB.Sn, "MBCT", mbct, Editor, DateTime.Now, DateTime.Now);
                CurrentMB.AddMBInfo(mbctInfo);

                FruDetInfo newFruDet = new FruDetInfo();
                newFruDet.sno = mbct;
                newFruDet.snoId = CurrentMB.Sn;
                newFruDet.tp = "VC";
                newFruDet.editor = Editor;
                newFruDet.cdt = DateTime.Now;
                newFruDet.udt = newFruDet.cdt;
                mbRepository.InsertFruDetInfoDefered(CurrentSession.UnitOfWork, newFruDet);

                MBLog newCTLog = new MBLog(0, CurrentMB.Sn, CurrentMB.Model, "SH", 1, "SA SHIPPING LABEL", Editor, DateTime.Now);
                CurrentMB.AddLog(newCTLog);
            }

            mbRepository.Update(CurrentMB, CurrentSession.UnitOfWork);

            return base.DoExecute(executionContext);
        }
Пример #12
0
        /// <summary>
        /// Update SMTMO
        /// Insert MoDismantleLog
        /// 删除PCB,更新PCBStatus,Insert PCB Log
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            //FisException ex;
            //List<string> erpara = new List<string>();
            
            IList<string> mbsnlist = (List<string>)CurrentSession.GetValue(Session.SessionKeys.MBNOList);
            if (mbsnlist != null && mbsnlist.Count > 0)
            {
                IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();

                ////	Update SMTMO
                IMBMORepository mbmoRepository = RepositoryFactory.GetInstance().GetRepository<IMBMORepository, IMBMO>();
                IMBMO mbmoObject = (IMBMO)CurrentSession.GetValue(Session.SessionKeys.MBMO);
                mbmoObject.PrintedQty = mbmoObject.PrintedQty - mbsnlist.Count;
                CurrentSession.AddValue(Session.SessionKeys.MBMO, mbmoObject);
                mbmoRepository.Update(mbmoObject, CurrentSession.UnitOfWork);
                //	Insert MoDismantleLog
                //	Delete PCB/PCBStatus
                var disReason = CurrentSession.GetValue(Session.SessionKeys.Reason).ToString();               
                IList<MODismantleLog> modislogs = new List<MODismantleLog>();
                IList<IMB> mbs = new List<IMB>();
                IList<MBStatus> mbstatuslist=new List<MBStatus>();
                IList<MBLog> mbloglist = new List<MBLog>();
                foreach (string mbsno in mbsnlist)
                {
                    IMB mbobject = mbRepository.Find(mbsno);
                    MODismantleLog modisObject = new MODismantleLog(mbsno, "SMTMo", mbobject.SMTMO, disReason, this.Editor, DateTime.Now, 0);
                    MBStatus mbstatus = new MBStatus(mbsno, this.Station, MBStatusEnum.Pass, this.Editor, this.Line, DateTime.Now, DateTime.Now);
                    MBLog mblog = new MBLog(0, mbsno, mbobject.Model, this.Station, 1, this.Line, this.Editor, DateTime.Now);

                    modislogs.Add(modisObject);
                    mbs.Add(mbobject);
                    mbstatuslist.Add(mbstatus);
                    mbloglist.Add(mblog);
                }
                IMODismantleLogRepository modismRepository = RepositoryFactory.GetInstance().GetRepository<IMODismantleLogRepository, MODismantleLog>();
                modismRepository.AddBatchDefered(CurrentSession.UnitOfWork, modislogs);
                mbRepository.RemoveBatchDefered(CurrentSession.UnitOfWork, mbs);
                //<Gao Yongbo> 修改为只删除PCB,更新PCBStatus,Insert PCB Log
                mbRepository.UpdateMBStatusBatchDefered(CurrentSession.UnitOfWork, mbstatuslist);
                mbRepository.AddMBLogBatchDefered(CurrentSession.UnitOfWork, mbloglist);
            }

                     
            # region "old"
            //  //   针对[Start MB SNo],[End MB SNo] 范围内的每一个MB SNo,都要进行如下操作:
          //  //	Update SMTMO
          //  //PrintQty  ITC-1103-0148     

          //  IMBMO mbmoObject = (IMBMO)CurrentSession.GetValue(Session.SessionKeys.MBMO);
          //  mbmoObject.PrintedQty = mbmoObject.PrintedQty - 1;
          //  CurrentSession.AddValue(Session.SessionKeys.MBMO, mbmoObject);
          //  mbmoRepository.Update(mbmoObject, CurrentSession.UnitOfWork);
          //  //	Insert MoDismantleLog
          //  //参考方法:
          //  //INSERT MoDismantleLog SELECT PCBNo,'SMTMo',SMTMO,@reason,@Editor,GETDATE() FROM PCB (nolock) WHERE PCBNo = @mbsno

          //  IMODismantleLogRepository modismRepository = RepositoryFactory.GetInstance().GetRepository<IMODismantleLogRepository, MODismantleLog>();
          //  //(string pcbNo, string tp, string smtMo, string reason, string editor, DateTime cdt, int id)
          //var disReason=CurrentSession .GetValue(Session.SessionKeys.Reason).ToString();
          //  MODismantleLog modisObject = new MODismantleLog(mbSn, "SMTMo",mbobject.SMTMO,disReason,this.Editor,DateTime.Now,0);
          //  modismRepository.Add(modisObject, CurrentSession.UnitOfWork);
          //  //	Delete PCB/PCBStatus
          //  //由于投产的MB 不允许进行Dismantle,因此,没有必要清理PCB_Parts            
          //  mbRepository.Remove(mbobject, CurrentSession.UnitOfWork);
# endregion
            return base.DoExecute(executionContext);
        }
Пример #13
0
        /// <summary>
        /// write MB LOG
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string station = this.Station;
            if (!string.IsNullOrEmpty(ManualStation))
            {
                string mStation = CurrentSession.GetValue(ManualStation) as string;
                if (mStation != null)
                {
                    station = mStation;
                }
            }
            int status = this.IsPass ? 1 : 0;
            if (station == "CL")
            {
                status = 2;
            }
            string line = default(string);
            var mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            if (IsSingle)
            {
                var mb = CurrentSession.GetValue(Session.SessionKeys.MB) as IMB;
                if (mb == null)
                {
                    throw new NullReferenceException("MB in session is null");
                }

                line = string.IsNullOrEmpty(this.Line) ? mb.MBStatus.Line : this.Line;
                if (!string.IsNullOrEmpty(this.LineSuffix))
                {
                    line = line + LineSuffix;
                }
                var mbLog = new MBLog(
                    0,
                    mb.Sn,
                    mb.Model,
                    station,
                    status,
                    line,
                    this.Editor,
                    DateTime.Now);

                mb.AddLog(mbLog);
                mbRepository.Update(mb, CurrentSession.UnitOfWork);
                CurrentSession.AddValue(Session.SessionKeys.MBLog, mbLog);
            }
            else
            {
                var mbList = CurrentSession.GetValue(Session.SessionKeys.MBList) as IList<IMB>;
                if (mbList == null)
                {
                    throw new NullReferenceException("MBList in session is null");
                }
                foreach (var mb in mbList)
                {
                    line = string.IsNullOrEmpty(this.Line) ? mb.MBStatus.Line : this.Line;
                    var mbLog = new MBLog(
                        0,
                        mb.Sn,
                        mb.Model,
                        station,
                        status,
                        line,
                        this.Editor,
                        DateTime.Now);

                    mb.AddLog(mbLog);
                    mbRepository.Update(mb, CurrentSession.UnitOfWork);
                }

            }
            return base.DoExecute(executionContext);
        }
Пример #14
0
        /// <summary>
        /// 刷mbsno,调用该方法启动工作流,根据输入mbsno获取Lot
        /// 返回MNSB LIST 
        /// </summary>
        /// <param name="mbsno">mbsno</param>
        /// <param name="editor">editor</param>
        /// <param name="station">station</param>
        /// <param name="customer">customer</param>
        /// <param name="curMBInfo">curMBInfo</param>
        /// <returns>model</returns>
        public ArrayList inputMBSnoORLotNo(string InputStr, string InputType, string editor, string station, string customer)
        {
            logger.Debug("(PCAOQCInputImpl)Input MBSN or LotNo start:" + InputStr + "editor:" + editor + "station:" + station + "customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();
            ArrayList retLst = new ArrayList();
            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            string LotNO = "";
            ArrayList lstRet = new ArrayList();
           try
            {
                //若刷入数据为MBSN,获取MBSN的所在LotNo(PCBLot.LotNo where PCBNo=@MBSN and Status=1),
                // 则不存在记录,则报错:“该MBSN未组Lot”
                if (InputType == "MBSN")
                {
                    PcblotInfo conPcblot = new PcblotInfo();
                    conPcblot.pcbno = InputStr;
                    conPcblot.status = "1";
                    IList<PcblotInfo> pcblotLstA = new List<PcblotInfo>();
                    pcblotLstA = iMBRepository.GetPcblotInfoList(conPcblot);
                    if ((pcblotLstA == null) || (pcblotLstA.Count == 0))
                    {
                        erpara.Add(InputStr);
                        ex = new FisException("CHK312", erpara); //该MBSN未组Lot
                        throw ex;
                    }
                    if (pcblotLstA.Count==1)
                    {
                        LotNO = pcblotLstA[0].lotNo;
                    }
                    else
                    {
                        var pcblotLst =
                            from item in pcblotLstA
                            orderby item.cdt descending
                            select item;
                        foreach (PcblotInfo tmpNode in pcblotLst)
                        {
                            LotNO = tmpNode.lotNo;
                            break;
                        }
                    }
                  
                }
                else
                {
                    LotNO = InputStr;
                }
                
                string sessionKey = LotNO;

                //2、	获取LotNo的详细信息(Lot.* where Lot.LotNo=@LotNo);若Lot信息不存在,则报错:“该Lot不存在”
                LotInfo conLotInfo = new LotInfo();
                conLotInfo.lotNo = LotNO;
                IList<LotInfo> getLotInfo = iMBRepository.GetlotInfoList(conLotInfo);
                if ((getLotInfo == null) || (getLotInfo.Count == 0))
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK313", erpara); //该Lot不存在
                    throw ex;
                }
                //若Lot.Status=’0’,则报错:“Lot没有组合完成”;
                if (getLotInfo[0].status == "0")
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK314", erpara); //Lot没有组合完成
                    throw ex;
                }
                //若Lot.Status=’4’,则报错:“该Lot已解散”;
                if (getLotInfo[0].status == "4")
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK315", erpara); //该Lot已解散
                    throw ex;
                }
                //若Lot.Status=’9’,则报错:“该Lot已经通过OQC”
                if (getLotInfo[0].status == "9")
                {
                    erpara.Add(LotNO);
                    ex = new FisException("CHK316", erpara); //该Lot已经通过OQC
                    throw ex;
                }
                //4、	Update Lot Status
                //若Lot.Status=1,则Update Lot.Status=2;
                //Update PCBStatus(where PCBNo in PCBLot.PCBNo and Status=1 and LotNo=@LotNo);
                UnitOfWork uow = new UnitOfWork(); 
                if (getLotInfo[0].status.Trim() == "1")
                {
                    LotInfo setLotInfo = new LotInfo();
                    conLotInfo = new LotInfo();
                    conLotInfo.lotNo = getLotInfo[0].lotNo;
                    //conLotInfo.type = strType;
                    //setLotInfo.qty = retlot[0].qty + 1;//1;//setValue.Qty赋1,其他按需要赋值即可
                    setLotInfo.status = "2";
                    setLotInfo.editor = editor;
                    setLotInfo.udt = DateTime.Now;
                    //itemRepository.UpdateLotInfoDefered(CurrentSession.UnitOfWork, setLotInfo, conLotInfo);
                    iMBRepository.UpdateLotInfoDefered(uow, setLotInfo, conLotInfo);
                //}
                    //DEBUG Mantis 1009(itc-1414-0224)
                    //update PCBStatus,PCBLog  ->条件也要: Lot.Status=1
                    
                   //Update PCBStatus:Station=’31A’Status=’1’
                    //Insert PCBLog
                    //Insert PCBLog:Station=’31A’Status=’1’
                    PcblotInfo conPcblot4 = new PcblotInfo();
                    //conPcblot = new PcblotInfo();
                    conPcblot4.lotNo= LotNO;
                    conPcblot4.status = "1";
                    IList<PcblotInfo>pcblotLst4 = new List<PcblotInfo>();
                    pcblotLst4 = iMBRepository.GetPcblotInfoList(conPcblot4);
                    if ((pcblotLst4 == null) || (pcblotLst4.Count == 0))
                    {

                    }
                    else
                    {
                        for (int i = 0; i < pcblotLst4.Count; i++)
                        {
                            IMB mb = iMBRepository.Find(pcblotLst4[i].pcbno);
                            if (mb != null)
                            {
                                mb.MBStatus.Station = "31A";
                                mb.MBStatus.Status = MBStatusEnum.Pass;
                                mb.MBStatus.Editor = editor;
                                mb.MBStatus.Udt = DateTime.Now;
                                //记录MB Log
                                MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "31A", (int) MBStatusEnum.Pass,
                                                         getLotInfo[0].line, editor, new DateTime());
                                mb.AddLog(mb_log);
                                iMBRepository.Update(mb, uow);
                            }
                        }
                    }
                }
                uow.Commit();

                //5、重新获取Lot信息,并显示LotNo Line[Line.Descr] Type PCS = Qty Status[2:OQC In;3:Locked]
                conLotInfo = new LotInfo();
                conLotInfo.lotNo = LotNO;
                IList<LotInfo> ReturnLotInfo = iMBRepository.GetlotInfoList(conLotInfo);
                ILineRepository lineRepository = RepositoryFactory.GetInstance().GetRepository<ILineRepository, Line>();
                Line lineInfo = lineRepository.Find(ReturnLotInfo[0].line);
                if (lineInfo == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK317", erpara); //该PCB %1 没有PdLine,请确认!
                    throw ex;
                }
                string lotLineinfo = ReturnLotInfo[0].line.Trim() + "[" +lineInfo.Descr.Trim() + "]";
                string strStatus="";
                if (ReturnLotInfo[0].status == "2")
                {
                    strStatus = "OQC In";
                }
                else if (ReturnLotInfo[0].status == "3")
                {
                    strStatus = "Locked";
                }
                //Old--获取PCBLot信息,并显示PCBLot.PCBNo where LotNo=@LotNo and Status=1
                //PcblotInfo RtnconPcblot = new PcblotInfo();
                //RtnconPcblot.lotNo = ReturnLotInfo[0].lotNo;
                //RtnconPcblot.status = "1";
                //IList<PcblotInfo> rtnpcblotLst = new List<PcblotInfo>();
                //rtnpcblotLst = iMBRepository.GetPcblotInfoList(RtnconPcblot);
                //IList<string> mbsnList = new List<string>();
                //foreach (PcblotInfo pcblotnode in rtnpcblotLst)
                //{
                //    mbsnList.Add(pcblotnode.pcbno.Trim());
                //}
               //UC Update 
               //	获取LotSetting.CheckQty(先用PdLine检索,若不存在,再用’ALL’检索,若不存在,则报错:“请IE维护LotSetting”),
               //若[Checked Qty]>=LotSetting.CheckQty,---则执行[4 Save Data] PASS分支:界面初始时不自动处理
                var checkQtyforLine = 0;
                LotSettingInfo conlotSetting = new LotSettingInfo();
                conlotSetting.line = ReturnLotInfo[0].line;
                //add type 
                conlotSetting.type = ReturnLotInfo[0].type;
                IList<LotSettingInfo> LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                {
                    conlotSetting = new LotSettingInfo();
                    conlotSetting.line = "ALL";
                    conlotSetting.type = ReturnLotInfo[0].type;
                    LotSettinglst = iMBRepository.GetLotSettingInfoList(conlotSetting);
                    if ((LotSettinglst == null) || (LotSettinglst.Count == 0))
                    {
                        //报错:“请与IE联系,维护 Lot 相关设置”
                        List<string> errpara = new List<string>();
                        //errpara.Add(currenMB.Sn);
                        FisException ex1 = new FisException("CHK278", errpara);
                        throw ex1;
                    }
                    else
                    {
                        checkQtyforLine = LotSettinglst[0].checkQty;
                    }
                }
                else
                {
                    checkQtyforLine = LotSettinglst[0].checkQty;
                }
               
               //======================================================================================
                //UC Update 2012/07/03 
                //6、	获取PCBLot信息,并显示在[MBSN List]和[Checked Qty]( [Checked Qty]: Sum(Checked))
                //参考方法:
                //select a.PCBNo, ISNULL(b.Status,'0') as Checked from PCBLot a
                //      left Join PCBLotCheck b
                //      on a..PCBNo where LotNo = b.=@LotNo
                //      and a.PCBNo = b.PCBNo
                //   where a.LotNo=@LotNo and a.Status=1
                //   order by a.PCBNo
                IList<string> mbsnList = new List<string>();
                IList<string> checkedList = new List<string>();
                DataTable PcbLotCheckedTable = iMBRepository.GetPcbNoAndCheckStatusList(ReturnLotInfo[0].lotNo, "1");
                if (PcbLotCheckedTable == null)
                {
                    //throw new FisException("CHM001", new string[] { model1 });
                }
                else
                {
                    var pcbLotCheckedCount = PcbLotCheckedTable.Rows.Count;
                    for (int i = 0; i < pcbLotCheckedCount; i++)
                    {
                        mbsnList.Add(PcbLotCheckedTable.Rows[i][0] as string);
                        checkedList.Add(PcbLotCheckedTable.Rows[i][1] as string);
                    }
                }
                var pcblotcheck = new PcblotcheckInfo();
                pcblotcheck.lotNo = LotNO;
                pcblotcheck.status = "1";
                var iCheckqty = iMBRepository.GetCountOfPcblotCheck(pcblotcheck);
                var havePromptstr = "";
                if (ReturnLotInfo[0].status !="2")
                {
                    try
                    {
                        throw new FisException("CHK401", new List<string>());

                    }
                    catch (FisException ex1)
                    {
                        havePromptstr = ex1.mErrmsg;
                    }
                }
             
                lstRet.Add(ReturnLotInfo[0].lotNo);      //0
                lstRet.Add(lotLineinfo);                 //1 
                lstRet.Add(ReturnLotInfo[0].type);       //2
                lstRet.Add(ReturnLotInfo[0].qty);        //3 
                lstRet.Add(strStatus);                   //4
                lstRet.Add(mbsnList);                    //5
                lstRet.Add(ReturnLotInfo[0].line);       //6
                lstRet.Add(checkedList);                 //7
                lstRet.Add(checkQtyforLine);             //8
                lstRet.Add(iCheckqty);                   //9
                lstRet.Add(havePromptstr);              //10
                return lstRet;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PCAOQCInputImpl)Input MBSN or LotNo end  Input:" + InputStr + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Пример #15
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            Session session = CurrentSession;
            var CurrentMB = (MB)session.GetValue(Session.SessionKeys.MB);
            string moNo = CurrentMB.SMTMO;
            string model = CurrentMB.Model;
            string custSn = string.Empty;
            string custVer = string.Empty;
            string cvsn = string.Empty;
            string uuid = string.Empty;

            bool IsRCTO = false;
            if (session.GetValue(Session.SessionKeys.IsRCTO) != null)
            {
                IsRCTO = (bool)session.GetValue(Session.SessionKeys.IsRCTO);
            }
            string CheckCode = session.GetValue(Session.SessionKeys.CheckCode) as string;

            string dateCode = session.GetValue(Session.SessionKeys.DCode) as string;
            string ecr = session.GetValue(Session.SessionKeys.ECR) as string;
            string iecVer = session.GetValue(Session.SessionKeys.IECVersion) as string;

            var MACList = (IList<string>)session.GetValue(Session.SessionKeys.MACList);
            var MBCTList = (IList<string>)session.GetValue(Session.SessionKeys.MBCTList);
            var EEPList = (IList<string>)session.GetValue(Session.SessionKeys.EEPList);

            var NewMBSnList = session.GetValue(Session.SessionKeys.MBNOList) as List<string>;

            var MBNOList = session.GetValue(Session.SessionKeys.MBNOList) as List<string>;
            if (IsRCTO && CheckCode !="R") {
                MBNOList = session.GetValue(Session.SessionKeys.RCTOChildMBSnList) as List<string>;
            }
            var MBObjectList = new List<IMB>();
            session.AddValue(Session.SessionKeys.MBList, MBObjectList);

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

            IPrintLogRepository LogRepository = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>();
            bool hasPCBVer = false;
            if (session.GetValue(ExtendSession.SessionKeys.HasPCBVer) != null)
            {
                hasPCBVer = (bool)session.GetValue(ExtendSession.SessionKeys.HasPCBVer);
                if (hasPCBVer)
                {
                    custVer = (string)session.GetValue(ExtendSession.SessionKeys.PCBVer);
                }
            }
            for (int i = 0; i < MBNOList.Count; i++)
            {

                string mac = string.Empty;
                if (MACList != null)
                {
                    mac = MACList[i];
                }
                MB mb = new MB(MBNOList[i], moNo, custSn, model, dateCode, mac, uuid, ecr, iecVer, custVer, cvsn, DateTime.Now, DateTime.Now);
                MBStatus mbStatus = new MBStatus(MBNOList[i], this.Station, MBStatusEnum.Pass, this.Editor, this.Line, DateTime.Now, DateTime.Now);
                mb.MBStatus = mbStatus;

                if (IsRCTO && CheckCode != "R")
                {
                    IMES.FisObject.PCA.MB.MBInfo RCTOChangeInfo = new IMES.FisObject.PCA.MB.MBInfo(0, mb.Sn, "RCTOChange", NewMBSnList[i], Editor, DateTime.Now, DateTime.Now);
                    mb.AddMBInfo(RCTOChangeInfo);
                }

                if (EEPList != null)
                {
                    IMES.FisObject.PCA.MB.MBInfo eepInfo = new IMES.FisObject.PCA.MB.MBInfo(0, mb.Sn, "EEPROM", EEPList[i], Editor, DateTime.Now, DateTime.Now);
                    mb.AddMBInfo(eepInfo);
                }

                if (MBCTList != null)
                {
                    IMES.FisObject.PCA.MB.MBInfo mbctInfo = new IMES.FisObject.PCA.MB.MBInfo(0, mb.Sn, "MBCT", MBCTList[i], Editor, DateTime.Now, DateTime.Now);
                    mb.AddMBInfo(mbctInfo);
                    FruDetInfo newFruDet = new FruDetInfo();
                    newFruDet.sno = MBCTList[i];
                    newFruDet.snoId = mb.Sn;
                    newFruDet.tp = "VC";
                    newFruDet.editor = Editor;
                    newFruDet.cdt = DateTime.Now;
                    newFruDet.udt = newFruDet.cdt;
                    mbRepository.InsertFruDetInfoDefered(session.UnitOfWork, newFruDet);

                    MBLog newCTLog = new MBLog(0, mb.Sn, mb.Model, "SH", 1, "SA SHIPPING LABEL", Editor, DateTime.Now);
                    mb.AddLog(newCTLog);
                }

                if (session.GetValue("IsPilotMOCheck") != null && (bool)session.GetValue("IsPilotMOCheck"))
                {
                    string pilotmo = (string)session.GetValue(Session.SessionKeys.PilotMoNo);
                    mb.SetExtendedProperty(ConstName.PCBInfo.PilotMo, pilotmo, this.Editor);                    
                }
                mb.SetExtendedProperty(ConstName.PCBInfo.ParentMBSN, mb.Sn, this.Editor);
               

                MBLog newLog = new MBLog(0, mb.Sn, mb.Model, Station, 1, Line, Editor, DateTime.Now);
                mb.AddLog(newLog);
                mbRepository.Add(mb, session.UnitOfWork);
                MBObjectList.Add(mb);

                var item = new PrintLog
                {
                    Name = session.GetValue(Session.SessionKeys.PrintLogName).ToString(),
                    BeginNo = MBNOList[i],
                    EndNo = MBNOList[i],
                    Descr = session.GetValue(Session.SessionKeys.PrintLogDescr).ToString(),
                    Editor = this.Editor
                };
                LogRepository.Add(item, session.UnitOfWork);
                
                IMES.FisObject.PCA.MB.MBInfo items = new IMES.FisObject.PCA.MB.MBInfo();
                items.InfoType = ConstName.PCBInfo.ChildMBSN;
                items.InfoValue = mb.Sn;
                items.Editor = this.Editor;
                CurrentMB.AddMBInfo(items);
            }

            return base.DoExecute(executionContext);
        }
Пример #16
0
        public string saveMB(string Inputstring, string editor, string station, string customer)
        {
            logger.Debug("(PCAOQCInputImpl)saveMB start Input:" + Inputstring + "editor:" + editor + "station:" + station + "customer:" + customer);

            //FisException ex;
            List<string> erpara = new List<string>();
            ArrayList retLst = new ArrayList();
            IMBRepository iMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            ArrayList lstRet = new ArrayList();
            UnitOfWork uow = new UnitOfWork();
            string returnstring = "OK";
            try
            {
                IMB mb = iMBRepository.Find(Inputstring);
                if (mb != null)
                {
                    string preStation = mb.MBStatus.Station;
                    string status = (string)mb.MBStatus.Status.ToString();
                    string line = mb.MBStatus.Line;
                    if (preStation != "15")
                    {
                        string[] param = { Inputstring, status, preStation };
                        throw new FisException("SFC009", param);
                    }
                    mb.MBStatus.Station = "31A";
                    mb.MBStatus.Status = MBStatusEnum.Pass;
                    mb.MBStatus.Editor = editor;
                    mb.MBStatus.Udt = DateTime.Now;
                    //记录MB Log
                    MBLog mb_log = new MBLog(0, mb.Sn, mb.Model, "31A", (int)MBStatusEnum.Pass, line, editor, new DateTime());
                    mb.AddLog(mb_log);
                    iMBRepository.Update(mb, uow);
                }
                uow.Commit();
                return returnstring;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(PCAOQCInputImpl)saveMB End Input:" + Inputstring + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Пример #17
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);
        }