public void ControlsToData() { SetValidationState(); if (!string.IsNullOrWhiteSpace(edtIdModelName.Text)) { if (_identification == null) _identification = new ItemDescriptionIdentification(); _identification.ModelName = edtIdModelName.GetValue<string>(); _identification.Version = edtIdVersion.GetValue<string>(); _identification.designator = edtDesignator.GetValue<string>(); _identification.IdentificationNumbers = indentificationNumbersListControl.IdentificationNumbers; _identification.Manufacturers = manufacturerListControl.Manufacturers; //TODO: Address when/if we handle extensions _identification.Extension = null; } else { _identification = null; } }
public override string ToString() { var sb = new StringBuilder(); if (!string.IsNullOrWhiteSpace(name)) { sb.Append(name).Append(" "); } if (!string.IsNullOrWhiteSpace(Description)) { sb.Append(Description).Append(" "); } ItemDescriptionIdentification itemDescriptionIdentification = Identification; if (itemDescriptionIdentification != null) { sb.Append(itemDescriptionIdentification.ModelName).Append(" "); if (itemDescriptionIdentification.IdentificationNumbers != null) { foreach (IdentificationNumber id in itemDescriptionIdentification.IdentificationNumbers) { var userId = id as UserDefinedIdentificationNumber; var mfrId = id as ManufacturerIdentificationNumber; sb.Append(id.type).Append(" Id: ").Append(id.number).Append(" "); if (userId != null) { sb.Append("Qfr:").Append(userId.qualifier).Append(" "); } if (mfrId != null) { sb.Append("Mfr:").Append(mfrId.manufacturerName).Append(" "); } } } } return(sb.ToString()); }
/** * */ public string LookupReferenceByPartNumber(string partNumber, string className) { string refUUID = ""; DocumentDAO dao = DataManager.getDocumentDAO(); AssetIdentificationBean asset = dao.FindAsset(AssetTypePart, partNumber); if (asset == null) { string uuid = Guid.NewGuid().ToString(); var id = new ItemDescriptionIdentification(); var idNo = new ManufacturerIdentificationNumber(); idNo.type = IdentificationNumberType.Part; idNo.number = partNumber; id.IdentificationNumbers = new List<IdentificationNumber>(); id.IdentificationNumbers.Add(idNo); id.ModelName = partNumber; string test1 = idNo.Serialize(); string test2 = id.Serialize(); LogManager.SourceError(ATMLReader.SOURCE, "Failed to locate asset for part number: {0} ", partNumber); Type _type = Type.GetType(className + ",ATMLModelLibrary"); if (_type == null) LogManager.SourceError(ATMLReader.SOURCE, "Invalid Class Name: {0}", className); else { object obj = Activator.CreateInstance(_type); PropertyInfo pi = _type.GetProperty("uuid"); if (pi == null) LogManager.SourceError(ATMLReader.SOURCE, "Class Name: {0} does not support the uuid property.", className); else { pi.SetValue(obj, uuid, null); } PropertyInfo piId = _type.GetProperty("Identification"); if (piId == null) { //check to see if there is an Item property and if the Item property is an ItemDescription type piId = _type.GetProperty("Item"); if (piId != null) piId = piId.GetType().GetProperty("Identification"); if (piId == null) LogManager.SourceError(ATMLReader.SOURCE, "Class Name: {0} does not support the Identification property.", className); else { piId.SetValue(obj, id, null); } } else { piId.SetValue(obj, id, null); } MethodInfo mi = _type.GetMethod("Save"); if (mi == null) LogManager.SourceError(ATMLReader.SOURCE, "Class Name: {0} does not support a save() method.", className); else { mi.Invoke(obj, null); refUUID = uuid; LogManager.SourceInfo(ATMLReader.SOURCE, "*** A Part Document has been created for part number: {0}.", partNumber); } } } else { refUUID = asset.uuid.ToString(); } return refUUID; }
public static bool LoadFromFile(string fileName, out ItemDescriptionIdentification obj) { System.Exception exception; return LoadFromFile(fileName, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an ItemDescriptionIdentification object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output ItemDescriptionIdentification object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out ItemDescriptionIdentification obj, out System.Exception exception) { exception = null; obj = default(ItemDescriptionIdentification); try { obj = LoadFromFile(fileName); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool Deserialize(string input, out ItemDescriptionIdentification obj) { System.Exception exception; return Deserialize(input, out obj, out exception); }
/// <summary> /// Deserializes workflow markup into an ItemDescriptionIdentification object /// </summary> /// <param name="input">string workflow markup to deserialize</param> /// <param name="obj">Output ItemDescriptionIdentification object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string input, out ItemDescriptionIdentification obj, out System.Exception exception) { exception = null; obj = default(ItemDescriptionIdentification); try { obj = Deserialize(input); return true; } catch (System.Exception ex) { exception = ex; return false; } }