public async void ValidatePhoneAsync() { string countryCode = cbCountry.SelectedValue.ToString(); string typedPhoneNumber = txtPhoneInput.Text; if (typedPhoneNumber.Length >= 1 && countryCode.Length >= 1) { PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance(); try { PhoneNumber phonenumberObject = null; await Task.Run(() => { phonenumberObject = phoneUtil.Parse(typedPhoneNumber, countryCode); PhoneNumberOfflineGeocoder geocoder = PhoneNumberOfflineGeocoder.GetInstance(); if (phoneUtil.IsValidNumber(phonenumberObject)) { PhoneNumberEnrichInformatica(phoneUtil.Format(phonenumberObject, PhoneNumberFormat.E164)); } }); } catch (Exception ex) { MessageBox.Show("Exception Occured :" + ex.StackTrace); btnValidate.Text = "Validate"; } } }
public async void ValidatePhoneHtmlAsync() { wbBrowser.DocumentText = "<html></html>";//Directly setting HTML content for first time doesnt work. StringBuilder htmlContent = new StringBuilder("<H3><CENTER>OPEN SOURCE PHONE VALIDATION<CENTER></H3>"); htmlContent.Append("<hr/>"); string countryCode = cbCountry.SelectedValue.ToString(); string typedPhoneNumber = txtPhoneInput.Text; if (typedPhoneNumber.Length >= 1 && countryCode.Length >= 1) { PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance(); try { PhoneNumber phonenumberObject = null; //await Task.Run(() => { phonenumberObject = phoneUtil.Parse(typedPhoneNumber, countryCode); string regionCoundFromPhoneNumber = phoneUtil.GetRegionCodeForCountryCode(phonenumberObject.CountryCode); htmlContent.Append("<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" style=\"font-family:verdana;font-size:12px;border-colapse:none\" width=\"100%\">"); htmlContent.Append($"<tr><td>Typed Phone Number</td><td>{typedPhoneNumber}</td></tr>"); htmlContent.Append($"<tr><td>Is Valid Phone Number</td><td>{regionCoundFromPhoneNumber == countryCode && phoneUtil.IsValidNumber(phonenumberObject)}</td></tr>"); PhoneNumberOfflineGeocoder geocoder = PhoneNumberOfflineGeocoder.GetInstance(); if (regionCoundFromPhoneNumber == countryCode && phoneUtil.IsValidNumber(phonenumberObject)) { htmlContent.Append($"<tr><td>Country Code</td><td>{Convert.ToString(phonenumberObject.CountryCode)}</td></tr>"); htmlContent.Append($"<tr><td>E164 Format </td><td>{phoneUtil.Format(phonenumberObject, PhoneNumberFormat.E164) }</td></tr>"); htmlContent.Append($"<tr><td>Intenational Format</td><td>{phoneUtil.Format(phonenumberObject, PhoneNumberFormat.INTERNATIONAL)}</td></tr>"); htmlContent.Append($"<tr><td>RFC Format </td><td>{phoneUtil.Format(phonenumberObject, PhoneNumberFormat.RFC3966) }</td></tr>"); htmlContent.Append($"<tr><td>National Format</td><td>{phoneUtil.Format(phonenumberObject, PhoneNumberFormat.NATIONAL)}</td></tr>"); htmlContent.Append($"<tr><td>Has CountryCode </td><td>{ Convert.ToString(phonenumberObject.HasCountryCode)}</td></tr>"); htmlContent.Append($"<tr><td>Phone Number Type </td><td>{ phoneUtil.GetNumberType(phonenumberObject)}</td></tr>"); htmlContent.Append($"<tr><td>Phone Location </td><td>{geocoder.GetDescriptionForNumber(phonenumberObject, Locale.ENGLISH)}</td></tr>"); htmlContent.Append("</table>"); WriteToHtmlControl(htmlContent.ToString()); //PhoneNumberEnrichInformaticaHtml(htmlContent, phoneUtil.Format(phonenumberObject, PhoneNumberFormat.E164)); } else { htmlContent.Append("</table>"); WriteToHtmlControl(htmlContent.ToString()); } } catch (NumberParseException ex) { MessageBox.Show("Invalid Phone Number"); } } }
public static void SetupFixture(TestContext context) { PhoneNumberUtil.ResetInstance(); geocoder = new PhoneNumberOfflineGeocoder(TEST_MAPPING_DATA_DIRECTORY); }
public void testInstantiationWithRegularData() { PhoneNumberUtil.ResetInstance(); geocoder = PhoneNumberOfflineGeocoder.GetInstance(); }
public void TestInstantiationWithRegularData() { PhoneNumberUtil.ResetInstance(); geocoder = PhoneNumberOfflineGeocoder.GetInstance(); }
public TestPhoneNumberOfflineGeocoder() { PhoneNumberUtil.ResetInstance(); geocoder = new PhoneNumberOfflineGeocoder(Test_MAPPING_DATA_DIRECTORY); }
public void TestInstantiationWithRegularData() { Assert.NotNull(PhoneNumberOfflineGeocoder.GetInstance()); }