Пример #1
0
        /// <summary>
        /// 输入Product Id相关信息并处理
        /// </summary>
        /// <param name="pdLine">Pd Line</param>
        /// <param name="NewMB">New MB</param>
        /// <param name="OldMB">Old MB</param>
        /// <param name="editor">operator</param>
        /// <returns>prestation</returns>
        public string CheckMBandSave(string pdLine, string NewMB, string OldMB, string editor, string stationId, string customer)
        {
            logger.Debug("(CheckMBandSaveImpl)CheckMBandSave start, [pdLine]:" + pdLine
                + " [NewMB]: " + NewMB
                + " [OldMB]: " + OldMB
                + " [editor]:" + editor
                + " [station]:" + stationId
                + " [customer]:" + customer);
            FisException ex;
            List<string> erpara = new List<string>();
            string retvalue = "sussend";

            //string checkContactType = "OLD MB";
            string checkNewType = "VGA";
            //string sessionKey = NewMB;
            IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            IMBChangeLogRepository mbChangeLogRep = RepositoryFactory.GetInstance().GetRepository<IMBChangeLogRepository, MBChangeLog>();
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IProduct newMbProduct = null;
            IProduct oldMbProduct = null;
            try
            {

               /* string[] checkContactValue = new string[2];
                checkContactValue[0] = NewMB;
                checkContactValue[1] = OldMB;
                IList<MBInfo> checkContactReturn = mbRepository.GetMbInfoListByInfoTypeAndPcbNoList(checkContactType, checkContactValue);*/

                MBChangeLog CheckItem = new MBChangeLog();
                CheckItem.Sn = OldMB;
                CheckItem.NewSn = NewMB;
                IList<MBChangeLog> checkContactReturn = mbChangeLogRep.GetMBChangeLogs(CheckItem);
                if (checkContactReturn.Count != 0)
                {
                    erpara.Add("This MB has been Contacted");
                    ex = new FisException("CHK217", erpara);
                    throw ex;
                }
                newMbProduct = productRepository.Find(NewMB);
                int NewMBCount = productRepository.GetProductInfoCountByInfoValue(checkNewType, NewMB);
                if (newMbProduct != null || NewMBCount != 0)
                {
                    erpara.Add("This NEW MB has been Combined PC");
                    ex = new FisException("CHK219", erpara);
                    throw ex;
                }

                oldMbProduct = productRepository.Find(OldMB);
                int OldMBCount = productRepository.GetProductInfoCountByInfoValue(checkNewType, OldMB);
                if (oldMbProduct != null || OldMBCount != 0)
                {
                    erpara.Add("This Old MB has been Combined PC");
                    ex = new FisException("CHK218", erpara);
                    throw ex;
                }
                //IMBRepository mbChangeLog = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
                MBChangeLog item = new MBChangeLog(OldMB, NewMB, "客退板", editor, DateTime.Now);
                //item.
                IUnitOfWork work = new UnitOfWork();
                mbChangeLogRep.Add(item, work);
                work.Commit();
                return retvalue;

            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(CheckMBandSaveImpl)InputProdId end, [pdLine]:" + pdLine
                    + " [prodId]: " + NewMB
                    + " [editor]:" + editor
                    + " [station]:" + stationId
                    + " [customer]:" + customer);
            }
        }
Пример #2
0
        /// <summary>
        /// GenerateMBSn
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string moNo;
            string model;
            string dateCode;
            string custSn;
            var mbmo = (IMBMO)CurrentSession.GetValue(Session.SessionKeys.MBMO);
            if (mbmo == null)
            {
                var CurrentMB = (MB)CurrentSession.GetValue(Session.SessionKeys.MB);
                moNo = CurrentMB.SMTMO;
                model = CurrentMB.Model;
                dateCode = CurrentMB.DateCode;
                custSn = ""; //CurrentMB.CustSn; //由于改过Kenel后报错,jiali Add

            }
            else
            {
                moNo = mbmo.MONo;
                model = mbmo.Model;
                dateCode = CurrentSession.GetValue(Session.SessionKeys.DateCode).ToString();
                //由于改过Kenel后报错,jiali Add
                custSn = "";// CurrentSession.Customer;
            }

            IList MBNOList = new ArrayList();
            MBNOList = (IList)CurrentSession.GetValue(Session.SessionKeys.MBNOList);

            var MBObjectList = new List<IMB>();

            IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
           
            // add check replaceMB case
            bool isReplaceMB=false;
            if (CurrentSession.GetValue(ExtendSession.SessionKeys.IsReplaceMB)!=null)
            {
                isReplaceMB = (bool)CurrentSession.GetValue(ExtendSession.SessionKeys.IsReplaceMB);
            }
            if (!isReplaceMB)
            {
                foreach (string item in MBNOList)
                {
                    string mac = "";
                    string uuid = "";
                    string ecr = "";
                    string iecVer = "";
                    string custVer = "";
                    string cvsn = "";
                    if (this.Station == "VG")
                    {
                        ecr = "00000";
                    }
                    //由于改过Kenel后报错,jiali Add custSn
                    MB mb = new MB(item, moNo, custSn, model, dateCode, mac, uuid, ecr, iecVer, custVer, cvsn, DateTime.Now, DateTime.Now);
                    MBStatus mbStatus = new MBStatus(item, this.Station, MBStatusEnum.Pass, this.Editor, this.Line, DateTime.Now, DateTime.Now);
                    mb.MBStatus = mbStatus;

                    mbRepository.Add(mb, CurrentSession.UnitOfWork);
                    MBObjectList.Add(mb);
                }
            }
            else
            {

                
                string oldMBSN = (string)CurrentSession.GetValue(Session.SessionKeys.OldMB);
                string newMBSN = MBNOList[0].ToString();
                string reason = (string)CurrentSession.GetValue(ExtendSession.SessionKeys.ChangMBReason);
                // Change to one Child MB SN for only one
                //newMBSN = newMBSN.Substring(0, 5) + oldMBSN.Substring(5, 1) + newMBSN.Substring(6, 4);
                if (newMBSN.Substring(5, 1) == "M" || newMBSN.Substring(5, 1) == "B")
                {
                    if (oldMBSN.Substring(5, 1) == "M" || oldMBSN.Substring(5, 1) == "B")
                        newMBSN = newMBSN.Substring(0, 6) + oldMBSN.Substring(6, 1) + newMBSN.Substring(7, 4);
                    else
                        newMBSN = newMBSN.Substring(0, 6) + oldMBSN.Substring(5, 1) + newMBSN.Substring(7, 4);
                }
                else
                {
                    if (oldMBSN.Substring(5, 1) == "M" || oldMBSN.Substring(5, 1) == "B")
                       newMBSN = newMBSN.Substring(0, 5) + oldMBSN.Substring(6, 1) + newMBSN.Substring(6, 4);
                    else
                       newMBSN = newMBSN.Substring(0, 5) + oldMBSN.Substring(5, 1) + newMBSN.Substring(6, 4);
                }
                MBNOList[0] = newMBSN;
               
                //Jiali Add
                MBChangeLogRepository mbchange = new MBChangeLogRepository();
                MBChangeLog mbchangelog = new MBChangeLog(oldMBSN, newMBSN, reason, Editor, DateTime.Now);
                mbchange.Add(mbchangelog, CurrentSession.UnitOfWork);

                mbRepository.ReplaceMBSn(oldMBSN, newMBSN);
                MBObjectList.Add(mbRepository.Find(newMBSN));
                              
            }
            CurrentSession.AddValue(Session.SessionKeys.MBList, MBObjectList);

           return base.DoExecute(executionContext);
        }