예제 #1
0
//        private ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        public void Save(object part_unit, object part_owner, string station, string key)
        {
            if (part_unit == null)
            {
                throw new ArgumentNullException();
            }
            if (part_owner == null)
            {
                throw new ArgumentNullException();
            }

            var product = (Product)part_owner;
            product.PCBID = ((PartUnit)part_unit).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 mb_repository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            IMB mb = mb_repository.Find(product.PCBID);
            if (mb != null)
            {
                product.PCBModel = mb.PCBModelID;
                product.MAC = mb.MAC;
                product.MBECR = mb.ECR;
                if (!string.IsNullOrEmpty(mb.CVSN))
                {
                    product.CVSN = mb.CVSN;
                }
//                product.CVSN = mb.CVSN;
                product.UUID = mb.UUID;
                //ProductInfo表
                //InfoType=‘IECECR’ 
                //InfoValue= PCB. IECECR
                product.SetExtendedProperty("IECECR", mb.IECVER, session.Editor);
                product.SetExtendedProperty("DateCode", mb.DateCode, 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);
                }

                #region recode PCBStatusEx for table structure

                IList<TbProductStatus> preStatusList = mb_repository.GetMBStatus(new List<string>() { mb.Sn });
                mb_repository.UpdatePCBPreStationDefered(session.UnitOfWork,
                                                                                    preStatusList);
                #endregion

                #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


                mb.MBStatus.Station = "32";
                mb.MBStatus.Status = MBStatusEnum.Pass;
                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);

                ProductPart set_value = new ProductPart();
                ProductPart condition = new ProductPart();
                if (!string.IsNullOrEmpty(mb.CVSN))
                {
                    set_value.PartSn = mb.CVSN;
                    condition.CheckItemType = "CPU";
                    condition.ProductID = product.ProId;
                    product_repository.UpdateProductPartDefered(session.UnitOfWork, set_value, condition);
                }
                if (product.IsCDSI)
                {
                    string CNRSModel = (string)product.ModelObj.GetAttribute("CNRS");
                    SpecialDetInfo item;
                    if (!string.IsNullOrEmpty(CNRSModel) && CNRSModel == "Y")
                    {
                        item = new SpecialDetInfo { snoId = product.ProId, tp = "CNRS", sno1 = product.MAC, cdt = new DateTime(), id = 0, udt = new DateTime() };
                    }
                    else
                    {
                        item = new SpecialDetInfo { snoId = product.ProId, tp = "CDSI", sno1 = product.MAC, cdt = new DateTime(), id = 0, udt = new DateTime() };
                    }
                        product_repository.InsertSpecialDet(item);
//                    logger.Debug(" IMES.CheckItemModule.MB.Filter.SaveModule.Save  Time : " + new DateTime());
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 根据BOM查询结果,对Special_Det表进行相应修改
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
/*//test,测试流程是否通,需去掉========
return base.DoExecute(executionContext);
//test,测试流程是否通,需去掉========*/

            Session session = CurrentSession;
            ActivityCommonImpl utl = ActivityCommonImpl.Instance;

            IProduct currenProduct = utl.IsNull<IProduct>(session, Session.SessionKeys.Product);
            var prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IList<AstDefineInfo> needCombineAstDefineList = utl.IsNull<IList<AstDefineInfo>>(session, Session.SessionKeys.NeedCombineAstDefineList);
            IList<IPart> needCombineAstPartList = utl.IsNull<IList<IPart>>(session, Session.SessionKeys.NeedCombineAstPartList);

            //var currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            var AssetSN = (string)CurrentSession.GetValue("AssetSN");

            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            bool isExist = false;

            //当BOM中存在BOMNodeType=”AT”(Asset Tag),其对应的Part.PartType=’ATSN7’ or ‘ATSN8’时,进行表修改
            //IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
            //IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currenProduct.Model);
            //IList<IBOMNode> bomNodes = bom.GetNodesByNodeType("AT");          
            //foreach (IBOMNode bomNode in bomNodes)
            foreach(IPart part in needCombineAstPartList)
            {
                //if (bomNode.Part.Type == "ATSN7" || bomNode.Part.Type == "ATSN8")
                if (part.Descr == "ATSN7" || part.Descr == "ATSN8")
                {
                    //ITC-1360-1761, Jesscia Liu, 2012-4-24
                    if (string.IsNullOrEmpty( AssetSN))
                    {
                        if (part.Descr == "ATSN8")
                        {
                            AssetSN = part.PN;
                        }
                    }

                    //ITC-1360-0857, Jesscia Liu, 2012-2-28
                    //isExist = productRepository.CheckExistSpecialDet(bomNode.Part.Type, currenProduct.ProId);
                    isExist = productRepository.CheckExistSpecialDet(part.Descr, currenProduct.ProId);
                    
                    if (isExist == true)
                    {
                        //若存在,则Update Sno1=@astsn,Udt=getdate()
                        //productRepository.UpdateSpecialDetSno1(AssetSN, bomNode.Part.Type, currenProduct.ProId);
                        productRepository.UpdateSpecialDetSno1Defered(session.UnitOfWork, AssetSN, part.Descr, currenProduct.ProId);
                    }
                    else
                    {
                        //否则Insert(Tp是’ATSN7’ or ‘ATSN8’)
                        SpecialDetInfo sd = new SpecialDetInfo();
                        sd.sno1 = AssetSN??"";
                        sd.snoId = currenProduct.ProId;
                        sd.tp = part.Descr;//bomNode.Part.Type;
                        productRepository.AddSpecialDetInfoDefered(session.UnitOfWork, sd);
                    }
                }               
            }
           
            return base.DoExecute(executionContext);
        }
예제 #3
0
        /// <summary>
        /// 根据BOM查询结果,对Special_Det表进行相应修改
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
/*//test,测试流程是否通,需去掉========
return base.DoExecute(executionContext);
//test,测试流程是否通,需去掉========*/

            var currenProduct = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            var AssetSN = (string)CurrentSession.GetValue("AssetSN");

            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            bool isExist = false;

            //当BOM中存在BOMNodeType=”AT”(Asset Tag),其对应的Part.PartType=’ATSN7’ or ‘ATSN8’时,进行表修改
            IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
            IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currenProduct.Model);
            IList<IBOMNode> bomNodes = bom.GetNodesByNodeType("AT");          
            foreach (IBOMNode bomNode in bomNodes)
            {
                //if (bomNode.Part.Type == "ATSN7" || bomNode.Part.Type == "ATSN8")
                if (bomNode.Part.Descr == "ATSN7" || bomNode.Part.Descr == "ATSN8")
                {
                    //ITC-1360-1761, Jesscia Liu, 2012-4-24
                    if (AssetSN == "null")
                    {
                        if (bomNode.Part.Descr == "ATSN8")
                        {
                            AssetSN = bomNode.Part.PN;
                        }
                    }

                    //ITC-1360-0857, Jesscia Liu, 2012-2-28
                    //isExist = productRepository.CheckExistSpecialDet(bomNode.Part.Type, currenProduct.ProId);
                    isExist = productRepository.CheckExistSpecialDet(bomNode.Part.Descr, currenProduct.ProId);
                    
                    if (isExist == true)
                    {
                        //若存在,则Update Sno1=@astsn,Udt=getdate()
                        //productRepository.UpdateSpecialDetSno1(AssetSN, bomNode.Part.Type, currenProduct.ProId);
                        productRepository.UpdateSpecialDetSno1(AssetSN, bomNode.Part.Descr, currenProduct.ProId);
                    }
                    else
                    {
                        //否则Insert(Tp是’ATSN7’ or ‘ATSN8’)
                        SpecialDetInfo sd = new SpecialDetInfo();
                        sd.sno1 = AssetSN;
                        sd.snoId = currenProduct.ProId;
                        sd.tp = bomNode.Part.Descr;//bomNode.Part.Type;
                        productRepository.AddSpecialDetInfo(sd);
                    }
                }               
            }
           
            return base.DoExecute(executionContext);
        }