Ejemplo n.º 1
0
        /// <summary>
        /// 检查rpt_PCARep是否存在同样的维修记录 ,Save Repair Item 
        /// </summary>
        /// <param name="sno"></param>
        /// <param name="reworkStation"></param>
        /// <returns></returns>
        public Rework addNew(string sno, string reworkStation)
        {
            logger.Debug("(BGAOutputImpl)addNew start, [MbSno]:" + sno + "[Station]:" + reworkStation);
            FisException ex;
            List<string> erpara = new List<string>();
            string sessionKey = sno;

            try
            {
                Session session = SessionManager.GetInstance.GetSession(sessionKey, SessionType);

                if (session == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {
                    session.AddValue(Session.SessionKeys.Remark, reworkStation);
                    session.Exception = null;
                    session.SwitchToWorkFlow();

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

                        throw session.Exception;
                    }
                }
                //===========================================================================
                MBRptRepair newMb = (MBRptRepair)session.GetValue(Session.SessionKeys.NewMB);
                Rework rework = new Rework();

                rework.ReworkCode = newMb.Remark;
                rework.Cdt = newMb.Cdt;
                rework.Udt = newMb.Udt;
                rework.Status = "1";

                return rework;

                //===========================================================================
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(BGAOutputImpl)Cancel end, [MbSno]:" + sno + "[Station]:" + reworkStation);
            } 
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 刷MBSno,启动工作流,检查输入的Sno,卡站,获取RepairList
        /// </summary>
        /// <param name="sno"></param>
        /// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ArrayList InputSno(string sno, string line, string editor, string station, string customer)
        {
            logger.Debug("(BGAOutputImpl)InputSno start, MBSno:" + sno);
            
            try
            {
                ArrayList retList = new ArrayList();
                string sessionKey = sno;
                
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
                
                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, SessionType, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", SessionType);
                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "BGAOutput.xoml", "BGAOutput.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);
                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        FisException ex;
                        List<string> erpara = new List<string>();
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }
                //==============================================================================
                
                //Get [Repair List] By [MBSno]
                //select SnoId,Remark,Username,Cdt,Udt from rpt_PCARep nolock 
                //where Tp='BGA' and SnoId=@MBSNo order by Cdt
              
                IMB curMb = (IMB)currentSession.GetValue(Session.SessionKeys.MB);
                IList<MBRptRepair>  repairList = curMb.MBRptRepairs;
                IList<Rework> infoList = new List<Rework>();
                //DEBUG ITC-1360-0736
                //order by Cdt
                var repairListOrderbyCdt =
                            from item in repairList
                            orderby item.Cdt 
                            select item;


                foreach (MBRptRepair tmpNode in repairListOrderbyCdt)
                {   
                    if (tmpNode.Tp == "BGA")
                    {
                        Rework info = new Rework() ;
                        info.ReworkCode = tmpNode.Remark;
                        info.Cdt = tmpNode.Cdt;
                        //DEBUG ITC-1360-0736
                        //info.Udt = tmpNode.Cdt;
                        info.Udt = tmpNode.Udt;
                        infoList.Add(info);
                    }
                }

                retList.Add(sno);
                retList.Add(infoList);
               //===============================================================================
                return retList;

            }
            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("(BGAOutputImpl)InputSno end, MBSno:" + sno);
            }
        }
Ejemplo n.º 3
0
        public ArrayList Save(List<string> SNList,
                              List<string> PNList,
                              List<string> errList, string Editor, string Station, string customer)
        {
            logger.Debug("(ReturnUsedKeysImpl)Save start" 
                
                + " [editor]:" + Editor
                + " [station]:" + Station
                + " [customer]:" + customer);
            FisException ex;
            List<string> erpara = new List<string>();
            ArrayList retvaluelist = new ArrayList();
            string ECOAReturnStatus = "0";
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            var currentRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();

            try
            {
                ///生成group id
                SqlTransactionManager.Begin();
                IUnitOfWork Number_uof = new UnitOfWork();//使用自己的UnitOfWork
                string prestr = "";
                string maxnum = "";
                bool addflag = false;
               
                INumControlRepository numControl = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();
                maxnum = numControl.GetMaxNumber("GroupID", prestr + "{0}");
                if (string.IsNullOrEmpty(maxnum))
                {
                    maxnum = "001";
                    addflag = true;
                }
                else
                {
                    if (maxnum.Substring(6, 3).ToUpper() == "999")
                    {
                        maxnum = "001";
                    }
                    else
                    {
                        int count = Int32.Parse(maxnum.Substring(6, 3));
                        count = count + 1;
                        maxnum = (count).ToString().PadLeft(3, '0');
                    }
                }
                DateTime dd = DateTime.Now;
                string Groupid = dd.Year.ToString().Substring(2,2) + dd.Month.ToString().PadLeft(2, '0') + dd.Day.ToString().PadLeft(2, '0') + maxnum;
                NumControl item = new NumControl();
                item.NOType = "GroupID";
                item.Value = Groupid;
                item.NOName = "";
                item.Customer = "HP";

                numControl.SaveMaxNumber(item, addflag, prestr + "{0}");
               
                Number_uof.Commit();  //立即提交UnitOfWork更新NumControl里面的最大值
                SqlTransactionManager.Commit();//提交事物,释放行级更新锁

                
                 
                /////////////////////////////////////////////////

                for (int i = 0; i < SNList.Count; i++)
                {
                    IProduct CurrentProduct = null;
                    if (errList[i] == "Pass")
                    {
                        string custSn = SNList[i];
                        
                        IUnitOfWork work = new UnitOfWork();
                        CurrentProduct = productRepository.GetProductByCustomSn(custSn);
                        if (CurrentProduct == null)
                        {
                            continue;
                        }
                        string line = CurrentProduct.Status.Line;
                        StationStatus Status = StationStatus.Pass;
                      
                        var productLog = new ProductLog
                        {
                            Model = CurrentProduct.Model,
                            Status = Status,
                            Editor = Editor,
                            Line = line,
                            Station = Station,
                            Cdt = DateTime.Now
                        };
                        CurrentProduct.AddLog(productLog);
                      
                        /////////update product status
                        var newStatus = new ProductStatus();
                        newStatus.Status = Status;
                        newStatus.StationId = Station;
                        newStatus.Editor = Editor;
                        newStatus.Line = line;
                        newStatus.TestFailCount = 0;

                        if (!string.IsNullOrEmpty(CurrentProduct.Status.ReworkCode) && productRepository.IsLastReworkStation(CurrentProduct.Status.ReworkCode, Station, (int)Status))
                        {
                            newStatus.ReworkCode = "";
                            IMES.DataModel.Rework r = new IMES.DataModel.Rework();
                            r.ReworkCode = CurrentProduct.Status.ReworkCode;
                            r.Editor = Editor;
                            r.Status = "3";
                            r.Udt = DateTime.Now;
                            productRepository.UpdateReworkConsideredProductStatusDefered(work, r, CurrentProduct.ProId);
                        }
                        else
                        {
                            newStatus.ReworkCode = CurrentProduct.Status.ReworkCode;
                        }
                        newStatus.ProId = CurrentProduct.ProId;
                        CurrentProduct.UpdateStatus(newStatus);
                        
                        productRepository.Update(CurrentProduct, work);

                        ECOAReturnStatus = "1";
                    }
                    dm.EcoareturnInfo item1 = new dm.EcoareturnInfo();
                    item1.custsn = SNList[i];
                    item1.partNo = PNList[i];
                    item1.message = errList[i];
                    item1.status = ECOAReturnStatus;
                    item1.line = CurrentProduct.Status.Line;
                    item1.groupNo = Groupid;
                    
                    currentRepository.InsertEcoareturn(item1);

                }
                retvaluelist.Add(Groupid);
                return retvaluelist;

            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);

                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(ReturnUsedKeysImpl)Save end" 
                    
                    + " [editor]:" + Editor
                    + " [station]:" + Station
                    + " [customer]:" + customer);
            }
        }
Ejemplo n.º 4
0
        private ReworkMaintainInfo convertToMaintainInfoFromObj(Rework temp)
        {
            ReworkMaintainInfo rework = new ReworkMaintainInfo();

            rework.ReworkCode = temp.ReworkCode;
            rework.Status = temp.Status;
            rework.Editor = temp.Editor;
            rework.Cdt = temp.Cdt;
            rework.Udt = temp.Udt;

            return rework;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 将被选Rework的状态改为2(Confirm)  ,复制数据, 解绑
        /// </summary>
        /// <returns></returns>
        public void ConfirmRework(string reworkCode,string editor)
        {
            string reworkStatus = productRepository.GetReworkStatus(reworkCode);
            if (reworkStatus == null)
            {
                return;
            }
            //判断rework的当前状态
            if (reworkStatus.Equals("0"))
            {
                List<string> erpara = new List<string>();
                FisException ex1 = new FisException("DMT028", erpara);
                throw ex1;
            }
            if (!reworkStatus.Equals("1"))
            {
                List<string> erpara = new List<string>();
                FisException ex2 = new FisException("DMT029", erpara);
                throw ex2;
            }

            Rework rework = new Rework();
            rework.ReworkCode = reworkCode;
            rework.Status = "2";
            rework.Editor = editor;
            rework.Udt = DateTime.Now;

            //复制数据,Update ProductStatus, Station=‘RW’, Status=1, Insert ProductLog。 
            //解绑数据
            //1,取得ReleaseType 
            //2,根据ReleaseType解绑数据
            //设置对应Rework Process的首站的PreStation(即PreStation=‘‘)为‘RW’
            productRepository.ClearData(reworkCode, editor);

            //更新Rework记录,Rework.Status=2(Create)
            productRepository.UpdateRework(rework);

        }
Ejemplo n.º 6
0
        /// <summary>
        /// 将被选Rework的状态改为1(Submit)  
        /// </summary>
        /// <returns></returns>
        public void SubmitRework(string reworkCode,string editor)
        {
            Rework rework = new Rework();
            rework.ReworkCode = reworkCode;
            rework.Status = "1";
            rework.Editor = editor;
            rework.Udt = DateTime.Now;

            //更新Rework记录,Rework.Status=1(Create)
            productRepository.UpdateRework(rework);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 创建Rework,检查Product List中所有Product是否可以做Rework,若不可以,则提示用户,放弃后续操作。
        /// </summary>
        /// <returns></returns>
        public string CreateRework(IList<string> productIDList,string editor)
        {
            string userKey = Guid.NewGuid().ToString();
            //string reworkCode;
            Rework rework = new Rework();
            try
            {
                //insert ProductIDListForRework(UserKey,ProductID) values(?,?)
                productRepository.CreateTempProductIDList(productIDList, userKey);

                //select count(1) 
                //from IMES_GetData.dbo.TempProductID a 
                //     join IMES_FA.dbo.Rework_Product b on a.ProductID = b.ProductID  
                //     join IMES_FA.dbo.Rework c on b.ReworkCode=c.ReworkCode 
                //where Rework.Status<>3 and a.UserKey=?
                int count1 = productRepository.GetUnitExistsCountByUserKey(userKey);

                //select count(1) 
                //from IMES_GetData.dbo.TempProductID a 
                //     join IMES_FA.dbo.ProductStatus b on a.ProductID = b.ProductID  
                //     join IMES_GetData.dbo.ReworkRejectStation c on b.Station =c.Station and b.Status=c.Status  
                //where a.UserKey=? 
                int count2 = productRepository.GetInvalidUnitCountByUserKey(userKey);

                List<string> erpara = new List<string>();
                if (count1 > 0)
                {
                    //存在Unit存在Rework_Product表且ReworkCode对应的Rework.Status<>3
                    FisException ex1 = new FisException("DMT023", erpara);
                    throw ex1;
                }
                if (count2 > 0)
                {
                    //存在unit的Product.Station and Status存在于ReworkRejectStation表
                    FisException ex2 = new FisException("DMT024", erpara);
                    throw ex2;
                }

                rework.Status = "0";
                rework.Editor = editor;
                rework.Cdt = DateTime.Now;
                rework.Udt = DateTime.Now;

                UnitOfWork uow = new UnitOfWork();
                //创建Rework记录,Rework.Status=0(Create)
                productRepository.CreateReworkDefered(uow, rework);
                //将对应ProductStatus表中的ReworkCode栏位设置为新产生的Rework Code。
                ReworkObj rwkObj = new ReworkObj();
                SetterBetween stbt = new SetterBetween(rework, "ReworkCodeProperty", rwkObj, "ReworkCodeProperty");
                uow.RegisterSetterBetween(stbt);
                productRepository.UpdateProductStatusReworkCodeByUserKeyDefered(uow, userKey, rwkObj);
                uow.Commit();
            }
            catch (Exception e)
            {
                logger.Debug(e.Message);
                throw e;
            }
            finally
            {
                //delete ProductIDListForRework where UserKey=? 
                productRepository.DeleteProductIDListByUserKey(userKey);
            }

            return rework.ReworkCode;
        }