private static void CreateAsset( string referenceId, string combinedPartNumber ) { AssetIdentificationBean asset; asset = new AssetIdentificationBean(); asset.uuid = Guid.Parse( referenceId ); asset.assetType = "Part"; asset.assetNumber = combinedPartNumber; asset.DataState = BASEBean.eDataState.DS_ADD; asset.save(); }
public static string CreateDocumentPlaceHolder( string partNumber, string assetType, string contentType, string docType, string description) { string refId = null; var asset = new AssetIdentificationBean(); DocumentDAO dao = DataManager.getDocumentDAO(); try { dao.StartTransaction(); //Lookup Part Number for document string rootPartNumber = partNumber.Split( '#' )[0]; Document document = GetDocument( rootPartNumber, (int) Enum.Parse( typeof (dbDocument.DocumentType), docType ) ); if (document == null) { document = new Document(); document.uuid = Guid.NewGuid().ToString(); document.name = rootPartNumber; document.Item = ""; //Content document.DocumentContent = Encoding.UTF8.GetBytes( document.Item ); document.ContentType = contentType ?? ""; document.Description = (description.Length>255?description.Substring( 0,254 ):description) ?? ""; document.DocumentType = (dbDocument.DocumentType) Enum.Parse( typeof (dbDocument.DocumentType), docType ); SaveDocument( document ); } //Add reference id to asset lookup asset = new AssetIdentificationBean(); asset.uuid = Guid.Parse( document.uuid ); asset.assetType = assetType; asset.assetNumber = partNumber; asset.DataState = BASEBean.eDataState.DS_ADD; asset.save(); refId = asset.uuid.ToString(); dao.CommitTransaction(); LogManager.Trace( "A placeholder document for \"{0}\" has been created.", partNumber ); } catch (Exception e) { dao.RollbackTransaction(); LogManager.Error( e, "An Error occurred creating a document for \"{0}\"", partNumber ); } finally { dao.EndTransaction(); } return refId; }
public static void Save(UUTDescription uut) { string uuid; if (uut != null) { string model = uut.Item.Identification.ModelName; string documentName = BuildAtmlFileName(model); uuid = uut.uuid; Document document = DocumentManager.GetDocument(uuid); if (document != null) { document.DocumentContent = Encoding.UTF8.GetBytes(uut.Serialize()); document.DataState = BASEBean.eDataState.DS_EDIT; document.name = documentName; DocumentManager.SaveDocument(document); } else { AssetIdentificationBean bean = new AssetIdentificationBean(); document = new Document(); document.name = documentName; document.DocumentContent = Encoding.UTF8.GetBytes(uut.Serialize()); document.DocumentType = dbDocument.DocumentType.UUT_DESCRIPTION; document.ContentType = "text/xml"; DocumentManager.SaveDocument(document); bean.assetNumber = model; bean.assetType = "Part"; bean.uuid = Guid.Parse(uuid); bean.DataState = BASEBean.eDataState.DS_ADD; bean.save(); } } }
public void Save() { string content = Serialize(); var document = new dbDocument(); var dao = new DocumentDAO(); bool documentExists = dao.hasDocument(uuid); //if( !documentExists ) // LogManager.Trace("Creating new Test Adapter Description with uuid of {0}", uuid); //else // LogManager.Trace("Saving Test Adapter Description with uuid of {0}", uuid); document.contentType = "text/xml"; document.documentDescription = "Test Adapter"; document.documentName = Identification.ModelName; document.documentVersion = version; document.documentSize = content.Length; document.documentTypeId = (int) dbDocument.DocumentType.TEST_ADAPTER_DESCRIPTION; document.documentContent = Encoding.UTF8.GetBytes(content); document.UUID = Guid.Parse(uuid); document.DataState = documentExists ? BASEBean.eDataState.DS_EDIT : BASEBean.eDataState.DS_ADD; document.save(); foreach (IdentificationNumber idNumber in Identification.IdentificationNumbers) { string type = Enum.GetName(typeof (IdentificationNumberType), idNumber.type); string number = idNumber.number; var asset = new AssetIdentificationBean(); asset.assetNumber = number; asset.assetType = type; asset.uuid = Guid.Parse(uuid); asset.DetermineDataState(); asset.save(); } }