Exemplo n.º 1
0
        /// <summary>
        /// Create IFC Address from the saved data obtained by the UI and saved in the extensible storage
        /// </summary>
        /// <param name="file"></param>
        /// <param name="document"></param>
        /// <returns>The handle of IFC file.</returns>
        private IFCAnyHandle CreateIFCAddressFromExtStorage(IFCFile file, Document document)
        {
            IFCAddress savedAddress = new IFCAddress();
            IFCAddressItem savedAddressItem;

            if (savedAddress.GetSavedAddress(document, out savedAddressItem) == true)
            {
                IFCAnyHandle postalAddress;
                
                // We have address saved in the extensible storage
                List<string> addressLines = new List<string>();
                if (!String.IsNullOrEmpty(savedAddressItem.AddressLine1))
                {
                    addressLines.Add(savedAddressItem.AddressLine1);
                    if (!String.IsNullOrEmpty(savedAddressItem.AddressLine2))
                        addressLines.Add(savedAddressItem.AddressLine2);
                }

                IFCAddressType? addressPurpose = null;
                if (!String.IsNullOrEmpty(savedAddressItem.Purpose))
                {
                    addressPurpose = IFCAddressType.UserDefined;     // set this as default value
                    if (String.Compare(savedAddressItem.Purpose, "OFFICE", true) == 0)
                        addressPurpose = Toolkit.IFCAddressType.Office;
                    else if (String.Compare(savedAddressItem.Purpose, "SITE", true) == 0)
                        addressPurpose = Toolkit.IFCAddressType.Site;
                    else if (String.Compare(savedAddressItem.Purpose, "HOME", true) == 0)
                        addressPurpose = Toolkit.IFCAddressType.Home;
                    else if (String.Compare(savedAddressItem.Purpose, "DISTRIBUTIONPOINT", true) == 0)
                        addressPurpose = Toolkit.IFCAddressType.DistributionPoint;
                    else if (String.Compare(savedAddressItem.Purpose, "USERDEFINED", true) == 0)
                        addressPurpose = Toolkit.IFCAddressType.UserDefined;
                }

                postalAddress = IFCInstanceExporter.CreatePostalAddress(file, addressPurpose, savedAddressItem.Description, savedAddressItem.UserDefinedPurpose,
                   savedAddressItem.InternalLocation, addressLines, savedAddressItem.POBox, savedAddressItem.TownOrCity, savedAddressItem.RegionOrState, savedAddressItem.PostalCode, 
                   savedAddressItem.Country);

                return postalAddress;
            }

            return null;
        }