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); }
internal static bool IsTaskGroup(IStorePropertyBag row, Guid groupId) { byte[] valueOrDefault = row.GetValueOrDefault <byte[]>(TaskGroupSchema.GroupClassId, null); return(TaskGroup.IsTaskGroup(row) && Util.CompareByteArray(groupId.ToByteArray(), valueOrDefault)); }
protected override void OnBeforeSave() { base.OnBeforeSave(); if (base.IsNew) { bool flag; byte[] nodeBefore = FolderTreeData.GetOrdinalValueOfFirstMatchingNode(base.MailboxSession, TaskGroup.FindLastGroupOrdinalSortOrder, (IStorePropertyBag row) => TaskGroup.IsFolderTreeData(row) && TaskGroup.IsTaskSection(row) && TaskGroup.IsTaskGroup(row), TaskGroup.TaskInfoProperties, out flag); if (flag && !FolderTreeData.MyFoldersClassId.Equals(this.GroupClassId)) { using (TaskGroup taskGroup = TaskGroup.CreateMyTasksGroup(base.MailboxSession)) { nodeBefore = taskGroup.NodeOrdinal; } } base.SetNodeOrdinalInternal(nodeBefore, null); } }
public static TaskGroup Bind(MailboxSession session, Guid groupClassId) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(groupClassId, "groupClassId"); if (groupClassId.Equals(Guid.Empty)) { throw new ArgumentException("Invalid GroupClassId", "groupClassId"); } TaskGroup taskGroup = null; bool flag = true; bool flag2 = false; TaskGroup result; 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 (flag) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10000); if (propertyBags.Length == 0) { break; } for (int i = 0; i < propertyBags.Length; i++) { IStorePropertyBag storePropertyBag = propertyBags[i]; if (!TaskGroup.IsTaskSection(storePropertyBag)) { flag = false; break; } if (TaskGroup.IsFolderTreeData(storePropertyBag)) { if (!flag2 && TaskGroup.IsTaskGroup(storePropertyBag, groupClassId)) { flag2 = true; VersionedId storeId = (VersionedId)storePropertyBag.TryGetProperty(ItemSchema.Id); taskGroup = TaskGroup.Bind(session, storeId); } if (flag2) { taskGroup.LoadChildNodesCollection(propertyBags, i); break; } } } } if (flag2) { result = taskGroup; } else { result = TaskGroup.CreateMyTasksGroup(session); } } } return(result); }