private static MultiValuedProperty <string> GetTargetUserExtensions(ADUser sourceUser, UMDialPlan targetDialPlan, out string targetUserSipResourceIdentifier) { EumAddress?eumAddress = null; foreach (ProxyAddress proxyAddress in sourceUser.EmailAddresses) { if (proxyAddress.IsPrimaryAddress && proxyAddress.Prefix == ProxyAddressPrefix.UM && EumAddress.IsValidEumAddress(proxyAddress.AddressString)) { eumAddress = new EumAddress?(EumAddress.Parse(proxyAddress.AddressString)); break; } } if (eumAddress == null) { throw new CouldNotGenerateExtensionException(); } MultiValuedProperty <string> multiValuedProperty = new MultiValuedProperty <string>(); UMUriType umuriType = Utils.DetermineNumberType(eumAddress.Value.Extension); if (umuriType != targetDialPlan.URIType) { throw new SourceAndTargetDialPlanURITypeMismatchException(umuriType.ToString(), targetDialPlan.URIType.ToString()); } if (umuriType == UMUriType.TelExtn) { multiValuedProperty.Add(eumAddress.Value.Extension); targetUserSipResourceIdentifier = null; } else { targetUserSipResourceIdentifier = eumAddress.Value.Extension; } foreach (ProxyAddress proxyAddress2 in sourceUser.EmailAddresses) { if (!proxyAddress2.IsPrimaryAddress && proxyAddress2.Prefix == ProxyAddressPrefix.UM && EumAddress.IsValidEumAddress(proxyAddress2.AddressString)) { EumAddress eumAddress2 = EumAddress.Parse(proxyAddress2.AddressString); if (eumAddress2.PhoneContext == eumAddress.Value.PhoneContext) { multiValuedProperty.Add(eumAddress2.Extension); } } } return(multiValuedProperty); }
public static LocalizedException ValidateDialedNumbers(MultiValuedProperty <string> dialedNumbers, UMDialPlan dialPlan) { int numberOfDigitsInExtension = dialPlan.NumberOfDigitsInExtension; UMUriType uritype = dialPlan.URIType; LocalizedException ex = null; foreach (string text in dialedNumbers) { switch (uritype) { case UMUriType.TelExtn: try { ValidationHelper.ValidateExtension(UMAutoAttendantSchema.PilotIdentifierList.ToString(), text, numberOfDigitsInExtension); } catch (InvalidPilotIdentiferException ex2) { ex = ex2; } catch (NumericArgumentLengthInvalidException ex3) { ex = ex3; } break; case UMUriType.E164: if (!Utils.IsUriValid(text, UMUriType.E164)) { ex = new InvalidPilotIdentiferException(Strings.ErrorUMInvalidE164AddressFormat(text)); } break; case UMUriType.SipName: ex = ValidationHelper.ValidateE164Entries(dialPlan, dialedNumbers); break; } if (ex != null) { break; } } return(ex); }