/// <summary> /// Convert a IfcDocumentReference to Document /// </summary> /// <param name="docReference">Document Reference Object</param> /// <param name="docInformation"></param> /// <returns>Document</returns> private CobieDocument ConvertToDocument(IIfcDocumentReference docReference, IIfcDocumentInformation docInformation) { var name = GetName(docInformation) ?? GetName(docReference); //fail to get from IfcDocumentReference, so try assign a default if (string.IsNullOrEmpty(name)) { name = "Document"; } //check for duplicates, if found add a (#) => "DocName(1)", if none return name unchanged name = Helper.GetNextName(name, UsedNames); var document = Exchanger.TargetRepository.Instances.New <CobieDocument>(); document.Name = name; document.Created = docInformation != null?GetCreatedInfo(docInformation) : null; document.DocumentType = (docInformation != null) && !string.IsNullOrEmpty(docInformation.Purpose) ? Helper.GetPickValue <CobieDocumentType>(docInformation.Purpose) : null; document.ApprovalType = (docInformation != null) && (!string.IsNullOrEmpty(docInformation.IntendedUse)) ? Helper.GetPickValue <CobieApprovalType>(docInformation.IntendedUse) : null; //once fixed document.Stage = (docInformation != null) && (!string.IsNullOrEmpty(docInformation.Scope)) ? Helper.GetPickValue <CobieStageType>(docInformation.Scope) : null; document.Directory = GetFileDirectory(docReference); document.File = GetFileName(docReference); document.ExternalSystem = null; document.ExternalObject = Helper.GetExternalObject(docReference); document.ExternalId = null; document.Description = (docInformation != null) && !string.IsNullOrEmpty(docInformation.Description) ? docInformation.Description.ToString() : null; document.Reference = docInformation != null ? docInformation.Identification : null; UsedNames.Add(document.Name); return(document); }
/// <summary> /// Convert a IfcDocumentReference to Document /// </summary> /// <param name="ifcDocumentReference">Document Reference Object</param> /// <param name="document">Document Object</param> /// <returns>Document</returns> private Document ConvertToDocument(IIfcDocumentReference ifcDocumentReference, IIfcDocumentInformation ifcDocumentInformation) { string name = GetName(ifcDocumentInformation) ?? GetName(ifcDocumentReference); //fail to get from IfcDocumentReference, so try assign a default if (string.IsNullOrEmpty(name)) { name = "Document"; } //check for duplicates, if found add a (#) => "DocName(1)", if none return name unchanged name = Helper.GetNextName(name, UsedNames); var document = new Document(); document.Name = name; document.CreatedBy = ifcDocumentInformation != null?GetCreatedBy(ifcDocumentInformation) : null; document.CreatedOn = ifcDocumentInformation != null?GetCreatedOn(ifcDocumentInformation) : null; document.Categories = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.Purpose)) ? new List <Category>(new[] { new Category { Code = ifcDocumentInformation.Purpose } }) : null; document.ApprovalBy = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.IntendedUse)) ? ifcDocumentInformation.IntendedUse : null; //once fixed document.Stage = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.Scope)) ? ifcDocumentInformation.Scope : null; document.Directory = GetFileDirectory(ifcDocumentReference); document.File = GetFileName(ifcDocumentReference); document.ExternalSystem = null; document.ExternalEntity = ifcDocumentReference.GetType().Name; document.ExternalId = null; document.Description = (ifcDocumentInformation != null) && (!string.IsNullOrEmpty(ifcDocumentInformation.Description)) ? ifcDocumentInformation.Description.ToString() : null; document.Reference = ifcDocumentInformation.Identification; UsedNames.Add(document.Name); return(document); }