示例#1
0
        /**
         *
         */
        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 ManufacturerIdentificationNumber obj)
 {
     System.Exception exception;
     return LoadFromFile(fileName, out obj, out exception);
 }
 public static bool Deserialize(string input, out ManufacturerIdentificationNumber obj)
 {
     System.Exception exception;
     return Deserialize(input, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an ManufacturerIdentificationNumber object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output ManufacturerIdentificationNumber 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 ManufacturerIdentificationNumber obj, out System.Exception exception)
 {
     exception = null;
     obj = default(ManufacturerIdentificationNumber);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 /// <summary>
 /// Deserializes workflow markup into an ManufacturerIdentificationNumber object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output ManufacturerIdentificationNumber 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 ManufacturerIdentificationNumber obj, out System.Exception exception)
 {
     exception = null;
     obj = default(ManufacturerIdentificationNumber);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }