// ReSharper disable once InconsistentNaming private static bool PreprocessPatternXX99XX99XX(StreetAnalysisData data, ICollection <StreetAnalysisData> deletions, ICollection <StreetAnalysisData> additions) { var matchLow = RegexXX99XX99XX.Match(data.PrimaryLowNumber); var matchHigh = RegexXX99XX99XX.Match(data.PrimaryHighNumber); if (!matchLow.Success || !matchHigh.Success) { return(false); // not handled } ProcessAddress( data, deletions, additions, matchLow, matchHigh, "{0}{1}{2}{3}{4}{5}", AddressPart.CreateAlpha("alpha1"), AddressPart.CreateNumeric("number1"), AddressPart.CreateAlpha("alpha2"), AddressPart.CreateNumeric("number2"), AddressPart.CreateAlpha("alpha3"), AddressPart.CreateNumeric("number3")); return(true); }
internal AddressField(string title, AddressPart type, bool visible, string decsription) { _title = title; _type = type; _visible = visible; _decsription = decsription; }
/// <summary> /// Create an address set /// </summary> public AddressSet CreateAddressSet(AD address, List <IResultDetail> dtls) { AddressSet retVal = new AddressSet(); AddressSet.AddressSetUse internalNameUse = ConvertAddressUse(address.Use, dtls); if (address == null || address.IsNull) { return(null); } retVal.Use = internalNameUse; // Create the parts foreach (ADXP namePart in address.Part) { var pt = new AddressPart() { AddressValue = namePart.Value, PartType = (AddressPart.AddressPartType)Enum.Parse(typeof(AddressPart.AddressPartType), namePart.Type.ToString()) }; if (pt.PartType == AddressPart.AddressPartType.AddressLine) // R1 doesn't use AL but SAL and the formatter { pt.PartType = AddressPart.AddressPartType.StreetAddressLine; } retVal.Parts.Add(pt); } if (address.UseablePeriod != null && !address.UseablePeriod.IsNull) { dtls.Add(new NotImplementedElementResultDetail("useablePeriod", "urn:hl7-org:v3")); } return(retVal); }
/// <summary> /// Parse an AD extension /// </summary> public static List <AddressPart> ParseADExtension(List <Extension> extension, List <IResultDetail> dtls) { try { List <AddressPart> retVal = new List <AddressPart>(); foreach (var adext in extension.FindAll(o => o.Url == GetExtensionNameUrl("addressPart"))) { AddressPart ap = new AddressPart(); ap.AddressValue = (adext.Value as FhirString); // Find the extension identifying the type var typeExt = adext.Extension.Find(o => o.Url == GetExtensionNameUrl("v3-addressPartTypes")); var typeCode = typeExt != null ? typeExt.Value as Coding : null as Coding; if (typeCode != null && typeCode.System == typeof(AddressPartType).GetValueSetDefinition()) { ap.PartType = (AddressPart.AddressPartType)MARC.Everest.Connectors.Util.Convert <AddressPartType>(typeCode.Code); } else { dtls.Add(new VocabularyIssueResultDetail(ResultDetailType.Error, String.Format("Extended address parts must carry a classification from code system {0}", typeof(AddressPartType).GetValueSetDefinition()), null, null)); } } return(retVal); } catch (VocabularyException e) { dtls.Add(new VocabularyIssueResultDetail(ResultDetailType.Error, String.Format(ApplicationContext.LocalizationService.GetString("FHIR007"), GetExtensionNameUrl("v3-addressPartTypes"), e.Message), e)); return(new List <AddressPart>()); } }
/// <summary> /// Extract locators, which depends mainly on requested addressPart. /// </summary> /// <param name="addressPart">Address part.</param> /// <param name="sublocators">Sublocators.</param> /// <returns>locators, which depends mainly on requested addressPart.</returns> private static List <LocatorInfo> _ExtractLocators(AddressPart addressPart, List <LocatorInfo> sublocators) { Debug.Assert(sublocators != null); List <LocatorInfo> extractedLocators = new List <LocatorInfo>(); // Get locators, which depends mainly on requested addressPart. foreach (LocatorInfo locatorInfo in sublocators) { foreach (AddressPart field in locatorInfo.InternalFields) { if (field == addressPart) { extractedLocators.Add(locatorInfo); break; } } } // REV: method shouldn't affect sublocators param, it is input and it is not evident that this param can be changed. // Remove extracted locators. foreach (LocatorInfo sublocatorInfo in extractedLocators) { sublocators.Remove(sublocatorInfo); } return(extractedLocators); }
private static bool PreprocessFractionals( StreetAnalysisData data, ICollection <StreetAnalysisData> deletions, ICollection <StreetAnalysisData> additions) { var matchLow = RegexFractional.Match(data.PrimaryLowNumber); var matchHigh = RegexFractional.Match(data.PrimaryHighNumber); if (!matchLow.Success || !matchHigh.Success) { return(false); // not handled } // There are two special cases here: // 1. If any of prefix, number or suffix1 is not empty, the pattern // needs a space before the fraction. // 2. If the numberLow is empty but numberHigh is not (like 1/2::2 1/2) // we need to create an extra entry for 1/2::1/2 before we let the // normal expansion handle the rest. var prefixHigh = matchHigh.FirstCaptureOrEmpty("prefix"); var numberLow = matchLow.FirstCaptureOrEmpty("number"); var numberHigh = matchHigh.FirstCaptureOrEmpty("number"); var suffix1High = matchHigh.FirstCaptureOrEmpty("suffix1"); // Case 1 string pattern; if ((prefixHigh.Length == 0) && (numberHigh.Length == 0) && (suffix1High.Length == 0)) { pattern = "{0}{1}{2}{3}{4}"; } else { pattern = "{0}{1}{2} {3}{4}"; } // Case 2 if ((numberLow.Length == 0) && (numberHigh.Length != 0)) { var toAdd = data.Clone(); toAdd.UpdateKey += "-00"; toAdd.PrimaryHighNumber = toAdd.PrimaryLowNumber; additions.Add(toAdd); } ProcessAddress( data, deletions, additions, matchLow, matchHigh, pattern, AddressPart.CreateAlpha("prefix"), AddressPart.CreateNumeric("number"), AddressPart.CreateAlpha("suffix1"), AddressPart.CreateFraction("fraction"), AddressPart.CreateAlpha("suffix2")); return(true); }
private CellEditor _GetAddressColumnEditor(AddressPart addressPart) { string keyName = string.Format(ADDRESS_COLUMN_EDITOR_KEY_FORMAT, addressPart.ToString()); CellEditor editor = (CellEditor)App.Current.FindResource(keyName); Debug.Assert(editor != null); return(editor); }
public void NotifyNewJsrInfo(JsrInfo info, AddressPart addressPart, long cycles) { Debug.Assert(info != null); Debug.Assert(JsrInfo == null); Debug.Assert(addressPart != AddressPart.NA); Debug.Assert(addressPart == AddressPart.High ? info.JsrReturnAddrH == this : info.JsrReturnAddrL == this); Debug.Assert(cycles == info.CyclesAfterJsr); JsrInfo = info; ReturnAddrPart = addressPart; LastAssignedCycles = cycles; }
/// <summary> /// Returns value of specififed address part. /// </summary> /// <param name="addressPart"></param> /// <returns></returns> public string this[AddressPart addressPart] { get { return(_GetAddressPart(addressPart)); } set { _SetAddressPart(addressPart, value); } }
//public EventAddress GetEventAddressByLocationName(string locationName) //{ // var model = GetByLocationName(locationName); // return GetEventAddress(model); //} //public EventAddress GetEventAddressByIdentity(string identifier) //{ // AddressPart model = GetByIdentity(identifier); // var data = GetEventAddress(model); // return data; //} //public EventAddress GetEventAddress(AddressPart model) //{ // var part = new EventAddress(); // if (model == null) return part; // part.AddressId = model.Identifier; // part.LocationName = model.LocationName; // part.MapEmbedCode = model.MapEmbedCode; // part.StreetAddress1 = model.StreetAddress1; // part.StreetAddress2 = model.StreetAddress2; // part.StreetAddress3 = model.StreetAddress3; // part.City = model.City; // part.State = model.State; // part.Zip = model.Zip; // part.Country = model.Country; // return part; //} //public IEnumerable<EventAddress> GetEventAddresses(VersionOptions version = null) //{ // var data = GetAddressParts(version).Select(GetEventAddress); // return data; //} //public void UpdateAddressPartFromEventAddress(AddressPart part, EventAddress model) //{ // if(model==null) return; // part.LocationName = model.LocationName; // part.MapEmbedCode = model.MapEmbedCode; // part.StreetAddress1 = model.StreetAddress1; // part.StreetAddress2 = model.StreetAddress2; // part.StreetAddress3 = model.StreetAddress3; // part.City = model.City; // part.State = model.State; // part.Zip = model.Zip; // part.Country = model.Country; //} //public string CreateAddress(EventAddress address) //{ // if (!string.IsNullOrWhiteSpace(address.AddressId)) // { // return null; // } // var item = Services.ContentManager.New<AddressPart>("Address"); // _contentManager.Create(item, VersionOptions.Draft); // var model = item.ContentItem.As<AddressPart>(); // UpdateAddressPartFromEventAddress(model,address); // _contentManager.Publish(model.ContentItem); // return model.ContentItem.Get<IdentityPart>().Identifier; //} public void UpdateEventForContentItem(ContentItem item, AddressPart model) { var part = item.As <AddressPart>(); part.LocationName = model.LocationName; part.MapEmbedCode = model.MapEmbedCode; part.StreetAddress1 = model.StreetAddress1; part.StreetAddress2 = model.StreetAddress2; part.StreetAddress3 = model.StreetAddress3; part.City = model.City; part.State = model.State; part.Zip = model.Zip; part.Country = model.Country; }
private AddressViewModel MapAddress(AddressPart addressPart) { dynamic address = addressPart; var addressViewModel = new AddressViewModel(); if (addressPart != null) { addressViewModel.Name = address.Name.Value; addressViewModel.AddressLine1 = address.AddressLine1.Value; addressViewModel.City = address.City.Value; addressViewModel.Country = address.Country.Value; } return(addressViewModel); }
/// <summary> /// Get an address set from the database /// </summary> public static AddressSet GetAddress(IDbConnection conn, IDbTransaction tx, decimal?addrSetId, bool loadFast) { IDbCommand cmd = CreateCommandStoredProc(conn, tx); try { cmd.CommandText = "get_addr_set"; if (!loadFast) { cmd.CommandText += "_efft"; } cmd.Parameters.Add(CreateParameterIn(cmd, "addr_set_id_in", DbType.Decimal, addrSetId)); // Execute a reader IDataReader reader = cmd.ExecuteReader(); AddressSet retVal = new AddressSet() { Use = AddressSet.AddressSetUse.PhysicalVisit, Key = addrSetId.Value }; // Populate set while (reader.Read()) { AddressPart part = new AddressPart(); part.AddressValue = Convert.ToString(reader["addr_cmp_value"]); part.PartType = (AddressPart.AddressPartType)Convert.ToInt32(reader["addr_cmp_cls"]); retVal.Parts.Add(part); // Effective time if (!loadFast && retVal.EffectiveTime == default(DateTime) && reader["efft_utc"] != DBNull.Value) { retVal.EffectiveTime = Convert.ToDateTime(reader["efft_utc"]); if (reader["obslt_utc"] != DBNull.Value) { retVal.EffectiveTime = Convert.ToDateTime(reader["obslt_utc"]); } } } return(retVal); } finally { cmd.Dispose(); } }
private AddressVM MapAddress(AddressPart addressPart) { dynamic address = addressPart; var addressVM = new AddressVM(); if (addressPart != null) { addressVM.Name = address.Name.Value; addressVM.AddressLine1 = address.AddressLine1.Value; addressVM.AddressLine2 = address.AddressLine2.Value; addressVM.Zipcode = address.Zipcode.Value; addressVM.City = address.City.Value; addressVM.Country = address.Country.Value; } return(addressVM); }
/// <summary> /// Parse full address property and fill address fields. /// </summary> /// <param name="addressToParse">Address to parse and fill.</param> public static void ParseAndFillAddress(Address addressToParse) { Debug.Assert(addressToParse != null); // Get field mappings for locator of candidate. AddressPart[] addressFieldTypes = _GetFieldMappingsForLocator(addressToParse.MatchMethod); // Split match_addr. string[] fieldsSeparator = new string[1]; fieldsSeparator[0] = ADDRESS_FIELDS_SEPARATOR; string[] addressFields; addressFields = addressToParse.FullAddress.Split(fieldsSeparator, StringSplitOptions.None); // Fill address. if (addressFields.Length != addressFieldTypes.Length) { // In case of field mappings length is not equals to splitted address parts count - // fill maximum possible values. string errorFmt = (string)App.Current.FindResource("WrongFieldCountInLocatorInfo"); string errorMessage = string.Format(errorFmt, addressToParse.MatchMethod); Logger.Warning(errorMessage); // Special case for errors in locator. int fieldCount = addressFieldTypes.Length; if (fieldCount > addressFields.Length) { fieldCount = addressFields.Length; } for (int index = 0; index < fieldCount; index++) { AddressPart addressPart = addressFieldTypes[index]; addressToParse[addressPart] = addressFields[index].Trim(); } } else { // Fill address fields in correct order. for (int index = 0; index < addressFields.Length; index++) { AddressPart addressPart = addressFieldTypes[index]; addressToParse[addressPart] = addressFields[index].Trim(); } } }
public bool LinkAddressToTown(AddressPart part, int townId) { IEnumerable <IContent> result = null; try { result = _mechanics.Value.CreateConnector(part, townId, "AddressToTown", true); if (result.Count() > 0) { return(true); } } catch (Exception e) { Logger.Error(e, "Error linking address to town"); } return(false); }
private AddressViewModel MapAddress(AddressPart addressPart, CustomerPart customer) { var addressViewModel = new AddressViewModel(); if (addressPart != null) { addressViewModel.Name = addressPart.Name; addressViewModel.Address = addressPart.Address; addressViewModel.State = addressPart.State; addressViewModel.Postcode = addressPart.Postcode; addressViewModel.City = addressPart.City; addressViewModel.CountryCode = addressPart.CountryCode; } addressViewModel.CountryCodes = CountryCode.SelectList; return(addressViewModel); }
private dynamic BuildModel(OrderPart order, EditOrderVM editModel) { CustomerPart customer = _customerService.GetCustomer(order.CustomerId); AddressPart shipAddressPart = _customerService.GetShippingAddress(customer.Id, order.Id); AddressPart custAddressPart = _customerService.GetInvoiceAddress(customer.Id); string shipName = string.Empty; if (shipAddressPart != null && !string.IsNullOrWhiteSpace(shipAddressPart.Name)) { shipName = shipAddressPart.Name; } string shipAddress = shipAddressPart == null ? "(same as Invoice Address)" : shipAddressPart.Address; string shipAddress2 = shipAddressPart == null ? string.Empty : shipAddressPart.City + " " + shipAddressPart.State + " " + shipAddressPart.Postcode; string shipCountry = shipAddressPart == null ? string.Empty : shipAddressPart.Country; string custAddress = custAddressPart.Address; string custAddress2 = custAddressPart.City + " " + custAddressPart.State + " " + custAddressPart.Postcode; string custCountry = custAddressPart.Country; return(Shape.Order( Order: order, CustomerName: customer.FullName, CustomerAddress1: custAddress, CustomerAddress2: custAddress2, CustomerCountry: custCountry, ShippingName: shipName, ShippingAddress1: shipAddress, ShippingAddress2: shipAddress2, ShippingCountry: shipCountry, Details: null, // Convert the whole thing to use Part instead of Record //Details: order.Details.Select( detail => // Shape.Detail // ( // Sku: detail.Sku, // Price: detail.UnitPrice, // Quantity: detail.Quantity, // Total: detail.Total, // Description: detail.Description // )).ToArray(), EditModel: editModel )); }
/// <summary> /// <para>Returns the specified portion of a full address in format nick!user@host.</para> /// </summary> /// <param name="source"></param> /// <param name="part"></param> /// <exception cref="MalformedAddressException" /> /// <returns></returns> public static String ClipAddress(this String source, AddressPart part) { int index1 = source.IndexOf('!'); int index2 = source.IndexOf('@'); if (index1 > index2) { throw new MalformedAddressException(source, "'!' is located after '@'"); } else if (index1 + 1 == source.Length || index2 + 1 == source.Length) { throw new MalformedAddressException(source, "No identd or host body"); } else if (index1 == 0) { throw new MalformedAddressException(source, "No nick body"); } string identd = source.Substring(index1 + 1, index2 - index1 - 1); if (identd[0] == '~' && identd.Length == 1) { throw new MalformedAddressException(source, "Identd contains only the identd marker (~) and is therefore invalid"); } switch (part) { case AddressPart.HOST: return(source.Substring(index2 + 1)); case AddressPart.IDENTD: return(identd); case AddressPart.NICK: return(source.Substring(0, index1)); default: throw new Exception("Error in ClipAddress: AddressPart enumeration not handled."); } }
// ReSharper disable once InconsistentNaming private static string IncrementAddressXXHyphenXX(string low, string high, string oddEven, ref bool stop) { var matchLow = RegexXXHyphenXX.Match(low); var matchHigh = RegexXXHyphenXX.Match(high); if (!matchLow.Success || !matchHigh.Success) { return(null); // not handled } stop = true; return(IncrementAddressCommon( matchLow, matchHigh, "{0}{1}-{2}{3}", oddEven, AddressPart.CreateNumeric("prenumber1"), AddressPart.CreateAlpha("alpha1"), AddressPart.CreateAlpha("alpha2"), AddressPart.CreateNumeric("postnumber1"))); }
public override string GetFullText(Connection conn) { TUCLP uclp = TUCLP.Seek(conn, this.uclp); //string filtered = FilterPrefixes(uclp.name, UclpPrefixes); TArea area = TArea.Seek(uclp.area); TRegion region = TRegion.Seek(uclp.area, uclp.region); StringBuilder fullText = new StringBuilder(); //if (area.name != filtered || region.name != filtered) fullText.AppendFormat("Област {0}, Община {1}, ", area.name, region.name); fullText.Append(uclp.name); if (street != 0) { fullText.AppendFormat(", {0}", TStreet.Seek(conn, this.uclp, street).name); } AddressPart[] parts = new AddressPart[] { new AddressPart("No ", adrNo), new AddressPart("Блок ", blockNo), new AddressPart("Подн.", subNo), new AddressPart("Вх.", entrance), new AddressPart("Ет.", floor), new AddressPart("Ап.", apartment) }; foreach (AddressPart part in parts) { if (part.text != "") { fullText.AppendFormat(", {0}{1}", part.prefix, part.text); } } return(fullText.ToString()); }
private static string IncrementAddressFractionals(string low, string high, string oddEven, ref bool stop) { var matchLow = RegexFractional.Match(low); var matchHigh = RegexFractional.Match(high); if (!matchLow.Success || !matchHigh.Success) { return(null); // not handled } stop = true; var prefixHigh = matchHigh.FirstCaptureOrEmpty("prefix"); var numberHigh = matchHigh.FirstCaptureOrEmpty("number"); var suffix1High = matchHigh.FirstCaptureOrEmpty("suffix1"); string pattern; if ((prefixHigh.Length == 0) && (numberHigh.Length == 0) && (suffix1High.Length == 0)) { pattern = "{0}{1}{2}{3}{4}"; } else { pattern = "{0}{1}{2} {3}{4}"; } return(IncrementAddressCommon( matchLow, matchHigh, pattern, oddEven, AddressPart.CreateAlpha("prefix"), AddressPart.CreateNumeric("number"), AddressPart.CreateAlpha("suffix1"), AddressPart.CreateFraction("fraction"), AddressPart.CreateAlpha("suffix2"))); }
public override string GetFullText(Connection conn) { UCLP uclp = UCLP.Seek(conn, this.uclp); //string filtered = FilterPrefixes(uclp.name, UclpPrefixes); Area area = Area.Seek(uclp.area); Region region = Region.Seek(uclp.area, uclp.region); StringBuilder fullText = new StringBuilder(); //if (area.name != filtered || region.name != filtered) fullText.AppendFormat("Îáëàñò {0}, Îáùèíà {1}, ", area.name, region.name); fullText.Append(uclp.name); if (street != 0) { fullText.AppendFormat(", {0}", Street.Seek(conn, this.uclp, street).name); } AddressPart[] parts = new AddressPart[] { new AddressPart("No ", adrNo), new AddressPart("Áëîê ", blockNo), new AddressPart("Ïîäí.", subNo), new AddressPart("Âõ.", entrance), new AddressPart("Åò.", floor), new AddressPart("Àï.", apartment) }; foreach (AddressPart part in parts) { if (part.text != "") { fullText.AppendFormat(", {0}{1}", part.prefix, part.text); } } return(fullText.ToString()); }
public static Extension CreateADExtension(AddressPart part) { AddressPartType v3PartType = (AddressPartType)Enum.Parse(typeof(AddressPartType), part.PartType.ToString()); string wireCode = MARC.Everest.Connectors.Util.ToWireFormat(v3PartType); return(new Extension() { Url = GetExtensionNameUrl("addressPart"), Extension = new List <Extension>() { new Extension() { Url = GetExtensionNameUrl("v3-addressPartTypes"), Value = new Coding(typeof(AddressPartType).GetValueSetDefinition(), wireCode) }, new Extension() { Url = GetExtensionNameUrl("addressPart-value"), Value = new FhirString(part.AddressValue), } } }); }
/// <summary> /// Creates <see cref="T:ESRI.ArcGIS.Geocoding.LocatorInfo"/> instance from the specified /// sub-locator information object. /// </summary> /// <param name="info">The reference to the sub-locator information object.</param> /// <returns>A new <see cref="T:ESRI.ArcGIS.Geocoding.LocatorInfo"/> with the specified /// sub-locator information.</returns> internal static LocatorInfo CreateLocatorInfo(SublocatorInfo info) { Debug.Assert(info != null); var internalFields = new List <AddressPart>(); // Copy field mappings. foreach (InternalFieldMapping fieldsMapping in info.FieldMappings.FieldMapping) { string addressPartName = fieldsMapping.AddressField; AddressPart addressPart = (AddressPart)Enum.Parse(typeof(AddressPart), addressPartName, true); internalFields.Add(addressPart); } var type = (SublocatorType)Enum.Parse(typeof(SublocatorType), info.Type, true); return(new LocatorInfo( info.name, info.title, info.primary, info.enable, type, internalFields)); }
public AddressComponentAttribute(AddressPart addressPart) { this.addressPart = addressPart; }
private AddressViewModel MapAddress(AddressPart addressPart, CustomerPart customer) { var addressViewModel = new AddressViewModel(); if (addressPart != null) { addressViewModel.Name = addressPart.Name; addressViewModel.Address = addressPart.Address; addressViewModel.State = addressPart.State; addressViewModel.Postcode = addressPart.Postcode; addressViewModel.City = addressPart.City; addressViewModel.CountryCode = addressPart.CountryCode; } addressViewModel.CountryCodes = CountryCode.SelectList; return addressViewModel; }
private AddressViewModel MapAddress(AddressPart addressPart) { dynamic address = addressPart; var addressViewModel = new AddressViewModel(); if (addressPart != null) { addressViewModel.Name = address.Name.Value; addressViewModel.AddressLine1 = address.AddressLine1.Value; addressViewModel.AddressLine2 = address.AddressLine2.Value; addressViewModel.Zipcode = address.Zipcode.Value; addressViewModel.City = address.City.Value; addressViewModel.Country = address.Country.Value; } return addressViewModel; }
private void _SetAddressPart(AddressPart addressPart, string value) { switch (addressPart) { case AddressPart.Unit: { Unit = value; break; } case AddressPart.FullAddress: { FullAddress = value; break; } case AddressPart.AddressLine: { AddressLine = value; break; } case AddressPart.Locality1: { Locality1 = value; break; } case AddressPart.Locality2: { Locality2 = value; break; } case AddressPart.Locality3: { Locality3 = value; break; } case AddressPart.CountyPrefecture: { CountyPrefecture = value; break; } case AddressPart.PostalCode1: { PostalCode1 = value; break; } case AddressPart.PostalCode2: { PostalCode2 = value; break; } case AddressPart.StateProvince: { StateProvince = value; break; } case AddressPart.Country: { Country = value; break; } default: throw new NotSupportedException(); } }
public TownPart GetTownForAddress(AddressPart part) { return _mechanics.Value.RightItemsFromConnectors( _mechanics.Value.Connectors(part, "AddressToTown").Slice(0, 1) ).FirstOrDefault().As<TownPart>(); }
/// <summary> /// Fill address parts list from field mappings of internal locators. /// </summary> /// <param name="addressFieldTypes">Address parts list.</param> /// <param name="internalFields">Internal locator fields.</param> private static void _FillByInternalFieldMappings(List<AddressPart> addressFieldTypes, AddressPart[] internalFields) { Debug.Assert(addressFieldTypes != null); Debug.Assert(internalFields != null); foreach (AddressPart field in internalFields) { addressFieldTypes.Add(field); } }
public static String getFromAddress(BingLocationResponse address, AddressPart addressPart) { String part = null; if (null != address) { BingLocationResponse.ResourceSet.Resource.Address a = address.resourceSets[0].resources[0].address; String aline = a.addressLine; switch (addressPart) { case AddressPart.COUNTRY: part = a.countryRegion; break; case AddressPart.STATE: part = a.adminDistrict2; break; case AddressPart.POSTALCODE: part = a.postalCode; break; case AddressPart.CITY: //liefert Prenzlauer Berg part = a.locality; break; case AddressPart.DESTRICT: //liefert Prenzlauer Berg part = a.locality; break; case AddressPart.STREET: if (null != aline) { Regex rx1 = new Regex("\b[0-9]* \b"); MatchCollection matches1 = rx1.Matches(aline); String foundVal = null; foreach (Match match in matches1) { String number = match.Value.Trim(); foundVal = aline.Replace(number, ""); foundVal = foundVal.Trim(); break; } if (null == foundVal) { part = aline; } else { part = foundVal; } } break; case AddressPart.HOUSENUMBER: if (null != aline) { Regex rx2 = new Regex("\b[0-9]* \b"); MatchCollection matches2 = rx2.Matches(aline); foreach (Match match in matches2) { part = match.Value.Trim(); break; } } break; } } return part; }
public TownPart GetTownForAddress(AddressPart part) { return(_mechanics.Value.RightItemsFromConnectors( _mechanics.Value.Connectors(part, "AddressToTown").Slice(0, 1) ).FirstOrDefault().As <TownPart>()); }
public static string AddressRemove(this UrlHelper urlHelper, AddressPart part) { return(urlHelper.Action("Remove", "AddressAdmin", new { id = part.Get <IdentityPart>().Identifier, area = "Orchard.CalendarEvents" })); }
private void _SetAddressPart(AddressPart addressPart, string value) { switch(addressPart) { case AddressPart.Unit: { Unit = value; break; } case AddressPart.FullAddress : { FullAddress = value; break; } case AddressPart.AddressLine : { AddressLine = value; break; } case AddressPart.Locality1 : { Locality1 = value; break; } case AddressPart.Locality2 : { Locality2 = value; break; } case AddressPart.Locality3 : { Locality3 = value; break; } case AddressPart.CountyPrefecture : { CountyPrefecture = value; break; } case AddressPart.PostalCode1 : { PostalCode1 = value; break; } case AddressPart.PostalCode2 : { PostalCode2 = value; break; } case AddressPart.StateProvince : { StateProvince = value; break; } case AddressPart.Country : { Country = value; break; } default: throw new NotSupportedException(); } }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// private string _GetAddressPart(AddressPart addressPart) { string result = string.Empty; switch(addressPart) { case AddressPart.Unit: { result = Unit; break; } case AddressPart.FullAddress : { result = FullAddress; break; } case AddressPart.AddressLine : { result = AddressLine; break; } case AddressPart.Locality1 : { result = Locality1; break; } case AddressPart.Locality2 : { result = Locality2; break; } case AddressPart.Locality3 : { result = Locality3; break; } case AddressPart.CountyPrefecture : { result = CountyPrefecture; break; } case AddressPart.PostalCode1 : { result = PostalCode1; break; } case AddressPart.PostalCode2 : { result = PostalCode2; break; } case AddressPart.StateProvince : { result = StateProvince; break; } case AddressPart.Country : { result = Country; break; } default: throw new NotSupportedException(); } return result; }
/// <summary> /// Returns value of specififed address part. /// </summary> /// <param name="addressPart"></param> /// <returns></returns> public string this[AddressPart addressPart] { get { return _GetAddressPart(addressPart); } set { _SetAddressPart(addressPart, value); } }
/// <summary> /// Convert registration event /// </summary> private static Models.PatientMatch ConvertRegistrationEvent(HealthServiceRecord reg) { var psn = reg.Items1.Where(o => o.hsrSite.roleType == HealthServiceRecordSiteRoleType.SubjectOf).First() as Person; ClientRegistryAdmin.Models.PatientMatch pm = new Models.PatientMatch(); NamePart familyNamePart = null, givenNamePart = null; pm.Status = psn.status.ToString(); pm.VersionId = psn.verId.ToString(); // Name if (psn.name != null && psn.name[0].part != null) { familyNamePart = psn.name[0].part.FirstOrDefault(o => o.type == NamePartType.Family); givenNamePart = psn.name[0].part.FirstOrDefault(o => o.type == NamePartType.Given); if (familyNamePart != null) { pm.FamilyName = familyNamePart.value; } if (givenNamePart != null) { pm.GivenName = givenNamePart.value; } } if (psn.birthTime != null) { pm.DateOfBirth = psn.birthTime.value; } pm.Gender = psn.genderCode; pm.Id = psn.id.ToString(); pm.RegistrationId = reg.id; pm.HealthServiceEvent = reg; pm.OriginalData = psn; pm.OtherIds = new List <KeyValuePair <string, string> >(); foreach (var altid in psn.altId) { pm.OtherIds.Add(new KeyValuePair <string, string>(altid.domain, altid.uid)); } // Address if (psn.addr != null) { AddressPart cityPart = psn.addr[0].part.FirstOrDefault(o => o.type == ClientRegistryAdminService.AddressPartType.City), countyPart = psn.addr[0].part.FirstOrDefault(o => o.type == ClientRegistryAdminService.AddressPartType.County), countryPart = psn.addr[0].part.FirstOrDefault(o => o.type == ClientRegistryAdminService.AddressPartType.Country), statePart = psn.addr[0].part.FirstOrDefault(o => o.type == ClientRegistryAdminService.AddressPartType.State), postalPart = psn.addr[0].part.FirstOrDefault(o => o.type == ClientRegistryAdminService.AddressPartType.PostalCode), censusPart = psn.addr[0].part.FirstOrDefault(o => o.type == ClientRegistryAdminService.AddressPartType.CensusTract), streetPart = psn.addr[0].part.FirstOrDefault(o => o.type == ClientRegistryAdminService.AddressPartType.AddressLine || o.type == ClientRegistryAdminService.AddressPartType.StreetAddressLine); if (cityPart != null) { pm.City = cityPart.value; } if (streetPart != null) { pm.Address = streetPart.value; } if (countyPart != null) { pm.County = countyPart.value; } if (countryPart != null) { pm.Country = countryPart.value; } if (statePart != null) { pm.State = statePart.value; } if (postalPart != null) { pm.PostCode = postalPart.value; } if (censusPart != null) { pm.CensusTract = censusPart.value; } } // Relationships if (psn.Items != null) { var mother = psn.Items.Where(o => o.hsrSite.roleType == HealthServiceRecordSiteRoleType.RepresentitiveOf) .Select(o => o as PersonalRelationship).FirstOrDefault(o => o.kind == "MTH"); if (mother != null) { pm.MothersId = mother.id.ToString(); if (mother.legalName != null && mother.legalName.part != null) { familyNamePart = mother.legalName.part.FirstOrDefault(o => o.type == NamePartType.Family); givenNamePart = mother.legalName.part.FirstOrDefault(o => o.type == NamePartType.Given); } else { familyNamePart = givenNamePart = new NamePart(); } if (familyNamePart != null) { pm.MothersName = familyNamePart.value + ", "; } if (givenNamePart != null) { pm.MothersName += givenNamePart.value; } if (pm.MothersName.EndsWith(", ")) { pm.MothersName = pm.MothersName.Substring(0, pm.MothersName.Length - 2); } } } return(pm); }
public bool LinkAddressToTown(AddressPart part, int townId) { IEnumerable<IContent> result = null; try { result = _mechanics.Value.CreateConnector(part, townId, "AddressToTown", true); if (result.Count()>0) return true; } catch (Exception e) { Logger.Error(e, "Error linking address to town"); } return false; }
public static String getFromAddress(YahooLocationResponse address, AddressPart addressPart) { String part = null; if (null != address && null != address.ResultSet && address.ResultSet.Found>0 && null != address.ResultSet.Results && address.ResultSet.Results.Length>0) { YahooLocationResponse.ResultSetCont.Result a = address.ResultSet.Results[0]; switch (addressPart) { case AddressPart.COUNTRY: part = a.country; break; case AddressPart.STATE: part = a.state; break; case AddressPart.POSTALCODE: part = a.postal; break; case AddressPart.CITY: part = a.city; break; case AddressPart.DESTRICT: part = a.neighborhood; break; case AddressPart.STREET: part = a.street; break; case AddressPart.HOUSENUMBER: part = a.house; break; } } return part; }
public bool PopulateAddressFromViewModel(AddressPart part, ViewModels.AddressEditViewModel viewModel, IUpdateModel updater, string prefix) { var ok = true; // Copy normal fields from view model if (String.IsNullOrWhiteSpace(viewModel.PostalCode)) { updater.AddModelError(prefix + ".PostalCode", T("Please enter a post code.")); ok = false; } else { // Strip any spaces part.PostalCode = viewModel.PostalCode = viewModel.PostalCode.Replace(" ", ""); } part.AddressType = viewModel.AddressType; if (String.IsNullOrWhiteSpace(viewModel.Address1)) { updater.AddModelError(prefix + ".Address1", T("Please enter at least the first line of the street address.")); ok = false; } part.Address1 = viewModel.Address1; part.Address2 = viewModel.Address2; part.Address3 = viewModel.Address3; // Attempt to create inputted country name if (!String.IsNullOrWhiteSpace(viewModel.CountryName)) { try { var country = GetOrCreateCountryByName(viewModel.CountryName); if (country != null) { viewModel.CountryId = country.Id; } } catch (Exception e) { Logger.Error(e, "Couldn't create country"); } } // Attempt to create inputted region name if (!viewModel.CountryId.HasValue) { updater.AddModelError(prefix + ".CountryName", T("Error saving country. Enter a valid country name or select from the list.")); ok = false; } if (viewModel.CountryId.HasValue && !String.IsNullOrWhiteSpace(viewModel.TownName)) { var region = GetOrCreateTownByName(viewModel.CountryId.Value, viewModel.TownName); if (region != null) { viewModel.TownId = region.Id; } } if (!viewModel.TownId.HasValue){ updater.AddModelError(prefix + ".TownName", T("Enter a valid town name or select from the list.")); ok = false; } return ok; }
private CellEditor _GetAddressColumnEditor(AddressPart addressPart) { string keyName = string.Format(ADDRESS_COLUMN_EDITOR_KEY_FORMAT, addressPart.ToString()); CellEditor editor = (CellEditor)App.Current.FindResource(keyName); Debug.Assert(editor != null); return editor; }
/// <summary> /// <para>Returns the specified portion of a full address in format nick!user@host.</para> /// </summary> /// <param name="source"></param> /// <param name="part"></param> /// <exception cref="MalformedAddressException" /> /// <returns></returns> public static String ClipAddress(this String source, AddressPart part) { int index1 = source.IndexOf('!'); int index2 = source.IndexOf('@'); if (index1 > index2) { throw new MalformedAddressException(source, "'!' is located after '@'"); } else if (index1 + 1 == source.Length || index2 + 1 == source.Length) { throw new MalformedAddressException(source, "No identd or host body"); } else if (index1 == 0) { throw new MalformedAddressException(source, "No nick body"); } string identd = source.Substring(index1 + 1, index2 - index1 - 1); if (identd[0] == '~' && identd.Length == 1) { throw new MalformedAddressException(source, "Identd contains only the identd marker (~) and is therefore invalid"); } switch (part) { case AddressPart.HOST: return source.Substring(index2 + 1); case AddressPart.IDENTD: return identd; case AddressPart.NICK: return source.Substring(0, index1); default: throw new Exception("Error in ClipAddress: AddressPart enumeration not handled."); } }
/// <summary> /// Extract locators, which depends mainly on requested addressPart. /// </summary> /// <param name="addressPart">Address part.</param> /// <param name="sublocators">Sublocators.</param> /// <returns>locators, which depends mainly on requested addressPart.</returns> private static List<LocatorInfo> _ExtractLocators(AddressPart addressPart, List<LocatorInfo> sublocators) { Debug.Assert(sublocators != null); List<LocatorInfo> extractedLocators = new List<LocatorInfo>(); // Get locators, which depends mainly on requested addressPart. foreach (LocatorInfo locatorInfo in sublocators) { foreach (AddressPart field in locatorInfo.InternalFields) { if (field == addressPart) { extractedLocators.Add(locatorInfo); break; } } } // REV: method shouldn't affect sublocators param, it is input and it is not evident that this param can be changed. // Remove extracted locators. foreach (LocatorInfo sublocatorInfo in extractedLocators) { sublocators.Remove(sublocatorInfo); } return extractedLocators; }
public bool PopulateAddressFromViewModel(AddressPart part, ViewModels.AddressEditViewModel viewModel, IUpdateModel updater, string prefix) { var ok = true; // Copy normal fields from view model if (String.IsNullOrWhiteSpace(viewModel.PostalCode)) { updater.AddModelError(prefix + ".PostalCode", T("Please enter a post code.")); ok = false; } else { // Strip any spaces part.PostalCode = viewModel.PostalCode = viewModel.PostalCode.Replace(" ", ""); } part.AddressType = viewModel.AddressType; if (String.IsNullOrWhiteSpace(viewModel.Address1)) { updater.AddModelError(prefix + ".Address1", T("Please enter at least the first line of the street address.")); ok = false; } part.Address1 = viewModel.Address1; part.Address2 = viewModel.Address2; part.Address3 = viewModel.Address3; // Attempt to create inputted country name if (!String.IsNullOrWhiteSpace(viewModel.CountryName)) { try { var country = GetOrCreateCountryByName(viewModel.CountryName); if (country != null) { viewModel.CountryId = country.Id; } } catch (Exception e) { Logger.Error(e, "Couldn't create country"); } } // Attempt to create inputted region name if (!viewModel.CountryId.HasValue) { updater.AddModelError(prefix + ".CountryName", T("Error saving country. Enter a valid country name or select from the list.")); ok = false; } if (viewModel.CountryId.HasValue && !String.IsNullOrWhiteSpace(viewModel.TownName)) { var region = GetOrCreateTownByName(viewModel.CountryId.Value, viewModel.TownName); if (region != null) { viewModel.TownId = region.Id; } } if (!viewModel.TownId.HasValue) { updater.AddModelError(prefix + ".TownName", T("Enter a valid town name or select from the list.")); ok = false; } return(ok); }