예제 #1
0
 public ContactAddress(ContactAddress source)
     : base(source)
 {
 }
예제 #2
0
        public bool Evaluate(UserConnection userConnection, AdElement element, Entity relatedEntity, Entity handler)
        {
            _logger.Info("Читаем адрес контакта");
            var    contact   = (Contact)relatedEntity;
            Guid?  countryId = null;
            Guid?  cityId    = null;
            string addr      = null;
            string room      = null;
            string zip       = null;

            // Страна
            string countryAttr = AdAttributesHelper.GetXmlElement("country", handler.GetTypedColumnValue <string>("NavHandlerParameterXML"));

            if (countryAttr.IsNotEmpty() && element.Attributes.ContainsKey(countryAttr))
            {
                string countryName = element.Attributes[countryAttr].Value;
                var    country     = (Country)AdAttributesHelper.GetOrCreateEntityByDisplayValue(userConnection, "Country", countryName);

                countryId = country.Id;

                _logger.Info("Страна = " + countryName);
            }

            // Город
            string cityAttr = AdAttributesHelper.GetXmlElement("city", handler.GetTypedColumnValue <string>("NavHandlerParameterXML"));

            if (cityAttr.IsNotEmpty() && element.Attributes.ContainsKey(cityAttr))
            {
                string cityName = element.Attributes[cityAttr].Value;
                var    city     = (City)AdAttributesHelper.GetOrCreateEntityByDisplayValue(userConnection, "City", cityName);

                cityId = city.Id;

                _logger.Info("Город = " + cityName);
            }

            // Улица, дом
            string addrAttr = AdAttributesHelper.GetXmlElement("address", handler.GetTypedColumnValue <string>("NavHandlerParameterXML"));

            if (addrAttr.IsNotEmpty() && element.Attributes.ContainsKey(addrAttr))
            {
                addr = element.Attributes[addrAttr].Value;

                _logger.Info("Адрес = " + addr);
            }

            // postalCode
            string zipAttr = AdAttributesHelper.GetXmlElement("postalCode", handler.GetTypedColumnValue <string>("NavHandlerParameterXML"));

            if (zipAttr.IsNotEmpty() && element.Attributes.ContainsKey(zipAttr))
            {
                zip = element.Attributes[zipAttr].Value;

                _logger.Info("zip = " + zip);
            }

            ContactAddress address = GetContactAddress(userConnection, contact);

            if (countryId != null || cityId != null || addr != null || zip != null)
            {
                _logger.Info("Сохраняем адрес контакта");

                address.SetColumnValue("CountryId", countryId);
                address.SetColumnValue("CityId", cityId);
                address.Address = addr;
                address.Zip     = zip;

                try
                {
                    address.Save(false);
                }
                catch (Exception ex)
                {
                    _logger.Error("Ошибка при сохранении адреса " + ex.ToString());
                }
            }
            else
            {
                _logger.Info("Удаляем адрес контакта");
                try
                {
                    address.Delete();
                }
                catch (Exception ex)
                {
                    _logger.Error("Ошибка при удалении адреса " + ex.ToString());
                }
            }

            return(true);
        }
예제 #3
0
 public ContactAddress(Terrasoft.Configuration.ContactAddress source)
     : base(source)
 {
     this.CopyEntityLookupProperties(source);
 }