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); } }
internal static TaskGroupEntryInfo GetTaskGroupEntryInfoFromRow(IStorePropertyBag row) { VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id); byte[] valueOrDefault = row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.NodeEntryId, null); byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null); string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty); byte[] valueOrDefault4 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null); row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.StoreEntryId, null); ExDateTime valueOrDefault5 = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue); row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder); FolderTreeDataFlags valueOrDefault6 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None); Guid safeGuidFromByteArray = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2); if (safeGuidFromByteArray.Equals(Guid.Empty)) { ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found TaskGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length); return(null); } if (IdConverter.IsFolderId(valueOrDefault)) { StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault); if ((valueOrDefault6 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore) { return(new TaskGroupEntryInfo(valueOrDefault3, versionedId, storeObjectId, safeGuidFromByteArray, valueOrDefault4, valueOrDefault5)); } ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found TaskGroupEntry of type {0} referencing a non-task folder. ObjectType: {0}. TaskFfolderName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId); } return(null); }
internal TaskGroup(ICoreItem coreItem) : base(coreItem) { if (base.IsNew) { this.InitializeNewGroup(); return; } this.groupClassId = FolderTreeData.GetSafeGuidFromByteArray(base.GetValueOrDefault <byte[]>(TaskGroupSchema.GroupClassId)); }
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); } }
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)); }
public override object this[PropertyDefinition propertyDefinition] { get { this.CheckDisposed("this::get"); return(base[propertyDefinition]); } set { this.CheckDisposed("this::set"); base[propertyDefinition] = value; if (propertyDefinition == TaskGroupSchema.GroupClassId) { byte[] guid = value as byte[]; this.groupClassId = FolderTreeData.GetSafeGuidFromByteArray(guid); } } }
public override object this[PropertyDefinition propertyDefinition] { get { this.CheckDisposed("this::get"); return(base[propertyDefinition]); } set { this.CheckDisposed("this::set"); base[propertyDefinition] = value; if (propertyDefinition == TaskGroupEntrySchema.NodeEntryId) { this.SetTaskFolderId(value as byte[]); return; } if (propertyDefinition == FolderTreeDataSchema.ParentGroupClassId) { this.parentGroupClassId = FolderTreeData.GetSafeGuidFromByteArray(value as byte[]); } } }
private void Initialize() { this.SetTaskFolderId(base.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.NodeEntryId)); this.parentGroupClassId = FolderTreeData.GetSafeGuidFromByteArray(base.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId)); }
public static VersionedId GetGroupEntryIdFromFolderId(MailboxSession session, StoreObjectId calendarFolderObjectId) { return(FolderTreeData.FindFirstRowMatchingFilter(session, CalendarGroup.CalendarInfoProperties, (IStorePropertyBag row) => CalendarGroup.IsFolderTreeData(row) && CalendarGroup.IsCalendarSection(row) && CalendarGroup.IsCalendarGroupEntryForCalendar(row, calendarFolderObjectId))); }
internal static CalendarGroupEntryInfo GetCalendarGroupEntryInfoFromRow(IStorePropertyBag row) { VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id); byte[] valueOrDefault = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.NodeEntryId, null); byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null); string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty); LegacyCalendarColor valueOrDefault4 = row.GetValueOrDefault <LegacyCalendarColor>(CalendarGroupEntrySchema.CalendarColor, LegacyCalendarColor.Auto); byte[] valueOrDefault5 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null); byte[] valueOrDefault6 = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.SharerAddressBookEntryId, null); byte[] valueOrDefault7 = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.StoreEntryId, null); ExDateTime valueOrDefault8 = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue); FolderTreeDataType valueOrDefault9 = row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder); FolderTreeDataFlags valueOrDefault10 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None); Guid safeGuidFromByteArray = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2); if (safeGuidFromByteArray.Equals(Guid.Empty)) { ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found CalendarGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length); return(null); } if (valueOrDefault9 != FolderTreeDataType.SharedFolder) { if (IdConverter.IsFolderId(valueOrDefault)) { StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault); if ((valueOrDefault10 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore) { return(new LocalCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, valueOrDefault5, safeGuidFromByteArray, (valueOrDefault10 & FolderTreeDataFlags.ICalFolder) == FolderTreeDataFlags.ICalFolder || (valueOrDefault10 & FolderTreeDataFlags.SharedIn) == FolderTreeDataFlags.SharedIn, valueOrDefault8)); } if ((valueOrDefault10 & FolderTreeDataFlags.PublicFolder) == FolderTreeDataFlags.PublicFolder) { string calendarOwner = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7); storeObjectId = StoreObjectId.FromLegacyFavoritePublicFolderId(storeObjectId); return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, calendarOwner, safeGuidFromByteArray, valueOrDefault5, false, true, valueOrDefault8)); } ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found CalendarGroupEntry of type {0} referencing a non-calendar folder. ObjectType: {0}. CalendarName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId); } return(null); } bool flag = true; Eidt eidt; string text; if (!AddressBookEntryId.IsAddressBookEntryId(valueOrDefault6, out eidt, out text)) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "AddressBookEntryId is missing, not primary calendar {0}", valueOrDefault3); if (valueOrDefault7 == null) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "StoreEntryId is missing for calendar: {0} - invalid entry, skipping.", valueOrDefault3); return(null); } text = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7); flag = false; } if (text == null) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Unable to determine owner of shared calendar: {0}. Skipping.", valueOrDefault3); return(null); } StoreObjectId storeObjectId2 = IdConverter.IsFolderId(valueOrDefault) ? StoreObjectId.FromProviderSpecificId(valueOrDefault) : null; if (!flag && storeObjectId2 == null) { ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Secondary shared calendar without a folder id encountered {0}. Skipping.", valueOrDefault3); return(null); } return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId2, text, safeGuidFromByteArray, valueOrDefault5, flag, false, valueOrDefault8)); }
protected static byte[] GetOrdinalValueOfFirstMatchingNode(MailboxSession session, SortBy[] sortOrder, FolderTreeData.RowMatchesFilterDelegate rowMatchesFilter, PropertyDefinition[] filterProperties, out bool noRowsFound) { return(FolderTreeData.GetValueFromFirstMatchingRow <byte[]>(session, sortOrder, rowMatchesFilter, filterProperties, FolderTreeDataSchema.Ordinal, out noRowsFound)); }
protected override void OnBeforeSave() { base.OnBeforeSave(); this.OutlookTagId = FolderTreeData.GenerateNewOutlookTagId(); }
protected static VersionedId FindFirstRowMatchingFilter(MailboxSession session, PropertyDefinition[] filterProperties, FolderTreeData.RowMatchesFilterDelegate rowMatchesFilter) { bool flag; return(FolderTreeData.GetValueFromFirstMatchingRow <VersionedId>(session, null, rowMatchesFilter, filterProperties, ItemSchema.Id, out flag)); }