Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        private static TaskGroup CreateMyTasksGroup(MailboxSession session)
        {
            TaskGroup taskGroup  = TaskGroup.InternalCreateDefaultGroup(session);
            bool      flag       = TaskGroup.AddDefaultTaskFolder(session, taskGroup, DefaultFolderType.ToDoSearch, ClientStrings.ToDoSearch.ToString(session.InternalCulture));
            string    folderType = DefaultFolderType.ToDoSearch.ToString();

            if (flag)
            {
                flag       = TaskGroup.AddDefaultTaskFolder(session, taskGroup, DefaultFolderType.Tasks, ClientStrings.Tasks.ToString(session.InternalCulture));
                folderType = DefaultFolderType.Tasks.ToString();
            }
            if (!flag)
            {
                AggregateOperationResult aggregateOperationResult = session.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                {
                    taskGroup.Id
                });
                if (aggregateOperationResult.OperationResult != OperationResult.Succeeded)
                {
                    ExTraceGlobals.StorageTracer.TraceWarning <SmtpAddress>(0L, "Unable to delete default task group after failing to add the default task folder to it. User: {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress);
                }
                throw new DefaultTaskNodeCreationException(folderType);
            }
            return(taskGroup);
        }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
        public static TaskGroup Create(MailboxSession session)
        {
            Util.ThrowOnNullArgument(session, "session");
            TaskGroup taskGroup = ItemBuilder.CreateNewItem <TaskGroup>(session, session.GetDefaultFolderId(DefaultFolderType.CommonViews), ItemCreateInfo.TaskGroupInfo, CreateMessageType.Associated);

            taskGroup.MailboxSession = session;
            return(taskGroup);
        }
Ejemplo n.º 5
0
        public static TaskGroup Bind(MailboxSession session, StoreId storeId, ICollection <PropertyDefinition> propsToReturn)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(storeId, "storeId");
            TaskGroup taskGroup = ItemBuilder.ItemBind <TaskGroup>(session, storeId, TaskGroupSchema.Instance, propsToReturn);

            taskGroup.MailboxSession = session;
            return(taskGroup);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        private static bool AddDefaultTaskFolder(MailboxSession session, TaskGroup taskGroup, DefaultFolderType folderType, string folderName)
        {
            bool result = true;

            using (TaskGroupEntry taskGroupEntry = TaskGroupEntry.Create(session, session.GetDefaultFolderId(folderType), FolderTreeData.MyFoldersClassId, taskGroup.GroupName))
            {
                taskGroupEntry.FolderName = folderName;
                ConflictResolutionResult conflictResolutionResult = taskGroupEntry.Save(SaveMode.NoConflictResolution);
                if (conflictResolutionResult.SaveStatus != SaveResult.Success)
                {
                    ExTraceGlobals.StorageTracer.TraceWarning <DefaultFolderType, SmtpAddress>(0L, "Unable to associate default task folder type: {0} with the MyTasks group for user: {1}. Attempting to delete default tasks group.", folderType, session.MailboxOwner.MailboxInfo.PrimarySmtpAddress);
                    result = false;
                }
            }
            return(result);
        }
Ejemplo n.º 8
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);
     }
 }
Ejemplo n.º 9
0
        private static TaskGroupInfo GetTaskGroupInfoFromRow(IStorePropertyBag row)
        {
            VersionedId id = (VersionedId)row.TryGetProperty(ItemSchema.Id);

            byte[] valueOrDefault  = row.GetValueOrDefault <byte[]>(TaskGroupSchema.GroupClassId, null);
            string valueOrDefault2 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty);

            byte[]     valueOrDefault3       = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null);
            ExDateTime valueOrDefault4       = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue);
            Guid       safeGuidFromByteArray = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault);

            if (safeGuidFromByteArray.Equals(Guid.Empty))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found task group with invalid group class id. ArrayLength: {0}", (valueOrDefault == null) ? -1 : valueOrDefault.Length);
                return(null);
            }
            return(new TaskGroupInfo(valueOrDefault2, id, safeGuidFromByteArray, TaskGroup.GetGroupTypeFromGuid(safeGuidFromByteArray), valueOrDefault3, valueOrDefault4));
        }
Ejemplo n.º 10
0
        private static TaskGroup InternalCreateDefaultGroup(MailboxSession session)
        {
            TaskGroup taskGroup;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                taskGroup              = TaskGroup.Create(session);
                taskGroup.GroupName    = ClientStrings.MyTasks.ToString(session.InternalCulture);
                taskGroup.GroupClassId = FolderTreeData.MyFoldersClassId;
                disposeGuard.Add <TaskGroup>(taskGroup);
                ConflictResolutionResult conflictResolutionResult = taskGroup.Save(SaveMode.NoConflictResolution);
                if (conflictResolutionResult.SaveStatus != SaveResult.Success)
                {
                    ExTraceGlobals.StorageTracer.TraceWarning <SmtpAddress>(0L, "Unable to create default group for user: {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress);
                    throw new DefaultTaskGroupCreationException();
                }
                taskGroup.Load();
                disposeGuard.Success();
            }
            return(taskGroup);
        }
Ejemplo n.º 11
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);
     }
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 public static TaskGroupEntry Create(MailboxSession session, Folder taskFolder, TaskGroup parentGroup)
 {
     Util.ThrowOnNullArgument(parentGroup, "parentGroup");
     Util.ThrowOnNullArgument(taskFolder, "TaskFolder");
     return(TaskGroupEntry.Create(session, taskFolder.Id.ObjectId, parentGroup.GroupClassId, parentGroup.GroupName));
 }
Ejemplo n.º 14
0
 internal static bool IsTaskFolderInGroup(IStorePropertyBag row, Guid groupClassId)
 {
     byte[] valueOrDefault = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
     return(TaskGroup.IsTaskGroupEntry(row) && Util.CompareByteArray(groupClassId.ToByteArray(), valueOrDefault));
 }
Ejemplo n.º 15
0
 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));
 }
Ejemplo n.º 16
0
 public TaskGroupInfo GetTaskGroupInfo()
 {
     return(TaskGroup.GetTaskGroupInfoFromRow(this));
 }
Ejemplo n.º 17
0
 public static TaskGroup Bind(MailboxSession session, StoreId storeId)
 {
     return(TaskGroup.Bind(session, storeId, null));
 }
Ejemplo n.º 18
0
        public static TaskGroupEntry Create(MailboxSession session, StoreObjectId taskFolderId, TaskGroup parentGroup)
        {
            Util.ThrowOnNullArgument(parentGroup, "parentGroup");
            TaskGroupEntry taskGroupEntry = TaskGroupEntry.Create(session, taskFolderId, parentGroup.GroupClassId, parentGroup.GroupName);

            taskGroupEntry.parentGroup = parentGroup;
            return(taskGroupEntry);
        }
Ejemplo n.º 19
0
 public static TaskGroup BindDefaultGroup(MailboxSession session)
 {
     return(TaskGroup.Bind(session, FolderTreeData.MyFoldersClassId));
 }