Ejemplo n.º 1
0
        /// <summary>
        /// Extract the email address lists for the owner of the IfcOwnerHistory passed
        /// </summary>
        /// <param name="ifcOwnerHistory">Entity to extract the email addresses for</param>
        /// <returns>string of comma delimited addresses</returns>
        protected string GetTelecomTelephoneNumber(IfcPersonAndOrganization ifcPersonAndOrganization)
        {
            string          telephoneNo     = "";
            IfcOrganization ifcOrganization = ifcPersonAndOrganization.TheOrganization;
            IfcPerson       ifcPerson       = ifcPersonAndOrganization.ThePerson;

            if (ifcPerson.Addresses != null)
            {
                telephoneNo = ifcPerson.Addresses.TelecomAddresses.Select(address => address.TelephoneNumbers).Where(item => item != null).SelectMany(em => em).Where(em => !string.IsNullOrEmpty(em)).FirstOrDefault();

                if (string.IsNullOrEmpty(telephoneNo))
                {
                    if (ifcOrganization.Addresses != null)
                    {
                        telephoneNo = ifcOrganization.Addresses.TelecomAddresses.Select(address => address.TelephoneNumbers).Where(item => item != null).SelectMany(em => em).Where(em => !string.IsNullOrEmpty(em)).FirstOrDefault();
                    }
                }
            }

            //if still no email lets make one up
            if (string.IsNullOrEmpty(telephoneNo))
            {
                telephoneNo = DEFAULT_STRING;
            }


            return(telephoneNo);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="authorName"></param>
        /// <param name="authorCompany"></param>
        /// <param name="softwareName"></param>
        /// <param name="softwareVersion"></param>
        /// <param name="softwareCompany"></param>
        public void SetCreator(
            string authorName,
            string authorCompany,
            string softwareName,
            string softwareVersion,
            string softwareCompany)
        {
            var person = new IfcPerson
            {
                GivenName  = authorName,
                FamilyName = authorName
            };
            var organization = new IfcOrganization(authorCompany);

            var personAndOrganization = new IfcPersonAndOrganization(person, organization);

            var appOrganization = new IfcOrganization(softwareCompany);

            var application = new IfcApplication
            {
                ApplicationDeveloper = appOrganization,
                Version               = softwareVersion,
                ApplicationFullName   = softwareName,
                ApplicationIdentifier = softwareCompany + @"." + softwareName,
            };

            IfcOwnerHistory = new IfcOwnerHistory()
            {
                OwningUser        = personAndOrganization,
                OwningApplication = application,
                State             = IfcStateEnum.READONLY,
                ChangeAction      = IfcChangeActionEnum.NOCHANGE,
                CreationDate      = IfcTimeStamp.GetTimeStamp(),
            };
        }
Ejemplo n.º 3
0
 public PersonOrgRelation(IfcStore model, Organization organization, Person person)
 {
     ifcPersonAndOrganization = model.Instances.New <IfcPersonAndOrganization>(p =>
     {
         p.ThePerson       = person.IfcPerson;
         p.TheOrganization = organization.IfcOrganization;
     });
     this.person       = person;
     this.organization = organization;
 }
Ejemplo n.º 4
0
 public IfcOwnerHistory(IfcPersonAndOrganization __OwningUser, IfcApplication __OwningApplication, IfcStateEnum?__State, IfcChangeActionEnum?__ChangeAction, IfcTimeStamp?__LastModifiedDate, IfcPersonAndOrganization __LastModifyingUser, IfcApplication __LastModifyingApplication, IfcTimeStamp __CreationDate)
 {
     this._OwningUser               = __OwningUser;
     this._OwningApplication        = __OwningApplication;
     this._State                    = __State;
     this._ChangeAction             = __ChangeAction;
     this._LastModifiedDate         = __LastModifiedDate;
     this._LastModifyingUser        = __LastModifyingUser;
     this._LastModifyingApplication = __LastModifyingApplication;
     this._CreationDate             = __CreationDate;
 }
Ejemplo n.º 5
0
        private string GetContact(IfcApproval ifcApproval)
        {
            string eMail = DEFAULT_STRING;

            if (ifcApprovalActorRelationships == null)
            {
                ifcApprovalActorRelationships = Model.FederatedInstances.OfType <IfcApprovalActorRelationship>().ToList();
            }
            IfcPersonAndOrganization IfcPersonAndOrganization = ifcApprovalActorRelationships
                                                                .Where(aar => aar.Approval.EntityLabel == ifcApproval.EntityLabel)
                                                                .Select(aar => aar.Actor).OfType <IfcPersonAndOrganization>().FirstOrDefault();

            if (IfcPersonAndOrganization != null)
            {
                eMail = GetTelecomEmailAddress(IfcPersonAndOrganization);
            }

            return(eMail);
        }
Ejemplo n.º 6
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
                _owningUser = (IfcPersonAndOrganization)(value.EntityVal);
                return;

            case 1:
                _owningApplication = (IfcApplication)(value.EntityVal);
                return;

            case 2:
                _state = (IfcStateEnum)System.Enum.Parse(typeof(IfcStateEnum), value.EnumVal, true);
                return;

            case 3:
                _changeAction = (IfcChangeActionEnum)System.Enum.Parse(typeof(IfcChangeActionEnum), value.EnumVal, true);
                return;

            case 4:
                _lastModifiedDate = value.IntegerVal;
                return;

            case 5:
                _lastModifyingUser = (IfcPersonAndOrganization)(value.EntityVal);
                return;

            case 6:
                _lastModifyingApplication = (IfcApplication)(value.EntityVal);
                return;

            case 7:
                _creationDate = value.IntegerVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Ejemplo n.º 7
0
        public virtual void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
                _owningUser = (IfcPersonAndOrganization)value.EntityVal;
                break;

            case 1:
                _owningApplication = (IfcApplication)value.EntityVal;
                break;

            case 2:
                _state = (IfcStateEnum?)Enum.Parse(typeof(IfcStateEnum), value.EnumVal, true);
                break;

            case 3:
                _changeAction = (IfcChangeActionEnum)Enum.Parse(typeof(IfcChangeActionEnum), value.EnumVal, true);
                break;

            case 4:
                _lastModifiedDate = value.IntegerVal;
                break;

            case 5:
                _lastModifyingUser = (IfcPersonAndOrganization)value.EntityVal;
                break;

            case 6:
                _lastModifyingApplication = (IfcApplication)value.EntityVal;
                break;

            case 7:
                _creationDate = value.IntegerVal;
                break;

            default:
                this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Extract the email address lists for the owner of the IfcOwnerHistory passed
 /// </summary>
 /// <returns>string of comma delimited addresses</returns>
 protected string GetTelecomEmailAddress(IfcPersonAndOrganization ifcPersonAndOrganization)
 {
     if (ifcPersonAndOrganization != null)
     {
         var ifcPerson = ifcPersonAndOrganization.ThePerson;
         if (Context.EMails.ContainsKey(ifcPerson.EntityLabel))
         {
             return(Context.EMails[ifcPerson.EntityLabel]);
         }
         else
         {
             var ifcOrganization = ifcPersonAndOrganization.TheOrganization;
             var email           = GetEmail(ifcOrganization, ifcPerson);
             Context.EMails.Add(ifcPerson.EntityLabel, email);
             return(email);
         }
     }
     else
     {
         return(Constants.DEFAULT_EMAIL);
     }
 }
Ejemplo n.º 9
0
        public void CreatePersonAndOrganization(COBieContactRow row, IfcPersonAndOrganization ifcPersonAndOrganization = null)
        {
            if (!Contacts.ContainsKey(row.Email)) //should filter on merge also unless Contacts is reset
            {
                IfcPerson ifcPerson = Model.Instances.New<IfcPerson>();
                IfcOrganization ifcOrganization = Model.Instances.New<IfcOrganization>();
                if (ifcPersonAndOrganization == null)
                    ifcPersonAndOrganization = Model.Instances.New<IfcPersonAndOrganization>();
                Contacts.Add(row.Email, ifcPersonAndOrganization); //build a list to reference for History objects

                //add email
                IfcTelecomAddress ifcTelecomAddress = Model.Instances.New<IfcTelecomAddress>();
                if (ValidateString(row.Email))
                {
                    if (ifcTelecomAddress.ElectronicMailAddresses == null)
                        ifcTelecomAddress.SetElectronicMailAddress(row.Email); //create the LabelCollection and set to ElectronicMailAddresses field
                    else
                        ifcTelecomAddress.ElectronicMailAddresses.Add(row.Email); //add to existing collection
                }

                //IfcPersonAndOrganization has no OwnerHistory so our COBie is extracting this from IfcProject so do nothing here

                //add Role from Category
                if (ValidateString(row.Category))
                {
                    IfcActorRole ifcActorRole = Model.Instances.New<IfcActorRole>();
                    ifcActorRole.RoleString = row.Category;
                    if (ifcPerson.Roles == null)
                        ifcPerson.SetRoles(ifcActorRole);//create the ActorRoleCollection and set to Roles field
                    else
                        ifcPerson.Roles.Add(ifcActorRole);//add to existing collection
                }
                //add Company
                if (ValidateString(row.Company))
                {
                    ifcOrganization.Name = row.Company;
                }
                else
                {
                    ifcOrganization.Name = "Unknown"; //is not an optional field so fill with unknown value
                }
                //add Phone
                if (ValidateString(row.Phone))
                {
                    if (ifcTelecomAddress.TelephoneNumbers == null)
                        ifcTelecomAddress.SetTelephoneNumbers(row.Phone);//create the LabelCollection and set to TelephoneNumbers field
                    else
                        ifcTelecomAddress.TelephoneNumbers.Add(row.Phone);//add to existing collection
                }

                //External System, as no history object we have to allow this to default to DEFAUL_STRING, so do nothing here
                //External Object is retrieved from object type IfcPersonAndOrganization so do nothing here

                //add External Identifier
                if (ValidateString(row.ExtIdentifier)) ifcPerson.Id = row.ExtIdentifier;
                //add Department
                IfcPostalAddress ifcPostalAddress = Model.Instances.New<IfcPostalAddress>();
                if (ValidateString(row.Department)) ifcPostalAddress.InternalLocation = row.Department;
                //add Organization code
                if (ValidateString(row.OrganizationCode)) ifcOrganization.Id = row.OrganizationCode;
                //add GivenName
                if (ValidateString(row.GivenName)) ifcPerson.GivenName = row.GivenName;
                //add Family Name
                if (ValidateString(row.FamilyName)) ifcPerson.FamilyName = row.FamilyName;
                //add Street
                if (ValidateString(row.Street)) ifcPostalAddress.SetAddressLines(row.Street.Split(','));
                //add PostalBox
                if (ValidateString(row.PostalBox)) ifcPostalAddress.PostalBox = row.PostalBox;
                //add Town
                if (ValidateString(row.Town)) ifcPostalAddress.Town = row.Town;
                //add StateRegion
                if (ValidateString(row.StateRegion)) ifcPostalAddress.Region = row.StateRegion;
                //add PostalCode
                if (ValidateString(row.PostalCode)) ifcPostalAddress.PostalCode = row.PostalCode;
                //add Country
                if (ValidateString(row.Country)) ifcPostalAddress.Country = row.Country;

                //add addresses into IfcPerson object
                //add Telecom Address
                if (ifcPerson.Addresses == null)
                    ifcPerson.SetTelecomAddresss(ifcTelecomAddress);//create the AddressCollection and set to Addresses field
                else
                    ifcPerson.Addresses.Add(ifcTelecomAddress);//add to existing collection
                // Add postal address
                if (ifcPerson.Addresses == null)
                    ifcPerson.SetPostalAddresss(ifcPostalAddress);//create the AddressCollection and set to Addresses field
                else
                    ifcPerson.Addresses.Add(ifcPostalAddress);//add to existing collection

                //add the person and the organization objects 
                ifcPersonAndOrganization.ThePerson = ifcPerson;
                ifcPersonAndOrganization.TheOrganization = ifcOrganization;
            }
        }
Ejemplo n.º 10
0
 public virtual void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _owningUser = (IfcPersonAndOrganization) value.EntityVal;
             break;
         case 1:
             _owningApplication = (IfcApplication) value.EntityVal;
             break;
         case 2:
             _state = (IfcStateEnum?) Enum.Parse(typeof (IfcStateEnum), value.EnumVal, true);
             break;
         case 3:
             _changeAction = (IfcChangeActionEnum) Enum.Parse(typeof (IfcChangeActionEnum), value.EnumVal, true);
             break;
         case 4:
             _lastModifiedDate = value.IntegerVal;
             break;
         case 5:
             _lastModifyingUser = (IfcPersonAndOrganization) value.EntityVal;
             break;
         case 6:
             _lastModifyingApplication = (IfcApplication) value.EntityVal;
             break;
         case 7:
             _creationDate = value.IntegerVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
        protected override IfcBuilding Mapping(Facility facility, IfcBuilding ifcBuilding)
        {
            #region Properties

            ifcBuilding.Name            = facility.Name;
            ifcBuilding.Description     = facility.Description;
            ifcBuilding.CompositionType = IfcElementCompositionEnum.ELEMENT;
            #endregion

            #region Default units

            Exchanger.DefaultLinearUnit   = new IfcUnitConverter(facility.LinearUnits.ToString());
            Exchanger.DefaultAreaUnit     = new IfcUnitConverter(facility.AreaUnits.ToString());
            Exchanger.DefaultVolumeUnit   = new IfcUnitConverter(facility.VolumeUnits.ToString());
            Exchanger.DefaultCurrencyUnit = facility.CurrencyUnit;

            #endregion

            #region Contacts
            if (facility.Contacts != null && facility.Contacts.Any())
            {
                var ContactMapping = Exchanger.GetOrCreateMappings <MappingContactToIfcPersonAndOrganization>();
                foreach (var contact in facility.Contacts)
                {
                    IfcPersonAndOrganization ifcPersonAndOrganization = ContactMapping.AddMapping(contact, ContactMapping.GetOrCreateTargetObject(contact.ExternalId));
                    //assign relationship
                    //create IfcActor to set CreatedBy and CreatedOn for next time ifc is imported as IfcActor is derived from IfcRoot
                    IfcActor actor = Exchanger.TargetRepository.Instances.New <IfcActor>();
                    Exchanger.SetUserHistory(actor, contact.ExternalSystem, (contact.CreatedBy == null) ? null : contact.CreatedBy.Email, (contact.CreatedOn == null) ? DateTime.Now : (DateTime)contact.CreatedOn);
                    using (OwnerHistoryEditScope context = new OwnerHistoryEditScope(Exchanger.TargetRepository, actor.OwnerHistory))
                    {
                        actor.TheActor = ifcPersonAndOrganization;
                    }
                    //assign the actor to the building
                    IfcRelAssignsToActor ifcRelAssignsToActor = Exchanger.TargetRepository.Instances.New <IfcRelAssignsToActor>();
                    Exchanger.SetUserHistory(ifcRelAssignsToActor, contact.ExternalSystem, (contact.CreatedBy == null) ? null : contact.CreatedBy.Email, (contact.CreatedOn == null) ? DateTime.Now : (DateTime)contact.CreatedOn);
                    using (OwnerHistoryEditScope context = new OwnerHistoryEditScope(Exchanger.TargetRepository, ifcRelAssignsToActor.OwnerHistory))
                    {
                        ifcRelAssignsToActor.RelatingActor = actor;
                        ifcRelAssignsToActor.RelatedObjects.Add(ifcBuilding);
                    }
                }
            }
            #endregion

            #region Categories
            if (facility.Categories != null)
            {
                foreach (var category in facility.Categories)
                {
                    Exchanger.ConvertCategoryToClassification(category, ifcBuilding);
                }
            }

            #endregion


            #region Project



            //COBie does nor require a project but Ifc does
            var ifcProject = Exchanger.TargetRepository.Instances.OfType <IfcProject>().FirstOrDefault();
            if (ifcProject == null)
            {
                ifcProject = Exchanger.TargetRepository.Instances.New <IfcProject>();
            }
            var projectMapping = Exchanger.GetOrCreateMappings <MappingProjectToIfcProject>();
            projectMapping.AddMapping(facility.Project, ifcProject);
            InitialiseUnits(ifcProject);
            #endregion

            #region Site
            //add the relationship between the site and the building if a site exists
            if (facility.Site != null)
            {
                var siteMapping = Exchanger.GetOrCreateMappings <MappingSiteToIfcSite>();
                var ifcSite     = siteMapping.AddMapping(facility.Site,
                                                         siteMapping.GetOrCreateTargetObject(facility.Site.ExternalId ?? Guid.NewGuid().ToString()));
                //add the relationship between the site and the project and the building
                ifcProject.AddSite(ifcSite);
                ifcSite.AddBuilding(ifcBuilding);
            }
            else //relate the building to the project
            {
                ifcProject.AddBuilding(ifcBuilding);
            }
            #endregion

            #region Floors
            //write out the floors if we have any
            if (facility.Floors != null)
            {
                var floorMapping = Exchanger.GetOrCreateMappings <MappingFloorToIfcBuildingStorey>();
                foreach (var floor in facility.Floors)
                {
                    var ifcFloor = floorMapping.AddMapping(floor, floorMapping.GetOrCreateTargetObject(floor.ExternalId));
                    ifcBuilding.AddToSpatialDecomposition(ifcFloor);
                }
            }
            #endregion


            #region AssetTypes
            //write out the floors if we have any
            if (facility.AssetTypes != null)
            {
                var assetTypeMapping = Exchanger.GetOrCreateMappings <MappingAssetTypeToIfcTypeObject>();
                foreach (var assetType in facility.AssetTypes.OrderBy(a => a.ExternalEntity))
                {
                    Exchanger.BeginAssetTypeInfoType();
                    assetTypeMapping.AddMapping(assetType, assetTypeMapping.GetOrCreateTargetObject(assetType.ExternalId));
                    Exchanger.EndAssetTypeInfoType();
                }
            }
            #endregion

            #region Attributes
            if (facility.Attributes != null)
            {
                foreach (var attribute in facility.Attributes)
                {
                    Exchanger.ConvertAttributeTypeToIfcObjectProperty(ifcBuilding, attribute);
                }
            }
            #endregion

            #region Zones

            if (facility.Zones != null)
            {
                var zoneTypeMapping = Exchanger.GetOrCreateMappings <MappingZoneToIfcZone>();
                foreach (var zone in facility.Zones)
                {
                    zoneTypeMapping.AddMapping(zone, zoneTypeMapping.GetOrCreateTargetObject(zone.ExternalId));
                }
            }

            #endregion

            #region Documents
            if (facility.Documents != null && facility.Documents.Any())
            {
                Exchanger.ConvertDocumentsToDocumentSelect(ifcBuilding, facility.Documents);
            }
            #endregion

            #region Add Space Geometry

            CreateSpaceProxies();

            #endregion

            return(ifcBuilding);
        }
Ejemplo n.º 12
0
        public void CreatePersonAndOrganization(COBieContactRow row, IfcPersonAndOrganization ifcPersonAndOrganization = null)
        {
            if (!Contacts.ContainsKey(row.Email)) //should filter on merge also unless Contacts is reset
            {
                IfcPerson       ifcPerson       = Model.Instances.New <IfcPerson>();
                IfcOrganization ifcOrganization = Model.Instances.New <IfcOrganization>();
                if (ifcPersonAndOrganization == null)
                {
                    ifcPersonAndOrganization = Model.Instances.New <IfcPersonAndOrganization>();
                }
                Contacts.Add(row.Email, ifcPersonAndOrganization); //build a list to reference for History objects

                //add email
                IfcTelecomAddress ifcTelecomAddress = Model.Instances.New <IfcTelecomAddress>();
                if (ValidateString(row.Email))
                {
                    if (ifcTelecomAddress.ElectronicMailAddresses == null)
                    {
                        ifcTelecomAddress.SetElectronicMailAddress(row.Email); //create the LabelCollection and set to ElectronicMailAddresses field
                    }
                    else
                    {
                        ifcTelecomAddress.ElectronicMailAddresses.Add(row.Email); //add to existing collection
                    }
                }

                //IfcPersonAndOrganization has no OwnerHistory so our COBie is extracting this from IfcProject so do nothing here

                //add Role from Category
                if (ValidateString(row.Category))
                {
                    IfcActorRole ifcActorRole = Model.Instances.New <IfcActorRole>();
                    ifcActorRole.RoleString = row.Category;
                    if (ifcPerson.Roles == null)
                    {
                        ifcPerson.SetRoles(ifcActorRole);//create the ActorRoleCollection and set to Roles field
                    }
                    else
                    {
                        ifcPerson.Roles.Add(ifcActorRole);//add to existing collection
                    }
                }
                //add Company
                if (ValidateString(row.Company))
                {
                    ifcOrganization.Name = row.Company;
                }
                else
                {
                    ifcOrganization.Name = "Unknown"; //is not an optional field so fill with unknown value
                }
                //add Phone
                if (ValidateString(row.Phone))
                {
                    if (ifcTelecomAddress.TelephoneNumbers == null)
                    {
                        ifcTelecomAddress.SetTelephoneNumbers(row.Phone);//create the LabelCollection and set to TelephoneNumbers field
                    }
                    else
                    {
                        ifcTelecomAddress.TelephoneNumbers.Add(row.Phone);//add to existing collection
                    }
                }

                //External System, as no history object we have to allow this to default to DEFAUL_STRING, so do nothing here
                //External Object is retrieved from object type IfcPersonAndOrganization so do nothing here

                //add External Identifier
                if (ValidateString(row.ExtIdentifier))
                {
                    ifcPerson.Id = row.ExtIdentifier;
                }
                //add Department
                IfcPostalAddress ifcPostalAddress = Model.Instances.New <IfcPostalAddress>();
                if (ValidateString(row.Department))
                {
                    ifcPostalAddress.InternalLocation = row.Department;
                }
                //add Organization code
                if (ValidateString(row.OrganizationCode))
                {
                    ifcOrganization.Id = row.OrganizationCode;
                }
                //add GivenName
                if (ValidateString(row.GivenName))
                {
                    ifcPerson.GivenName = row.GivenName;
                }
                //add Family Name
                if (ValidateString(row.FamilyName))
                {
                    ifcPerson.FamilyName = row.FamilyName;
                }
                //add Street
                if (ValidateString(row.Street))
                {
                    ifcPostalAddress.SetAddressLines(row.Street.Split(','));
                }
                //add PostalBox
                if (ValidateString(row.PostalBox))
                {
                    ifcPostalAddress.PostalBox = row.PostalBox;
                }
                //add Town
                if (ValidateString(row.Town))
                {
                    ifcPostalAddress.Town = row.Town;
                }
                //add StateRegion
                if (ValidateString(row.StateRegion))
                {
                    ifcPostalAddress.Region = row.StateRegion;
                }
                //add PostalCode
                if (ValidateString(row.PostalCode))
                {
                    ifcPostalAddress.PostalCode = row.PostalCode;
                }
                //add Country
                if (ValidateString(row.Country))
                {
                    ifcPostalAddress.Country = row.Country;
                }

                //add addresses into IfcPerson object
                //add Telecom Address
                if (ifcPerson.Addresses == null)
                {
                    ifcPerson.SetTelecomAddresss(ifcTelecomAddress);//create the AddressCollection and set to Addresses field
                }
                else
                {
                    ifcPerson.Addresses.Add(ifcTelecomAddress);//add to existing collection
                }
                // Add postal address
                if (ifcPerson.Addresses == null)
                {
                    ifcPerson.SetPostalAddresss(ifcPostalAddress);//create the AddressCollection and set to Addresses field
                }
                else
                {
                    ifcPerson.Addresses.Add(ifcPostalAddress);//add to existing collection
                }
                //add the person and the organization objects
                ifcPersonAndOrganization.ThePerson       = ifcPerson;
                ifcPersonAndOrganization.TheOrganization = ifcOrganization;
            }
        }
Ejemplo n.º 13
0
        public Model(IDictionary <Guid, BaseIfc> storage, string name, string description, IfcAddress address, IfcPerson user, IfcOrganization owner)
        {
            this.storage = storage;

            this.storage.Add(address.Id, address);
            this.storage.Add(user.Id, user);
            this.storage.Add(owner.Id, owner);

            // Create an organization for app creation.
            var appOrg = new IfcOrganization(APPNAME);

            this.storage.Add(appOrg.Id, appOrg);

            // Create an authoring application.
            var v   = owner.GetType().Assembly.GetName().Version.ToString();
            var app = new IfcApplication(appOrg, v, APPNAME, APPNAME);

            this.storage.Add(app.Id, app);

            // Create an person and history for the owner history.
            var personAndOrg = new IfcPersonAndOrganization(user, owner);

            this.storage.Add(personAndOrg.Id, personAndOrg);

            // Create an owner history for the project.
            var history = new IfcOwnerHistory(personAndOrg, app, UnixNow());

            this.storage.Add(history.Id, history);

            var lu = new IfcSIUnit(null, IfcUnitEnum.LENGTHUNIT, IfcSIUnitName.METRE);

            this.storage.Add(lu.Id, lu);
            var lengthUnit = new IfcUnit(lu);

            var au = new IfcSIUnit(null, IfcUnitEnum.AREAUNIT, IfcSIUnitName.SQUARE_METRE);

            this.storage.Add(au.Id, au);
            var areaUnit = new IfcUnit(au);

            var vu = new IfcSIUnit(null, IfcUnitEnum.VOLUMEUNIT, IfcSIUnitName.CUBIC_METRE);

            this.storage.Add(vu.Id, vu);
            var volumeUnit = new IfcUnit(vu);

            var sau = new IfcSIUnit(null, IfcUnitEnum.SOLIDANGLEUNIT, IfcSIUnitName.STERADIAN);

            this.storage.Add(sau.Id, sau);
            var solidAngleUnit = new IfcUnit(sau);

            var mu = new IfcSIUnit(null, IfcUnitEnum.MASSUNIT, IfcSIUnitName.GRAM);

            this.storage.Add(mu.Id, mu);
            var massUnit = new IfcUnit(mu);

            var tu = new IfcSIUnit(null, IfcUnitEnum.TIMEUNIT, IfcSIUnitName.SECOND);

            this.storage.Add(tu.Id, tu);
            var timeUnit = new IfcUnit(tu);

            var thu = new IfcSIUnit(null, IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT, IfcSIUnitName.DEGREE_CELSIUS);

            this.storage.Add(thu.Id, thu);
            var thermUnit = new IfcUnit(thu);

            var lmu = new IfcSIUnit(null, IfcUnitEnum.LUMINOUSINTENSITYUNIT, IfcSIUnitName.LUMEN);

            this.storage.Add(lmu.Id, lmu);
            var lumUnit = new IfcUnit(lmu);

            var pau = new IfcSIUnit(null, IfcUnitEnum.PLANEANGLEUNIT, IfcSIUnitName.RADIAN);

            this.storage.Add(pau.Id, pau);
            var planeAngleUnit = new IfcUnit(pau);

            var measure = new IfcMeasureWithUnit(new IfcValue(new IfcMeasureValue(new IfcPlaneAngleMeasure(1.745e-2))), planeAngleUnit);

            this.storage.Add(measure.Id, measure);

            var dimExp = new IfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0);

            this.storage.Add(dimExp.Id, dimExp);

            var du = new IfcConversionBasedUnit(dimExp, IfcUnitEnum.PLANEANGLEUNIT, "DEGREE", measure);

            this.storage.Add(du.Id, du);
            var degree = new IfcUnit(du);

            var units = new List <IfcUnit> {
                lengthUnit, areaUnit, volumeUnit, solidAngleUnit, massUnit, timeUnit, thermUnit, lumUnit, planeAngleUnit, degree
            };
            var unitAss = new IfcUnitAssignment(units);

            this.storage.Add(unitAss.Id, unitAss);

            // Create the project.
            var proj = new IfcProject(IfcGuid.ToIfcGuid(Guid.NewGuid()), history, name, description, null, null, null, null, unitAss);

            this.storage.Add(proj.Id, proj);
        }
        public static string GetValuesAsString(this IfcObjectReferenceSelect ifcObjectReferenceSelect)
        {
            var material = ifcObjectReferenceSelect as IfcMaterial;

            if (material != null)
            {
                return(material.Name.ToString());
            }
            var person = ifcObjectReferenceSelect as IfcPerson;

            if (person != null)
            {
                return(person.GetFullName());
            }
            var time = ifcObjectReferenceSelect as IfcDateAndTime;

            if (time != null)
            {
                return(time.AsString());
            }

            var list = ifcObjectReferenceSelect as IfcMaterialList;

            if (list != null)
            {
                List <string> values = list.Materials.Select(item => item.Name.ToString()).ToList();
                return(values.Count > 0 ? string.Join(", ", values) : string.Empty);
            }
            var @select = ifcObjectReferenceSelect as IfcOrganization;

            if (@select != null)
            {
                return(@select.Name.ToString());
            }
            var date = ifcObjectReferenceSelect as IfcCalendarDate;

            if (date != null)
            {
                return(date.AsString());
            }
            var localTime = ifcObjectReferenceSelect as IfcLocalTime;

            if (localTime != null)
            {
                return(localTime.AsString());
            }
            var organization = ifcObjectReferenceSelect as IfcPersonAndOrganization;

            if (organization != null)
            {
                IfcPersonAndOrganization ifcPersonAndOrganization = organization;
                string value = ifcPersonAndOrganization.ThePerson.GetFullName();
                value  = value.Trim();
                value += ", " + ifcPersonAndOrganization.TheOrganization.Name.ToString();
                return(value);
            }
            var layer = ifcObjectReferenceSelect as IfcMaterialLayer;

            if (layer != null)
            {
                IfcMaterialLayer ifcMaterialLayer = layer;
                string           value            = string.Empty;
                if (ifcMaterialLayer.Material != null)
                {
                    value += ifcMaterialLayer.Material.Name.ToString();
                }
                if (string.IsNullOrEmpty(value))
                {
                    value = ifcMaterialLayer.LayerThickness.Value.ToString();
                }
                else
                {
                    value += "(" + ifcMaterialLayer.LayerThickness.Value + ")";
                }
                return(value);
            }
            var reference = ifcObjectReferenceSelect as IfcExternalReference;

            if (reference != null)
            {
                if (reference.Location.HasValue)
                {
                    return(reference.Location.ToString());
                }
                return(string.Empty);
            }
            var series = ifcObjectReferenceSelect as IfcTimeSeries;

            if (series != null)
            {
                return(series.GetAsString());
            }
            var address = ifcObjectReferenceSelect as IfcAddress;

            if (address != null)
            {
                return(address.GetAsString());
            }
            var appliedValue = ifcObjectReferenceSelect as IfcAppliedValue;

            if (appliedValue != null)
            {
                return(appliedValue.AsString());
            }

            return(string.Empty);
        }
Ejemplo n.º 15
0
 public static bool HasEmail(this IfcPersonAndOrganization personOrg, string emailAddress)
 {
     return(personOrg.TheOrganization.HasEmail(emailAddress) || personOrg.ThePerson.HasEmail(emailAddress));
 }
Ejemplo n.º 16
0
        public static string GetValuesAsString(this IfcObjectReferenceSelect ifcObjectReferenceSelect)
        {
            if (ifcObjectReferenceSelect is IfcMaterial)
            {
                return((ifcObjectReferenceSelect as IfcMaterial).Name.ToString());
            }
            if (ifcObjectReferenceSelect is IfcPerson)
            {
                return((ifcObjectReferenceSelect as IfcPerson).GetFullName());
            }
            if (ifcObjectReferenceSelect is IfcDateAndTime)
            {
                return((ifcObjectReferenceSelect as IfcDateAndTime).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcMaterialList)
            {
                List <string> values = new List <string>();
                foreach (var item in (ifcObjectReferenceSelect as IfcMaterialList).Materials)
                {
                    values.Add(item.Name.ToString());
                }
                if (values.Count > 0)
                {
                    return(string.Join(", ", values));
                }
                else
                {
                    return(string.Empty);
                }
            }
            if (ifcObjectReferenceSelect is IfcOrganization)
            {
                return((ifcObjectReferenceSelect as IfcOrganization).Name.ToString());
            }
            if (ifcObjectReferenceSelect is IfcCalendarDate)
            {
                return((ifcObjectReferenceSelect as IfcCalendarDate).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcLocalTime)
            {
                return((ifcObjectReferenceSelect as IfcLocalTime).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcPersonAndOrganization)
            {
                IfcPersonAndOrganization ifcPersonAndOrganization = (ifcObjectReferenceSelect as IfcPersonAndOrganization);
                string value = ifcPersonAndOrganization.ThePerson.GetFullName();
                value  = value.Trim();
                value += ", " + ifcPersonAndOrganization.TheOrganization.Name.ToString();
                return(value);
            }
            if (ifcObjectReferenceSelect is IfcMaterialLayer)
            {
                IfcMaterialLayer ifcMaterialLayer = (ifcObjectReferenceSelect as IfcMaterialLayer);
                string           value            = string.Empty;
                if (ifcMaterialLayer.Material != null)
                {
                    value += ifcMaterialLayer.Material.Name.ToString();
                }
                if (string.IsNullOrEmpty(value))
                {
                    value = ifcMaterialLayer.LayerThickness.Value.ToString();
                }
                else
                {
                    value += "(" + ifcMaterialLayer.LayerThickness.Value.ToString() + ")";
                }
                return(value);
            }
            if (ifcObjectReferenceSelect is IfcExternalReference)
            {
                IfcExternalReference ifcExternalReference = (ifcObjectReferenceSelect as IfcExternalReference);
                if (ifcExternalReference.Location.HasValue)
                {
                    return(ifcExternalReference.Location.ToString());
                }
                return(string.Empty);
            }
            if (ifcObjectReferenceSelect is IfcTimeSeries)
            {
                return((ifcObjectReferenceSelect as IfcTimeSeries).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcAddress)
            {
                return((ifcObjectReferenceSelect as IfcAddress).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcAppliedValue)
            {
                return((ifcObjectReferenceSelect as IfcAppliedValue).GetAsString());
            }

            return(string.Empty);
        }