Пример #1
0
 public static AuthorData ToAuthorData(this IIfcPerson ifcPerson)
 {
     return(new AuthorData
     {
         Name = ifcPerson?.FamilyName,
         GivenName = ifcPerson?.GivenName,
         Addresses = ifcPerson?.Addresses.Select(i => i.ToAddressData()).ToArray(),
         Organisations = ifcPerson?.EngagedIn.Select(i => i.TheOrganization.ToOrganisationData()).ToArray()
     });
 }
Пример #2
0
        public static string EmailAddressOf(IIfcActorSelect personOrg)
        {
            IIfcPerson       person       = null;
            IIfcOrganization organisation = null;

            if (personOrg is IIfcPerson)
            {
                person = personOrg as IIfcPerson;
            }
            if (personOrg is IIfcOrganization)
            {
                organisation = personOrg as IIfcOrganization;
            }
            if (personOrg is IIfcPersonAndOrganization)
            {
                person       = (personOrg as IIfcPersonAndOrganization).ThePerson;
                organisation = (personOrg as IIfcPersonAndOrganization).TheOrganization;
            }

            string email;
            string phone; // not used

            // priority goes to person
            if (person != null)
            {
                GetTelecom(person.Addresses, out email, out phone);
                if (email != null)
                {
                    return(email);
                }
            }
            if (organisation != null)
            {
                GetTelecom(organisation.Addresses, out email, out phone);
                if (email != null)
                {
                    return(email);
                }
            }
            return(DefaultUniqueEmail(personOrg));
        }
Пример #3
0
        public void processOwnerHistory()
        {
            string currStep = string.Empty;

            DBOperation.beginTransaction();

            OracleCommand command = new OracleCommand(" ", DBOperation.DBConn);

            IEnumerable <IIfcOwnerHistory> ownerHistoryList = _model.Instances.OfType <IIfcOwnerHistory>();

            foreach (IIfcOwnerHistory ownH in ownerHistoryList)
            {
                string columnSpec = "ID, ModelID";
                int    ID         = Math.Abs(ownH.EntityLabel);
                string valueList  = ID.ToString() + ", " + BIMRLProcessModel.currModelID;

                IIfcPerson thePerson   = ownH.OwningUser.ThePerson;
                string     givenName   = string.Empty;
                string     familyName  = string.Empty;
                string     middleNames = string.Empty;
                if (thePerson.MiddleNames != null)
                {
                    foreach (string middleName in thePerson.MiddleNames)
                    {
                        BIMRLCommon.appendToString(middleName.Trim(), " ", ref middleNames);
                    }
                }
                if (thePerson.GivenName != null)
                {
                    givenName = thePerson.GivenName.ToString().Trim();
                }
                if (thePerson.FamilyName != null)
                {
                    familyName = thePerson.FamilyName.ToString().Trim();
                }
                string owningPersonName = givenName + " " + middleNames + " " + familyName;

                if (!string.IsNullOrEmpty(owningPersonName))
                {
                    columnSpec += ", OwningPersonName";
                    valueList  += ", '" + owningPersonName + "'";
                }

                if (ownH.OwningUser.Roles != null)
                {
                    string roleString = string.Empty;
                    foreach (var role in ownH.OwningUser.Roles)
                    {
                        string roleStr = role.RoleString;
                        if (roleStr.Equals("USERDEFINED") && role.UserDefinedRole.HasValue)
                        {
                            roleStr = role.UserDefinedRole.Value.ToString();
                        }
                        BIMRLCommon.appendToString(roleStr, ", ", ref roleString);
                    }
                    if (!string.IsNullOrEmpty(roleString))
                    {
                        columnSpec += ", OwningPersonRoles";
                        valueList  += ", '" + roleString + "'";
                    }
                }
                //if (ownH.OwningUser.RolesString != null)
                //    {
                //        string owningPersonRoles = ownH.OwningUser.RolesString.Trim();
                //        if (!string.IsNullOrEmpty(owningPersonRoles))
                //        {
                //            columnSpec += ", OwningPersonRoles";
                //            valueList += ", '" + owningPersonRoles + "'";
                //        }
                //    }

                if (ownH.OwningUser.ThePerson.Addresses != null)
                {
                    string owningPersonAddresses = "";
                    foreach (IIfcAddress addr in ownH.OwningUser.ThePerson.Addresses)
                    {
                        BIMRLAddressData addrData = new BIMRLAddressData(addr);
                        BIMRLCommon.appendToString(addrData.ToString(), "; ", ref owningPersonAddresses);
                    }

                    if (!string.IsNullOrEmpty(owningPersonAddresses))
                    {
                        columnSpec += ", OwningPersonAddresses";
                        valueList  += ", '" + owningPersonAddresses + "'";
                    }
                }

                if (ownH.OwningUser.TheOrganization.Identification != null)
                {
                    columnSpec += ", OwningOrganizationId";
                    valueList  += ", '" + ownH.OwningUser.TheOrganization.Identification + "'";
                }

                if (ownH.OwningUser.TheOrganization.Name != null)
                {
                    columnSpec += ", OwningOrganizationName";
                    valueList  += ", '" + ownH.OwningUser.TheOrganization.Name + "'";
                }

                if (ownH.OwningUser.TheOrganization.Description != null)
                {
                    columnSpec += ", OwningOrganizationDescription";
                    valueList  += ", '" + ownH.OwningUser.TheOrganization.Description + "'";
                }

                if (ownH.OwningUser.TheOrganization.Roles != null)
                {
                    string roleString = string.Empty;
                    foreach (var role in ownH.OwningUser.TheOrganization.Roles)
                    {
                        string roleStr = role.RoleString;
                        if (roleStr.Equals("USERDEFINED") && role.UserDefinedRole.HasValue)
                        {
                            roleStr = role.UserDefinedRole.Value.ToString();
                        }
                        BIMRLCommon.appendToString(roleStr, ", ", ref roleString);
                    }
                    if (!string.IsNullOrEmpty(roleString))
                    {
                        columnSpec += ", OwningOrganizationRoles";
                        valueList  += ", '" + roleString + "'";
                    }

                    //string owningOrganizationRoles = ownH.OwningUser.TheOrganization.RolesString.Trim();
                    //     if (!string.IsNullOrEmpty(owningOrganizationRoles))
                    //     {
                    //         columnSpec += ", OwningOrganizationRoles";
                    //         valueList += ", '" + owningOrganizationRoles + "'";
                    //     }
                }

                if (ownH.OwningUser.TheOrganization.Addresses != null)
                {
                    string owningOrganizationAddresses = "";
                    foreach (IIfcAddress addr in ownH.OwningUser.TheOrganization.Addresses)
                    {
                        BIMRLAddressData addrData = new BIMRLAddressData(addr);
                        BIMRLCommon.appendToString(addrData.ToString(), "; ", ref owningOrganizationAddresses);
                    }

                    if (!string.IsNullOrEmpty(owningOrganizationAddresses))
                    {
                        columnSpec += ", OwningOrganizationAddresses";
                        valueList  += ", '" + owningOrganizationAddresses + "'";
                    }
                }

                columnSpec += ", ApplicationName, ApplicationVersion, ApplicationDeveloper, ApplicationID";
                valueList  += ", '" + ownH.OwningApplication.ApplicationFullName + "', '" + ownH.OwningApplication.Version + "', '"
                              + ownH.OwningApplication.ApplicationDeveloper.Name + "', '" + ownH.OwningApplication.ApplicationIdentifier + "'";

                if (ownH.State != null)
                {
                    columnSpec += ", State";
                    valueList  += ", '" + ownH.State.ToString() + "'";
                }

                columnSpec += ", ChangeAction";
                valueList  += ", '" + ownH.ChangeAction.ToString() + "'";

                if (ownH.LastModifiedDate != null)
                {
                    long lastModTS = (long)ownH.LastModifiedDate.Value / 86400; // No of days
                    columnSpec += ", LastModifiedDate";
                    valueList  += ", to_date('01-01-1970 00:00:00','DD-MM-YYYY HH24:MI:SS')+" + lastModTS.ToString() + " ";
                }

                if (ownH.LastModifyingUser != null)
                {
                    columnSpec += ", LastModifyingUserID";
                    IIfcPerson modPerson           = ownH.LastModifyingUser.ThePerson;
                    string     LastModifyingUserId = modPerson.GivenName.ToString().Trim() + " " + modPerson.MiddleNames.ToString().Trim() + " " + modPerson.FamilyName.ToString().Trim();

                    valueList += ", '" + LastModifyingUserId + "'";
                }

                if (ownH.LastModifyingApplication != null)
                {
                    columnSpec += ", LastModifyingApplicationID";
                    valueList  += ", 'ID: " + ownH.LastModifyingApplication.ApplicationIdentifier + "; Name: " + ownH.LastModifyingApplication.ApplicationFullName
                                  + "; Ver: " + ownH.LastModifyingApplication.Version + "; Dev: " + ownH.LastModifyingApplication.ApplicationDeveloper.Name + "'";
                }

                long crDateTS = ownH.CreationDate / 86400; // No of days
                columnSpec += ", CreationDate";
                valueList  += ", to_date('01-01-1970 00:00:00','DD-MM-YYYY HH24:MI:SS')+" + crDateTS.ToString() + " ";

                string sqlStmt = "insert into " + DBOperation.formatTabName("BIMRL_OWNERHISTORY") + "(" + columnSpec + ") values (" + valueList + ")";
                currStep = sqlStmt;

                command.CommandText = sqlStmt;

                try
                {
                    int commandStatus          = command.ExecuteNonQuery();
                    Tuple <int, int> ownHEntry = new Tuple <int, int>(ID, BIMRLProcessModel.currModelID);
                    _refBIMRLCommon.OwnerHistoryAdd(ownHEntry);
                }
                catch (OracleException e)
                {
                    string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushIgnorableError(excStr);
                }
                catch (SystemException e)
                {
                    string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep;
                    _refBIMRLCommon.StackPushError(excStr);
                    throw;
                }
            }

            DBOperation.commitTransaction();
            command.Dispose();
        }
        private void ConvertPerson(CobieContact target, IIfcPerson ifcPerson)
        {
            target.FamilyName = ifcPerson.FamilyName;
            target.GivenName  = ifcPerson.GivenName;

            if (ifcPerson.Addresses != null)
            {
                var telecom = ifcPerson.Addresses.OfType <IIfcTelecomAddress>().FirstOrDefault(a => a.ElectronicMailAddresses.Any(e => !string.IsNullOrWhiteSpace(e)));
                var postal  = ifcPerson.Addresses.OfType <IIfcPostalAddress>().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;
                    }
                    target.Street = postal.AddressLines != null && postal.AddressLines.Any() ? string.Join(", ", postal.AddressLines) : null;

                    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 (string.IsNullOrWhiteSpace(target.Email))
            {
                target.Email = string.Format("unknown{0}@undefined.email", ifcPerson.EntityLabel);
            }

            if (ifcPerson.Roles == null)
            {
                return;
            }
            var role = ifcPerson.Roles.FirstOrDefault();

            if (role == null)
            {
                return;
            }
            var catString = role.UserDefinedRole ?? Enum.GetName(typeof(IfcRoleEnum), role.Role);

            target.Category = Helper.GetPickValue <CobieRole>(catString);
        }
Пример #5
0
        /// <summary>
        /// Get email address from IfcPerson
        /// </summary>
        /// <param name="ifcOrganization"></param>
        /// <param name="ifcPerson"></param>
        /// <returns></returns>
        public static string GetEmail(IIfcOrganization ifcOrganization, IIfcPerson ifcPerson)
        {
            var email  = "";
            var emails = Enumerable.Empty <IfcLabel>();

            if ((ifcPerson != null) && (ifcPerson.Addresses != null))
            {
                emails = ifcPerson
                         .Addresses.OfType <IfcTelecomAddress>()
                         .Select(address => address.ElectronicMailAddresses)
                         .Where(item => item != null).SelectMany(em => em)
                         .Where(em => !string.IsNullOrEmpty(em))
                         .ToList();
            }
            if (!emails.Any())
            {
                if ((ifcOrganization != null) && (ifcOrganization.Addresses != null))
                {
                    emails = ifcOrganization.Addresses.OfType <IfcTelecomAddress>().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.Any())
            {
                email = string.Join(" : ", emails);
            }
            else
            {
                var first        = "";
                var lastName     = "";
                var organization = "";
                if (ifcPerson != null)
                {
                    first    = ifcPerson.GivenName.ToString();
                    lastName = ifcPerson.FamilyName.ToString();
                }
                if (ifcOrganization != null)
                {
                    organization = ifcOrganization.Name.ToString();
                }
                var domType = "";
                if (!string.IsNullOrEmpty(first))
                {
                    var split = first.Split('.');
                    if (split.Length > 1)
                    {
                        first = split[0];                   //assume first
                    }
                }

                if (!string.IsNullOrEmpty(lastName))
                {
                    var split = lastName.Split('.');
                    if (split.Length > 1)
                    {
                        lastName = split.Last();                   //assume last
                    }
                }


                if (!string.IsNullOrEmpty(organization))
                {
                    var split = organization.Split('.');
                    var index = 1;
                    foreach (var 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);
        }
Пример #6
0
        private void ConvertPerson(IIfcPerson ifcPerson, CoBieLiteHelper helper)
        {
            ContactFamilyName = ifcPerson.FamilyName;
            ContactGivenName  = ifcPerson.GivenName;

            if (ifcPerson.Addresses != null)
            {
                var telecom             = ifcPerson.Addresses.OfType <IIfcTelecomAddress>();
                var postal              = ifcPerson.Addresses.OfType <IIfcPostalAddress>();
                var ifcTelecomAddresses = telecom as IIfcTelecomAddress[] ?? 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 IIfcPostalAddress[] ?? 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(IIfcPerson ifcPerson, CoBieLiteUkHelper helper)
        {
            FamilyName = ifcPerson.FamilyName;
            GivenName  = ifcPerson.GivenName;

            if (ifcPerson.Addresses != null)
            {
                var telecom             = ifcPerson.Addresses.OfType <IIfcTelecomAddress>();
                var postal              = ifcPerson.Addresses.OfType <IIfcPostalAddress>();
                var ifcTelecomAddresses = 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.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
                        });
                    }
                }
            }
        }
        internal static void ConvertPerson(Contact target, IIfcPerson ifcPerson)
        {
            // specific fields (different from ifcorganisation)
            target.FamilyName = ifcPerson.FamilyName;
            target.GivenName  = ifcPerson.GivenName;

            // ========================= postal address
            //
            string department;
            string street;
            string postalBox;
            string town;
            string stateRegion;
            string postalCode;

            var c = ContactFunctions.GetPostal(ifcPerson.Addresses,
                                               out department,
                                               out street,
                                               out postalBox,
                                               out town,
                                               out stateRegion,
                                               out postalCode
                                               );

            if (c > 0)
            {
                if (department != null)
                {
                    target.Department = department;
                }
                if (street != null)
                {
                    target.Street = street;
                }
                if (postalBox != null)
                {
                    target.PostalBox = postalBox;
                }
                if (town != null)
                {
                    target.Town = town;
                }
                if (stateRegion != null)
                {
                    target.StateRegion = stateRegion;
                }
                if (postalCode != null)
                {
                    target.PostalCode = postalCode;
                }
            }

            // ========================= telecom address
            //

            string email;
            string phone;

            var c2 = ContactFunctions.GetTelecom(ifcPerson.Addresses,
                                                 out email,
                                                 out phone
                                                 );

            if (c2 > 0)
            {
                if (email != null)
                {
                    target.Email = email;
                }
                if (phone != null)
                {
                    target.Phone = phone;
                }
            }

            // ========================= roles are used for classification
            //
            if (ifcPerson.Roles == null)
            {
                return;
            }
            var roles = ifcPerson.Roles;

            if (!roles.Any())
            {
                return;
            }
            if (target.Categories == null)
            {
                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
                });
            }
        }
Пример #9
0
        private void ConvertPerson(Contact target, IIfcPerson ifcPerson)
        {
            target.FamilyName = ifcPerson.FamilyName;
            target.GivenName  = ifcPerson.GivenName;

            if (ifcPerson.Addresses != null)
            {
                var telecom = ifcPerson.Addresses.OfType <IIfcTelecomAddress>().FirstOrDefault();
                var postal  = ifcPerson.Addresses.OfType <IIfcPostalAddress>().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
                        });
                    }
                }
            }
        }