Exemplo n.º 1
0
 private UMAAMenuKeyMapping(CustomMenuKeyMapping keymapping, Dictionary <string, ADRecipient> legacyToRecipient)
 {
     this.Prompt = keymapping.Description;
     this.Key    = keymapping.Key;
     this.ActionPromptFileName = keymapping.PromptFileName;
     this.TransferToExtension  = string.Empty;
     if (!string.IsNullOrEmpty(keymapping.Extension))
     {
         this.ActionType          = UMAAMenuActionTypeEnum.TransferToExtension;
         this.TransferToExtension = keymapping.Extension;
         this.ActionSummary       = Strings.UMKeyMappingActionSummaryTransferToExtension(keymapping.Extension);
         return;
     }
     if (!string.IsNullOrEmpty(keymapping.AutoAttendantName))
     {
         this.TransferToAutoAttendant = new Identity(keymapping.AutoAttendantName, keymapping.AutoAttendantName);
         this.ActionType    = UMAAMenuActionTypeEnum.TransferToAutoAttendant;
         this.ActionSummary = Strings.UMKeyMappingActionSummaryTransferToAA(keymapping.AutoAttendantName);
         return;
     }
     if (!string.IsNullOrEmpty(keymapping.LegacyDNToUseForLeaveVoicemailFor))
     {
         this.ActionType = UMAAMenuActionTypeEnum.LeaveVoicemailFor;
         ADRecipient adrecipient;
         if (legacyToRecipient.TryGetValue(keymapping.LegacyDNToUseForLeaveVoicemailFor, out adrecipient))
         {
             this.LeaveVoicemailForUser = new Identity(adrecipient.Id, adrecipient.DisplayName);
             this.ActionSummary         = Strings.UMKeyMappingActionSummaryLeaveVM(adrecipient.DisplayName);
             return;
         }
         this.LeaveVoicemailForUser = new Identity(keymapping.LegacyDNToUseForLeaveVoicemailFor, keymapping.LegacyDNToUseForLeaveVoicemailFor);
         this.ActionSummary         = Strings.UMKeyMappingActionSummaryLeaveVM(keymapping.LegacyDNToUseForLeaveVoicemailFor);
         return;
     }
     else
     {
         if (!string.IsNullOrEmpty(keymapping.AnnounceBusinessLocation))
         {
             this.ActionType    = UMAAMenuActionTypeEnum.AnnounceBusinessLocation;
             this.ActionSummary = Strings.UMKeyMappingActionSummaryAnnounceBusinessLocation;
             return;
         }
         if (!string.IsNullOrEmpty(keymapping.AnnounceBusinessHours))
         {
             this.ActionType    = UMAAMenuActionTypeEnum.AnnounceBusinessHours;
             this.ActionSummary = Strings.UMKeyMappingActionSummaryAnnounceBusinessHours;
             return;
         }
         this.ActionType    = UMAAMenuActionTypeEnum.None;
         this.ActionSummary = string.Empty;
         return;
     }
 }
Exemplo n.º 2
0
 private void Write3_CustomMenuKeyMapping(string n, string ns, CustomMenuKeyMapping o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
         return;
     }
     if (!needType)
     {
         Type type = o.GetType();
         if (!(type == typeof(CustomMenuKeyMapping)))
         {
             throw base.CreateUnknownTypeException(o);
         }
     }
     base.WriteStartElement(n, ns, o, false, null);
     if (needType)
     {
         base.WriteXsiType("CustomMenuKeyMapping", string.Empty);
     }
     base.WriteElementString("MappedKey", string.Empty, this.Write1_CustomMenuKey(o.MappedKey));
     base.WriteElementString("Description", string.Empty, o.Description);
     base.WriteElementString("Extension", string.Empty, o.Extension);
     base.WriteElementString("AutoAttendantName", string.Empty, o.AutoAttendantName);
     base.WriteElementString("LeaveVoicemailFor", string.Empty, o.LeaveVoicemailFor);
     base.WriteElementString("LegacyDNToUseForLeaveVoicemailFor", string.Empty, o.LegacyDNToUseForLeaveVoicemailFor);
     base.WriteElementString("TransferToMailbox", string.Empty, o.TransferToMailbox);
     base.WriteElementString("LegacyDNToUseForTransferToMailbox", string.Empty, o.LegacyDNToUseForTransferToMailbox);
     base.WriteElementString("PromptFileName", string.Empty, o.PromptFileName);
     base.WriteElementString("AsrPhrases", string.Empty, o.AsrPhrases);
     base.WriteElementString("AnnounceBusinessLocation", string.Empty, o.AnnounceBusinessLocation);
     base.WriteElementString("AnnounceBusinessHours", string.Empty, o.AnnounceBusinessHours);
     base.WriteEndElement(o);
 }
Exemplo n.º 3
0
        protected static object GetSingleProperty(object prop, Type type)
        {
            if (prop == null)
            {
                return(null);
            }
            object obj = null;

            if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                obj = MockObjectCreator.GetSingleProperty(prop, type.GetGenericArguments()[0]);
            }
            else if (type == typeof(ADObjectId) && prop is PSObject)
            {
                obj = new ADObjectId(((PSObject)prop).Members["DistinguishedName"].Value.ToString(), new Guid(((PSObject)prop).Members["ObjectGuid"].Value.ToString()));
            }
            else if (type == typeof(EnhancedTimeSpan))
            {
                obj = EnhancedTimeSpan.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <EnhancedTimeSpan>))
            {
                obj = Unlimited <EnhancedTimeSpan> .Parse(prop.ToString());
            }
            else if (type == typeof(ByteQuantifiedSize))
            {
                obj = ByteQuantifiedSize.Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <ByteQuantifiedSize>))
            {
                obj = Unlimited <ByteQuantifiedSize> .Parse(prop.ToString());
            }
            else if (type == typeof(Unlimited <int>))
            {
                obj = Unlimited <int> .Parse(prop.ToString());
            }
            else if (type == typeof(ProxyAddress))
            {
                obj = ProxyAddress.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpAddress))
            {
                obj = new SmtpAddress(prop.ToString());
            }
            else if (type == typeof(SmtpDomain))
            {
                obj = SmtpDomain.Parse(prop.ToString());
            }
            else if (type == typeof(CountryInfo))
            {
                obj = CountryInfo.Parse(prop.ToString());
            }
            else if (type == typeof(SharingPolicyDomain))
            {
                obj = SharingPolicyDomain.Parse(prop.ToString());
            }
            else if (type == typeof(ApprovedApplication))
            {
                obj = ApprovedApplication.Parse(prop.ToString());
            }
            else if (type == typeof(SmtpDomainWithSubdomains))
            {
                obj = SmtpDomainWithSubdomains.Parse(prop.ToString());
            }
            else if (type == typeof(UMLanguage))
            {
                obj = UMLanguage.Parse(prop.ToString());
            }
            else if (type == typeof(UMSmartHost))
            {
                obj = UMSmartHost.Parse(prop.ToString());
            }
            else if (type == typeof(ScheduleInterval))
            {
                obj = ScheduleInterval.Parse(prop.ToString());
            }
            else if (type == typeof(NumberFormat))
            {
                obj = NumberFormat.Parse(prop.ToString());
            }
            else if (type == typeof(DialGroupEntry))
            {
                obj = DialGroupEntry.Parse(prop.ToString());
            }
            else if (type == typeof(CustomMenuKeyMapping))
            {
                obj = CustomMenuKeyMapping.Parse(prop.ToString());
            }
            else if (type == typeof(HolidaySchedule))
            {
                obj = HolidaySchedule.Parse(prop.ToString());
            }
            else if (type == typeof(UMTimeZone))
            {
                obj = UMTimeZone.Parse(prop.ToString());
            }
            else if (type == typeof(ServerVersion))
            {
                obj = ServerVersion.ParseFromSerialNumber(prop.ToString());
            }
            else if (type == typeof(X509Certificate2))
            {
                obj = new X509Certificate2(((PSObject)prop).Members["RawData"].Value as byte[]);
            }
            else if (type == typeof(LocalizedString))
            {
                obj = new LocalizedString(prop.ToString());
            }
            else if (type == typeof(ExchangeObjectVersion))
            {
                obj = ExchangeObjectVersion.Parse(prop.ToString());
            }
            else if (type == typeof(bool))
            {
                obj = bool.Parse(prop.ToString());
            }
            else if (type == typeof(SecurityPrincipalIdParameter))
            {
                obj = new SecurityPrincipalIdParameter(prop.ToString());
            }
            else if (type == typeof(ActiveDirectoryAccessRule))
            {
                obj = (prop as ActiveDirectoryAccessRule);
            }
            else if (type == typeof(ObjectId))
            {
                string text = prop.ToString();
                if (!ADObjectId.IsValidDistinguishedName(text) && text.Contains("/"))
                {
                    text = MockObjectCreator.ConvertDNFromTreeStructure(text);
                }
                obj = new ADObjectId(text);
            }
            else if (type.IsEnum)
            {
                try
                {
                    obj = Enum.Parse(type, prop.ToString());
                }
                catch (ArgumentException)
                {
                    obj = Enum.GetValues(type).GetValue(0);
                }
            }
            return(obj ?? prop);
        }
Exemplo n.º 4
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));
                }
            }
        }
        private CustomMenuKeyMapping Read3_CustomMenuKeyMapping(bool isNullable, bool checkType)
        {
            XmlQualifiedName xmlQualifiedName = checkType ? base.GetXsiType() : null;
            bool             flag             = false;

            if (isNullable)
            {
                flag = base.ReadNull();
            }
            if (checkType && !(xmlQualifiedName == null) && (xmlQualifiedName.Name != this.id14_CustomMenuKeyMapping || xmlQualifiedName.Namespace != this.id2_Item))
            {
                throw base.CreateUnknownTypeException(xmlQualifiedName);
            }
            if (flag)
            {
                return(null);
            }
            CustomMenuKeyMapping customMenuKeyMapping = new CustomMenuKeyMapping();

            bool[] array = new bool[12];
            while (base.Reader.MoveToNextAttribute())
            {
                if (!base.IsXmlnsAttribute(base.Reader.Name))
                {
                    base.UnknownNode(customMenuKeyMapping);
                }
            }
            base.Reader.MoveToElement();
            if (base.Reader.IsEmptyElement)
            {
                base.Reader.Skip();
                return(customMenuKeyMapping);
            }
            base.Reader.ReadStartElement();
            base.Reader.MoveToContent();
            int num         = 0;
            int readerCount = base.ReaderCount;

            while (base.Reader.NodeType != XmlNodeType.EndElement && base.Reader.NodeType != XmlNodeType.None)
            {
                if (base.Reader.NodeType == XmlNodeType.Element)
                {
                    if (!array[0] && base.Reader.LocalName == this.id15_MappedKey && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.MappedKey = this.Read1_CustomMenuKey(base.Reader.ReadElementString());
                        array[0] = true;
                    }
                    else if (!array[1] && base.Reader.LocalName == this.id16_Description && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.Description = base.Reader.ReadElementString();
                        array[1] = true;
                    }
                    else if (!array[2] && base.Reader.LocalName == this.id17_Extension && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.Extension = base.Reader.ReadElementString();
                        array[2] = true;
                    }
                    else if (!array[3] && base.Reader.LocalName == this.id18_AutoAttendantName && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.AutoAttendantName = base.Reader.ReadElementString();
                        array[3] = true;
                    }
                    else if (!array[4] && base.Reader.LocalName == this.id19_LeaveVoicemailFor && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.LeaveVoicemailFor = base.Reader.ReadElementString();
                        array[4] = true;
                    }
                    else if (!array[5] && base.Reader.LocalName == this.id20_Item && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.LegacyDNToUseForLeaveVoicemailFor = base.Reader.ReadElementString();
                        array[5] = true;
                    }
                    else if (!array[6] && base.Reader.LocalName == this.id21_TransferToMailbox && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.TransferToMailbox = base.Reader.ReadElementString();
                        array[6] = true;
                    }
                    else if (!array[7] && base.Reader.LocalName == this.id22_Item && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.LegacyDNToUseForTransferToMailbox = base.Reader.ReadElementString();
                        array[7] = true;
                    }
                    else if (!array[8] && base.Reader.LocalName == this.id23_PromptFileName && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.PromptFileName = base.Reader.ReadElementString();
                        array[8] = true;
                    }
                    else if (!array[9] && base.Reader.LocalName == this.id24_AsrPhrases && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.AsrPhrases = base.Reader.ReadElementString();
                        array[9] = true;
                    }
                    else if (!array[10] && base.Reader.LocalName == this.id25_AnnounceBusinessLocation && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.AnnounceBusinessLocation = base.Reader.ReadElementString();
                        array[10] = true;
                    }
                    else if (!array[11] && base.Reader.LocalName == this.id26_AnnounceBusinessHours && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        customMenuKeyMapping.AnnounceBusinessHours = base.Reader.ReadElementString();
                        array[11] = true;
                    }
                    else
                    {
                        base.UnknownNode(customMenuKeyMapping, ":MappedKey, :Description, :Extension, :AutoAttendantName, :LeaveVoicemailFor, :LegacyDNToUseForLeaveVoicemailFor, :TransferToMailbox, :LegacyDNToUseForTransferToMailbox, :PromptFileName, :AsrPhrases, :AnnounceBusinessLocation, :AnnounceBusinessHours");
                    }
                }
                else
                {
                    base.UnknownNode(customMenuKeyMapping, ":MappedKey, :Description, :Extension, :AutoAttendantName, :LeaveVoicemailFor, :LegacyDNToUseForLeaveVoicemailFor, :TransferToMailbox, :LegacyDNToUseForTransferToMailbox, :PromptFileName, :AsrPhrases, :AnnounceBusinessLocation, :AnnounceBusinessHours");
                }
                base.Reader.MoveToContent();
                base.CheckReaderCount(ref num, ref readerCount);
            }
            base.ReadEndElement();
            return(customMenuKeyMapping);
        }