/// <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 GetTelecomEmailAddress(IfcOwnerHistory ifcOwnerHistory) { if ((ifcOwnerHistory != null) && (ifcOwnerHistory.OwningUser != null) && (ifcOwnerHistory.OwningUser.ThePerson != null) ) { IfcPerson ifcPerson = ifcOwnerHistory.OwningUser.ThePerson; if (Context.EMails.ContainsKey(ifcPerson.EntityLabel)) { return(Context.EMails[ifcPerson.EntityLabel]); } else { IfcOrganization ifcOrganization = ifcOwnerHistory.OwningUser.TheOrganization; string email = GetEmail(ifcOrganization, ifcPerson); //save to the email directory for quick retrieval Context.EMails.Add(ifcPerson.EntityLabel, email); return(email); } } else if (Context.EMails.Count == 1) //if only one then no contact are probably set up so use as default { return(Context.EMails.First().Value); } else { return(Constants.DEFAULT_EMAIL); } }
/// <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); }
/// <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(), }; }
public void CreateProductIfc(ProductIfcRequest request, Stream outputStream) { IfcPerson person = IfcInit.CreatePerson(request.owner.person.givenName, request.owner.person.familyName, request.owner.person.identifier); IfcOrganization organization = IfcInit.CreateOrganization(request.owner.organization.name, request.owner.organization.description, request.owner.organization.identifier); IfcOrganization applicationOrganization = IfcInit.CreateOrganization(request.owner.application.organization.name, request.owner.application.organization.description, request.owner.application.organization.identifier); IfcApplication application = IfcInit.CreateApplication(applicationOrganization, request.owner.application.version, request.owner.application.name, request.owner.application.identifier); IfcOwnerHistory ownerHistory = IfcInit.CreateOwnerHistory(person, organization, application); IfcProject project = IfcInit.CreateProject(request.project.name, request.project.description, ownerHistory); IfcSite site = IfcInit.CreateSite(null, null, ownerHistory); project.Aggregate(site, ownerHistory); IfcBuilding building = IfcInit.CreateBuilding(null, null, ownerHistory, site.ObjectPlacement); site.Aggregate(building, ownerHistory); IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, ownerHistory, building.ObjectPlacement); building.Aggregate(storey, ownerHistory); IfcProduct product; switch (request.product.type) { default: product = IfcInit.CreateProxy(request.product.name, request.product.description, ownerHistory, storey.ObjectPlacement, null); break; } List <IfcRepresentationContext> contextList = new List <IfcRepresentationContext> (project.RepresentationContexts); product.Representation = CreateProductRepresentation(contextList, request.product.representations); storey.Contains(product, ownerHistory); project.SerializeToStep(outputStream, request.schema.ToString(), null); return; }
public static bool HasEmail(this IfcPerson ifcPerson, string emailAddress) { if (ifcPerson.Addresses != null) { return(ifcPerson.Addresses.OfType <IfcTelecomAddress>().Select(address => address.ElectronicMailAddresses) .Where(item => item != null).SelectMany(em => em) .FirstOrDefault(em => string.Compare(emailAddress, em, true) == 0) != null); } return(false); }
public Person(IfcStore model, string name, string familyName) { ifcPerson = model.Instances.New <IfcPerson>(p => { p.Id = name; p.FamilyName = familyName; }); this.name = name; this.familyName = familyName; }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: base.Parse(propIndex, value, nestedIndex); return; case 5: _assetID = value.StringVal; return; case 6: _originalValue = (IfcCostValue)(value.EntityVal); return; case 7: _currentValue = (IfcCostValue)(value.EntityVal); return; case 8: _totalReplacementCost = (IfcCostValue)(value.EntityVal); return; case 9: _owner = (IfcActorSelect)(value.EntityVal); return; case 10: _user = (IfcActorSelect)(value.EntityVal); return; case 11: _responsiblePerson = (IfcPerson)(value.EntityVal); return; case 12: _incorporationDate = (IfcCalendarDate)(value.EntityVal); return; case 13: _depreciatedValue = (IfcCostValue)(value.EntityVal); return; default: throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper())); } }
public override void IfcParse(int propIndex, IPropertyValue value) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: base.IfcParse(propIndex, value); break; case 5: _AssetID = value.StringVal; break; case 6: _OriginalValue = (IfcCostValue)value.EntityVal; break; case 7: _CurrentValue = (IfcCostValue)value.EntityVal; break; case 8: _TotalReplacementCost = (IfcCostValue)value.EntityVal; break; case 9: _Owner = (IfcActorSelect)value.EntityVal; break; case 10: _User = (IfcActorSelect)value.EntityVal; break; case 11: _ResponsiblePerson = (IfcPerson)value.EntityVal; break; case 12: _IncorporationDate = (IfcCalendarDate)value.EntityVal; break; case 13: _DepreciatedValue = (IfcCostValue)value.EntityVal; break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
public IfcAsset(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcLabel?__ObjectType, IfcIdentifier __AssetID, IfcCostValue __OriginalValue, IfcCostValue __CurrentValue, IfcCostValue __TotalReplacementCost, IfcActorSelect __Owner, IfcActorSelect __User, IfcPerson __ResponsiblePerson, IfcCalendarDate __IncorporationDate, IfcCostValue __DepreciatedValue) : base(__GlobalId, __OwnerHistory, __Name, __Description, __ObjectType) { this._AssetID = __AssetID; this._OriginalValue = __OriginalValue; this._CurrentValue = __CurrentValue; this._TotalReplacementCost = __TotalReplacementCost; this._Owner = __Owner; this._User = __User; this._ResponsiblePerson = __ResponsiblePerson; this._IncorporationDate = __IncorporationDate; this._DepreciatedValue = __DepreciatedValue; }
protected override IfcPersonAndOrganization Mapping(Contact contact, IfcPersonAndOrganization ifcPersonAndOrganization) { IfcPerson ifcPerson = Exchanger.TargetRepository.Instances.New <IfcPerson>(); IfcOrganization ifcOrganization = Exchanger.TargetRepository.Instances.New <IfcOrganization>(); //add Organization code if (Exchanger.StringHasValue(contact.OrganizationCode)) { ifcOrganization.Id = contact.OrganizationCode; } if (Exchanger.StringHasValue(contact.Company)) { ifcOrganization.Name = contact.Company; } //add GivenName if (Exchanger.StringHasValue(contact.GivenName)) { ifcPerson.GivenName = contact.GivenName; } //add Family Name if (Exchanger.StringHasValue(contact.FamilyName)) { ifcPerson.FamilyName = contact.FamilyName; } if (contact.Categories != null && contact.Categories.Any()) { SetRoles(contact, ifcPerson); } //add addresses into IfcPerson object //add Telecom Address IfcTelecomAddress ifcTelecomAddress = SetTelecomAddress(contact); ifcPerson.Addresses.Add(ifcTelecomAddress);//add to existing collection // Add postal address IfcPostalAddress ifcPostalAddress = SetAddress(contact); ifcPerson.Addresses.Add(ifcPostalAddress);//add to existing collection //add the person and the organization objects ifcPersonAndOrganization.ThePerson = ifcPerson; ifcPersonAndOrganization.TheOrganization = ifcOrganization; return(ifcPersonAndOrganization); }
private void SetRoles(Contact contact, IfcActorSelect actor) { IfcActorRole ifcActorRole = null; IfcPerson ifcPerson = (actor is IfcPerson) ? actor as IfcPerson : null; IfcOrganization ifcOrganization = (actor is IfcOrganization) ? actor as IfcOrganization : null; //IfcPersonAndOrganization ifcPersonAndOrganization = (actor is IfcPersonAndOrganization) ? actor as IfcPersonAndOrganization : null; //does not handle IfcPersonAndOrganization although it is a IfcActorSelect if (actor is IfcPersonAndOrganization) { throw new ArgumentException("Expecting IfcPerson or IfcOrganization"); } //swap categories into Roles foreach (var item in contact.Categories) { if (Exchanger.StringHasValue(item.Code)) { ifcActorRole = Exchanger.TargetRepository.Instances.New <IfcActorRole>(); ifcActorRole.RoleString = item.Code; ifcActorRole.Description = item.Description; if (ifcPerson != null) { ifcPerson.Roles.Add(ifcActorRole);//add to existing collection } if (ifcOrganization != null) { ifcOrganization.Roles.Add(ifcActorRole);//add to existing collection } //if (ifcPersonAndOrganization != null) //{ // if (ifcPersonAndOrganization.Roles == null) // { // ifcPersonAndOrganization.SetRoles(ifcActorRole);//create the ActorRoleCollection and set to Roles field // } // else // { // ifcPersonAndOrganization.Roles.Add(ifcActorRole);//add to existing collection // } //} } } }
public void CreateProjectInitTest() { //==== DEFAULT PROJECT ==== IfcProject project_default = IfcInit.CreateProject(null, null, null); IfcSite site_default = IfcInit.CreateSite(null, null, null); project_default.Aggregate(site_default, null); IfcBuilding building_default = IfcInit.CreateBuilding(null, null, null, null); site_default.Aggregate(building_default, null); IfcBuildingStorey storey_default = IfcInit.CreateBuildingStorey(null, null, null, null); building_default.Aggregate(storey_default, null); using (FileStream fs = File.Create("./default_project.ifc")) { project_default.SerializeToStep(fs, "IFC2X3", null); } //==== MANUAL CONTENT PROJECT ==== IfcPerson person = IfcInit.CreatePerson("Melange", "Cedric"); IfcOrganization organization = IfcInit.CreateOrganization("test organization", "a dummy organization for testing", "MyOrg"); IfcApplication application = IfcInit.CreateApplication(organization, "1.0", "test app", "TestApp"); IfcOwnerHistory ownerHistory = IfcInit.CreateOwnerHistory(person, organization, application); IfcProject project_manual = IfcInit.CreateProject("manual", "My manual test project", ownerHistory); IfcSite site_manual = IfcInit.CreateSite("test site", "a dummy site for testing", ownerHistory); project_manual.Aggregate(site_manual, ownerHistory); IfcBuilding building_manual = IfcInit.CreateBuilding("test building", "a dummy building for testing", ownerHistory, site_manual.ObjectPlacement); site_manual.Aggregate(building_manual, ownerHistory); IfcBuildingStorey storey_manual = IfcInit.CreateBuildingStorey("first storey", "first storey for testing", ownerHistory, building_manual.ObjectPlacement); building_manual.Aggregate(storey_manual, null); using (FileStream fs = File.Create("./manual_project.ifc")) { project_manual.SerializeToStep(fs, "IFC2X3", "my company"); } }
public static string GetFullName(this IfcPerson ifcPerson) { string name = string.Empty; if (ifcPerson.PrefixTitles != null) { foreach (var item in ifcPerson.PrefixTitles) { name += string.IsNullOrEmpty(item) ? "" : item.ToString() + " "; } } if (ifcPerson.GivenName.HasValue) { name += ifcPerson.GivenName + " "; } if (ifcPerson.MiddleNames != null) { foreach (var item in ifcPerson.MiddleNames) { name += string.IsNullOrEmpty(item) ? "" : item.ToString() + " "; } } if (ifcPerson.FamilyName.HasValue) { name += ifcPerson.FamilyName + " "; } if (ifcPerson.SuffixTitles != null) { foreach (var item in ifcPerson.SuffixTitles) { name += string.IsNullOrEmpty(item) ? "" : item.ToString() + " "; } } return(name); }
/// <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 GetTelecomEmailAddress(IfcPersonAndOrganization ifcPersonAndOrganization) { if (ifcPersonAndOrganization != null) { IfcPerson ifcPerson = ifcPersonAndOrganization.ThePerson; if (Context.EMails.ContainsKey(ifcPerson.EntityLabel)) { return(Context.EMails[ifcPerson.EntityLabel]); } else { IfcOrganization ifcOrganization = ifcPersonAndOrganization.TheOrganization; string email = GetEmail(ifcOrganization, ifcPerson); Context.EMails.Add(ifcPerson.EntityLabel, email); return(email); } } else { return(Constants.DEFAULT_EMAIL); } }
public IfcPersonAndOrganization(IfcPerson person, IfcOrganization organization) { ThePerson = person; TheOrganization = organization; }
private void ConvertPerson(Contact target, IfcPerson ifcPerson) { target.FamilyName = ifcPerson.FamilyName; target.GivenName = ifcPerson.GivenName; if (ifcPerson.Addresses != null) { var telecom = ifcPerson.Addresses.OfType <IfcTelecomAddress>().FirstOrDefault(); var postal = ifcPerson.Addresses.OfType <IfcPostalAddress>().FirstOrDefault(); if (telecom != null) { if (telecom.ElectronicMailAddresses != null) { var emailAddress = telecom.ElectronicMailAddresses.FirstOrDefault(t => !string.IsNullOrWhiteSpace(t)); if (!string.IsNullOrWhiteSpace(emailAddress)) //override any set if we have one at person level { target.Email = emailAddress; } } if (telecom.TelephoneNumbers != null) { var phoneNum = telecom.TelephoneNumbers.FirstOrDefault(t => !string.IsNullOrWhiteSpace(t)); if (!string.IsNullOrWhiteSpace(phoneNum)) { target.Phone = phoneNum; } } } if (postal != null) { var deptName = postal.InternalLocation; if (deptName.HasValue) { target.Department = deptName; } if (postal.AddressLines != null) { var streetNames = postal.AddressLines.ToString(); if (!string.IsNullOrWhiteSpace(streetNames)) { target.Street = streetNames; } } if (!string.IsNullOrWhiteSpace(postal.PostalBox)) { target.PostalBox = postal.PostalBox; } if (!string.IsNullOrWhiteSpace(postal.Town)) { target.Town = postal.Town; } if (!string.IsNullOrWhiteSpace(postal.Region)) { target.StateRegion = postal.Region; } if (!string.IsNullOrWhiteSpace(postal.PostalCode)) { target.PostalCode = postal.PostalCode; } } } if (ifcPerson.Roles != null) { var roles = ifcPerson.Roles; if (roles.Any()) { target.Categories = new List <Category>(roles.Count); foreach (var role in roles) { target.Categories.Add(new Category { Classification = "Role", Code = role.Role.ToString(), Description = role.Description }); } } } }
/// <summary> /// Fill sheet rows for Contact sheet /// </summary> /// <returns>COBieSheet</returns> public override COBieSheet <COBieContactRow> Fill() { ProgressIndicator.ReportMessage("Starting Contacts..."); ClearEMails(); //clear the email dictionary for a new file conversion //create new sheet COBieSheet <COBieContactRow> contacts = new COBieSheet <COBieContactRow>(Constants.WORKSHEET_CONTACT); IEnumerable <string> cobieContacts = Model.Instances.OfType <IfcPropertySingleValue>().Where(psv => psv.Name == "COBieCreatedBy" || psv.Name == "COBieTypeCreatedBy").GroupBy(psv => psv.NominalValue).Select(g => g.First().NominalValue.ToString()); IEnumerable <IfcPersonAndOrganization> ifcPersonAndOrganizations = Model.Instances.OfType <IfcPersonAndOrganization>(); ProgressIndicator.Initialise("Creating Contacts", ifcPersonAndOrganizations.Count() + cobieContacts.Count()); List <IfcOrganizationRelationship> ifcOrganizationRelationships = null; foreach (IfcPersonAndOrganization ifcPersonAndOrganization in ifcPersonAndOrganizations) { ProgressIndicator.IncrementAndUpdate(); //check we do not have a default email address, if skip it as we want the validation warning string email = GetTelecomEmailAddress(ifcPersonAndOrganization); if (email == Constants.DEFAULT_EMAIL) { continue; } COBieContactRow contact = new COBieContactRow(contacts); // get person and organization IfcOrganization ifcOrganization = ifcPersonAndOrganization.TheOrganization; IfcPerson ifcPerson = ifcPersonAndOrganization.ThePerson; contact.Email = email; //lets default the creator to that user who created the project for now, no direct link to OwnerHistory on IfcPersonAndOrganization, IfcPerson or IfcOrganization contact.CreatedBy = GetTelecomEmailAddress(Model.IfcProject.OwnerHistory); contact.CreatedOn = GetCreatedOnDateAsFmtString(Model.IfcProject.OwnerHistory); IfcActorRole ifcActorRole = null; if (ifcPerson.Roles != null) { ifcActorRole = ifcPerson.Roles.FirstOrDefault(); } if (ifcOrganization.Roles != null) { ifcActorRole = ifcOrganization.Roles.FirstOrDefault(); } if ((ifcActorRole != null) && (!string.IsNullOrEmpty(ifcActorRole.UserDefinedRole))) { contact.Category = ifcActorRole.UserDefinedRole.ToString(); } else { contact.Category = DEFAULT_STRING; } contact.Company = (string.IsNullOrEmpty(ifcOrganization.Name)) ? DEFAULT_STRING : ifcOrganization.Name.ToString(); contact.Phone = GetTelecomTelephoneNumber(ifcPersonAndOrganization); contact.ExtSystem = DEFAULT_STRING; // TODO: Person is not a Root object so has no Owner. What should this be? contact.ExtObject = "IfcPersonAndOrganization"; if (!string.IsNullOrEmpty(ifcPerson.Id)) { contact.ExtIdentifier = ifcPerson.Id; } //get department string department = ""; if (ifcPerson.Addresses != null) { department = ifcPerson.Addresses.PostalAddresses.Select(dept => dept.InternalLocation).Where(dept => !string.IsNullOrEmpty(dept)).FirstOrDefault(); } if (string.IsNullOrEmpty(department)) { if (ifcOrganizationRelationships == null) { ifcOrganizationRelationships = Model.Instances.OfType <IfcOrganizationRelationship>().ToList(); } IfcOrganization ifcRelOrganization = ifcOrganizationRelationships .Where(Or => Or.RelatingOrganization.EntityLabel == ifcOrganization.EntityLabel && Or.RelatedOrganizations.Last() != null) .Select(Or => Or.RelatedOrganizations.Last()) .LastOrDefault(); if (ifcRelOrganization != null) { department = ifcRelOrganization.Name.ToString(); } } if (string.IsNullOrEmpty(department)) { department = ifcOrganization.Description.ToString(); //only place to match example files } contact.Department = (string.IsNullOrEmpty(department)) ? contact.Company : department; contact.OrganizationCode = (string.IsNullOrEmpty(ifcOrganization.Id)) ? DEFAULT_STRING : ifcOrganization.Id.ToString(); contact.GivenName = (string.IsNullOrEmpty(ifcPerson.GivenName)) ? DEFAULT_STRING : ifcPerson.GivenName.ToString(); contact.FamilyName = (string.IsNullOrEmpty(ifcPerson.FamilyName)) ? DEFAULT_STRING : ifcPerson.FamilyName.ToString(); if (ifcPerson.Addresses != null) { GetContactAddress(contact, ifcPerson.Addresses); } else { GetContactAddress(contact, ifcOrganization.Addresses); } contacts.AddRow(contact); } foreach (string email in cobieContacts) { ProgressIndicator.IncrementAndUpdate(); COBieContactRow contact = new COBieContactRow(contacts); contact.Email = email; //lets default the creator to that user who created the project for now, no direct link to OwnerHistory on IfcPersonAndOrganization, IfcPerson or IfcOrganization contact.CreatedBy = GetTelecomEmailAddress(Model.IfcProject.OwnerHistory); contact.CreatedOn = GetCreatedOnDateAsFmtString(Model.IfcProject.OwnerHistory); contact.Category = DEFAULT_STRING; contact.Company = DEFAULT_STRING; contact.Phone = DEFAULT_STRING; contact.ExtSystem = DEFAULT_STRING; contact.ExtObject = "IfcPropertySingleValue"; contact.Department = DEFAULT_STRING; contact.OrganizationCode = DEFAULT_STRING; contact.GivenName = DEFAULT_STRING; contact.FamilyName = DEFAULT_STRING; contact.Street = DEFAULT_STRING; contact.PostalBox = DEFAULT_STRING; contact.Town = DEFAULT_STRING; contact.StateRegion = DEFAULT_STRING; contact.PostalCode = DEFAULT_STRING; contact.Country = DEFAULT_STRING; contacts.AddRow(contact); } ProgressIndicator.Finalise(); contacts.OrderBy(s => s.Email); return(contacts); }
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; } }
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); }
private void ConvertPerson(IfcPerson ifcPerson, CoBieLiteHelper helper) { ContactFamilyName = ifcPerson.FamilyName; ContactGivenName = ifcPerson.GivenName; if (ifcPerson.Addresses != null) { var telecom = ifcPerson.Addresses.OfType<IfcTelecomAddress>(); var postal = ifcPerson.Addresses.OfType<IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";", ifcTelecomAddresses.Where(t => t.ElectronicMailAddresses!=null).SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) ContactEmail = string.Join(";", emailAddresses, ContactEmail ?? ""); var phoneNums = string.Join(";", ifcTelecomAddresses.Where(t => t.TelephoneNumbers!=null).SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) ContactPhoneNumber = string.Join(";", phoneNums, ContactPhoneNumber ?? ""); var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); if (!string.IsNullOrWhiteSpace(url)) ContactURL = string.Join(";", url, ContactURL ?? ""); ; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";", ifcPostalAddresses.Where(p => p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) ContactDepartmentName = string.Join(";", deptNames,ContactDepartmentName??""); var streetNames = string.Join(";", ifcPostalAddresses.Where(p => p.AddressLines != null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) ContactStreet = string.Join(";", streetNames, ContactStreet ?? ""); var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) ContactPostalBoxNumber = string.Join(";", postalBox, ContactPostalBoxNumber ?? ""); var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) ContactTownName = string.Join(";", town, ContactTownName ?? ""); var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) ContactRegionCode = string.Join(";", region, ContactRegionCode ?? ""); var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) ContactPostalCode = string.Join(";", postalCode, ContactPostalCode ?? ""); } } if (ifcPerson.Roles != null) { var roles = string.Join(";", ifcPerson.Roles.SelectMany(r => r.RoleString)); //deals with User defined roles if (!string.IsNullOrWhiteSpace(roles)) ContactCategory = string.Join(";", roles, ContactCategory ?? ""); } }
private void ConvertPerson(IfcPerson ifcPerson, CoBieLiteUkHelper helper) { FamilyName = ifcPerson.FamilyName; GivenName = ifcPerson.GivenName; if (ifcPerson.Addresses != null) { var telecom = ifcPerson.Addresses.OfType <IfcTelecomAddress>(); var postal = ifcPerson.Addresses.OfType <IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";", ifcTelecomAddresses.Where(t => t.ElectronicMailAddresses != null).SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) { Email = string.Join(";", emailAddresses, Email ?? ""); } var phoneNums = string.Join(";", ifcTelecomAddresses.Where(t => t.TelephoneNumbers != null).SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) { Phone = string.Join(";", phoneNums, Phone ?? ""); } //var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); //if (!string.IsNullOrWhiteSpace(url)) // ContactURL = string.Join(";", url, ContactURL ?? ""); ; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";", ifcPostalAddresses.Where(p => p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) { Department = string.Join(";", deptNames, Department ?? ""); } var streetNames = string.Join(";", ifcPostalAddresses.Where(p => p.AddressLines != null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) { Street = string.Join(";", streetNames, Street ?? ""); } var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) { PostalBox = string.Join(";", postalBox, PostalBox ?? ""); } var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) { Town = string.Join(";", town, Town ?? ""); } var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) { StateRegion = string.Join(";", region, StateRegion ?? ""); } var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) { PostalCode = string.Join(";", postalCode, PostalCode ?? ""); } } } if (ifcPerson.Roles != null) { var roles = ifcPerson.Roles; if (roles.Any()) { Categories = new List <Category>(roles.Count); foreach (var role in roles) { Categories.Add(new Category { Classification = "Role", Code = role.Role.ToString(), Description = role.Description }); } } } }
private void ConvertPerson(IfcPerson ifcPerson, CoBieLiteUkHelper helper) { FamilyName = ifcPerson.FamilyName; GivenName = ifcPerson.GivenName; if (ifcPerson.Addresses != null) { var telecom = ifcPerson.Addresses.OfType<IfcTelecomAddress>(); var postal = ifcPerson.Addresses.OfType<IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";", ifcTelecomAddresses.Where(t => t.ElectronicMailAddresses != null).SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) Email = string.Join(";", emailAddresses, Email ?? ""); var phoneNums = string.Join(";", ifcTelecomAddresses.Where(t => t.TelephoneNumbers!=null).SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) Phone = string.Join(";", phoneNums, Phone ?? ""); //var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); //if (!string.IsNullOrWhiteSpace(url)) // ContactURL = string.Join(";", url, ContactURL ?? ""); ; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";", ifcPostalAddresses.Where(p => p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) Department = string.Join(";", deptNames,Department??""); var streetNames = string.Join(";", ifcPostalAddresses.Where(p => p.AddressLines != null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) Street = string.Join(";", streetNames,Street ?? ""); var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) PostalBox = string.Join(";", postalBox, PostalBox ?? ""); var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) Town = string.Join(";", town, Town ?? ""); var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) StateRegion = string.Join(";", region, StateRegion ?? ""); var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) PostalCode = string.Join(";", postalCode, PostalCode ?? ""); } } if (ifcPerson.Roles != null) { var roles = ifcPerson.Roles; if (roles.Any()) { Categories = new List<Category>(roles.Count); foreach (var role in roles) Categories.Add(new Category { Classification = "Role", Code = role.Role.ToString(), Description = role.Description }); } } }
private void ConvertPerson(IfcPerson ifcPerson, CoBieLiteHelper helper) { ContactFamilyName = ifcPerson.FamilyName; ContactGivenName = ifcPerson.GivenName; if (ifcPerson.Addresses != null) { var telecom = ifcPerson.Addresses.OfType <IfcTelecomAddress>(); var postal = ifcPerson.Addresses.OfType <IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";", ifcTelecomAddresses.SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) { ContactEmail = string.Join(";", emailAddresses, ContactEmail ?? ""); } var phoneNums = string.Join(";", ifcTelecomAddresses.SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) { ContactPhoneNumber = string.Join(";", phoneNums, ContactPhoneNumber ?? ""); } var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); if (!string.IsNullOrWhiteSpace(url)) { ContactURL = string.Join(";", url, ContactURL ?? ""); } ; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";", ifcPostalAddresses.Where(p => p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) { ContactDepartmentName = string.Join(";", deptNames, ContactDepartmentName ?? ""); } var streetNames = string.Join(";", ifcPostalAddresses.Where(p => p.AddressLines != null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) { ContactStreet = string.Join(";", streetNames, ContactStreet ?? ""); } var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) { ContactPostalBoxNumber = string.Join(";", postalBox, ContactPostalBoxNumber ?? ""); } var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) { ContactTownName = string.Join(";", town, ContactTownName ?? ""); } var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) { ContactRegionCode = string.Join(";", region, ContactRegionCode ?? ""); } var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) { ContactPostalCode = string.Join(";", postalCode, ContactPostalCode ?? ""); } } } if (ifcPerson.Roles != null) { var roles = string.Join(";", ifcPerson.Roles.SelectMany(r => r.RoleString)); //deals with User defined roles if (!string.IsNullOrWhiteSpace(roles)) { ContactCategory = string.Join(";", roles, ContactCategory ?? ""); } } }
/// <summary> /// Get email address from IfcPerson /// </summary> /// <param name="ifcOrganization"></param> /// <param name="ifcPerson"></param> /// <returns></returns> public static string GetEmail(IfcOrganization ifcOrganization, IfcPerson ifcPerson) { string email = ""; IEnumerable <IfcLabel> emails = Enumerable.Empty <IfcLabel>(); if ((ifcPerson != null) && (ifcPerson.Addresses != null)) { emails = ifcPerson.Addresses.TelecomAddresses.Select(address => address.ElectronicMailAddresses).Where(item => item != null).SelectMany(em => em).Where(em => !string.IsNullOrEmpty(em)); } if ((emails == null) || (emails.Count() == 0)) { if ((ifcOrganization != null) && (ifcOrganization.Addresses != null)) { emails = ifcOrganization.Addresses.TelecomAddresses.Select(address => address.ElectronicMailAddresses).Where(item => item != null).SelectMany(em => em).Where(em => !string.IsNullOrEmpty(em)); } } //if still no email lets make one up if ((emails != null) && (emails.Count() > 0)) { email = string.Join(" : ", emails); } else { string first = ""; string lastName = ""; string organization = ""; if (ifcPerson != null) { first = ifcPerson.GivenName.ToString(); lastName = ifcPerson.FamilyName.ToString(); } if (ifcOrganization != null) { organization = ifcOrganization.Name.ToString(); } string domType = ""; if (!string.IsNullOrEmpty(first)) { string[] split = first.Split('.'); if (split.Length > 1) { first = split[0]; //assume first } } if (!string.IsNullOrEmpty(lastName)) { string[] split = lastName.Split('.'); if (split.Length > 1) { lastName = split.Last(); //assume last } } if (!string.IsNullOrEmpty(organization)) { string[] split = organization.Split('.'); int index = 1; foreach (string item in split) { if (index == 1) { organization = item; //first item always } else if (index < split.Length) //all the way up to the last item { organization += "." + item; } else { domType = "." + item; //last item assume domain type } index++; } } email += (string.IsNullOrEmpty(first)) ? "unknown" : first; email += "."; email += (string.IsNullOrEmpty(lastName)) ? "unknown" : lastName; email += "@"; email += (string.IsNullOrEmpty(organization)) ? "unknown" : organization; email += (string.IsNullOrEmpty(domType)) ? ".com" : domType; email = email.Replace(" ", ""); //remove any spaces } return(email); }