Ejemplo n.º 1
0
        private void CheckDocumentInformations(Ifc4.IfcRoot ifcRoot)
        {
            if (ifcRoot == null)
            {
                return;
            }

            foreach (var ifcRelAssociatesDocument in this.Document.GetIfcRelAssociatesDocumentCollection(ifcRoot))
            {
                if (ifcRelAssociatesDocument.RelatingDocument != null && ifcRelAssociatesDocument.RelatingDocument.Item != null)
                {
                    m_IfcDocumentInformationRefs.Add(ifcRelAssociatesDocument.RelatingDocument.Item.Ref);
                }

                if (ifcRelAssociatesDocument.RelatedObjects == null)
                {
                    foreach (var item in ifcRelAssociatesDocument.RelatedObjects.Items)
                    {
                        CheckDocumentInformations(item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public T AddNewDocumentInformation(
            string fullName,
            Ifc4.IfcClassificationReference ifcClassificationReference,
            Ifc4.IfcRoot ifcRoot,
            out bool alreadyExists)
        {
            alreadyExists = false;

            if (String.IsNullOrWhiteSpace(fullName))
            {
                throw new ArgumentNullException(nameof(fullName));
            }

            if (!System.IO.File.Exists(fullName))
            {
                throw new System.IO.FileNotFoundException(nameof(fullName));
            }

            System.IO.FileInfo fileInfo = new System.IO.FileInfo(fullName);

            string zipFileLocation             = Document.GetZipFileLocation(fileInfo.FullName);
            var    existingDocumentInformation = Document.Project.DocumentContainer.SingleOrDefault(item => item.Location != null && item.Location.Equals(zipFileLocation, StringComparison.OrdinalIgnoreCase));

            if (existingDocumentInformation != null)
            {
                alreadyExists = true;
                return((T)existingDocumentInformation);
            }

            //<IfcExternalReferenceRelationship>
            //<RelatingReference xsi:type="IfcClassificationReference" ref="i91175"/>
            //<RelatedResourceObjects>
            //<IfcDocumentInformation ref="i91651"/>
            //</RelatedResourceObjects>
            //</IfcExternalReferenceRelationship>

            EventType enabledEventTypes = BaseObject.EventsEnabled;

            BaseObject.EventsEnabled = EventType.None;
            try
            {
                T ifcDocumentInformation = (T)AddNew();
                ifcDocumentInformation.InternalFullName = fileInfo.FullName;
                ifcDocumentInformation.Identification   = Guid.NewGuid().ToString("N");
                ifcDocumentInformation.Name             = fileInfo.Name;
                ifcDocumentInformation.CreationTime     = fileInfo.CreationTime.ToString();
                ifcDocumentInformation.LastRevisionTime = fileInfo.LastWriteTime.ToString();
                ifcDocumentInformation.Location         = this.Document.GetZipFileLocation(fileInfo.FullName);
                ifcDocumentInformation.ElectronicFormat = Document.GetMimeFromFile(fileInfo.FullName);
                ifcDocumentInformation.AddRelatedObject(ifcRoot);
                ifcDocumentInformation.IfcClassificationReference = ifcClassificationReference;

                return(ifcDocumentInformation);
            }
            catch (Exception exc)
            {
                return(default(T));
            }
            finally
            {
                BaseObject.EventsEnabled = enabledEventTypes;
            }
        }