Example #1
0
        public static TaskGroupInfoList GetTaskGroupsView(MailboxSession session)
        {
            bool flag  = false;
            bool flag2 = true;
            Dictionary <Guid, TaskGroupInfo> guidToGroupMapping       = new Dictionary <Guid, TaskGroupInfo>();
            Dictionary <StoreObjectId, TaskGroupEntryInfo> dictionary = new Dictionary <StoreObjectId, TaskGroupEntryInfo>();
            List <FolderTreeDataInfo> duplicateNodes = new List <FolderTreeDataInfo>();
            Dictionary <TaskGroupType, TaskGroupInfo> defaultGroups = new Dictionary <TaskGroupType, TaskGroupInfo>();
            TaskGroupInfoList taskGroupInfoList = new TaskGroupInfoList(duplicateNodes, defaultGroups, dictionary);

            using (Folder folder = Folder.Bind(session, DefaultFolderType.CommonViews))
            {
                using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.Associated, null, TaskGroup.TaskGroupViewSortOrder, TaskGroup.TaskInfoProperties))
                {
                    queryResult.SeekToCondition(SeekReference.OriginBeginning, TaskGroup.TaskSectionFilter);
                    while (flag2)
                    {
                        IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10000);
                        if (propertyBags.Length == 0)
                        {
                            break;
                        }
                        foreach (IStorePropertyBag storePropertyBag in propertyBags)
                        {
                            if (!TaskGroup.IsTaskSection(storePropertyBag))
                            {
                                flag2 = false;
                                break;
                            }
                            if (TaskGroup.IsFolderTreeData(storePropertyBag))
                            {
                                if (TaskGroup.IsTaskGroup(storePropertyBag))
                                {
                                    if (flag)
                                    {
                                        ExTraceGlobals.StorageTracer.TraceDebug <VersionedId, string>(0L, "Unexpected processing task group out of order. ItemId: {0}, Subject: {1}", (VersionedId)storePropertyBag.TryGetProperty(ItemSchema.Id), storePropertyBag.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty));
                                    }
                                    else
                                    {
                                        TaskGroup.AddGroupToList(storePropertyBag, guidToGroupMapping, taskGroupInfoList);
                                    }
                                }
                                else if (TaskGroup.IsTaskGroupEntry(storePropertyBag))
                                {
                                    flag = true;
                                    TaskGroup.AddTaskFolderToList(storePropertyBag, guidToGroupMapping, dictionary, taskGroupInfoList);
                                }
                            }
                        }
                    }
                }
            }
            return(taskGroupInfoList);
        }
Example #2
0
        private static void AddTaskFolderToList(IStorePropertyBag row, Dictionary <Guid, TaskGroupInfo> guidToGroupMapping, Dictionary <StoreObjectId, TaskGroupEntryInfo> taskFolderIdToGroupEntryMapping, TaskGroupInfoList taskGroups)
        {
            TaskGroupEntryInfo taskGroupEntryInfoFromRow = TaskGroupEntry.GetTaskGroupEntryInfoFromRow(row);

            if (taskGroupEntryInfoFromRow == null)
            {
                return;
            }
            TaskGroupInfo taskGroupInfo;

            if (!guidToGroupMapping.TryGetValue(taskGroupEntryInfoFromRow.ParentGroupClassId, out taskGroupInfo))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string, Guid, VersionedId>(0L, "Found a task group entry with an invalid parent id. TaskFolderName: {0}, ParentId: {1}, ItemId: {2}", taskGroupEntryInfoFromRow.FolderName, taskGroupEntryInfoFromRow.ParentGroupClassId, taskGroupEntryInfoFromRow.Id);
                return;
            }
            TaskGroupEntryInfo taskGroupEntryInfo;

            if (taskFolderIdToGroupEntryMapping.TryGetValue(taskGroupEntryInfoFromRow.TaskFolderId, out taskGroupEntryInfo))
            {
                if (taskGroupEntryInfo.LastModifiedTime.CompareTo(taskGroupEntryInfoFromRow.LastModifiedTime) > 0)
                {
                    taskGroups.DuplicateNodes.Add(taskGroupEntryInfoFromRow);
                    return;
                }
                taskGroups.DuplicateNodes.Add(taskGroupEntryInfo);
                guidToGroupMapping[taskGroupEntryInfo.ParentGroupClassId].TaskFolders.Remove(taskGroupEntryInfo);
                taskFolderIdToGroupEntryMapping[taskGroupEntryInfoFromRow.TaskFolderId] = taskGroupEntryInfoFromRow;
            }
            else
            {
                taskFolderIdToGroupEntryMapping.Add(taskGroupEntryInfoFromRow.TaskFolderId, taskGroupEntryInfoFromRow);
            }
            taskGroupInfo.TaskFolders.Add(taskGroupEntryInfoFromRow);
        }
Example #3
0
        private static void AddGroupToList(IStorePropertyBag row, Dictionary <Guid, TaskGroupInfo> guidToGroupMapping, TaskGroupInfoList taskGroups)
        {
            TaskGroupInfo taskGroupInfoFromRow = TaskGroup.GetTaskGroupInfoFromRow(row);

            if (taskGroupInfoFromRow == null)
            {
                return;
            }
            TaskGroupInfo taskGroupInfo;

            if (guidToGroupMapping.TryGetValue(taskGroupInfoFromRow.GroupClassId, out taskGroupInfo))
            {
                if (taskGroupInfo.LastModifiedTime.CompareTo(taskGroupInfoFromRow.LastModifiedTime) > 0)
                {
                    taskGroups.DuplicateNodes.Add(taskGroupInfoFromRow);
                    return;
                }
                guidToGroupMapping[taskGroupInfoFromRow.GroupClassId] = taskGroupInfoFromRow;
                taskGroups.DuplicateNodes.Add(taskGroupInfo);
                taskGroups.Remove(taskGroupInfo);
                if (taskGroups.DefaultGroups.ContainsKey(taskGroupInfoFromRow.GroupType))
                {
                    taskGroups.DefaultGroups[taskGroupInfoFromRow.GroupType] = taskGroupInfoFromRow;
                }
            }
            else
            {
                guidToGroupMapping.Add(taskGroupInfoFromRow.GroupClassId, taskGroupInfoFromRow);
                if (taskGroupInfoFromRow.GroupType != TaskGroupType.Normal)
                {
                    taskGroups.DefaultGroups.Add(taskGroupInfoFromRow.GroupType, taskGroupInfoFromRow);
                }
            }
            taskGroups.Add(taskGroupInfoFromRow);
        }