Ejemplo n.º 1
0
        /// <summary>
        /// Create a Request.Attendees instance with required child elements.
        /// </summary>
        /// <param name="attendeeEmailAddress">The attendee email address</param>
        /// <param name="attendeeName">The attendee display name</param>
        /// <returns>The created Request.Attendees instance.</returns>
        internal static Request.Attendees CreateAttendeesRequired(string[] attendeeEmailAddress, string[] attendeeName)
        {
            List <Request.AttendeesAttendee> attendeelist = new List <Request.AttendeesAttendee>();

            for (int i = 0; i < attendeeEmailAddress.Length; i++)
            {
                Request.AttendeesAttendee attendee = new Request.AttendeesAttendee
                {
                    Email                 = attendeeEmailAddress[i],
                    Name                  = attendeeName[i],
                    AttendeeType          = 1,
                    AttendeeTypeSpecified = true
                };
                attendeelist.Add(attendee);
            }

            Request.Attendees attendees = new Request.Attendees
            {
                Attendee = attendeelist.ToArray()
            };

            return(attendees);
        }
        /// <summary>
        /// Create a Request.Attendees instance with required child elements.
        /// </summary>
        /// <param name="attendeeEmailAddress">The attendee email address</param>
        /// <param name="attendeeName">The attendee display name</param>
        /// <returns>The created Request.Attendees instance.</returns>
        internal static Request.Attendees CreateAttendeesRequired(string[] attendeeEmailAddress, string[] attendeeName)
        {
            List<Request.AttendeesAttendee> attendeelist = new List<Request.AttendeesAttendee>();

            for (int i = 0; i < attendeeEmailAddress.Length; i++)
            {
                Request.AttendeesAttendee attendee = new Request.AttendeesAttendee
                {
                    Email = attendeeEmailAddress[i],
                    Name = attendeeName[i],
                    AttendeeType = 1,
                    AttendeeTypeSpecified = true
                };
                attendeelist.Add(attendee);
            }

            Request.Attendees attendees = new Request.Attendees
            {
                Attendee = attendeelist.ToArray()
            };

            return attendees;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a default calendar object in the current login user calendar folder
        /// </summary>
        /// <param name="subject">The calendar subject</param>
        /// <param name="organizerEmailAddress">The organizer email address</param>
        /// <param name="attendeeEmailAddress">The attendee email address</param>
        /// <param name="calendarUID">The uid of calendar</param>
        /// <param name="timestamp">The DtStamp of calendar</param>
        /// <param name="startTime">The StartTime of calendar</param>
        /// <param name="endTime">The EndTime of calendar</param>
        /// <returns>Returns the Calendar instance</returns>
        protected Calendar CreateDefaultCalendar(
            string subject,
            string organizerEmailAddress,
            string attendeeEmailAddress,
            string calendarUID,
            DateTime?timestamp,
            DateTime?startTime,
            DateTime?endTime)
        {
            #region Configure the default calendar application data
            Request.SyncCollectionAdd syncAddCollection = new Request.SyncCollectionAdd();
            string clientId = TestSuiteHelper.GetClientId();
            syncAddCollection.ClientId        = clientId;
            syncAddCollection.ApplicationData = new Request.SyncCollectionAddApplicationData();

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>();

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1"))
            {
                items.Add(true);
                itemsElementName.Add(Request.ItemsChoiceType8.ResponseRequested);
            }
            #region TIME/Subject/Location/UID
            items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == startTime ? DateTime.UtcNow.AddDays(5) : startTime.Value));
            itemsElementName.Add(Request.ItemsChoiceType8.StartTime);

            items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == endTime ? DateTime.UtcNow.AddDays(5).AddMinutes(30) : endTime.Value));
            itemsElementName.Add(Request.ItemsChoiceType8.EndTime);

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") && !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == timestamp ? DateTime.UtcNow.AddDays(5) : timestamp.Value));
                itemsElementName.Add(Request.ItemsChoiceType8.DtStamp);
            }

            items.Add(subject);
            itemsElementName.Add(Request.ItemsChoiceType8.Subject);

            items.Add(calendarUID ?? Guid.NewGuid().ToString());
            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") || Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                itemsElementName.Add(Request.ItemsChoiceType8.ClientUid);
            }
            else
            {
                itemsElementName.Add(Request.ItemsChoiceType8.UID);
            }

            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") || Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                Request.Location location = new Request.Location();
                location.DisplayName = "OFFICE";
                items.Add(location);
                itemsElementName.Add(Request.ItemsChoiceType8.Location);
            }
            else
            {
                items.Add("OFFICE");
                itemsElementName.Add(Request.ItemsChoiceType8.Location1);
            }
            #endregion

            #region Attendee/Organizer
            Request.AttendeesAttendee attendee = new Request.AttendeesAttendee
            {
                Email                 = attendeeEmailAddress,
                Name                  = new MailAddress(attendeeEmailAddress).User,
                AttendeeStatus        = 0x0,
                AttendeeTypeSpecified = true,
                AttendeeType          = 0x1
            };

            // 0x0 = Response unknown

            // 0x1 = Required
            items.Add(new Request.Attendees()
            {
                Attendee = new Request.AttendeesAttendee[] { attendee }
            });
            itemsElementName.Add(Request.ItemsChoiceType8.Attendees);

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") && !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                items.Add(organizerEmailAddress);
                itemsElementName.Add(Request.ItemsChoiceType8.OrganizerEmail);
                items.Add(new MailAddress(organizerEmailAddress).DisplayName);
                itemsElementName.Add(Request.ItemsChoiceType8.OrganizerName);
            }
            #endregion

            #region Sensitivity/BusyStatus/AllDayEvent
            // 0x0 == Normal
            items.Add((byte)0x0);
            itemsElementName.Add(Request.ItemsChoiceType8.Sensitivity);

            // 0x1 == Tentative
            items.Add((byte)0x1);
            itemsElementName.Add(Request.ItemsChoiceType8.BusyStatus);

            // 0x0 not an all-day event
            items.Add((byte)0x0);
            itemsElementName.Add(Request.ItemsChoiceType8.AllDayEvent);
            #endregion

            syncAddCollection.ApplicationData.Items            = items.ToArray();
            syncAddCollection.ApplicationData.ItemsElementName = itemsElementName.ToArray();
            #endregion

            #region Execute the Sync command to upload the calendar
            SyncStore   initSyncResponse      = this.InitializeSync(this.User1Information.CalendarCollectionId);
            SyncRequest uploadCalendarRequest = TestSuiteHelper.CreateSyncAddRequest(initSyncResponse.SyncKey, this.User1Information.CalendarCollectionId, syncAddCollection);
            this.EMAILAdapter.Sync(uploadCalendarRequest);
            #endregion

            #region Get the new added calendar item
            SyncStore getItemResponse = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null);
            Sync      calendarItem    = TestSuiteHelper.GetSyncAddItem(getItemResponse, subject);
            Site.Assert.IsNotNull(calendarItem, "The item with subject {0} should be found in the folder {1}.", subject, FolderType.Calendar.ToString());
            #endregion

            return(calendarItem.Calendar);
        }
        /// <summary>
        /// Create a default calendar object in the current login user calendar folder
        /// </summary>
        /// <param name="subject">The calendar subject</param>
        /// <param name="organizerEmailAddress">The organizer email address</param>
        /// <param name="attendeeEmailAddress">The attendee email address</param>
        /// <param name="calendarUID">The uid of calendar</param>
        /// <param name="timestamp">The DtStamp of calendar</param>
        /// <param name="startTime">The StartTime of calendar</param>
        /// <param name="endTime">The EndTime of calendar</param>
        /// <returns>Returns the Calendar instance</returns>
        protected Calendar CreateDefaultCalendar(
            string subject,
            string organizerEmailAddress,
            string attendeeEmailAddress,
            string calendarUID,
            DateTime? timestamp,
            DateTime? startTime,
            DateTime? endTime)
        {
            #region Configure the default calendar application data
            Request.SyncCollectionAdd syncAddCollection = new Request.SyncCollectionAdd();
            string clientId = TestSuiteHelper.GetClientId();
            syncAddCollection.ClientId = clientId;
            syncAddCollection.ApplicationData = new Request.SyncCollectionAddApplicationData();

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType8> itemsElementName = new List<Request.ItemsChoiceType8>();

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1"))
            {
                items.Add(true);
                itemsElementName.Add(Request.ItemsChoiceType8.ResponseRequested);
            }
            #region TIME/Subject/Location/UID
            items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == startTime ? DateTime.UtcNow.AddDays(5) : startTime.Value));
            itemsElementName.Add(Request.ItemsChoiceType8.StartTime);

            items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == endTime ? DateTime.UtcNow.AddDays(5).AddMinutes(30) : endTime.Value));
            itemsElementName.Add(Request.ItemsChoiceType8.EndTime);

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0"))
            {
                items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == timestamp ? DateTime.UtcNow.AddDays(5) : timestamp.Value));
                itemsElementName.Add(Request.ItemsChoiceType8.DtStamp);
            }

            items.Add(subject);
            itemsElementName.Add(Request.ItemsChoiceType8.Subject);

            items.Add(calendarUID ?? Guid.NewGuid().ToString());
            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0"))
            {
                itemsElementName.Add(Request.ItemsChoiceType8.ClientUid);
            }
            else
            {
                itemsElementName.Add(Request.ItemsChoiceType8.UID);
            }

            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0"))
            {
                Request.Location location = new Request.Location();
                location.DisplayName = "OFFICE";
                items.Add(location);
                itemsElementName.Add(Request.ItemsChoiceType8.Location1);
            }
            else
            {
                items.Add("OFFICE");
                itemsElementName.Add(Request.ItemsChoiceType8.Location);
            }
            #endregion

            #region Attendee/Organizer
            Request.AttendeesAttendee attendee = new Request.AttendeesAttendee
            {
                Email = attendeeEmailAddress,
                Name = new MailAddress(attendeeEmailAddress).User,
                AttendeeStatus = 0x0,
                AttendeeTypeSpecified = true,
                AttendeeType = 0x1
            };

            // 0x0 = Response unknown

            // 0x1 = Required
            items.Add(new Request.Attendees() { Attendee = new Request.AttendeesAttendee[] { attendee } });
            itemsElementName.Add(Request.ItemsChoiceType8.Attendees);

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0"))
            {
                items.Add(organizerEmailAddress);
                itemsElementName.Add(Request.ItemsChoiceType8.OrganizerEmail);
                items.Add(new MailAddress(organizerEmailAddress).DisplayName);
                itemsElementName.Add(Request.ItemsChoiceType8.OrganizerName);
            }
            #endregion

            #region Sensitivity/BusyStatus/AllDayEvent
            // 0x0 == Normal
            items.Add((byte)0x0);
            itemsElementName.Add(Request.ItemsChoiceType8.Sensitivity);

            // 0x1 == Tentative
            items.Add((byte)0x1);
            itemsElementName.Add(Request.ItemsChoiceType8.BusyStatus);

            // 0x0 not an all-day event
            items.Add((byte)0x0);
            itemsElementName.Add(Request.ItemsChoiceType8.AllDayEvent);
            #endregion

            syncAddCollection.ApplicationData.Items = items.ToArray();
            syncAddCollection.ApplicationData.ItemsElementName = itemsElementName.ToArray();
            #endregion

            #region Execute the Sync command to upload the calendar
            SyncStore initSyncResponse = this.InitializeSync(this.User1Information.CalendarCollectionId);
            SyncRequest uploadCalendarRequest = TestSuiteHelper.CreateSyncAddRequest(initSyncResponse.SyncKey, this.User1Information.CalendarCollectionId, syncAddCollection);
            this.EMAILAdapter.Sync(uploadCalendarRequest);
            #endregion

            #region Get the new added calendar item
            SyncStore getItemResponse = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null);
            Sync calendarItem = TestSuiteHelper.GetSyncAddItem(getItemResponse, subject);
            Site.Assert.IsNotNull(calendarItem, "The item with subject {0} should be found in the folder {1}.", subject, FolderType.Calendar.ToString());
            #endregion

            return calendarItem.Calendar;
        }