示例#1
0
 public void DeleteCalendarItemType(CalendarItemType type)
 {
     if (type != null)
     {
         _calendarItemTypeRepository.DeleteOnSubmit(type);
     }
 }
示例#2
0
        public override void Sync(ItemType item, MailboxSession mailboxSession, ExchangeService exchangeService)
        {
            CalendarItemType calendarItemType = item as CalendarItemType;

            if (calendarItemType == null)
            {
                ItemSynchronizer.Tracer.TraceDebug <CalendarItemSynchronizer, string>((long)this.GetHashCode(), "{0}: Found non-Calendar item in a Calendar folder: {1}. Skipping.", this, item.ItemId.Id);
                return;
            }
            CalendarItem calendarItem = base.FindLocalCopy(calendarItemType.ItemId.Id, mailboxSession) as CalendarItem;

            if (calendarItem == null)
            {
                ItemSynchronizer.Tracer.TraceDebug <CalendarItemSynchronizer, string>((long)this.GetHashCode(), "{0}: Item not found locally {1}.", this, calendarItemType.ItemId.Id);
                this.appointmentTranslator.CreateAppointment(exchangeService, mailboxSession, calendarItemType, this.localFolder);
            }
            else
            {
                try
                {
                    this.appointmentTranslator.UpdateAppointment(exchangeService, mailboxSession, calendarItemType, calendarItem);
                }
                catch (LastOccurrenceDeletionException arg)
                {
                    ItemSynchronizer.Tracer.TraceDebug <CalendarItemSynchronizer, string, LastOccurrenceDeletionException>((long)this.GetHashCode(), "{0}: All occurrences in the series were deleted - {1}, Error - {2}, We will delete the local item.", this, calendarItemType.ItemId.Id, arg);
                    this.localFolder.SelectItemToDelete(calendarItem.Id.ObjectId);
                }
                finally
                {
                    calendarItem.Dispose();
                }
            }
            PerformanceCounters.CalendarItemsSynced.Increment();
        }
        /// <summary>
        /// Log on to a mailbox with a specified user account and check whether the specified calendar item is cancelled or not.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">Password of the user.</param>
        /// <param name="userDomain">Domain of the user.</param>
        /// <param name="folderName">Name of the folder which should be searched for the specified meeting message.</param>
        /// <param name="itemSubject">Subject of the meeting message which should exist.</param>
        /// <returns>If the specified calendar item exists and is canceled, return true, otherwise return false.</returns>
        public bool IsCalendarItemCanceled(string userName, string userPassword, string userDomain, string folderName, string itemSubject)
        {
            // Parse the parent folder name to DistinguishedFolderIdNameType.
            DistinguishedFolderIdNameType parentFolderIdName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), folderName, true);

            // Switch to specified user mailbox.
            bool isSwitched = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site);

            Site.Assert.IsTrue(
                isSwitched,
                string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain));

            // Loop to find the meeting message
            ItemType item = this.LoopToFindItem(parentFolderIdName, itemSubject, Item.CalendarItem);

            if (item != null)
            {
                CalendarItemType calendarItem = item as CalendarItemType;

                // If the IsCancelled property of the item is true, return true
                if (calendarItem.IsCancelled == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        private static SanitizedHtmlString BuildCancelRecurringTable(CalendarItemType type, ExDateTime cancelFromDate)
        {
            SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder = new SanitizingStringBuilder <OwaHtml>("<table class=\"caltm\" cellpadding=\"0\" cellspacing=\"0\">");

            if (type == CalendarItemType.Single)
            {
                throw new ArgumentException("Unhandled calendar item type.");
            }
            bool flag = true;

            if (type == CalendarItemType.Exception || type == CalendarItemType.Occurrence)
            {
                sanitizingStringBuilder.Append("<tr><td class=\"rb\"><input class=\"rb\" type=\"radio\" name=\"delprompt\" checked=\"checked\" id=\"delocc\" value=\"0\" />\n<label class=\"lb\" for=\"delocc\">");
                sanitizingStringBuilder.Append(LocalizedStrings.GetNonEncoded(-673339501));
                sanitizingStringBuilder.Append("</label></td></tr>");
                flag = false;
            }
            sanitizingStringBuilder.Append("<tr><td><input class=\"rb\" type=\"radio\" name=\"delprompt\" ");
            sanitizingStringBuilder.Append(flag ? "checked " : string.Empty);
            sanitizingStringBuilder.Append("id=\"delfwd\" value=\"1\" />\n<label class=\"lb\" for=\"delfwd\">");
            sanitizingStringBuilder.Append(string.Format(LocalizedStrings.GetNonEncoded(-1062918861), string.Empty));
            sanitizingStringBuilder.Append("</label></td>");
            using (SanitizingStringWriter <OwaHtml> sanitizingStringWriter = new SanitizingStringWriter <OwaHtml>())
            {
                CalendarUtilities.RenderDateTimeTable(sanitizingStringWriter, "seldel", cancelFromDate, DateTimeUtilities.GetLocalTime().Year, null, string.Empty, "onSelDelTm(this);", null);
                sanitizingStringBuilder.Append("<td>");
                sanitizingStringBuilder.Append <SanitizedHtmlString>(sanitizingStringWriter.ToSanitizedString <SanitizedHtmlString>());
                sanitizingStringBuilder.Append("</td></tr>");
            }
            sanitizingStringBuilder.Append("<tr><td><input class=\"rb\" type=\"radio\" name=\"delprompt\" id=\"delall\" value=\"2\" />\n<label class=\"lb\" for=\"delall\">");
            sanitizingStringBuilder.Append(LocalizedStrings.GetNonEncoded(1631668395));
            sanitizingStringBuilder.Append("</label></td></tr></table>");
            return(sanitizingStringBuilder.ToSanitizedString <SanitizedHtmlString>());
        }
        // Token: 0x060010F3 RID: 4339 RVA: 0x00046BD0 File Offset: 0x00044DD0
        private SyncCalendarItemType GetTypedItem(PropertyDefinition[] xsoRequiredProperties, object[] itemRow, out ExDateTime itemStart)
        {
            itemStart = ExDateTime.MinValue;
            StoreId          itemId           = null;
            string           uid              = null;
            CalendarItemType calendarItemType = CalendarItemType.Single;
            ExDateTime?      startWallClock   = null;
            ExDateTime?      end              = null;
            ExDateTime?      endWallClock     = null;
            Dictionary <PropertyDefinition, object> dictionary = new Dictionary <PropertyDefinition, object>(itemRow.Length);

            for (int i = 0; i < xsoRequiredProperties.Length; i++)
            {
                if (!(itemRow[i] is PropertyError) && !dictionary.ContainsKey(xsoRequiredProperties[i]))
                {
                    if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.StartTime)
                    {
                        itemStart = (ExDateTime)itemRow[i];
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.StartWallClock)
                    {
                        startWallClock = new ExDateTime?((ExDateTime)itemRow[i]);
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.EndTime)
                    {
                        end = new ExDateTime?((ExDateTime)itemRow[i]);
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.EndWallClock)
                    {
                        endWallClock = new ExDateTime?((ExDateTime)itemRow[i]);
                    }
                    else if (xsoRequiredProperties[i] == ItemSchema.Id)
                    {
                        itemId = (VersionedId)itemRow[i];
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemBaseSchema.CalendarItemType)
                    {
                        calendarItemType = (CalendarItemType)itemRow[i];
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemBaseSchema.GlobalObjectId)
                    {
                        uid = new GlobalObjectId((byte[])itemRow[i]).Uid;
                    }
                    dictionary.Add(xsoRequiredProperties[i], itemRow[i]);
                }
            }
            return(new SyncCalendarItemType
            {
                ItemId = itemId,
                UID = uid,
                CalendarItemType = calendarItemType,
                Start = new ExDateTime?(itemStart),
                StartWallClock = startWallClock,
                End = end,
                EndWallClock = endWallClock,
                RowData = dictionary
            });
        }
示例#6
0
        public async Task <bool> DeleteCalendarItemTypeAsync(CalendarItemType type, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (type != null)
            {
                return(await _calendarItemTypeRepository.DeleteAsync(type, cancellationToken));
            }

            return(false);
        }
        public void MSOXWSMTGS_S05_TC04_MoveMultipleCalendarItems()
        {
            #region Define two calendar items to move
            CalendarItemType calendarItem1 = new CalendarItemType();
            calendarItem1.UID     = Guid.NewGuid().ToString();
            calendarItem1.Subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("MeetingSubject", this.Site));
            CalendarItemType calendarItem2 = new CalendarItemType();
            calendarItem2.UID     = Guid.NewGuid().ToString();
            calendarItem2.Subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("MeetingSubject", this.Site));
            #endregion

            #region Create the two calendar items
            ItemInfoResponseMessageType[] calendars = this.CreateMultipleCalendarItems(Role.Organizer, new ItemType[] { calendarItem1, calendarItem2 }, CalendarItemCreateOrDeleteOperationType.SendToNone);
            Site.Assert.IsNotNull(calendars, "The calendars should be created successfully.");
            Site.Assert.IsTrue(calendars.Length == 2, "There should be only two calendars created.");

            ItemIdType[] calendarIds = new ItemIdType[] { calendars[0].Items.Items[0].ItemId, calendars[1].Items.Items[0].ItemId };
            #endregion

            #region Move the two calendar items to Inbox folder
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            Site.Assert.IsNotNull(
                this.MoveMultipleCalendarItems(Role.Organizer, calendarIds, targetFolderId),
                "The calendars should be moved into the inbox folder successfully.");

            #endregion

            #region Call FindItem to verify the two calendar items are moved to Inbox folder
            Site.Assert.IsNull(
                this.SearchDeletedSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", calendarItem1.UID),
                "The original calendar should not be in organizer's calendar folder after MoveItem operation.");

            Site.Assert.IsNotNull(
                this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.inbox, "IPM.Appointment", calendarItem1.UID),
                "The original calendar should be in organizer's inbox folder after MoveItem operation.");

            Site.Assert.IsNull(
                this.SearchDeletedSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", calendarItem2.UID),
                "The original calendar should not be in organizer's calendar folder after MoveItem operation.");

            Site.Assert.IsNotNull(
                this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.inbox, "IPM.Appointment", calendarItem2.UID),
                "The original calendar should be in organizer's inbox folder after MoveItem operation.");
            #endregion

            #region Clean up organizer's inbox folder.
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.inbox
            });
            #endregion
        }
        /// <summary>
        /// Loop to find the item with the specified subject.
        /// </summary>
        /// <param name="folderName">Name of the specified folder.</param>
        /// <param name="itemSubject">Subject of the specified item.</param>
        /// <param name="itemType">Type of the specified item.</param>
        /// <returns>Item with the specified subject.</returns>
        private ItemType LoopToFindItem(DistinguishedFolderIdNameType folderName, string itemSubject, Item itemType)
        {
            ItemType[] items          = null;
            ItemType   firstFoundItem = null;
            int        sleepTimes     = 0;

            // Get the query sleep delay and times from ptfconfig file.
            int queryDelay = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int queryTimes = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            // Loop to find the item, in case that the sent item has still not been received.
            do
            {
                Thread.Sleep(queryDelay);
                items = this.FindAllItems(folderName);
                sleepTimes++;
            }while (items == null && sleepTimes < queryTimes);

            ItemType type = null;

            switch (itemType)
            {
            case Item.MeetingRequest:
                type = new MeetingRequestMessageType();
                break;

            case Item.MeetingResponse:
                type = new MeetingResponseMessageType();
                break;

            case Item.MeetingCancellation:
                type = new MeetingCancellationMessageType();
                break;

            case Item.CalendarItem:
                type = new CalendarItemType();
                break;
            }

            if (items != null)
            {
                // Find the item with the specified subject and store its ID.
                for (int i = 0; i < items.Length; i++)
                {
                    if (items[i].Subject.Contains(itemSubject) && items[i].GetType().ToString() == type.ToString())
                    {
                        firstFoundItem = items[i];
                        break;
                    }
                }
            }

            return(firstFoundItem);
        }
示例#9
0
        private IList <CalendarItemType> GetModifiedOccurrences(CalendarItemType calendarItem)
        {
            List <ItemIdType> exceptionIds = new List <ItemIdType>();

            foreach (OccurrenceInfoType occurenceInfo in calendarItem.ModifiedOccurrences)
            {
                exceptionIds.Add(occurenceInfo.ItemId);
            }

            return(GetCalendarItems(exceptionIds.ToArray()));
        }
示例#10
0
        public bool Delete(int id, string from, string to, string type, string sickness)
        {
            Employee employee = (from emp in repository.Employees where emp.EmployeeID == id select emp).FirstOrDefault();

            if (employee != null)
            {
                DateTime parseFrom;
                DateTime parseTo;

                if (type != "SickAbsence")
                {
                    return(false);
                }

                CalendarItemType cType = CalendarItemType.SickAbsence;

                try
                {
                    parseFrom = DateTime.ParseExact(from, "dd.MM.yyyy", null);
                    parseTo   = DateTime.ParseExact(to, "dd.MM.yyyy", null);
                }
                catch (SystemException)
                {
                    return(false);
                }

                Sickness sicks = (from sick in employee.Sicknesses
                                  where sick.From == parseFrom &&
                                  sick.To == parseTo &&
                                  sick.SickOf == employee &&
                                  sick.EmployeeID == employee.EmployeeID
                                  select sick).FirstOrDefault();

                CalendarItem item = (from i in employee.CalendarItems
                                     where i.Employee == employee &&
                                     i.EmployeeID == employee.EmployeeID &&
                                     i.From == parseFrom &&
                                     i.To == parseTo &&
                                     i.Type == cType
                                     select i).FirstOrDefault();

                if (sicks != null && item != null)
                {
                    repository.DeleteSick(sicks.SickID);
                    employee.CalendarItems.Remove(item);
                    repository.DeleteCalendarItem(item.CalendarItemID);
                    return(true);
                }
                return(false);
            }
            return(false);
        }
 internal static GlobalObjectId GetGlobalObjectId(CalendarItemType remoteItem)
 {
     if (remoteItem != null && remoteItem.ExtendedProperty != null)
     {
         foreach (ExtendedPropertyType extendedPropertyType in remoteItem.ExtendedProperty)
         {
             if (extendedPropertyType.ExtendedFieldURI != null && extendedPropertyType.Item != null && string.Compare(extendedPropertyType.ExtendedFieldURI.PropertySetId, CalendarItemFields.PSETIDMeeting.ToString(), StringComparison.OrdinalIgnoreCase) == 0 && extendedPropertyType.ExtendedFieldURI.PropertyId == CalendarItemFields.GlobalObjectIdProp.PropertyId && extendedPropertyType.ExtendedFieldURI.PropertyType == CalendarItemFields.GlobalObjectIdProp.PropertyType)
             {
                 return(new GlobalObjectId(Convert.FromBase64String((string)extendedPropertyType.Item)));
             }
         }
     }
     return(null);
 }
示例#12
0
        public bool Create(int id, string from, string to, string type, string sickness)
        {
            Employee employee = (from emp in repository.Employees where emp.EmployeeID == id select emp).FirstOrDefault();

            if (employee != null)
            {
                DateTime parseFromDate;
                DateTime parseToDate;

                if (type != "SickAbsence")
                {
                    return(false);
                }

                CalendarItemType cType = CalendarItemType.SickAbsence;

                try
                {
                    parseFromDate = DateTime.ParseExact(from, "dd.MM.yyyy", null);
                    parseToDate   = DateTime.ParseExact(to, "dd.MM.yyyy", null);
                }
                catch (SystemException)
                {
                    return(false);
                }

                Sickness sick = new Sickness();
                sick.From         = parseFromDate;
                sick.To           = parseToDate;
                sick.EmployeeID   = employee.EmployeeID;
                sick.SicknessType = sickness;

                CalendarItem item = new CalendarItem
                {
                    Employee   = employee,
                    EmployeeID = employee.EmployeeID,
                    From       = parseFromDate,
                    To         = parseToDate,
                    Type       = cType
                };
                employee.CalendarItems.Add(item);
                repository.SaveSick(sick);
                repository.SaveCalendarItem(item);

                return(true);
            }
            return(false);
        }
示例#13
0
        private static SetItemFieldType GetSubjectUpdate(Appointment apt)
        {
            SetItemFieldType subjectUpdate = new SetItemFieldType();

            PathToUnindexedFieldType subjectPath = new PathToUnindexedFieldType();

            subjectPath.FieldURI = UnindexedFieldURIType.itemSubject;

            CalendarItemType subjectData = new CalendarItemType();

            subjectData.Subject = apt.Subject;

            subjectUpdate.Item  = subjectPath;
            subjectUpdate.Item1 = subjectData;
            return(subjectUpdate);
        }
示例#14
0
        private void InsertRecurrenceException(RadScheduler owner, Appointment appointmentToInsert, DateTime exceptionDate)
        {
            Appointment      master          = owner.Appointments.FindByID(appointmentToInsert.RecurrenceParentID);
            int              occurrenceIndex = GetOccurrenceIndex(exceptionDate, master);
            CalendarItemType occurrenceItem  = GetOccurrenceItem(master, occurrenceIndex);

            occurrenceItem.MeetingTimeZone = GetTimeZone(appointmentToInsert.Owner.TimeZoneOffset);

            // Update the occurrence
            ItemChangeType itemUpdates = GetAppointmentChanges(appointmentToInsert);

            itemUpdates.Item = occurrenceItem.ItemId;
            ItemChangeType[] changes = new ItemChangeType[] { itemUpdates };

            UpdateCalendarItem(changes);
        }
示例#15
0
        private void SynchronizeDeletedOccurrences(Appointment apt)
        {
            RecurrenceRule rrule;

            if (!RecurrenceRule.TryParse(apt.RecurrenceRule, out rrule))
            {
                return;
            }

            ItemIdType itemId = new ItemIdType();

            itemId.Id        = apt.Attributes[ExchangeIdAttribute];
            itemId.ChangeKey = apt.Attributes[ExchangeChangeKeyAttribute];
            CalendarItemType calendarItem = GetCalendarItems(new ItemIdType[] { itemId })[0];

            List <DateTime> existingExceptions = new List <DateTime>();

            if (calendarItem.ModifiedOccurrences != null)
            {
                foreach (CalendarItemType modifiedOccurrence in GetModifiedOccurrences(calendarItem))
                {
                    existingExceptions.Add(modifiedOccurrence.OriginalStart);
                }
            }

            if (calendarItem.DeletedOccurrences != null)
            {
                foreach (DeletedOccurrenceInfoType deletedOccurrence in calendarItem.DeletedOccurrences)
                {
                    existingExceptions.Add(deletedOccurrence.Start);
                }
            }

            foreach (DateTime recurrenceException in rrule.Exceptions)
            {
                // Search in ModifiedOccurrences and DeletedOccurrences for this exception.
                if (existingExceptions.Contains(recurrenceException))
                {
                    continue;
                }

                // If it is not found in either, delete the occurrence.
                int occurrenceIndex             = GetOccurrenceIndex(recurrenceException, apt);
                CalendarItemType occurrenceItem = GetOccurrenceItem(apt, occurrenceIndex);
                DeleteItem(occurrenceItem.ItemId);
            }
        }
示例#16
0
        public void MSOXWSMTGS_S03_TC01_CopySingleCalendar()
        {
            #region Define a calendar item to copy
            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID     = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            #endregion

            #region Create the calendar item with CalendarItemCreateOrDeleteOperationType set to SendToNone
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);
            Site.Assert.IsNotNull(item, "Create a calendar item should be successful.");
            ItemIdType calendarId = item.Items.Items[0].ItemId;
            #endregion

            #region Copy the calendar item to Drafts folder
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.drafts;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            ItemInfoResponseMessageType copiedItem = this.CopySingleCalendarItem(Role.Organizer, calendarId, targetFolderId);

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R602");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R602
            this.Site.CaptureRequirementIfIsNotNull(
                copiedItem,
                602,
                @"[In Messages] CopyItemSoapIn: For each item being copied that is not a recurring calendar item, the ItemIds element MUST contain an ItemId child element ([MS-OXWSCORE] section 2.2.4.11).");
            #endregion

            #region Call GetItem operation to verify whether the calendar item is really copied
            CalendarItemType calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.drafts, "IPM.Appointment", calendarItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The calendar item should be in organizer's drafts folder.");

            CalendarItemType calendarInCalendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", calendarItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendarInCalendar, "The calendar item should also be in organizer's calendar folder.");
            #endregion

            #region Clean up organizer's drafts and calendar folders
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.calendar, DistinguishedFolderIdNameType.drafts
            });
            #endregion
        }
        private bool CheckFoundItem(CalendarFolder folder, CalendarItemBase item, MeetingExistenceConsistencyCheckResult result, string itemQueryError)
        {
            bool flag = false;

            if (item != null)
            {
                CalendarItemType calendarItemType  = base.Context.BaseItem.CalendarItemType;
                CalendarItemType calendarItemType2 = item.CalendarItemType;
                if ((calendarItemType == CalendarItemType.Single || calendarItemType == CalendarItemType.RecurringMaster) && (calendarItemType2 == CalendarItemType.Occurrence || calendarItemType2 == CalendarItemType.Exception))
                {
                    result.ItemIsFound = false;
                    string description = string.Format("Item type mismatch. [BaseType|BaseGoid - FoundType|FoundGoid] ({0}|{1} - {2}|{3})", new object[]
                    {
                        calendarItemType,
                        base.Context.BaseItem.GlobalObjectId,
                        calendarItemType2,
                        item.GlobalObjectId
                    });
                    this.FailCheck(result, this.GetInconsistencyFullDescription(description, itemQueryError));
                    flag = true;
                }
                else
                {
                    result.ItemIsFound = true;
                }
            }
            else
            {
                result.ItemIsFound = false;
                if (this.FailOnAbsence)
                {
                    string description2 = string.Format("Could not find the matching meeting in {0}'s calendar.", base.Context.OppositeRole.ToString().ToLower());
                    try
                    {
                        string inconsistencyFullDescription = this.GetInconsistencyFullDescription(description2, itemQueryError);
                        this.FailCheck(result, base.Context.CalendarInstance.GetInconsistency(base.Context, inconsistencyFullDescription));
                    }
                    catch (CalendarVersionStoreNotPopulatedException ex)
                    {
                        this.FailCheck(result, Inconsistency.CreateInstance(base.Context.OppositeRole, string.Format("The Calendar Version Store is not fully populated yet (Wait Time: {0}).", ex.WaitTimeBeforeThrow), CalendarInconsistencyFlag.MissingCvs, base.Context));
                    }
                    flag = true;
                }
            }
            return(!flag);
        }
示例#18
0
        private static SetItemFieldType GetEndUpdate(Appointment apt)
        {
            SetItemFieldType endUpdate = new SetItemFieldType();

            PathToUnindexedFieldType endPath = new PathToUnindexedFieldType();

            endPath.FieldURI = UnindexedFieldURIType.calendarEnd;

            CalendarItemType endData = new CalendarItemType();

            endData.End          = apt.End;
            endData.EndSpecified = true;

            endUpdate.Item  = endPath;
            endUpdate.Item1 = endData;
            return(endUpdate);
        }
示例#19
0
        private static SetItemFieldType GetStartUpdate(Appointment apt)
        {
            SetItemFieldType startUpdate = new SetItemFieldType();

            PathToUnindexedFieldType startPath = new PathToUnindexedFieldType();

            startPath.FieldURI = UnindexedFieldURIType.calendarStart;

            CalendarItemType startData = new CalendarItemType();

            startData.Start          = apt.Start;
            startData.StartSpecified = true;

            startUpdate.Item  = startPath;
            startUpdate.Item1 = startData;
            return(startUpdate);
        }
        public void MSOXWSMTGS_S04_TC01_MoveSingleCalendar()
        {
            #region Define a calendar item to move
            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.UID     = Guid.NewGuid().ToString();
            calendarItem.Subject = this.Subject;
            #endregion

            #region Create the calendar item
            ItemInfoResponseMessageType item = this.CreateSingleCalendarItem(Role.Organizer, calendarItem, CalendarItemCreateOrDeleteOperationType.SendToNone);
            ItemIdType calendarId            = item.Items.Items[0].ItemId;
            #endregion

            #region Move the created calendar item to Inbox folder
            DistinguishedFolderIdType folderId = new DistinguishedFolderIdType();
            folderId.Id = DistinguishedFolderIdNameType.inbox;
            TargetFolderIdType targetFolderId = new TargetFolderIdType();
            targetFolderId.Item = folderId;

            ItemInfoResponseMessageType movedItem = this.MoveSingleCalendarItem(Role.Organizer, calendarId, targetFolderId);

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMTGS_R640");

            // Verify MS-OXWSMTGS requirement: MS-OXWSMTGS_R640
            this.Site.CaptureRequirementIfIsNotNull(
                movedItem,
                640,
                @"[In Messages] MoveItemSoapIn: For each item being moved that is not a recurring calendar item, the ItemIds element MUST contain an ItemId child element ([MS-OXWSCORE] section 2.2.4.11).");
            #endregion

            #region Verify the calendar item is moved to Inbox folder
            CalendarItemType calendar = this.SearchSingleItem(Role.Organizer, DistinguishedFolderIdNameType.inbox, "IPM.Appointment", calendarItem.UID) as CalendarItemType;
            Site.Assert.IsNotNull(calendar, "The calendar item should be moved to Inbox folder.");

            CalendarItemType calendarInCalendar = this.SearchDeletedSingleItem(Role.Organizer, DistinguishedFolderIdNameType.calendar, "IPM.Appointment", calendarItem.UID) as CalendarItemType;
            Site.Assert.IsNull(calendarInCalendar, "The calendar item should not be in the Calendar folder.");
            #endregion

            #region Clean up organizer's inbox folder.
            this.CleanupFoldersByRole(Role.Organizer, new List <DistinguishedFolderIdNameType>()
            {
                DistinguishedFolderIdNameType.inbox
            });
            #endregion
        }
        public string TypeToChar(CalendarItemType type)
        {
            string charType = "";
            switch (type)
            {
                case CalendarItemType.Event:
                    charType = "E";
                    break;
                case CalendarItemType.Task:
                    charType = "T";
                    break;
                case CalendarItemType.DueDate:
                    charType = "D";
                    break;
            }

            return charType;
        }
示例#22
0
        private CalendarItemType GetOccurrenceItem(Appointment master, int index)
        {
            ItemIdType masterItemId = new ItemIdType();

            masterItemId.Id        = master.Attributes[ExchangeIdAttribute];
            masterItemId.ChangeKey = master.Attributes[ExchangeChangeKeyAttribute];

            OccurrenceItemIdType occurrenceItemId = new OccurrenceItemIdType();

            occurrenceItemId.RecurringMasterId = masterItemId.Id;
            occurrenceItemId.InstanceIndex     = index;

            PathToUnindexedFieldType calendarItemTypePath = new PathToUnindexedFieldType();

            calendarItemTypePath.FieldURI = UnindexedFieldURIType.calendarCalendarItemType;

            GetItemType getItemRequest = new GetItemType();

            getItemRequest.ItemShape                      = new ItemResponseShapeType();
            getItemRequest.ItemShape.BaseShape            = DefaultShapeNamesType.IdOnly;
            getItemRequest.ItemShape.AdditionalProperties = new BasePathToElementType[] { calendarItemTypePath };
            getItemRequest.ItemIds = new BaseItemIdType[] { masterItemId, occurrenceItemId };

            GetItemResponseType getItemResponse = Service.GetItem(getItemRequest);

            CalendarItemType occurrenceItem = null;

            foreach (ItemInfoResponseMessageType getItemResponseMessage in getItemResponse.ResponseMessages.Items)
            {
                if (getItemResponseMessage.ResponseClass == ResponseClassType.Success &&
                    getItemResponseMessage.Items.Items != null &&
                    getItemResponseMessage.Items.Items.Length > 0)
                {
                    occurrenceItem = (CalendarItemType)getItemResponseMessage.Items.Items[0];
                }
            }

            if (occurrenceItem == null)
            {
                throw new Exception("Unable to find occurrence");
            }

            return(occurrenceItem);
        }
示例#23
0
        /// <summary>
        /// Inserts the specified appointment.
        /// </summary>
        /// <param name="owner">The owner RadScheduler instance.</param>
        /// <param name="appointmentToInsert">The appointment to insert.</param>
        public override void Insert(RadScheduler owner, Appointment appointmentToInsert)
        {
            CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext;

            if (createExceptionContext != null)
            {
                Debug.Assert(appointmentToInsert.RecurrenceState == RecurrenceState.Exception);
                InsertRecurrenceException(owner, appointmentToInsert, createExceptionContext.RecurrenceExceptionDate);
                return;
            }


            CalendarItemType calendarItem = CreateCalendarItem(owner, appointmentToInsert);

            CreateItemType createItemRequest = new CreateItemType();

            DistinguishedFolderIdType destFolder = new DistinguishedFolderIdType();

            destFolder.Id = DistinguishedFolderIdNameType.calendar;

            EmailAddressType emailAddressType = new EmailAddressType();

            emailAddressType.EmailAddress = this.CalendarNames;

            destFolder.Mailbox = emailAddressType;

            createItemRequest.SavedItemFolderId      = new TargetFolderIdType();
            createItemRequest.SavedItemFolderId.Item = destFolder;


            createItemRequest.SendMeetingInvitations          = CalendarItemCreateOrDeleteOperationType.SendToNone;
            createItemRequest.SendMeetingInvitationsSpecified = true;
            createItemRequest.Items       = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new CalendarItemType[] { calendarItem };

            CreateItemResponseType response        = Service.CreateItem(createItemRequest);
            ResponseMessageType    responseMessage = response.ResponseMessages.Items[0];

            if (responseMessage.ResponseCode != ResponseCodeType.NoError)
            {
                throw new Exception("CreateItem failed with response code " + responseMessage.ResponseCode);
            }
        }
        // Token: 0x0600091E RID: 2334 RVA: 0x0003D7E8 File Offset: 0x0003B9E8
        private static CalendarNotificationType AnalyzeEvent(MailboxData mailboxData, MapiEvent mapiEvent, StoreObject item)
        {
            StoreObjectId defaultCalendarFolderId = mailboxData.DefaultCalendarFolderId;

            if (item == null)
            {
                return(CalendarNotificationType.DeletedUpdate);
            }
            AppointmentStateFlags     valueOrDefault            = item.GetValueOrDefault <AppointmentStateFlags>(CalendarItemBaseSchema.AppointmentState);
            ChangeHighlightProperties changeHighlightProperties = item.GetValueOrDefault <ChangeHighlightProperties>(CalendarItemBaseSchema.ChangeHighlight);
            CalendarItemType          valueOrDefault2           = item.GetValueOrDefault <CalendarItemType>(CalendarItemBaseSchema.CalendarItemType, CalendarItemType.Single);
            ResponseType valueOrDefault3 = item.GetValueOrDefault <ResponseType>(CalendarItemBaseSchema.ResponseType, ResponseType.None);

            if (changeHighlightProperties == ChangeHighlightProperties.None && valueOrDefault2 != CalendarItemType.Single)
            {
                changeHighlightProperties = (ChangeHighlightProperties)(-1);
            }
            return(CalendarChangeProcessor.AnalyzeEvent(mapiEvent, defaultCalendarFolderId, valueOrDefault, changeHighlightProperties, valueOrDefault3));
        }
示例#25
0
        private static SetItemFieldType GetRecurrenceUpdate(Appointment apt)
        {
            SetItemFieldType recurrenceUpdate = new SetItemFieldType();

            PathToUnindexedFieldType recurrencePath = new PathToUnindexedFieldType();

            recurrencePath.FieldURI = UnindexedFieldURIType.calendarRecurrence;

            CalendarItemType recurrenceData = new CalendarItemType();
            RecurrenceRule   rrule;

            RecurrenceRule.TryParse(apt.RecurrenceRule, out rrule);
            if (rrule != null && rrule.Pattern.Frequency != RecurrenceFrequency.Hourly)
            {
                recurrenceData.Recurrence = CreateRecurrence(rrule, apt.Owner);
            }

            recurrenceUpdate.Item  = recurrencePath;
            recurrenceUpdate.Item1 = recurrenceData;
            return(recurrenceUpdate);
        }
示例#26
0
        protected virtual CalendarItemType CreateCalendarItem(RadScheduler owner, Appointment apt)
        {
            CalendarItemType calendarItem = new CalendarItemType();

            calendarItem.Subject        = apt.Subject;
            calendarItem.Start          = apt.Start;
            calendarItem.StartSpecified = true;
            calendarItem.End            = apt.End;
            calendarItem.EndSpecified   = true;

            calendarItem.MeetingTimeZone = GetTimeZone(owner.TimeZoneOffset);

            RecurrenceRule rrule;

            RecurrenceRule.TryParse(apt.RecurrenceRule, out rrule);
            if (rrule != null && rrule.Pattern.Frequency != RecurrenceFrequency.Hourly)
            {
                calendarItem.Recurrence = CreateRecurrence(rrule, owner);
            }

            return(calendarItem);
        }
示例#27
0
        private void ProcessRecurringCalendarItem(Appointment targetAppointment, CalendarItemType calendarItem, RadScheduler owner, ICollection <Appointment> instances)
        {
            targetAppointment.RecurrenceState = RecurrenceState.Master;

            RecurrencePattern pattern = calendarItem.Recurrence.Item.ConvertToRecurrencePattern();

            RecurrenceRange range = calendarItem.Recurrence.Item1.ConvertToRecurrenceRange();

            range.EventDuration = targetAppointment.Duration;
            range.Start         = targetAppointment.Start;

            RecurrenceRule rrule = RecurrenceRule.FromPatternAndRange(pattern, range);

            if (calendarItem.ModifiedOccurrences != null)
            {
                foreach (CalendarItemType modifiedOccurrence in GetModifiedOccurrences(calendarItem))
                {
                    foreach (Appointment aptException in CreateAppointmentsFromCalendarItem(owner, modifiedOccurrence))
                    {
                        aptException.RecurrenceState    = RecurrenceState.Exception;
                        aptException.RecurrenceParentID = calendarItem.ItemId.Id;

                        instances.Add(aptException);
                    }

                    rrule.Exceptions.Add(modifiedOccurrence.OriginalStart);
                }
            }

            if (calendarItem.DeletedOccurrences != null)
            {
                foreach (DeletedOccurrenceInfoType occurenceInfo in calendarItem.DeletedOccurrences)
                {
                    rrule.Exceptions.Add(occurenceInfo.Start);
                }
            }

            targetAppointment.RecurrenceRule = rrule.ToString();
        }
        public void UpdateCalendarsItem_UpdateNotExistingEvent_ShouldThrowException(CalendarItemType type)
        {
            //Arrange
            var actualUpdatedEvent = new Event()
            {
                StartDateTime = new DateTime(2020, 4, 5),
                EndDateTime   = new DateTime(2020, 4, 6)
            };
            var actualItem = new CalendarItemViewModel()
            {
                MetaType = type
            };
            var mockItemRepo  = new Mock <ICalendarItemRepository>();
            var mockEventRepo = new Mock <IEventRepository>();
            var itemDomain    = new CalendarItemDomain(mockItemRepo.Object, _mapper, null, mockEventRepo.Object);

            mockEventRepo.Setup(x => x.UpdateCalendarEvent(actualUpdatedEvent)).Verifiable();

            // Act and Assert
            Assert.Throws <NotFoundException>(() => itemDomain.UpdateCalendarsItem(actualItem));
            mockEventRepo.Verify(item => item.UpdateCalendarEvent(actualUpdatedEvent), Times.Never());
        }
示例#29
0
        protected override void UpdateCalendarItemInternal(ref CalendarItemBase originalCalendarItem)
        {
            ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingResponse.UpdateCalendarItemInternal: GOID={0}", this.GlobalObjectId);
            CalendarItemBase calendarItemBase = originalCalendarItem;
            bool             flag;
            Attendee         attendee = this.FindOrAddAttendee(calendarItemBase, out flag);

            if (attendee == null)
            {
                return;
            }
            if (this.IsAttendeeResponseOutOfDate(attendee))
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingResponse.UpdateCalendarItemInternal: GOID={0}. Old Response, doing nothing", this.GlobalObjectId);
                return;
            }
            attendee.ResponseType = this.ResponseType;
            ExDateTime exDateTime = base.GetValueOrDefault <ExDateTime>(InternalSchema.AttendeeCriticalChangeTime, ExDateTime.MinValue);

            if (exDateTime == ExDateTime.MinValue)
            {
                exDateTime = base.SentTime;
            }
            if (exDateTime != ExDateTime.MinValue)
            {
                attendee.ReplyTime = exDateTime;
            }
            if (!base.IsSeriesMessage)
            {
                CalendarItemType calendarItemType = calendarItemBase.CalendarItemType;
                if (calendarItemType == CalendarItemType.Exception || calendarItemType == CalendarItemType.Occurrence)
                {
                    attendee.RecipientFlags |= RecipientFlags.ExceptionalResponse;
                }
                this.ProcessCounterProposal(calendarItemBase, attendee);
            }
        }
        private void CopyCalendarProperties(CalendarItemBase localItem, CalendarItemType remoteItem)
        {
            ExTimeZone desiredTimeZone  = ExTimeZone.UtcTimeZone;
            ExTimeZone desiredTimeZone2 = ExTimeZone.UtcTimeZone;

            if (remoteItem.StartTimeZone != null)
            {
                AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, string>((long)this.GetHashCode(), "{0}: Converting StartTimeZone - Id: {1}, Name: {2}", this, remoteItem.StartTimeZone.Id, remoteItem.StartTimeZone.Name);
                desiredTimeZone = new TimeZoneDefinitionAdaptor(remoteItem.StartTimeZone).ExTimeZone;
            }
            if (remoteItem.EndTimeZone != null)
            {
                AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, string>((long)this.GetHashCode(), "{0}: Converting EndTimeZone - Id: {1}, Name: {2}", this, remoteItem.EndTimeZone.Id, remoteItem.EndTimeZone.Name);
                desiredTimeZone2 = new TimeZoneDefinitionAdaptor(remoteItem.EndTimeZone).ExTimeZone;
            }
            AppointmentTranslator.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Copying Subject: {1}, Location: {2}, StartTime: {3}, EndTime: {4}", new object[]
            {
                this,
                remoteItem.Subject,
                remoteItem.Location,
                remoteItem.Start,
                remoteItem.End
            });
            localItem.StartTime      = new ExDateTime(desiredTimeZone, this.NormalizeDateToUtc(remoteItem.Start));
            localItem.EndTime        = new ExDateTime(desiredTimeZone2, this.NormalizeDateToUtc(remoteItem.End));
            localItem.Sensitivity    = this.Convert(remoteItem.Sensitivity);
            localItem.FreeBusyStatus = this.Convert(remoteItem.LegacyFreeBusyStatus);
            if (remoteItem.Location != null)
            {
                localItem.Location = remoteItem.Location;
            }
            else
            {
                localItem.Location = string.Empty;
            }
            if (localItem.Sensitivity != Sensitivity.Normal)
            {
                localItem.Subject = ClientStrings.PrivateAppointmentSubject.ToString(this.ClientCulture);
            }
            else if (remoteItem.Subject != null)
            {
                localItem.Subject = remoteItem.Subject;
            }
            else
            {
                localItem.Subject = this.ConvertFreeBusyToTitle(localItem.FreeBusyStatus);
            }
            localItem.Reminder.Disable();
            string     value      = string.Empty;
            BodyFormat bodyFormat = BodyFormat.TextPlain;

            if (remoteItem.Body != null)
            {
                value = remoteItem.Body.Value;
                switch (remoteItem.Body.BodyType1)
                {
                case BodyTypeType.HTML:
                    bodyFormat = BodyFormat.TextHtml;
                    break;

                case BodyTypeType.Text:
                    bodyFormat = BodyFormat.TextPlain;
                    break;

                default:
                    throw new InvalidAppointmentException();
                }
                AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Copying body: {1}", this, remoteItem.Body.Value);
            }
            using (TextWriter textWriter = localItem.Body.OpenTextWriter(bodyFormat))
            {
                textWriter.Write(value);
            }
            AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Copying Id: {1}", this, remoteItem.ItemId.Id);
            localItem[SharingSchema.ExternalSharingMasterId] = remoteItem.ItemId.Id;
        }
 public void UpdateAppointment(ExchangeService exchangeService, MailboxSession session, CalendarItemType remoteItem, CalendarItem localItem)
 {
     AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Updating appointment {1}", this, remoteItem.ItemId.Id);
     this.CopyCalendarProperties(localItem, remoteItem);
     localItem.Recurrence = null;
     if (remoteItem.Recurrence != null)
     {
         localItem.ExTimeZone = localItem.StartTimeZone;
         localItem.Recurrence = this.ConvertRecurrence(localItem.StartTimeZone, localItem.EndTimeZone, remoteItem.Recurrence);
     }
     AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Saving local item {1}", this, remoteItem.ItemId.Id);
     localItem.Save(SaveMode.NoConflictResolution);
     localItem.Load();
     if (remoteItem.Recurrence != null)
     {
         this.CopyExceptions(exchangeService, localItem, remoteItem);
     }
 }
示例#32
0
 public static CalendarItemType CreateCalendarItemType(int calendarItemTypeID)
 {
     CalendarItemType calendarItemType = new CalendarItemType();
     calendarItemType.CalendarItemTypeID = calendarItemTypeID;
     return calendarItemType;
 }
示例#33
0
 public void AddToCalendarItemTypes(CalendarItemType calendarItemType)
 {
     base.AddObject("CalendarItemTypes", calendarItemType);
 }