Esempio n. 1
0
 private void LoadChildNodesCollection(IStorePropertyBag[] rows, int startIndex)
 {
     for (int i = startIndex; i < rows.Length; i++)
     {
         IStorePropertyBag storePropertyBag = rows[i];
         if (TaskGroup.IsTaskSection(storePropertyBag) && TaskGroup.IsFolderTreeData(storePropertyBag) && TaskGroup.IsTaskGroupEntry(storePropertyBag))
         {
             byte[] valueOrDefault = storePropertyBag.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
             if (valueOrDefault == null || valueOrDefault.Length != 16)
             {
                 ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found TaskGroupEntry with invalid parent group id. ArrayLength: {0}", (valueOrDefault == null) ? -1 : valueOrDefault.Length);
             }
             else
             {
                 Guid g = new Guid(valueOrDefault);
                 if (this.groupClassId.Equals(g))
                 {
                     TaskGroupEntryInfo taskGroupEntryInfoFromRow = TaskGroupEntry.GetTaskGroupEntryInfoFromRow(storePropertyBag);
                     if (taskGroupEntryInfoFromRow != null)
                     {
                         this.children.Add(taskGroupEntryInfoFromRow);
                     }
                 }
             }
         }
     }
     this.hasLoadedTaskFoldersCollection = true;
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
 protected override void OnBeforeSave()
 {
     base.OnBeforeSave();
     if (base.IsNew)
     {
         if (Guid.Empty.Equals(this.ParentGroupClassId))
         {
             throw new NotSupportedException("A new Task group entry needs to have its ParentGroupClassId set.");
         }
         byte[] nodeBefore = null;
         if (this.parentGroup != null)
         {
             ReadOnlyCollection <TaskGroupEntryInfo> childTaskFolders = this.parentGroup.GetChildTaskFolders();
             if (childTaskFolders.Count > 0)
             {
                 nodeBefore = childTaskFolders[childTaskFolders.Count - 1].Ordinal;
             }
         }
         else
         {
             bool flag;
             nodeBefore = FolderTreeData.GetOrdinalValueOfFirstMatchingNode(base.MailboxSession, TaskGroupEntry.FindLastTaskFolderOrdinalSortOrder, (IStorePropertyBag row) => TaskGroup.IsFolderTreeData(row) && TaskGroup.IsTaskSection(row) && TaskGroup.IsTaskFolderInGroup(row, this.ParentGroupClassId), TaskGroup.TaskInfoProperties, out flag);
         }
         base.SetNodeOrdinalInternal(nodeBefore, null);
     }
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
        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);
        }