private int CheckPartMatch(ref IProductPart pp, ref IList<IBOMNode> lstBomsC2) { int pos = -1; for (int i = 0; i < lstBomsC2.Count; i++) { IBOMNode n = lstBomsC2[i]; if (pp.PartID.Equals(n.Part.PN)) // case 1, 结合的是PartNo { return i; } foreach (PartInfo pi in n.Part.Attributes) { if ("VendorCode".Equals(pi.InfoType)) { if (pp.PartSn.Length >= 5 && pp.PartSn.Substring(0, 5).Equals(pi.InfoValue)) // case 2, 结合的是CT { return i; } } if ("SUB".Equals(pi.InfoType)) { if (pp.PartID.Equals(pi.InfoValue)) // case 3, 替代料 { return i; } } } } return pos; }
/// <summary> /// Bind part to owner /// 1.Update COAStatus, Status=A1 ///2.记录COALOG ///3.Product.COAID=Code /// </summary> /// <param name="part">part</param> /// <param name="owner">owner</param> public override void BindTo(IProductPart part, IPartOwner owner) { // if (!part.ValueType.Equals(("SN"))) // { // base.BindTo(part, owner); // return; // } var product = (IProduct)owner; Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product); var productRepoistory = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); var coaRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>(); COAStatus coa = coaRepository.Find(part.Value); //1 coa.Status = COAStatus.COAStatusConst.A1; //2 var log = new COALog { COASN = coa.COASN, StationID = session.Station, LineID = session.Line, Editor = session.Editor, Cdt = DateTime.Now }; coa.addCOALog(log); //3 product.COAID = part.Value; coaRepository.Update(coa, session.UnitOfWork); productRepoistory.Update(product, session.UnitOfWork); }
protected Product GetProduct(HtmlHelper html, IProductPart item) { if (item == null) { return(null); } Product product = null; var currentController = html.ViewContext.Controller as INimbusContentController; try { long pid; if (!long.TryParse(item.Product, out pid)) { return(null); } if (currentController == null || (!currentController.Products.TryGetValue(pid, out product) && !currentController.BogusProductIds.Contains(pid))) { product = _catalogApi.GetProductAsync(_catalogApi.GetProductUri(pid)).Result; } } catch (Exception e) { Logger.Error(e, "Unable to retrieve product with product ID {0}", item.Product); product = null; } return(product); }
public override void BindTo(IProductPart part, IPartOwner owner) { var product = (IProduct)owner; Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product); var productRepoistory = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); product.IMEI = part.Value; productRepoistory.Update(product, session.UnitOfWork); }
/// <summary> /// 将part绑定到Product/MB的默认实现,即直接绑定至owner /// </summary> /// <param name="part">part</param> /// <param name="owner">owner</param> public virtual void BindTo(IProductPart part, IPartOwner owner) { PartCheck checkSetting = this.GetPartCheckSettingData(part.ValueType); if (checkSetting == null) { string msg = string.Format("PartCheck data of {0} type does not exist.", part.PartType); Exception ex = new Exception(msg); throw ex; } part = ProductPart.PartSpecialDeal(part); if (checkSetting.NeedSave == 1) { owner.AddPart(part); } }
public async Task<OfferListViewModel> GetProductOfferListAsync(ProductOfferListPart productOfferListPart, IProductPart page, ICatalogApi catalogApi) { // The driving product is taken off of either the product on the page (if the page is a product page) or off of the "Product" picker on the part. // The Product picker will override the page's product. long pid; if (!long.TryParse(productOfferListPart.Product, out pid) || pid == 0) { if (page != null && page.Product.Contains(",")) { var parts = page.Product.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 0) long.TryParse(parts[0], out pid); } } if (pid == 0) return await GetOfferListAsync(productOfferListPart).ConfigureAwait(false); if (String.IsNullOrEmpty(productOfferListPart.PopName)) return new OfferListViewModel(); var offers = await _offersApi.GetOffersAsync(productOfferListPart.PopName, catalogApi.GetProductUri(pid)).ConfigureAwait(false); return OffersToOfferListViewModel(productOfferListPart, offers); }
/// <summary> /// /// </summary> //public void GenerateRepairByTestLog() //{ // throw new NotImplementedException(); //} /// <summary> /// 将指定partID对应的Part替换 /// </summary> /// <param name="partID">指定partID</param> /// <param name="newPart">新Part</param> public void ChangePart(int partID, IProductPart newPart) { foreach(var part in this.MBParts) { if (part.ID == partID) { part.PartID = newPart.PartID; part.Value = newPart.Value; part.PartSn = newPart.PartSn; } } }
/// <summary> /// 在ProductPart列表中添加指定part /// 这是PartOwner的默认行为,只将 /// Part单纯绑定到Owner不会针对不 /// 同的Part类型进行特殊的处理 /// </summary> /// <param name="part">part</param> public void AddPart(IProductPart part) { if (part == null) return; lock (_syncObj_parts) { object naught = this.PizzaParts; ((ProductPart)part).Tracker = this._tracker.Merge(((ProductPart)part).Tracker); this._parts.Add(part); this._tracker.MarkAsAdded(part); this._tracker.MarkAsModified(this); } }
private IProductPart getUpdatedPart(IProductPart part, bool isSn, string val, String objType) { IProductPart ret = null; if (string.Compare(objType, "MB", true) == 0) { IProductPart tempPart = part; if (isSn) { ret = new ProductPart(tempPart.ID, tempPart.PartID, tempPart.ProductID, val, string.Empty, tempPart.Station, tempPart.Editor, tempPart.Cdt, DateTime.Now); } } else { IProductPart tempPart = part; if (isSn) { //ret = new ProductPart(tempPart.ID, tempPart.PartID, tempPart.ProductID, val, string.Empty, tempPart.Station, tempPart.Editor, tempPart.Cdt, DateTime.Now); ret = new ProductPart(tempPart.ID, tempPart.PartID, tempPart.ProductID, val, string.Empty, tempPart.Station, this.Editor, tempPart.Cdt, DateTime.Now); } else { //ret = new ProductPart(tempPart.ID, tempPart.PartID, val, tempPart.Value, string.Empty, tempPart.Station, tempPart.Editor, tempPart.Cdt, DateTime.Now); ret = new ProductPart(tempPart.ID, tempPart.PartID, val, tempPart.Value, string.Empty, tempPart.Station, this.Editor, tempPart.Cdt, DateTime.Now); } } return ret; }
void CreateDefectComponentInfo(DefectComponentInfo v, RepairInfo ri, IProduct prod, IProductPart pp, string OldPart, string PartType, string BomNodeType, string IECPn, string CheckItemType) { v.RepairID = int.Parse(ri.repairID); v.BatchID = ""; //remark v.Customer = this.Customer; v.Model = prod.Model; v.Family = prod.Family == null ? "" : prod.Family; v.DefectCode = ri.defectCodeID; v.DefectDescr = ri.defectCodeDesc == null ? "" : ri.defectCodeDesc; v.ReturnLine = ""; v.PartSn = ri.oldPartSno; v.PartNo = OldPart; v.PartType = PartType; v.BomNodeType = BomNodeType; v.IECPn = IECPn; v.CustomerPn = ""; v.Vendor = ""; v.CheckItemType = CheckItemType; v.Comment = ""; v.Status = this.Status; v.Editor = this.Editor; v.Cdt = DateTime.Now; v.Udt = DateTime.Now; }
public async Task <OfferListViewModel> GetProductOfferListAsync(ProductOfferListPart productOfferListPart, IProductPart page, ICatalogApi catalogApi) { // The driving product is taken off of either the product on the page (if the page is a product page) or off of the "Product" picker on the part. // The Product picker will override the page's product. long pid; if (!long.TryParse(productOfferListPart.Product, out pid) || pid == 0) { if (page != null && page.Product.Contains(",")) { var parts = page.Product.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 0) { long.TryParse(parts[0], out pid); } } } if (pid == 0) { return(await GetOfferListAsync(productOfferListPart).ConfigureAwait(false)); } if (String.IsNullOrEmpty(productOfferListPart.PopName)) { return(new OfferListViewModel()); } var offers = await _offersApi.GetOffersAsync(productOfferListPart.PopName, catalogApi.GetProductUri(pid)).ConfigureAwait(false); return(OffersToOfferListViewModel(productOfferListPart, offers)); }
private void backupProductPartById(IProductPart part) { IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); prodRep.BackUpProductPartById( part.ID, this.Editor); }
protected Product GetProduct(HtmlHelper html, IProductPart item) { if (item == null) return null; Product product = null; var currentController = html.ViewContext.Controller as INimbusContentController; try { long pid; if (!long.TryParse(item.Product, out pid)) return null; if (currentController == null || (!currentController.Products.TryGetValue(pid, out product) && !currentController.BogusProductIds.Contains(pid))) product = _catalogApi.GetProductAsync(_catalogApi.GetProductUri(pid)).Result; } catch (Exception e) { Logger.Error(e, "Unable to retrieve product with product ID {0}", item.Product); product = null; } return product; }
/// <summary> /// Bind pat to owner: /// A.Product.PCBID=mb sn# ///B.需要修改MB 的PCA..PCBStatus.Station = 32 ///C.记录MB Log Inert PCA..PCBLog ///D.将MB相关信息写入Product表: ///Product.PCBModel=PCA..PCB.PCBModelID ///Product. MAC =PCA..PCB. MAC ///Product. UUID =PCA..PCB. UUID ///Product. MBECR =PCA..PCB. ECR /// </summary> /// <param name="part">part</param> /// <param name="owner">owner</param> public override void BindTo(IProductPart part, IPartOwner owner) { // if (!part.ValueType.Equals(("SN"))) // { // base.BindTo(part, owner); // return; // } var product = (IProduct)owner; Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product); var productRepoistory = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); var mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>(); var mb = mbRepository.Find(part.Value); string line = string.IsNullOrEmpty(session.Line) ? product.Status.Line : session.Line; //A product.PCBID = mb.Sn; //B var status = new MBStatus(mb.Key.ToString(), "32", MBStatusEnum.Pass , session.Editor, line, DateTime.Now, DateTime.Now); mb.MBStatus = status; //C var mbLog = new MBLog( 0, mb.Sn, mb.Model, "32", 1, line, session.Editor, DateTime.Now); mb.AddLog(mbLog); //D product.PCBModel = mb.Model; product.MAC = mb.MAC; product.UUID = mb.UUID; product.MBECR = mb.ECR; product.CVSN = mb.CVSN; mbRepository.Update(mb, session.UnitOfWork); productRepoistory.Update(product, session.UnitOfWork); }
/// <summary> /// 有些类型的Part保存前需要对part数据进行特殊改变, 取出后也要进行反向转换 /// </summary> /// <param name="part"></param> /// <returns></returns> public static IProductPart PartReverseSpecialDeal(IProductPart part) { //B-CASS: PVS记录到Pizza_Parts, Code去掉前后A字符后,每4码中间使用-分割保存到DB中 if (part.PartType.Equals("B-CASS") && part.ValueType.Equals("SN")) { String bcassSn = part.Value; bcassSn = "A" + bcassSn + "A"; bcassSn = bcassSn.Replace("-", ""); ((ProductPart)part).SetValueSilently(bcassSn); } return part; }
/// <summary> /// 在ProductPart列表中添加指定part /// 这是PartOwner的默认行为,只将 /// Part单纯绑定到Owner不会针对不 /// 同的Part类型进行特殊的处理 /// </summary> /// <param name="part">part</param> public void AddPart(IProductPart part) { if (part == null) return; lock (_syncObj_part) { foreach (var oldPart in this.MBParts) { //PCA Shipping Label 中的VGA SN/CPU SN 不需要检查是否和MB 已绑定资料是否一致; //如果发现MB 已经绑定VGA SN/CPU SN 等,在Save 的时候进行Update;如果尚未绑定,则Insert //因为MB 重流缺失了解绑part的站,因此需要此处特殊处理,相关内容参考GetMB中注释 if (part.PartType.Equals(oldPart.PartType) && part.PartSn.Equals(oldPart.PartSn)) { oldPart.PartID = part.PartID; oldPart.Value = part.Value; oldPart.Station = part.Station; oldPart.Iecpn = part.Iecpn; oldPart.CustomerPn = part.CustomerPn; oldPart.BomNodeType = part.BomNodeType; oldPart.CheckItemType = part.CheckItemType; oldPart.Cdt = part.Cdt; oldPart.Udt = DateTime.Now; oldPart.Editor = part.Editor; this._tracker.MarkAsModified(this); return; } } ((ProductPart)part).Tracker = this._tracker.Merge(((ProductPart)part).Tracker); this._part.Add(part); this._tracker.MarkAsAdded(part); this._tracker.MarkAsModified(this); } }
/// <summary> /// /// </summary> /// <param name="session"></param> /// <param name="product"></param> /// <param name="conditionInfoList"></param> /// <param name="productPart"></param> /// <param name="editor"></param> public static void UnPackProduct(Session session, IProduct product, IList<ConstValueInfo> conditionInfoList, IProductPart productPart, string editor) { var matchInfo = conditionInfoList.Where(x => x.name == productPart.PartType).FirstOrDefault(); //IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); if (matchInfo != null) { string returnStation = matchInfo.value; string snRE = matchInfo.description; string custSN = null; if (string.IsNullOrEmpty(snRE) || !snRE.Contains("<SN>")) { custSN = productPart.PartSn; } else { Match match = Regex.Match(productPart.PartSn, snRE, RegexOptions.Compiled); if (match.Success) { Group groupSN =match.Groups["SN"]; if (groupSN != null && groupSN.Success) { custSN = groupSN.Value; } } } if (!string.IsNullOrEmpty(custSN)) { IProduct unpackProd = prodRep.FindOneProductWithProductIDOrCustSN(custSN); if (unpackProd != null) { DateTime now = DateTime.Now; unpackProd.AddLog(new ProductLog { ProductID = unpackProd.ProId, Model = unpackProd.Model, Line = unpackProd.Status.Line, Station = returnStation, Status = IMES.FisObject.Common.Station.StationStatus.Pass, Editor = editor, Cdt = now }); var newStatus = new IMES.FisObject.FA.Product.ProductStatus(); newStatus.Status = IMES.FisObject.Common.Station.StationStatus.Pass; newStatus.StationId = returnStation; newStatus.Editor = editor; newStatus.Line = unpackProd.Status.Line; newStatus.TestFailCount = 0; newStatus.ReworkCode = ""; unpackProd.UpdateStatus(newStatus); IList<IMES.DataModel.TbProductStatus> stationList = prodRep.GetProductStatus(new List<string> { unpackProd.ProId }); prodRep.UpdateProductPreStationDefered(session.UnitOfWork, stationList); prodRep.Update(unpackProd, session.UnitOfWork); } } } }
/// <summary> /// /// </summary> //public void GenerateRepairByTestLog() //{ // throw new NotImplementedException(); //} /// <summary> /// 改Part /// </summary> /// <param name="partID">Part Id</param> /// <param name="newPart">new part</param> public void ChangePart(int partID, IProductPart newPart) { lock (_syncObj_parts) { object naught = ProductParts; foreach (var part in _parts) { if (part.ID == partID) { part.PartID = newPart.PartID; part.PartSn = newPart.PartSn; part.Value = newPart.Value; part.Editor = newPart.Editor; } } } }