Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            /*IRepairTarget repairTarget=null;

            repairTarget =(IRepairTarget)CurrentSession.GetValue(ExtendSession.SessionKeys.ProductRepair);

            Repair repair=new Repair();*/
            
            //IRepairTarget repairTarget = GetRepairTarget();
            //TestLog testLog = (TestLog)CurrentSession.GetValue(ExtendSession.SessionKeys.TestLog);
            //IList<RepairDefect> repairDefects=(IList<RepairDefect>)CurrentSession.GetValue(ExtendSession.SessionKeys.RepairDefect);
            //Repair repair = new Repair(0,testLog.Sn, repairTarget.RepairTargetModel, testLog.Type, testLog.Line, Station, IMES.FisObject.Common.Repair.Repair.RepairStatus.NotFinished, repairDefects, testLog.Editor, testLog.ID.ToString(), DateTime.Now, DateTime.Now);
              
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();
            var currentProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            //Repair currentRepair =currentProduct.GetCurrentRepair();
            //int ProductRepairID = currentRepair.ID;
            //IList<RepairDefect> currentRepairDefects =currentRepair.Defects;
            
            //TestLog OQCTestLog = new TestLog(0, testLog.Sn, testLog.Line, testLog.FixtureId, Station, testLog.Status, testLog.JoinID, Editor, testLog.Type, DateTime.Now);
            //currentProduct.SetExtendedProperty(ExtendSession.SessionKeys.ProductRepairID, ProductRepairID.ToString(), Editor);
            
            //Project.ProductInfo insert/update
            currentProduct.SetExtendedProperty(ExtendSession.SessionKeys.OQCRepairStation, Station, Editor);
            productRepository.Update(currentProduct, CurrentSession.UnitOfWork);

            
            Repair OQCRepair = currentProduct.GetCurrentRepair();
            /*SELECT t1.ID,t1.ProductID,t1.Model,t1.Type,t1.Line,t1.Station,t1.TestLogID,t1.Status,t1.Editor,t1.Cdt,t1.Udt,
                t2.ID,t2.ProductRepairID,t2.Type,t2.DefectCode,t2.Cause,t2.Obligation,t2.Component,t2.Site,t2.Location,t2.MajorPart,t2.Remark,t2.VendorCT,t2.PartType,t2.OldPart,t2.OldPartSno,t2.NewPart,t2.NewPartSno,t2.Manufacture,t2.VersionA,t2.VersionB,t2.ReturnSign,t2.Mark,t2.SubDefect,t2.PIAStation,t2.Distribution,t2.[4M],t2.Responsibility,t2.Action,t2.Cover,t2.Uncover,t2.TrackingStatus,t2.IsManual,t2.MTAID,t2.Editor,t2.Cdt,t2.Udt 
                FROM ProductRepair t1,ProductRepair_DefectInfo t2 
                WHERE t1.ID=t2.ProductRepairID AND t1.ProductID='T01237475' AND t1.Status= 0 
                order by t2.Cdt desc*/

            RepairDefect repairDefect = null;
            IList<RepairDefect> repairDefects = new List<RepairDefect>();

            if (OQCRepair == null)
            {                
                throw new FisException();
            }
            else
            {
                foreach (RepairDefect item in OQCRepair.Defects)
                {
                   /* item.ID = 0;
                    item.RepairID = 0;
                    item.Cdt = DateTime.Now;
                    item.Udt = DateTime.Now;*/

                    /*repairDefect = new RepairDefect(0, 0, item.Type,item.DefectCodeID, null, null, null, null, null,
                        null, null, null, null, null, null, null, null, null, false, null,
                        null, null, "0", null, "0", null, null, null, null, null, null, null,
                        null, null, null, item.Editor, DateTime.Now, DateTime.Now);*/

                    repairDefect = new RepairDefect(0, 0, item.Type, item.DefectCodeID, item.Cause, item.Obligation, item.Component, item.Site, item.Location,
                                                    item.MajorPart, item.Remark, item.VendorCT, item.PartType, item.OldPart, item.OldPartSno,item.NewPart, item.NewPartSno,
                                                    item.NewPartDateCode,item.IsManual,item.Manufacture,item.VersionA, item.VersionB, item.ReturnSign, item.Side, item.Mark,
                                                    item.SubDefect, item.PIAStation, item.Distribution, item._4M, item.Responsibility, item.Action, item.Cover, item.Uncover,
                                                    item.TrackingStatus, item.MTAID, null, CurrentSession.Editor, DateTime.Now, DateTime.Now);
                    repairDefects.Add(repairDefect);
                
                }
                Repair repair = new Repair(0,
                                           OQCRepair.Sn,
                                           OQCRepair.Model,
                                           OQCRepair.Type,
                                           OQCRepair.LineID,
                                           Station,
                                           IMES.FisObject.Common.Repair.Repair.RepairStatus.NotFinished,
                                           //OQCRepair.Defects,
                                           repairDefects,
                                           //OQCRepair.Editor,
                                           CurrentSession.Editor,
                                           OQCRepair.TestLogID,
                                           OQCRepair.LogId,
                                            DateTime.Now,
                                            DateTime.Now);
                //currentProduct.Repairs.Add(repair);
                currentProduct.AddRepair(repair);
                productRepository.Update(currentProduct, CurrentSession.UnitOfWork);
                //this.UpdateMainObject(currentProduct);
            }


            return base.DoExecute(executionContext);

            //CurrentSession.AddValue(Session.SessionKeys.Product, currentProduct);        
        }
Example #2
0
File: MB.cs Project: wra222/testgit
 /// <summary>
 /// 填充RepairDefects
 /// </summary>
 /// <param name="rep"></param>
 public static void FillingRepairDefects(Repair rep)
 {
     MbRepository.FillRepairDefectInfo(rep);
 }
Example #3
0
File: MB.cs Project: wra222/testgit
        /// <summary>
        /// 向主板中添加一条添加维修记录。
        /// </summary>
        /// <param name="rep">维修记录对象</param>
        public void AddRepair(Repair rep)
        {
            if (rep == null)
                return;

            lock (_syncObj_repair)
            {
                //if (this._repair == null)
                //    this._repair = new List<Repair>();
                object naught = this.Repairs;
                if (this._repair.Contains(rep))
                    return;

                rep.Tracker = this._tracker.Merge(rep.Tracker);
                this._repair.Add(rep);
                rep.FillingRepairDefects += new FillRepair(FillingRepairDefects);
                this._tracker.MarkAsAdded(rep);
                this._tracker.MarkAsModified(this);
            }
        }
        /// <summary>
        /// 用于初次进入Repair时,根据TestLog创建Repair信息。
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            try
            {
                IRepairTarget repairTarget = GetRepairTarget();
                TestLog testLog = null;
                //IList<TestLog> testLogs = repairTarget.GetTestLog(); //Dean 20110315 performance Issue
                IList<TestLogDefect> testLogDefects = null;
                IStationRepository stationRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository, IStation>();
                IStation station = stationRepository.Find(Station);

                string OQCStation = "";
                IProduct product = null;
                if (string.Compare(RepairStationType, "FA", true) == 0)
                {
                    //Update Dean 20110315
                    product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);



                    IList<ProductInfo> productinfos = product.ProductInfoes;
                    foreach (ProductInfo info in productinfos)
                    {
                        if (info.InfoType == ExtendSession.SessionKeys.OQCRepairStation && info.InfoValue != "")
                        {
                            OQCStation = info.InfoValue;
                            break;
                        }
                    }
                }
                //Update Dean 20110315
                if (OQCStation == "") //Update Dean 20110315
                {

                    //if (testLogs != null && testLogs.Count != 0)
                    //{
                    Repair repair = null;
                    RepairDefect repairDefect = null;
                    IList<RepairDefect> repairDefects = new List<RepairDefect>();

                    testLog = repairTarget.LatestTestLog;//抓取latestTestLog by PreStation 

                    if (testLog == null)
                    {
                        List<string> errpara = new List<string>();
                        errpara.Add(Key);
                        throw new FisException("CHK025", errpara);
                    }

                    if (testLog.Status == TestLog.TestLogStatus.Pass)
                    {
                        List<string> errpara = new List<string>();
                        throw new FisException("CHK024", errpara);
                    }

                    testLogDefects = testLog.Defects;

                    if (testLogDefects != null && testLogDefects.Count != 0)
                    {
                        //if (station.StationType == StationType.SARepair)
                        if (string.Compare(RepairStationType, "SA", true) == 0)
                        {
                            foreach (TestLogDefect defectItem in testLogDefects)
                            {
                                //ITC-1103-0134 Tong.Zhi-Yong 2010-01-26
                                repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                    null, null, null, null, null, null, null, null, null, false, null,
                                    null, null, string.Empty, null, "0", null, null, null, null, null, null, null,
                                    null, null, null, testLog.Editor, DateTime.Now, DateTime.Now);

                                repairDefects.Add(repairDefect);
                            }
                        }
                        //else if (station.StationType == StationType.FARepair)
                        else if (string.Compare(RepairStationType, "FA", true) == 0)
                        {
                            foreach (TestLogDefect defectItem in testLogDefects)
                            {
                                repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                    null, null, null, null, null, null, null, null, null, false, null,
                                    null, null, "0", null, "0", null, null, null, null, null, null, null,
                                    null, null, null, testLog.Editor, DateTime.Now, DateTime.Now);

                                repairDefects.Add(repairDefect);
                            }
                        }
                        else if (string.Compare(RepairStationType, "PAQC", true) == 0)
                        {
                            foreach (TestLogDefect defectItem in testLogDefects)
                            {
                                //ITC-1155-0109 Tong.Zhi-Yong 2010-05-17
                                repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                    null, null, null, null, null, null, null, null, null, false, null,
                                    null, null, "0", null, "0", null, null, null, null, null, null, null,
                                    null, null, null, testLog.Editor, DateTime.Now, DateTime.Now);

                                repairDefects.Add(repairDefect);
                            }
                        }
                        else
                        {
                            foreach (TestLogDefect defectItem in testLogDefects)
                            {
                                repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                    null, null, null, null, null, null, null, null, null, false, null,
                                    null, null, string.Empty, null, "0", null, null, null, null, null, null, null,
                                    null, null, null, testLog.Editor, DateTime.Now, DateTime.Now);

                                repairDefects.Add(repairDefect);
                            }
                        }

                    }

                    repair = new Repair(0, testLog.Sn, repairTarget.RepairTargetModel, testLog.Type, testLog.Line, testLog.Station, IMES.FisObject.Common.Repair.Repair.RepairStatus.NotFinished, repairDefects, testLog.Editor, testLog.ID.ToString(), DateTime.Now, DateTime.Now);
                    repairTarget.AddRepair(repair);
                    UpdateRepairTarget(repairTarget);
                    CurrentSession.AddValue(ExtendSession.SessionKeys.IsOQCRepair, false);



                    //Update Dean 20110315
                    //CurrentSession.AddValue(ExtendSession.SessionKeys.TestLog, testLog);                    
                    //CurrentSession.AddValue(ExtendSession.SessionKeys.RepairDefect, repairDefects);                    
                    //}
                    /*else
                    {
                        List<string> errpara = new List<string>();
                        errpara.Add(Key);
                        throw new FisException("CHK025", errpara);
                    }*/
                }
                else  // get and copy repair info from OQC repair station   Update Dean  20110316
                {
                    IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();
                    product.SetExtendedProperty(ExtendSession.SessionKeys.OQCRepairStation, "", Editor);
                    productRepository.Update(product, CurrentSession.UnitOfWork);

                }
                return base.DoExecute(executionContext);
            }
            catch (FisException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
            }
        }
        /// <summary>
        /// 用于初次进入Repair时,根据TestLog创建Repair信息。
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IRepairTarget repairTarget = GetRepairTarget();
            IList<RepairDefect> repairDefects = new List<RepairDefect>();

            TestLog testLog;
            //2012-01-10
            //There maybe "PCA Repair Input" staion in SA process before "PCA Repair", 
            //so MBStatus.Station is not necessorily a test station. Therefor we get 
            //latestTestlog for SA in a different way than we have done for FA and PAQC.
            //For SA we get the latest test FAIL log, while for others we get the latest
            //log and check whether it's pass or fail.
            if (string.Compare(RepairStationType, "SA", true) == 0)
            {
                testLog = repairTarget.LatestFailTestLog;
                if (testLog == null)
                {
                    var errpara = new List<string> { Key };
                    throw new FisException("CHK025", errpara);
                }
            }
            else
            {
                testLog = repairTarget.LatestTestLog;
                if (testLog == null)
                {
                    var errpara = new List<string> { Key };
                    throw new FisException("CHK025", errpara);
                }
                if (testLog.Status == TestLog.TestLogStatus.Pass)
                {
                    var errpara = new List<string>();
                    throw new FisException("CHK024", errpara);
                }
            }
            
            //get Latest fail log id
            int logId = 0;
            
            if (string.Compare(RepairStationType, "SA", true) == 0)
            {
                MBLog log = ((IMB) repairTarget).GetLatestFailLog();
                if (log != null)
                {
                    logId = log.ID;
                }
            }
            else
            {
                ProductLog log = ((IProduct)repairTarget).GetLatestFailLog();
                if (log != null)
                {
                    logId = log.Id;
                }
            }

            IList<TestLogDefect> testLogDefects = testLog.Defects;
            if (testLogDefects != null && testLogDefects.Count != 0)
            {
                RepairDefect repairDefect;
                if (string.Compare(RepairStationType, "SA", true) == 0)
                {
                    foreach (TestLogDefect defectItem in testLogDefects)
                    {
                        repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                                        null, null, null, null, null, null, null, null, null, false, null,
                                                        null, null, string.Empty, null, "0", null, null, null, null, null, null, null,
                                                        null, null, null, null,testLog.Editor, DateTime.Now, DateTime.Now);
                        var mta = new MtaMarkInfo {mark = "0", rep_Id = 0};
                        repairDefect.Remark = testLog.Descr.Length > 1024 ? testLog.Descr.Substring(0, 1024) : testLog.Descr;
                        repairDefect.MTAMark = mta;
                        repairDefects.Add(repairDefect);
                    }
                }
                else if (string.Compare(RepairStationType, "FA", true) == 0)
                {
                    foreach (TestLogDefect defectItem in testLogDefects)
                    {
                        repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                                        null, null, null, null, null, null, null, null, null, false, null,
                                                        null, null, "0", null, "0", null, null, null, null, null, null, null,
                                                        null, null, null, null, testLog.Editor, DateTime.Now, DateTime.Now);
                        //Add Return Station:
                        var stationRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.Station.IStationRepository, IMES.FisObject.Common.Station.IStation>();
                        IProduct productObj = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);                        
                        
                        if(productObj == null)
                        {
                            List<string> errpara = new List<string>();
                            errpara.Add(this.Key);                            
                            throw new FisException("SFC002", errpara);
                        }
                        else
                        {
                            /*DefectCodeStationInfo cond = new DefectCodeStationInfo();
                            IList<DefectCodeStationInfo> info = null;
                            cond.defect = defectItem.DefectCode;
                            cond.pre_stn = productObj.Status.StationId;
                            cond.crt_stn = this.Station;
                            info = stationRepository.GetDefectCodeStationList(cond);
                            if (info != null && info.Count > 0)
                            {
                                repairDefect.ReturnStation = info[0].nxt_stn;
                            }
                            else
                            {
                                List<string> errpara = new List<string>();
                                FisException e = new FisException("CHK830", errpara);
                                throw e;                                
                            }*/
                        }
                        repairDefects.Add(repairDefect);
                    }
                }
                else if (string.Compare(RepairStationType, "PAQC", true) == 0)
                {
                    foreach (TestLogDefect defectItem in testLogDefects)
                    {
                        repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                                        null, null, null, null, null, null, null, null, null, false, null,
                                                        null, null, "0", null, "0", null, null, null, null, null, null, null,
                                                        null, null, null, null, testLog.Editor, DateTime.Now, DateTime.Now);

                        repairDefects.Add(repairDefect);
                    }
                }
                else
                {
                    foreach (TestLogDefect defectItem in testLogDefects)
                    {
                        repairDefect = new RepairDefect(0, 0, testLog.Type, defectItem.DefectCode, null, null, null, null, null,
                                                        null, null, null, null, null, null, null, null, null, false, null,
                                                        null, null, string.Empty, null, "0", null, null, null, null, null, null, null,
                                                        null, null, null, null, testLog.Editor, DateTime.Now, DateTime.Now);

                        repairDefects.Add(repairDefect);
                    }
                }
            }

            var repair = new Repair(0, testLog.Sn, repairTarget.RepairTargetModel, testLog.Type, testLog.Line, testLog.Station, Repair.RepairStatus.NotFinished, repairDefects, testLog.Editor, testLog.ID.ToString(), logId, DateTime.Now, DateTime.Now);
            repairTarget.AddRepair(repair);
            UpdateRepairTarget(repairTarget);
            CurrentSession.AddValue(ExtendSession.SessionKeys.IsOQCRepair, false);

            return base.DoExecute(executionContext);
        }
Example #6
0
        /// <summary>
        /// MB成退
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            try
            {
                IRepairTarget repairTarget = GetRepairTarget();
                IProduct product = (IProduct)repairTarget;
                Repair currentRepair = repairTarget.GetCurrentRepair();
                IMBRepository imr = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                
                IList<RepairDefect> repairDefects = new List<RepairDefect>();
                RepairDefect defect = (RepairDefect)CurrentSession.GetValue(Session.SessionKeys.CurrentRepairdefect);
                IMiscRepository miscRpst = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>();

                //Insert a Repair to PCB
                IMB oldMB = (IMB)CurrentSession.GetValue(Session.SessionKeys.MB);
                Repair repair = null;
                RepairDefect repairDefect = new RepairDefect(0, 0, oldMB.ModelObj == null ? string.Empty : oldMB.ModelObj.Type, defect.DefectCodeID, null, null, null, null, null,
                                null, null, null, null, null, null, null, null, null, false, null,
                                null, null, string.Empty, null, "0", null, null, null, null, null, null, null,
                                null, null, null, null,this.Editor, DateTime.Now, DateTime.Now);
                repairDefects.Add(repairDefect);


                //[2012-7-25]:PCBRepair.LogID(PCBLog.ID from PCBLog where PCBNo=#OldMB order by Cdt desc)
                //MBLog oldlog = (MBLog)CurrentSession.GetValue(Session.SessionKeys.MBLog);
                //if (oldlog != null)
                //{
                //    repair = new Repair(0, oldMB.Sn, oldMB.Model, oldMB.ModelObj == null ? string.Empty : oldMB.ModelObj.Type, this.Line, "33", IMES.FisObject.Common.Repair.Repair.RepairStatus.NotFinished, repairDefects, this.Editor, null, oldlog.ID, DateTime.Now, DateTime.Now);
                //}
                //else
                //{
                //    repair = new Repair(0, oldMB.Sn, oldMB.Model, oldMB.ModelObj == null ? string.Empty : oldMB.ModelObj.Type, this.Line, "33", IMES.FisObject.Common.Repair.Repair.RepairStatus.NotFinished, repairDefects, this.Editor, null, 0, DateTime.Now, DateTime.Now);
                //}
                //CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(oldlog, "ID", repair, "LogId"));

                //将记录保存到PCBRepair(Line是FA Line,Station是PCA Station=33)
                repair = new Repair(0, oldMB.Sn, oldMB.Model, oldMB.ModelObj == null ? string.Empty : oldMB.ModelObj.Type, this.Line, "33", IMES.FisObject.Common.Repair.Repair.RepairStatus.NotFinished, repairDefects, this.Editor, null, 0, DateTime.Now, DateTime.Now);
                MBLog log = (MBLog) CurrentSession.GetValue(Session.SessionKeys.MBLog);
                if (log != null)
                {
                    CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(log, "ID", repair, "setter_LogId"));
                    imr.AddPcbRepairDefered(CurrentSession.UnitOfWork, repair);

                    CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(repair, "ID", repairDefect, "setter_RepairId"));
                    imr.AddPcbRepairDefectDefered(CurrentSession.UnitOfWork, repairDefect);
                }
                //oldMB.AddRepair(repair);
                //imr.Update(oldMB, CurrentSession.UnitOfWork);



                


                //Insert Record To ReturnRepair Table
                ReturnRepair returnRepair = new ReturnRepair();
                //ITC-1122-0188 Tong.Zhi-Yong 2010-03-05
                CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(defect, "RepairID", returnRepair, "setter_ProductRepairID"));

                if (defect.ID == 0) //Add
                {
                    CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(defect, "ID", returnRepair, "setter_ProductRepairDefectID"));
                }
                else
                {
                    returnRepair.ProductRepairDefectID = defect.ID;
                }

                CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(repair, "ID", returnRepair, "setter_PCBRepairID"));
                miscRpst.AddReturnRepairDefered(CurrentSession.UnitOfWork, returnRepair);

                return base.DoExecute(executionContext);
            }
            catch (FisException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #7
0
        /// <summary>
        /// 向主板中添加一条添加维修记录。
        /// </summary>
        /// <param name="rep">维修记录对象</param>
        /// <returns>Defect号</returns>
        public void AddRepair(Repair rep)
        {
            if (rep == null)
                return;

            lock (_syncObj_repairs)
            {
                object naught = Repairs;
                if (_repairs.Contains(rep))
                    return;

                rep.Tracker = _tracker.Merge(rep.Tracker);
                _repairs.Add(rep);
                rep.FillingRepairDefects += new FillRepair(FillingRepairDefects);
                //GetRepair().Add(rep);
                _tracker.MarkAsAdded(rep);
                _tracker.MarkAsModified(this);
                //int defectNo = 0;
                // TODO: How to return the defect No?
                //return defectNo;
            }
        }
Example #8
0
        /// <summary>
        /// MB成退
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            try
            {
                IRepairTarget repairTarget = GetRepairTarget();
                IProduct product = (IProduct)repairTarget;
                Repair currentRepair = repairTarget.GetCurrentRepair();
                IMBRepository imr = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                IList<RepairDefect> repairDefects = new List<RepairDefect>();
                RepairDefect defect = (RepairDefect)CurrentSession.GetValue(Session.SessionKeys.CurrentRepairdefect);
                IMiscRepository miscRpst = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>();

                //Insert a Repair to PCB
                IMB oldMB = (IMB)CurrentSession.GetValue(Session.SessionKeys.MB);
                Repair repair = null;
                RepairDefect repairDefect = new RepairDefect(0, 0, oldMB.ModelObj == null ? string.Empty : oldMB.ModelObj.Type, defect.DefectCodeID, null, null, null, null, null,
                                null, null, null, null, null, null, null, null, null, false, null,
                                null, null, string.Empty, null, "0", null, null, null, null, null, null, null,
                                null, null, null, this.Editor, DateTime.Now, DateTime.Now);
                repairDefects.Add(repairDefect);
                //Update by Dean 20110615 由23-->18(SARepair Station),TSB為23,E-Book為18
                repair = new Repair(0, oldMB.Sn, oldMB.Model, oldMB.ModelObj == null ? string.Empty : oldMB.ModelObj.Type, this.Line, "18", IMES.FisObject.Common.Repair.Repair.RepairStatus.NotFinished, repairDefects, this.Editor, null, DateTime.Now, DateTime.Now);
                oldMB.AddRepair(repair);
                imr.Update(oldMB, CurrentSession.UnitOfWork);

                //Insert Record To ReturnRepair Table
                ReturnRepair returnRepair = new ReturnRepair();
                //ITC-1122-0188 Tong.Zhi-Yong 2010-03-05
                CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(defect, "RepairID", returnRepair, "setter_ProductRepairID"));

                if (defect.ID == 0) //Add
                {
                    CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(defect, "ID", returnRepair, "setter_ProductRepairDefectID"));
                }
                else
                {
                    returnRepair.ProductRepairDefectID = defect.ID;
                }

                CurrentSession.UnitOfWork.RegisterSetterBetween(new IMES.Infrastructure.UnitOfWork.SetterBetween(repair, "ID", returnRepair, "setter_PCBRepairID"));
                miscRpst.AddReturnRepairDefered(CurrentSession.UnitOfWork, returnRepair);

                return base.DoExecute(executionContext);
            }
            catch (FisException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }