/// <summary>
        /// Parses the response.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Response object.</returns>
        internal override object ParseResponse(EwsServiceXmlReader reader)
        {
            GetUserAvailabilityResults serviceResponse = new GetUserAvailabilityResults();

            if (this.IsFreeBusyViewRequested)
            {
                serviceResponse.AttendeesAvailability = new ServiceResponseCollection <AttendeeAvailability>();

                reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponseArray);

                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponse))
                    {
                        AttendeeAvailability freeBusyResponse = new AttendeeAvailability();

                        freeBusyResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

                        if (freeBusyResponse.ErrorCode == ServiceError.NoError)
                        {
                            freeBusyResponse.LoadFreeBusyViewFromXml(reader, this.Options.RequestedFreeBusyView);
                        }

                        serviceResponse.AttendeesAvailability.Add(freeBusyResponse);
                    }
                }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponseArray));
            }

            if (this.IsSuggestionsViewRequested)
            {
                serviceResponse.SuggestionsResponse = new SuggestionsResponse();

                reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SuggestionsResponse);

                serviceResponse.SuggestionsResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

                if (serviceResponse.SuggestionsResponse.ErrorCode == ServiceError.NoError)
                {
                    serviceResponse.SuggestionsResponse.LoadSuggestedDaysFromXml(reader);
                }

                reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.SuggestionsResponse);
            }

            return(serviceResponse);
        }
        /// <summary>
        /// Get the Outlook calendars for the queue.
        /// <para>This method fetches the calendars for the current user and the rest of the queue members. Only the day specified is retrieved. The calendars are stored in the communication object until <c>getCal</c> is called again.</para>
        /// </summary>
        /// <param name="start">The <see cref=" DateTime"/> value for the day to fetch the calendars</param>
        /// <returns>True or False depending upon the success of finding the calendar.</returns>
        public bool getCal(DateTime start)
        {
            bool result = false;

            try
            {
                //Set up user list
                List <EWS.AttendeeInfo> whoList = new List <EWS.AttendeeInfo>();
                whoList.Add(new EWS.AttendeeInfo()
                {
                    SmtpAddress  = userName,
                    AttendeeType = EWS.MeetingAttendeeType.Required
                });

                foreach (string who in getTASNames())
                {
                    whoList.Add(new EWS.AttendeeInfo()
                    {
                        SmtpAddress  = who,
                        AttendeeType = EWS.MeetingAttendeeType.Required
                    });
                }

                //fetch availability
                EWS.AvailabilityOptions opt = new EWS.AvailabilityOptions();
                opt.MeetingDuration       = ((QueueDef)queueDefList[queueName]).slotDuration;
                opt.RequestedFreeBusyView = EWS.FreeBusyViewType.FreeBusy;
                EWS.TimeWindow tw = new EWS.TimeWindow(start, start.AddDays(1));
                freeBusy = service.GetUserAvailability(whoList, tw, EWS.AvailabilityData.FreeBusy, opt);
                result   = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                //throw (e);
            }
            return(result);
        }
        /// <summary>
        /// Parses the response.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Response object.</returns>
        internal override object ParseResponse(EwsServiceXmlReader reader)
        {
            GetUserAvailabilityResults serviceResponse = new GetUserAvailabilityResults();

            if (this.IsFreeBusyViewRequested)
            {
                serviceResponse.AttendeesAvailability = new ServiceResponseCollection<AttendeeAvailability>();

                reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponseArray);

                do
                {
                    reader.Read();

                    if (reader.IsStartElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponse))
                    {
                        AttendeeAvailability freeBusyResponse = new AttendeeAvailability();

                        freeBusyResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

                        if (freeBusyResponse.ErrorCode == ServiceError.NoError)
                        {
                            freeBusyResponse.LoadFreeBusyViewFromXml(reader, this.Options.RequestedFreeBusyView); 
                        }

                        serviceResponse.AttendeesAvailability.Add(freeBusyResponse);
                    }
                }
                while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.FreeBusyResponseArray));
            }

            if (this.IsSuggestionsViewRequested)
            {
                serviceResponse.SuggestionsResponse = new SuggestionsResponse();

                reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.SuggestionsResponse);

                serviceResponse.SuggestionsResponse.LoadFromXml(reader, XmlElementNames.ResponseMessage);

                if (serviceResponse.SuggestionsResponse.ErrorCode == ServiceError.NoError)
                {
                    serviceResponse.SuggestionsResponse.LoadSuggestedDaysFromXml(reader);
                }

                reader.ReadEndElement(XmlNamespace.Messages, XmlElementNames.SuggestionsResponse);
            }

            return serviceResponse;
        }