private void GetAttachmentsFromItemByStoreId(StoreSession session, StoreId storeId, List <ModernAttachment> outModernAttachments) { if (session == null || storeId == null || outModernAttachments == null || this.IsAttachmentCountExceeded()) { return; } try { using (Item item = Item.Bind(session, storeId, ItemBindOption.LoadRequiredPropertiesOnly, GetModernAttachmentsCommand.bindItemPropDefs)) { this.perfItemsBoundCount++; if (item.AttachmentCollection != null) { IdAndSession idAndSession = new IdAndSession(item.Id, item.Session); IList <AttachmentHandle> handles = item.AttachmentCollection.GetHandles(); for (int i = 0; i < handles.Count; i++) { AttachmentHandle attachmentHandle = handles[i]; using (Attachment attachment = item.AttachmentCollection.Open(attachmentHandle)) { if (GetModernAttachmentsCommand.Utilities.ShowAttachment(attachment, 100000)) { ModernAttachment modernAttachment = new ModernAttachment(); GetModernAttachmentsCommand.PopulateAttachmentProperties(idAndSession, item, attachment, modernAttachment); GetModernAttachmentsCommand.PopulateItemProperties(idAndSession, item, modernAttachment); modernAttachment.Info = new ModernAttachment.AttachmentInfo(); modernAttachment.Info.Index = i; modernAttachment.Info.Path = new string[] { GetModernAttachmentsCommand.Utilities.FormatParam("ATT.N", attachmentHandle.AttachNumber) }; outModernAttachments.Add(modernAttachment); this.perfAttachmentCount++; } this.perfAttachmentsEnumeratedCount++; } } } } } catch (Exception exception) { StructuredErrors structuredErrors = this.ConvertToNestedErrors(exception); structuredErrors.Path = new string[] { "GetAttachmentsFromItemByStoreId", GetModernAttachmentsCommand.Utilities.FormatParam("storeId", storeId.ToBase64String()) }; this.response.AddError(structuredErrors); } }
private UnifiedPolicyNotificationBase GetNotificationFromStoreId(StoreId storeId) { UnifiedPolicyNotificationBase unifiedPolicyNotificationBase = null; using (MessageItem messageItem = MessageItem.Bind(base.MailboxSession, storeId)) { WorkItemBase workItemBase = null; using (Stream stream = messageItem.PropertyBag.OpenPropertyStream(MessageItemSchema.UnifiedPolicyNotificationData, PropertyOpenMode.ReadOnly)) { if (stream.Length > 0L) { byte[] array = new byte[stream.Length]; stream.Position = 0L; stream.Read(array, 0, array.Length); workItemBase = WorkItemBase.Deserialize(array); } } unifiedPolicyNotificationBase = UnifiedPolicyNotificationFactory.Create(workItemBase, base.MailboxSession.MailboxOwner.ObjectId); workItemBase.WorkItemId = storeId.ToBase64String(); workItemBase.HasPersistentBackUp = true; unifiedPolicyNotificationBase.StoreObjectId = messageItem.Id; } return(unifiedPolicyNotificationBase); }
protected override bool InternalExecute() { InstantMessageProvider provider = base.Provider; StoreId storeId = null; if (provider == null) { ExTraceGlobals.InstantMessagingTracer.TraceError((long)this.GetHashCode(), "instant message provider is null"); return(false); } using (Folder folder = Folder.Bind(base.MailboxIdentityMailboxSession, DefaultFolderType.QuickContacts)) { ExTraceGlobals.InstantMessagingTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Removing instant message buddy:{0},{1}", this.instantMessageBuddy.DisplayName, this.instantMessageBuddy.SipUri); ComparisonFilter queryFilter = new ComparisonFilter(ComparisonOperator.Equal, ContactSchema.PersonId, this.personId); using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, queryFilter, null, RemoveBuddy.contactProperties)) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(1); if (propertyBags == null || propertyBags.Length == 0) { ExTraceGlobals.InstantMessagingTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Lync contact cannot be found in store: {0},{1}", this.instantMessageBuddy.DisplayName, this.instantMessageBuddy.SipUri); return(false); } storeId = propertyBags[0].GetValueOrDefault <VersionedId>(ItemSchema.Id, null).ObjectId; } } ExTraceGlobals.InstantMessagingTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Removing instant message buddy after retrieving store id of the contact:{0},{1}", this.instantMessageBuddy.DisplayName, storeId.ToBase64String()); provider.RemoveBuddy(base.MailboxIdentityMailboxSession, this.instantMessageBuddy, storeId); return(true); }
// Token: 0x060010EE RID: 4334 RVA: 0x00046958 File Offset: 0x00044B58 private int AddNewOrChangedItems(StoreId id, IList <SyncCalendarItemType> updatedItemsList, IList <SyncCalendarItemType> recurrenceMastersWithInstances, IList <SyncCalendarItemType> recurrenceMastersWithoutInstances, IDictionary <StoreId, SyncCalendarItemType> unchangedRecurrenceMastersWithInstances, IList <StoreId> deletedItemsList, HashSet <StoreId> syncItemsHashSet, IList <KeyValuePair <StoreId, LocalizedException> > caughtExceptions) { int addedItems = 0; try { GrayException.MapAndReportGrayExceptions(delegate() { using (CalendarItem calendarItem = CalendarItem.Bind(this.session, id, new PropertyDefinition[] { CalendarItemInstanceSchema.StartWallClock, CalendarItemInstanceSchema.EndWallClock })) { string uid; try { uid = new GlobalObjectId(calendarItem).Uid; } catch (Exception arg) { ExTraceGlobals.SyncCalendarTracer.TraceWarning <StoreId, Exception>((long)this.GetHashCode(), "Skipping the corrupt recurring calendar GlobalObjectId (Id: '{0}'). {1}", id, arg); uid = null; } SyncCalendarItemType typedItem = this.GetTypedItem(calendarItem.Id, uid, calendarItem.CalendarItemType, calendarItem.StartTime, calendarItem.StartWallClock, calendarItem.EndTime, calendarItem.EndWallClock); if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster) { if (calendarItem.Recurrence == null) { ExTraceGlobals.SyncCalendarTracer.TraceWarning <StoreId>((long)this.GetHashCode(), "Skipping the corrupt recurring calendar item with no recurrence (Id: '{0}').", id); } else { IList <OccurrenceInfo> occurrenceInfoList = calendarItem.Recurrence.GetOccurrenceInfoList(this.windowStart, this.windowEnd); if (occurrenceInfoList.Count != 0) { addedItems += this.AddSyncItem(typedItem, recurrenceMastersWithInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false); using (IEnumerator <OccurrenceInfo> enumerator = occurrenceInfoList.GetEnumerator()) { while (enumerator.MoveNext()) { OccurrenceInfo occurrenceInfo = enumerator.Current; CalendarItemType type; ExDateTime startWallClock; ExDateTime endWallClock; if (occurrenceInfo is ExceptionInfo) { type = CalendarItemType.Exception; startWallClock = ExDateTime.MinValue; endWallClock = ExDateTime.MinValue; } else { type = CalendarItemType.Occurrence; startWallClock = calendarItem.StartWallClock.TimeZone.ConvertDateTime(occurrenceInfo.StartTime); endWallClock = calendarItem.EndWallClock.TimeZone.ConvertDateTime(occurrenceInfo.EndTime); } SyncCalendarItemType typedItem2 = this.GetTypedItem(occurrenceInfo.VersionedId, uid, type, occurrenceInfo.StartTime, startWallClock, occurrenceInfo.EndTime, endWallClock); addedItems += this.AddSyncItem(typedItem2, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false); } goto IL_2D1; } } addedItems += this.AddSyncItem(typedItem, recurrenceMastersWithoutInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false); } } else { bool flag = this.windowStart <calendarItem.EndTime && this.windowEnd> calendarItem.StartTime; if (flag) { addedItems += this.AddSyncItem(typedItem, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false); } else { addedItems += this.AddDeletedItem(id, syncItemsHashSet, deletedItemsList); } } IL_2D1:; } }, new GrayException.IsGrayExceptionDelegate(GrayException.IsSystemGrayException)); } catch (LocalizedException ex) { ExTraceGlobals.SyncCalendarTracer.TraceWarning <string, LocalizedException>((long)this.GetHashCode(), "XsoSyncCalendar.AddNewOrChangedItems: Exception thrown while processing item {0}: {1}", id.ToBase64String(), ex); caughtExceptions.Add(new KeyValuePair <StoreId, LocalizedException>(id, ex)); } return(addedItems); }
// Token: 0x060010EC RID: 4332 RVA: 0x000462C8 File Offset: 0x000444C8 private CalendarViewQueryResumptionPoint DoQuerySync(HashSet <StoreId> syncItemsHashSet, List <SyncCalendarItemType> updatedItemsList, List <SyncCalendarItemType> recurrenceMastersWithInstances, Dictionary <StoreId, SyncCalendarItemType> unchangedRecurrenceMastersWithInstances, ExDateTime queryWindowStart, ExDateTime queryWindowEnd, int maxCount, IList <KeyValuePair <StoreId, LocalizedException> > caughtExceptions, out int addedItems) { ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar.DoQuerySync: Start"); int localAddedItems = 0; CalendarViewBatchingStrategy calendarViewBatchingStrategy = (this.syncState.QueryResumptionPoint == null) ? CalendarViewBatchingStrategy.CreateNewBatchingInstance(maxCount) : CalendarViewBatchingStrategy.CreateResumingInstance(maxCount, this.syncState.QueryResumptionPoint); using (CalendarFolder calendarFolder = CalendarFolder.Bind(this.session, this.folderId)) { PropertyDefinition[] xsoRequiredProperties = this.getPropertiesToFetchDelegate(calendarFolder); object[][] syncView = calendarFolder.GetSyncView(queryWindowStart, queryWindowEnd, calendarViewBatchingStrategy, xsoRequiredProperties, false); object[][] array = syncView; for (int i = 0; i < array.Length; i++) { object[] itemRow = array[i]; try { GrayException.MapAndReportGrayExceptions(delegate() { ExDateTime t; SyncCalendarItemType typedItem = this.GetTypedItem(xsoRequiredProperties, itemRow, out t); if (typedItem.CalendarItemType != CalendarItemType.RecurringMaster) { if (this.windowStart == queryWindowStart || t >= queryWindowStart) { localAddedItems += this.AddSyncItem(typedItem, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false); } return; } bool flag = false; if (this.windowStart == queryWindowStart) { flag = true; } else { using (CalendarItem calendarItem = CalendarItem.Bind(this.session, typedItem.ItemId)) { IList <OccurrenceInfo> occurrenceInfoList = calendarItem.Recurrence.GetOccurrenceInfoList(this.windowStart, queryWindowStart); flag = (occurrenceInfoList.Count == 0); } } if (flag) { localAddedItems += this.AddSyncItem(typedItem, recurrenceMastersWithInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false); return; } localAddedItems += this.AddSyncItem(typedItem, null, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, true); }, new GrayException.IsGrayExceptionDelegate(GrayException.IsSystemGrayException)); } catch (LocalizedException ex) { StoreId storeId = (StoreId)itemRow[0]; ExTraceGlobals.SyncCalendarTracer.TraceWarning <string, LocalizedException>((long)this.GetHashCode(), "XsoSyncCalendar.DoQuerySync: Exception thrown while processing item {0}: {1}", storeId.ToBase64String(), ex); caughtExceptions.Add(new KeyValuePair <StoreId, LocalizedException>(storeId, ex)); } } } ExTraceGlobals.SyncCalendarTracer.TraceDebug((long)this.GetHashCode(), "XsoSyncCalendar.DoQuerySync: End"); addedItems = localAddedItems; return(calendarViewBatchingStrategy.ResumptionPoint); }
private string ConvertToKey(Guid mailboxGuid, StoreId folderId) { return(mailboxGuid.ToString() + "/" + folderId.ToBase64String()); }
private bool TryFetchFavoritePublicFolder(object[] row, int folderTreeDataSectionValue, out IFavoritePublicFolder favoritePublicFolder, out bool shouldContinue) { favoritePublicFolder = null; shouldContinue = true; StoreId storeId = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <StoreId>(row, null, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Id); if (storeId == null) { FavoritePublicFoldersManager.Tracer.TraceError((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: detected item with null id"); return(false); } FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: processing item '{0}'", storeId.ToBase64String()); string text = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <string>(row, string.Empty, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.ItemClass); if (!ObjectClass.IsFolderTreeData(text)) { shouldContinue = false; FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected item class '{0}', stopping enumeration", text); return(false); } int num = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <int>(row, -1, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.GroupSection); if (folderTreeDataSectionValue != num) { FavoritePublicFoldersManager.Tracer.TraceDebug <int, int>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected group section (expected '{0}', actual '{1}'), skipping", folderTreeDataSectionValue, num); return(false); } int num2 = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <int>(row, -1, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Type); if (num2 != 0 && num2 != 2 && num2 != 1) { FavoritePublicFoldersManager.Tracer.TraceDebug <int>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: not the expected folder type '{0}', skipping", num2); return(false); } byte[] array = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <byte[]>(row, null, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.NodeEntryId); if (array == null) { FavoritePublicFoldersManager.Tracer.TraceError((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: folderEntryId was null"); return(false); } StoreObjectId storeObjectId = null; try { storeObjectId = StoreObjectId.FromProviderSpecificId(array); if (!storeObjectId.IsPublicFolderType()) { FavoritePublicFoldersManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TryFetchFavoritePublicFolder: folderStoreObjectId is not of the expected type (actual '{0}'), skipping", (storeObjectId == null) ? "null" : storeObjectId.ToHexEntryId()); return(false); } storeObjectId = StoreObjectId.FromLegacyFavoritePublicFolderId(storeObjectId); } catch (CorruptDataException arg) { FavoritePublicFoldersManager.Tracer.TraceError <CorruptDataException, string>((long)this.GetHashCode(), "GetFavorites: Exception {0} encountered trying to retrieve navigation node entry ID for folder entry id {1}", arg, (array == null) ? "null" : Convert.ToBase64String(array)); return(false); } string displayName = FavoritePublicFoldersManager.InternalGetItemPropertyOrDefault <string>(row, string.Empty, FavoritePublicFoldersManager.FavoriteFolderEntryPropertyIndex.Subject); favoritePublicFolder = new FavoritePublicFolder(storeObjectId, displayName); return(true); }