Example #1
0
 private void ValidateParameters()
 {
     if (this.CallAnsweringRuleId != null)
     {
         using (UMSubscriber umsubscriber = UMRecipient.Factory.FromADRecipient <UMSubscriber>(this.adUser))
         {
             if (umsubscriber != null)
             {
                 using (IPAAStore ipaastore = PAAStore.Create(umsubscriber))
                 {
                     if (ipaastore.GetAutoAttendant(this.CallAnsweringRuleId.RawRuleGuid.Value, PAAValidationMode.None) == null)
                     {
                         base.WriteError(new CallAnsweringRuleNotFoundException(this.CallAnsweringRuleId.RawRuleGuid.Value.ToString()), ErrorCategory.InvalidArgument, null);
                     }
                     goto IL_99;
                 }
             }
             base.WriteError(new UserNotUmEnabledException(this.adUser.Id.ToString()), (ErrorCategory)1000, null);
             IL_99:;
         }
     }
 }
        public void Save()
        {
            string text = (string)base.GetParameter("Name");

            if (!string.IsNullOrEmpty(text))
            {
                text = text.Trim();
            }
            if (string.IsNullOrEmpty(text))
            {
                base.RenderPartialFailure(-1816947001);
                return;
            }
            if (text.Length > 256)
            {
                text = text.Substring(0, 256);
            }
            string text2 = (string)base.GetParameter("Id");

            using (IPAAStore ipaastore = PAAStore.Create(base.UserContext.ExchangePrincipal))
            {
                IList <PersonalAutoAttendant> list = null;
                ipaastore.TryGetAutoAttendants(PAAValidationMode.None, out list);
                if (list.Count >= 9 && string.IsNullOrEmpty(text2))
                {
                    base.RenderPartialFailure(1125061902);
                }
                else
                {
                    PersonalAutoAttendant personalAutoAttendant = PersonalAutoAttendant.CreateNew();
                    personalAutoAttendant.Name = text;
                    string[] array = (string[])base.GetParameter("Ext");
                    if (array != null)
                    {
                        foreach (string item in array)
                        {
                            personalAutoAttendant.ExtensionList.Add(item);
                        }
                    }
                    if (base.IsParameterSet("SchS"))
                    {
                        int freeBusy = (int)base.GetParameter("SchS");
                        personalAutoAttendant.FreeBusy = (FreeBusyStatusEnum)freeBusy;
                    }
                    this.AddDuration(personalAutoAttendant);
                    this.AddCallerId(personalAutoAttendant);
                    if (base.GetParameter("OOF") != null)
                    {
                        personalAutoAttendant.OutOfOffice = OutOfOfficeStatusEnum.Oof;
                    }
                    this.AddFindMe(personalAutoAttendant);
                    this.AddTransferTo(personalAutoAttendant);
                    if (base.GetParameter("RecVM") == null)
                    {
                        personalAutoAttendant.KeyMappingList.Remove(10);
                    }
                    personalAutoAttendant.EnableBargeIn = (bool)base.GetParameter("Intrpt");
                    personalAutoAttendant.Enabled       = true;
                    if (string.IsNullOrEmpty(text2))
                    {
                        list.Add(personalAutoAttendant);
                    }
                    else
                    {
                        Guid identity = new Guid(Convert.FromBase64String(text2));
                        personalAutoAttendant.Identity = identity;
                        PersonalAutoAttendant autoAttendant = ipaastore.GetAutoAttendant(identity, PAAValidationMode.None);
                        int index = list.Count;
                        if (autoAttendant != null)
                        {
                            index = list.IndexOf(autoAttendant);
                            list.RemoveAt(index);
                        }
                        list.Insert(index, personalAutoAttendant);
                    }
                    if (base.IsParameterSet("SvO"))
                    {
                        this.Writer.Write("<div id=paaId>");
                        Utilities.HtmlEncode(Convert.ToBase64String(personalAutoAttendant.Identity.ToByteArray()), this.Writer);
                        this.Writer.Write("</div>");
                    }
                    ipaastore.Save(list);
                }
            }
        }