예제 #1
0
        public static void ValidateLinkedAutoAttendant(IConfigDataProvider session, string autoAttendantName, bool checkEnabled, UMAutoAttendant referringAutoAttendant)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (autoAttendantName == null)
            {
                throw new ArgumentNullException("autoAttendantName");
            }
            if (referringAutoAttendant == null)
            {
                throw new ArgumentNullException("referringAutoAttendant");
            }
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, autoAttendantName),
                new ComparisonFilter(ComparisonOperator.Equal, UMAutoAttendantSchema.UMDialPlan, referringAutoAttendant.UMDialPlan)
            });
            UMAutoAttendant umautoAttendant = null;

            UMAutoAttendant[] array = (UMAutoAttendant[])session.Find <UMAutoAttendant>(filter, referringAutoAttendant.Id.Parent, false, null);
            if (array != null && array.Length == 1)
            {
                umautoAttendant = array[0];
            }
            if (umautoAttendant == null)
            {
                throw new InvalidAutoAttendantException(Strings.InvalidAutoAttendantInDialPlan(autoAttendantName, referringAutoAttendant.UMDialPlan.Name));
            }
            if (checkEnabled && umautoAttendant.Status != StatusEnum.Enabled)
            {
                throw new InvalidAutoAttendantException(Strings.DisabledLinkedAutoAttendant(autoAttendantName, referringAutoAttendant.Id.ToString()));
            }
        }
예제 #2
0
        private IConfigDataProvider CreateSessionForAA()
        {
            IConfigurationSession configurationSession = (IConfigurationSession)base.CreateSession();

            this.AutoAttendant   = (UMAutoAttendant)base.GetDataObject <UMAutoAttendant>(this.UMAutoAttendant, configurationSession, null, new LocalizedString?(Strings.NonExistantAutoAttendant(this.UMAutoAttendant.ToString())), new LocalizedString?(Strings.MultipleAutoAttendantsWithSameId(this.UMAutoAttendant.ToString())));
            configurationSession = (IConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(configurationSession, this.AutoAttendant.OrganizationId, true);
            base.VerifyIsWithinScopes(configurationSession, this.AutoAttendant, true, new DataAccessTask <UMDialPlan> .ADObjectOutOfScopeString(Strings.ScopeErrorOnAutoAttendant));
            this.Identity = (TIdentity)((object)new UMDialPlanIdParameter(this.AutoAttendant.UMDialPlan));
            return(configurationSession);
        }
예제 #3
0
 public static void ValidateDtmfFallbackAA(UMAutoAttendant dataObject, UMDialPlan aaDialPlan, UMAutoAttendant dtmfFallbackAA)
 {
     if (dtmfFallbackAA.Guid.Equals(dataObject.Guid))
     {
         throw new InvalidDtmfFallbackAutoAttendantException(Strings.InvalidDtmfFallbackAutoAttendantSelf(dtmfFallbackAA.Identity.ToString()));
     }
     if (!dtmfFallbackAA.UMDialPlan.ObjectGuid.Equals(aaDialPlan.Guid))
     {
         throw new InvalidDtmfFallbackAutoAttendantException(Strings.InvalidDtmfFallbackAutoAttendantDialPlan(dtmfFallbackAA.Identity.ToString()));
     }
     if (dtmfFallbackAA.SpeechEnabled)
     {
         throw new InvalidDtmfFallbackAutoAttendantException(Strings.InvalidDtmfFallbackAutoAttendant(dtmfFallbackAA.Identity.ToString()));
     }
     if (dataObject.SpeechEnabled && dataObject.Status == StatusEnum.Enabled && dtmfFallbackAA.Status == StatusEnum.Disabled)
     {
         throw new InvalidDtmfFallbackAutoAttendantException(Strings.InvalidDtmfFallbackAutoAttendant_Disabled(dtmfFallbackAA.Identity.ToString()));
     }
 }
예제 #4
0
        public static bool IsFallbackAAInDialPlan(IConfigDataProvider dataSession, UMAutoAttendant dataObject, out ADObjectId targetAA)
        {
            bool result = false;

            targetAA = null;
            IEnumerable <UMAutoAttendant> autoAttendantsInSameDialPlan = ValidationHelper.GetAutoAttendantsInSameDialPlan(dataSession, dataObject, dataObject.UMDialPlan);

            if (autoAttendantsInSameDialPlan == null)
            {
                return(false);
            }
            foreach (UMAutoAttendant umautoAttendant in autoAttendantsInSameDialPlan)
            {
                if (!umautoAttendant.Id.ObjectGuid.Equals(dataObject.Id.ObjectGuid) && umautoAttendant.DTMFFallbackAutoAttendant != null && umautoAttendant.DTMFFallbackAutoAttendant.ObjectGuid.Equals(dataObject.Guid))
                {
                    result   = true;
                    targetAA = umautoAttendant.Id;
                    break;
                }
            }
            return(result);
        }
        public static void OnPostGetObject(DataRow inputRow, DataTable dataTable, DataObjectStore store)
        {
            if (dataTable.Rows.Count == 0 || store == null)
            {
                return;
            }
            DataRow         dataRow         = dataTable.Rows[0];
            UMAutoAttendant umautoAttendant = (UMAutoAttendant)store.GetDataObject("UMAutoAttendant");

            if (umautoAttendant != null)
            {
                UMDialPlan dialPlan = umautoAttendant.GetDialPlan();
                dataRow["ExtensionLength"] = dialPlan.NumberOfDigitsInExtension;
                dataRow["IsTelex"]         = (dialPlan.URIType == UMUriType.TelExtn);
                List <UMAAMenuKeyMapping> value;
                List <UMAAMenuKeyMapping> value2;
                UMAAMenuKeyMapping.CreateMappings((MultiValuedProperty <CustomMenuKeyMapping>)dataRow["BusinessHoursKeyMapping"], (MultiValuedProperty <CustomMenuKeyMapping>)dataRow["AfterHoursKeyMapping"], out value, out value2);
                dataRow["BusinessHoursKeyMapping"] = value;
                dataRow["AfterHoursKeyMapping"]    = value2;
                dataRow["BusinessHoursSchedule"]   = new ScheduleBuilder(new Schedule(umautoAttendant.BusinessHoursSchedule)).GetEntireState();
            }
        }
예제 #6
0
        private static IEnumerable <UMAutoAttendant> GetAutoAttendantsInSameDialPlan(IConfigDataProvider session, UMAutoAttendant autoAttendant, ADObjectId dialPlanId)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (autoAttendant == null)
            {
                throw new ArgumentNullException("autoAttendant");
            }
            if (dialPlanId == null)
            {
                throw new ArgumentNullException("dialPlanId");
            }
            ComparisonFilter filter = new ComparisonFilter(ComparisonOperator.Equal, UMAutoAttendantSchema.UMDialPlan, dialPlanId);
            ADObjectId       parent = autoAttendant.Id.Parent;

            return(session.FindPaged <UMAutoAttendant>(filter, parent, false, null, 0));
        }
예제 #7
0
        private static void CheckLinkWithOtherAAsInDialPlan(IConfigDataProvider dataSession, UMAutoAttendant dataObject)
        {
            IEnumerable <UMAutoAttendant> autoAttendantsInSameDialPlan = ValidationHelper.GetAutoAttendantsInSameDialPlan(dataSession, dataObject, dataObject.UMDialPlan);

            if (autoAttendantsInSameDialPlan == null)
            {
                return;
            }
            foreach (UMAutoAttendant umautoAttendant in autoAttendantsInSameDialPlan)
            {
                if (umautoAttendant != null && !umautoAttendant.Guid.Equals(dataObject.Guid))
                {
                    if (umautoAttendant.DTMFFallbackAutoAttendant != null && umautoAttendant.DTMFFallbackAutoAttendant.ObjectGuid.Equals(dataObject.Guid))
                    {
                        throw new InvalidDtmfFallbackAutoAttendantException(Strings.CannotDisableAutoAttendant(umautoAttendant.Id.ToString()));
                    }
                    if (umautoAttendant.BusinessHoursKeyMapping != null && umautoAttendant.BusinessHoursKeyMapping.Count > 0)
                    {
                        foreach (CustomMenuKeyMapping customMenuKeyMapping in umautoAttendant.BusinessHoursKeyMapping)
                        {
                            if (!string.IsNullOrEmpty(customMenuKeyMapping.AutoAttendantName) && string.Equals(dataObject.Name, customMenuKeyMapping.AutoAttendantName, StringComparison.OrdinalIgnoreCase))
                            {
                                throw new InvalidDtmfFallbackAutoAttendantException(Strings.CannotDisableAutoAttendant_KeyMapping(umautoAttendant.Id.ToString()));
                            }
                        }
                    }
                    if (umautoAttendant.AfterHoursKeyMapping != null && umautoAttendant.AfterHoursKeyMapping.Count > 0)
                    {
                        foreach (CustomMenuKeyMapping customMenuKeyMapping2 in umautoAttendant.AfterHoursKeyMapping)
                        {
                            if (!string.IsNullOrEmpty(customMenuKeyMapping2.AutoAttendantName) && string.Equals(dataObject.Name, customMenuKeyMapping2.AutoAttendantName, StringComparison.OrdinalIgnoreCase))
                            {
                                throw new InvalidDtmfFallbackAutoAttendantException(Strings.CannotDisableAutoAttendant_KeyMapping(umautoAttendant.Id.ToString()));
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
 internal static void ValidateDisabledAA(IConfigDataProvider dataSession, UMDialPlan dialPlanConfig, UMAutoAttendant disabledAutoAttendant)
 {
     if (dialPlanConfig.ContactScope == CallSomeoneScopeEnum.AutoAttendantLink)
     {
         ADObjectId umautoAttendant = dialPlanConfig.UMAutoAttendant;
         if (umautoAttendant != null && umautoAttendant.ObjectGuid.Equals(disabledAutoAttendant.Guid))
         {
             throw new DefaultAutoAttendantInDialPlanException(dialPlanConfig.Id.ToString());
         }
     }
     ValidationHelper.CheckLinkWithOtherAAsInDialPlan(dataSession, disabledAutoAttendant);
 }
예제 #9
0
        internal static void ValidateCustomMenu(LocalizedString setting, IConfigurationSession session, string property, MultiValuedProperty <CustomMenuKeyMapping> customMenu, int numberOfDigitsInExtension, UMAutoAttendant containingAutoAttendant, DataAccessHelper.GetDataObjectDelegate getUniqueObject, out bool serializeAgain)
        {
            serializeAgain = false;
            new List <string>();
            IRecipientSession recipientSessionScopedToOrganization = Utility.GetRecipientSessionScopedToOrganization(containingAutoAttendant.OrganizationId, true);

            foreach (CustomMenuKeyMapping customMenuKeyMapping in customMenu)
            {
                if (!string.IsNullOrEmpty(customMenuKeyMapping.AutoAttendantName))
                {
                    ValidationHelper.ValidateLinkedAutoAttendant(session, customMenuKeyMapping.AutoAttendantName, containingAutoAttendant.Status == StatusEnum.Enabled, containingAutoAttendant);
                }
                string text = Utils.TrimSpaces(customMenuKeyMapping.PromptFileName);
                if (text != null)
                {
                    ValidationHelper.ValidateWavFile(text);
                }
                if (!string.IsNullOrEmpty(customMenuKeyMapping.LeaveVoicemailFor))
                {
                    string legacyDNToUseForLeaveVoicemailFor;
                    ValidationHelper.ValidateMailbox(setting, customMenuKeyMapping.LeaveVoicemailFor, containingAutoAttendant.UMDialPlan, recipientSessionScopedToOrganization, getUniqueObject, out legacyDNToUseForLeaveVoicemailFor);
                    customMenuKeyMapping.LegacyDNToUseForLeaveVoicemailFor = legacyDNToUseForLeaveVoicemailFor;
                    serializeAgain = true;
                }
                if (!string.IsNullOrEmpty(customMenuKeyMapping.TransferToMailbox))
                {
                    string legacyDNToUseForTransferToMailbox;
                    ValidationHelper.ValidateMailbox(setting, customMenuKeyMapping.TransferToMailbox, containingAutoAttendant.UMDialPlan, recipientSessionScopedToOrganization, getUniqueObject, out legacyDNToUseForTransferToMailbox);
                    customMenuKeyMapping.LegacyDNToUseForTransferToMailbox = legacyDNToUseForTransferToMailbox;
                    serializeAgain = true;
                }
            }
            CustomMenuKeyMapping[]           array       = customMenu.ToArray();
            Dictionary <string, int>         dictionary  = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase);
            Dictionary <CustomMenuKey, bool> dictionary2 = new Dictionary <CustomMenuKey, bool>();

            for (int i = 0; i < array.Length; i++)
            {
                CustomMenuKeyMapping customMenuKeyMapping2 = array[i];
                try
                {
                    dictionary.Add(customMenuKeyMapping2.Description, i);
                }
                catch (ArgumentException)
                {
                    throw new InvalidCustomMenuException(Strings.DuplicateMenuName(customMenuKeyMapping2.Description));
                }
                if (!string.IsNullOrEmpty(customMenuKeyMapping2.AsrPhrases) && customMenuKeyMapping2.AsrPhrases.Length > 256)
                {
                    throw new InvalidCustomMenuException(Strings.MaxAsrPhraseLengthExceeded(customMenuKeyMapping2.Description));
                }
                string[] asrPhraseList = customMenuKeyMapping2.AsrPhraseList;
                if (asrPhraseList != null)
                {
                    if (asrPhraseList.Length > 9)
                    {
                        throw new InvalidCustomMenuException(Strings.MaxAsrPhraseCountExceeded(customMenuKeyMapping2.Description));
                    }
                    for (int j = 0; j < asrPhraseList.Length; j++)
                    {
                        if (string.IsNullOrEmpty(asrPhraseList[j]))
                        {
                            throw new InvalidCustomMenuException(Strings.EmptyASRPhrase(customMenuKeyMapping2.Description));
                        }
                        try
                        {
                            dictionary.Add(asrPhraseList[j], -1);
                        }
                        catch (ArgumentException)
                        {
                            if (dictionary[asrPhraseList[j]] != i)
                            {
                                throw new InvalidCustomMenuException(Strings.DuplicateASRPhrase(asrPhraseList[j]));
                            }
                        }
                    }
                }
                try
                {
                    if (customMenuKeyMapping2.MappedKey != CustomMenuKey.NotSpecified)
                    {
                        dictionary2.Add(customMenuKeyMapping2.MappedKey, true);
                    }
                }
                catch (ArgumentException)
                {
                    throw new InvalidCustomMenuException(Strings.DuplicateKeys(customMenuKeyMapping2.Key));
                }
            }
        }
예제 #10
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            UMDialPlan umdialPlan = (UMDialPlan)base.PrepareDataObject();

            if (base.HasErrors)
            {
                return(null);
            }
            if (base.Fields.IsModified("ContactRecipientContainer") && base.Fields.IsModified("ContactAddressList"))
            {
                base.WriteError(new InvalidALParameterException(), ErrorCategory.NotSpecified, null);
                TaskLogger.LogExit();
                return(null);
            }
            if (base.Fields.IsModified("CountryOrRegionCode"))
            {
                if (string.IsNullOrEmpty(this.CountryOrRegionCode))
                {
                    base.WriteError(new InvalidParameterException(Strings.EmptyCountryOrRegionCode), ErrorCategory.InvalidArgument, null);
                }
                else
                {
                    umdialPlan.CountryOrRegionCode = this.CountryOrRegionCode;
                }
            }
            if (base.Fields.IsModified("ContactRecipientContainer"))
            {
                OrganizationalUnitIdParameter contactRecipientContainer = this.ContactRecipientContainer;
                if (contactRecipientContainer != null)
                {
                    bool useConfigNC = this.ConfigurationSession.UseConfigNC;
                    this.ConfigurationSession.UseConfigNC = false;
                    ADConfigurationObject adconfigurationObject = (ADConfigurationObject)base.GetDataObject <ExchangeOrganizationalUnit>(contactRecipientContainer, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.ContactRecipientContainer.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.ContactRecipientContainer.ToString())));
                    this.ConfigurationSession.UseConfigNC = useConfigNC;
                    if (!base.HasErrors)
                    {
                        umdialPlan.ContactAddressList = adconfigurationObject.Id;
                    }
                }
                else
                {
                    umdialPlan.ContactAddressList = null;
                }
            }
            if (base.Fields.IsModified("ContactAddressList"))
            {
                AddressListIdParameter contactAddressList = this.ContactAddressList;
                if (contactAddressList != null)
                {
                    IEnumerable <AddressBookBase> objects = contactAddressList.GetObjects <AddressBookBase>(null, this.ConfigurationSession);
                    using (IEnumerator <AddressBookBase> enumerator = objects.GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            umdialPlan.ContactAddressList = (ADObjectId)enumerator.Current.Identity;
                        }
                        goto IL_19C;
                    }
                }
                umdialPlan.ContactAddressList = null;
            }
IL_19C:
            if (umdialPlan.ContactScope != CallSomeoneScopeEnum.AddressList)
            {
                umdialPlan.ContactAddressList = null;
            }
            if (base.Fields.IsModified("UMAutoAttendant"))
            {
                UMAutoAttendantIdParameter umautoAttendant = this.UMAutoAttendant;
                if (umautoAttendant != null)
                {
                    UMAutoAttendant umautoAttendant2 = (UMAutoAttendant)base.GetDataObject <UMAutoAttendant>(umautoAttendant, this.ConfigurationSession, null, new LocalizedString?(Strings.NonExistantAutoAttendant(umautoAttendant.ToString())), new LocalizedString?(Strings.MultipleAutoAttendantsWithSameId(umautoAttendant.ToString())));
                    if (!base.HasErrors)
                    {
                        umdialPlan.UMAutoAttendant = umautoAttendant2.Id;
                    }
                }
                else
                {
                    umdialPlan.UMAutoAttendant = null;
                }
            }
            TaskLogger.LogExit();
            return(umdialPlan);
        }