public static string GetValidPhoneNumber(string uri) { string result2; if (uri != null && (uri.StartsWith("sip:") || uri.StartsWith("sip:") || uri.StartsWith("tel:"))) { SipUri sipUri = new SipUri(uri); if (sipUri.isValid()) { string userName = sipUri.getUserName(); if (userName != null) { try { string scheme = sipUri.getScheme(); if (scheme != null && scheme.Equals("tel")) { userName = userName.Replace("-", ""); } long result = System.Convert.ToInt64(userName.StartsWith("+") ? userName.Substring(1) : userName); if (result < 1000000000000L) { result2 = userName; return(result2); } } catch (System.FormatException) { } catch (System.Exception e) { UriUtils.LOG.Error(e); } } } sipUri.Dispose(); } else { try { uri = uri.Replace("-", ""); long result = System.Convert.ToInt64(uri.StartsWith("+") ? uri.Substring(1) : uri); if (result < 1000000000000L) { result2 = uri; return(result2); } } catch (System.FormatException) { } catch (System.Exception e) { UriUtils.LOG.Error(e); } } result2 = null; return(result2); }
// very dirty public static String GetValidPhoneNumber(String uri) { if (uri != null && (uri.StartsWith("sip:") || uri.StartsWith("sip:") || uri.StartsWith("tel:"))) { SipUri sipUri = new SipUri(uri); if (sipUri.isValid()) { String userName = sipUri.getUserName(); if (userName != null) { try { String scheme = sipUri.getScheme(); if (scheme != null && scheme.Equals("tel")) { userName = userName.Replace("-", ""); } long result = Convert.ToInt64(userName.StartsWith("+") ? userName.Substring(1) : userName); if (result < UriUtils.MAX_PHONE_NUMBER) { return(userName); } } catch (FormatException) { } catch (Exception e) { LOG.Error(e); } } } sipUri.Dispose(); } else { try { uri = uri.Replace("-", ""); long result = Convert.ToInt64(uri.StartsWith("+") ? uri.Substring(1) : uri); if (result < UriUtils.MAX_PHONE_NUMBER) { return(uri); } } catch (FormatException) { } catch (Exception e) { LOG.Error(e); } } return(null); }
public static string GetUserName(string uri) { string userName = null; if (!string.IsNullOrEmpty(uri)) { SipUri sipUri = new SipUri(uri); if (sipUri.isValid()) { userName = sipUri.getUserName(); } sipUri.Dispose(); } return((userName == null) ? uri : userName); }
public static String GetDisplayName(String uri) { String displayname = null; if (!String.IsNullOrEmpty(uri)) { Contact contact = UriUtils.ServiceManager.ContactService.ContactFind(uri); if (contact != null && (displayname = contact.DisplayName) != null) { return(displayname); } SipUri sipUri = new SipUri(uri); if (sipUri.isValid()) { displayname = sipUri.getUserName(); } sipUri.Dispose(); } return(displayname == null ? uri : displayname); }