Пример #1
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);
        }
Пример #2
0
        /// <summary>
        /// reprint ecr label
        /// </summary>
        /// <param name="mbSno"></param>
        /// <param name="reason"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <param name="printItems"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        public IList<PrintItem> EcrReprint(string mbSno, string reason, string ecr , string editor, string line, string station, string customer, IList<PrintItem> printItems)
        {
            //todo: make sure what is the key condition of this label

            _logger.Debug("(ICTInput)EcrReprint start, MBSno:" + mbSno + " Reason:" + reason + " editor:" + editor + " station:" + station + " customerId:" + customer);

            try
            {
                IList<EcrVersion> ecrlist = new List<EcrVersion>();

                var ecrRep = RepositoryFactory.GetInstance().GetRepository<IEcrVersionRepository, EcrVersion>();
                var mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository,IMB>();
                IPartRepository CurrentPartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                           
                var mb = mbRepository.Find(mbSno);
                if (mb == null)
                {
                    var ex = new FisException("SFC001", new[] { mbSno });
                    throw ex;
                }

                if (!string.IsNullOrEmpty(ecr))
                {
                    //select Count(*) from EcrVersion where Family=@Family and MBCode = MBCode and ECR = @ECR
                    //若不存在,则报错:“ECR不存在”
                    IPart curPart = CurrentPartRepository.Find(mb.Model);
                    if (curPart == null || string.IsNullOrEmpty(curPart.Descr))
                    {
                        throw new FisException("CHK223", new string[] {mbSno});
                    }

                    ecrlist = ecrRep.GetECRVersionByFamilyMBCodeAndECR(curPart.Descr, mb.MBCode, ecr);
                    if (ecrlist.Count <= 0)
                    {
                        var ex = new FisException("ICT001", new[] { ecr });
                        throw ex;
                    }
                }

                string sessionKey = mbSno;
                const Session.SessionType sessionType = Session.SessionType.Common;
                Session session = SessionManager.GetInstance.GetSession(sessionKey, sessionType);

                if (session == null)
                {
                    session = new Session(sessionKey, sessionType, editor, station, line, customer);
                    var wfArguments = new Dictionary<string, object>
                                          {
                                              {"Key", sessionKey},
                                              {"Station", ""},
                                              {"CurrentFlowSession", session},
                                              {"Editor", editor},
                                              {"PdLine", line},
                                              {"Customer", customer},
                                              {"SessionType", sessionType}
                                          };

                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "ECRReprint.xoml", string.Empty, out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);
                    session.AddValue(Session.SessionKeys.MB, mb);
                    //session.AddValue(Session.SessionKeys.MBMONO, mb.SMTMO);
                    session.AddValue(Session.SessionKeys.PrintItems, printItems);
                    session.AddValue(Session.SessionKeys.PrintLogName, "ECRLabel");
                    session.AddValue(Session.SessionKeys.PrintLogBegNo, mb.Sn);
                    session.AddValue(Session.SessionKeys.PrintLogEndNo, mb.Sn);
                    session.AddValue(Session.SessionKeys.Reason, reason);
                    session.AddValue(Session.SessionKeys.PrintLogDescr, "Reprint");
                    session.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(session))
                    {
                        session.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        var ex = new FisException("CHK020", new[] { sessionKey });
                        throw ex;
                    }
                    session.WorkflowInstance.Start();
                    session.SetHostWaitOne();
                }
                else
                {
                    var ex = new FisException("CHK020", new[] { sessionKey });
                    throw ex;
                }

                //check workflow exception
                if (session.Exception != null)
                {
                    if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        session.ResumeWorkFlow();
                    }
                    throw session.Exception;
                }

                if (!string.IsNullOrEmpty(ecr)){
                    //若[ECR]为刷入的数据,则Update PCB
                    //PCB.ECR = ECR
                    //PCB.IECVER = EcrVersion.IECVer
                    PcbEntityInfo setValue = new PcbEntityInfo();
                    setValue.ecr = ecr;
                    setValue.iecver = ecrlist[0].IECVer;

                    PcbEntityInfo cond = new PcbEntityInfo();
                    cond.pcbno = mbSno;
                   
                    mbRepository.UpdatePcb(setValue, cond);
                }

                return (IList<PrintItem>)session.GetValue(Session.SessionKeys.PrintItems);
            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                _logger.Debug("(ICTInput)EcrReprint end, MBSno:" + mbSno + " Reason:" + reason + " editor:" + editor + " customerId:" + customer);
            }
        }