internal void UpdateFilterStateWithAddOrChange(ISyncItemId itemId, bool calendar, bool recurring, ExDateTime endTime) { if (itemId == null) { throw new ArgumentNullException("itemId"); } DateTimeCustomSyncFilter.FilterState filterState = null; if (this.CustomFilterState == null) { this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>(); } try { if (!this.CustomFilterState.ContainsKey(itemId)) { filterState = new DateTimeCustomSyncFilter.FilterState(); this.CustomFilterState[itemId] = filterState; } else { filterState = this.CustomFilterState[itemId]; } filterState.IsCalendarItem = calendar; if (calendar) { filterState.IsRecurring = recurring; if (recurring) { if (endTime.Equals(ExDateTime.MinValue)) { filterState.DoesRecurrenceEnd = false; } else { filterState.DoesRecurrenceEnd = true; filterState.EndTime = endTime; } } else { filterState.EndTime = endTime; } } } catch (Exception ex) { if (ex is ObjectNotFoundException || !SyncCommand.IsItemSyncTolerableException(ex)) { throw; } if (filterState != null) { filterState.IsCalendarItem = false; } } }
public override bool HasSchemaPropertyChanged(ISyncItem syncItem, int?[] oldChangeTrackingInformation, XmlDocument xmlResponse, MailboxLogger mailboxLogger) { bool flag = false; XmlNode xmlItemRoot = xmlResponse.CreateElement("ApplicationData", "AirSync:"); try { this.EntityDataObject.Bind(syncItem.NativeItem); base.AirSyncDataObject.Bind(xmlItemRoot); base.AirSyncDataObject.CopyFrom(this.EntityDataObject); } catch (Exception ex) { if (!SyncCommand.IsItemSyncTolerableException(ex)) { throw; } if (mailboxLogger != null) { mailboxLogger.SetData(MailboxLogDataName.MailboxSyncCommand_HasSchemaPropertyChanged_Exception, ex); } AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex); AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "Sync-tolerable Entity conversion Exception was thrown. HasSchemaPropertyChanged() {0}", arg); flag = true; } finally { this.EntityDataObject.Unbind(); base.AirSyncDataObject.Unbind(); } if (!flag) { int?[] array = base.ChangeTrackFilter.UpdateChangeTrackingInformation(xmlItemRoot, oldChangeTrackingInformation); AirSyncDiagnostics.TraceDebug <int?[], int?[]>(ExTraceGlobals.RequestsTracer, this, "HasSchemaPropertyChanged oldCCI {0} newCCI {1}", oldChangeTrackingInformation, array); flag = !ChangeTrackingFilter.IsEqual(array, oldChangeTrackingInformation); } return(flag); }
// Token: 0x06000C40 RID: 3136 RVA: 0x000404C0 File Offset: 0x0003E6C0 public void BuildResponse(XmlNode responseNode) { XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("Fetch", "ItemOperations:"); XmlNode xmlNode2 = responseNode.OwnerDocument.CreateElement("Status", "ItemOperations:"); XmlNode xmlNode3 = responseNode.OwnerDocument.CreateElement("Class", "AirSync:"); XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement("Properties", "ItemOperations:"); XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("ServerId", "AirSync:"); XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("CollectionId", "AirSync:"); XmlNode xmlNode7 = responseNode.OwnerDocument.CreateElement("LongId", "Search:"); FlexibleSchemaStrategy missingPropertyStrategy = new FlexibleSchemaStrategy(this.schemaTags); this.schemaConverterOptions["BodyPreference"] = this.bodyPreferences; this.schemaConverterOptions["BodyPartPreference"] = this.bodyPartPreferences; this.schemaConverterOptions["MIMESupport"] = this.mimeSupport; bool flag = false; try { using (Item item = Item.Bind(this.mailboxSession, this.storeObjectId)) { if (this.removeRightsManagementProtection) { this.IrmRemoveRestriction(item); } if (this.bodyPartPreferences != null && this.bodyPartPreferences.Count > 0) { ConversationId valueOrDefault = item.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null); if (valueOrDefault != null) { Conversation conversation; Command.CurrentCommand.GetOrCreateConversation(valueOrDefault, true, out conversation); conversation.LoadItemParts(new List <StoreObjectId> { item.StoreObjectId }); } } foreach (KeyValuePair <string, AirSyncSchemaState> keyValuePair in this.schemaStates) { AirSyncSchemaState value = keyValuePair.Value; AirSyncXsoSchemaState airSyncXsoSchemaState = value as AirSyncXsoSchemaState; AirSyncEntitySchemaState airSyncEntitySchemaState = value as AirSyncEntitySchemaState; IServerDataObject serverDataObject; if (airSyncXsoSchemaState != null) { serverDataObject = airSyncXsoSchemaState.GetXsoDataObject(); } else { if (airSyncEntitySchemaState == null) { throw new NotImplementedException(string.Format("Schema state for \"{0}\" is not implemented yet.", keyValuePair.Key)); } serverDataObject = airSyncEntitySchemaState.GetEntityDataObject(); } if (serverDataObject.CanConvertItemClassUsingCurrentSchema(item.ClassName)) { AirSyncDataObject airSyncDataObject = value.GetAirSyncDataObject(this.schemaConverterOptions, missingPropertyStrategy); if (this.rightsManagementSupport) { Command.CurrentCommand.DecodeIrmMessage(item, true); } item.Load(serverDataObject.GetPrefetchProperties()); try { serverDataObject.Bind(item); airSyncDataObject.Bind(xmlNode4); airSyncDataObject.CopyFrom(serverDataObject); } finally { airSyncDataObject.Unbind(); serverDataObject.Unbind(); } if (this.rightsManagementSupport) { Command.CurrentCommand.SaveLicense(item); } xmlNode3.InnerText = keyValuePair.Key; flag = true; break; } } } } catch (ObjectNotFoundException innerException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException, false) { ErrorStringForProtocolLogger = "NotFoundInMbxFetch" }; } catch (AirSyncPermanentException) { throw; } catch (Exception ex) { if (!SyncCommand.IsItemSyncTolerableException(ex)) { throw; } AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.ConversionTracer, this, "Sync-tolerable Item conversion Exception was thrown. Location BuildResponse(). {0}", ex); } if (!flag) { throw new AirSyncPermanentException(StatusCode.Sync_InvalidWaitTime, false) { ErrorStringForProtocolLogger = "ConvertErrorInMbxFetch" }; } xmlNode2.InnerText = 1.ToString(CultureInfo.InvariantCulture); xmlNode.AppendChild(xmlNode2); if (this.longId != null) { xmlNode7.InnerText = this.longId; xmlNode.AppendChild(xmlNode7); } else { xmlNode6.InnerText = this.collectionId; xmlNode.AppendChild(xmlNode6); xmlNode5.InnerText = this.serverId; xmlNode.AppendChild(xmlNode5); } xmlNode.AppendChild(xmlNode3); xmlNode.AppendChild(xmlNode4); if (this.multiPartResponse) { XmlNode xmlNode8 = xmlNode4["Body"]; if (xmlNode8 != null) { XmlNode xmlNode9 = xmlNode8["Data"]; AirSyncBlobXmlNode airSyncBlobXmlNode = xmlNode9 as AirSyncBlobXmlNode; if (xmlNode9 != null && (!string.IsNullOrEmpty(xmlNode9.InnerText) || (airSyncBlobXmlNode != null && airSyncBlobXmlNode.Stream != null))) { XmlNode xmlNode10 = responseNode.OwnerDocument.CreateElement("Part", "ItemOperations:"); xmlNode10.InnerText = this.partNumber.ToString(CultureInfo.InvariantCulture); xmlNode8.ReplaceChild(xmlNode10, xmlNode9); if (airSyncBlobXmlNode != null && airSyncBlobXmlNode.Stream != null) { this.outStream = airSyncBlobXmlNode.Stream; if (airSyncBlobXmlNode.Stream is AirSyncStream) { this.delayStreamDispose = true; } AirSyncDiagnostics.TraceError <Type>(ExTraceGlobals.ConversionTracer, this, "blobNode.Stream is of {0} type.", airSyncBlobXmlNode.Stream.GetType()); } else { UTF8Encoding utf8Encoding = new UTF8Encoding(); this.outStream = new MemoryStream(utf8Encoding.GetBytes(xmlNode9.InnerText)); } } } } responseNode.AppendChild(xmlNode); }
public void UpdateFilterState(SyncOperation syncOperation) { if (syncOperation == null) { throw new ArgumentNullException("syncOperation"); } if (this.prepopulate) { return; } if (this.CustomFilterState == null) { this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>(); } switch (syncOperation.ChangeType) { case ChangeType.Add: case ChangeType.Change: case ChangeType.ReadFlagChange: { CalendarItem calendarItem = null; try { calendarItem = (syncOperation.GetItem(new PropertyDefinition[0]).NativeItem as CalendarItem); if (calendarItem == null) { this.UpdateFilterStateWithAddOrChange(syncOperation.Id, false, false, ExDateTime.MinValue); } else if (calendarItem.Recurrence == null) { this.UpdateFilterStateWithAddOrChange(syncOperation.Id, true, false, calendarItem.EndTime); } else if (calendarItem.Recurrence.Range is NoEndRecurrenceRange) { this.UpdateFilterStateWithAddOrChange(syncOperation.Id, true, true, ExDateTime.MinValue); } else { this.UpdateFilterStateWithAddOrChange(syncOperation.Id, true, true, calendarItem.Recurrence.GetLastOccurrence().EndTime); } } catch (Exception ex) { if (ex is ObjectNotFoundException) { if (this.CustomFilterState.ContainsKey(syncOperation.Id)) { this.CustomFilterState.Remove(syncOperation.Id); } } else { if (!SyncCommand.IsItemSyncTolerableException(ex)) { throw; } StoreId storeId = null; string text = "Unknown"; ExDateTime exDateTime = ExDateTime.MinValue; try { if (calendarItem != null) { storeId = calendarItem.Id; text = calendarItem.Subject; exDateTime = calendarItem.StartTime; } } catch { } AirSyncUtility.ExceptionToStringHelper exceptionToStringHelper = new AirSyncUtility.ExceptionToStringHelper(ex); AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Exception was caught in UpdateFilterState. Item id=\"{0}\", subject=\"{1}\", meetingTime={2}\r\n{3}\r\nIgnoring exception and proceeding to next item.", new object[] { (storeId != null) ? storeId : "null", text, exDateTime, exceptionToStringHelper }); } } break; } case (ChangeType)3: break; case ChangeType.Delete: this.CustomFilterState.Remove(syncOperation.Id); return; default: return; } }
internal void Prepopulate(Folder folder) { if (folder == null) { throw new ArgumentNullException("folder"); } this.prepopulate = true; if (this.CustomFilterState == null) { this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>(); } using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, null, new PropertyDefinition[] { ItemSchema.Id, CalendarItemInstanceSchema.EndTime, CalendarItemBaseSchema.CalendarItemType, StoreObjectSchema.ItemClass, ItemSchema.Subject, CalendarItemInstanceSchema.StartTime })) { bool flag = false; while (!flag) { object[][] rows = queryResult.GetRows(10000); flag = (rows.Length == 0); for (int i = 0; i < rows.Length; i++) { StoreObjectId storeObjectId = null; DateTimeCustomSyncFilter.FilterState filterState = null; ISyncItemId key = null; try { storeObjectId = ((VersionedId)rows[i][0]).ObjectId; string itemClass = rows[i][3] as string; key = MailboxSyncItemId.CreateForNewItem(storeObjectId); if (!this.CustomFilterState.ContainsKey(key)) { filterState = new DateTimeCustomSyncFilter.FilterState(); this.CustomFilterState[key] = filterState; } else { filterState = this.CustomFilterState[key]; } if (!ObjectClass.IsCalendarItem(itemClass)) { filterState.IsCalendarItem = false; } else { filterState.IsCalendarItem = true; if (!(rows[i][2] is CalendarItemType)) { filterState.IsCalendarItem = false; } else { filterState.IsRecurring = (CalendarItemType.RecurringMaster == (CalendarItemType)rows[i][2]); if (filterState.IsRecurring) { using (CalendarItem calendarItem = CalendarItem.Bind(folder.Session, storeObjectId)) { if (calendarItem.Recurrence != null) { if (calendarItem.Recurrence.Range is NoEndRecurrenceRange) { filterState.DoesRecurrenceEnd = false; } else { filterState.DoesRecurrenceEnd = true; OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence(); filterState.EndTime = lastOccurrence.EndTime; } } else { filterState.IsCalendarItem = false; } goto IL_1E6; } } if (!(rows[i][1] is ExDateTime)) { filterState.IsCalendarItem = false; } else { filterState.EndTime = (ExDateTime)rows[i][1]; } IL_1E6 :; } } } catch (Exception ex) { if (ex is ObjectNotFoundException) { this.CustomFilterState.Remove(key); } else { if (!SyncCommand.IsItemSyncTolerableException(ex)) { throw; } string text = "Unknown"; ExDateTime exDateTime = ExDateTime.MinValue; try { text = (rows[i][4] as string); exDateTime = (ExDateTime)rows[i][5]; } catch { } AirSyncUtility.ExceptionToStringHelper exceptionToStringHelper = new AirSyncUtility.ExceptionToStringHelper(ex); AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Exception was caught in Prepopulate. Item id=\"{0}\", subject=\"{1}\", meetingTime={2}\r\n{3}\r\nIgnoring exception and proceeding to next item.", new object[] { (storeObjectId != null) ? storeObjectId : "null", text, exDateTime, exceptionToStringHelper }); if (filterState != null) { filterState.IsCalendarItem = false; } } } } } } }
public void BuildResponse(XmlElement responseNode) { MailboxSearchProvider.BuildResponseState buildResponseState = MailboxSearchProvider.BuildResponseState.Seeking; int num = -1; bool flag = false; this.totalRowCount = 0; this.numberResponses = 0; XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("Status", "Search:"); responseNode.AppendChild(xmlNode); xmlNode.InnerText = 1.ToString(CultureInfo.InvariantCulture); foreach (MailboxSearchCriteriaBuilder.SchemaCacheItem schemaCacheItem in this.schemaCache.Values) { schemaCacheItem.SchemaState.Options.Clear(); this.mailboxSchemaOptions.PopulateOptionsCollection(this.context.Request.DeviceIdentity.DeviceType, schemaCacheItem.SchemaState.Options); } bool flag2 = false; int num2 = 0; bool hasBodyPartPreferences = this.mailboxSchemaOptions.HasBodyPartPreferences; if (this.queryFilter != null) { using (QueryResult queryResult = this.searchFolder.ItemQuery(ItemQueryType.None, null, this.defaultSortBy, MailboxSearchProvider.queryColumns)) { this.uncappedResultCount = queryResult.EstimatedRowCount; num2 = this.uncappedResultCount; while (!flag2 && num <= this.maxRange) { object[][] rows = queryResult.GetRows(this.maxRange + 1); flag2 = (rows.Length == 0); for (int i = 0; i < rows.Length; i++) { StoreObjectId objectId = (rows[i][0] as VersionedId).ObjectId; string itemClass = rows[i][1] as string; StoreObjectId parentFolderId = rows[i][2] as StoreObjectId; string innerText = null; try { AirSyncDataObject airSyncDataObject = null; IServerDataObject serverDataObject = null; foreach (string text in this.schemaCache.Keys) { MailboxSearchCriteriaBuilder.SchemaCacheItem schemaCacheItem2 = this.schemaCache[text]; if (schemaCacheItem2.MailboxDataObject.CanConvertItemClassUsingCurrentSchema(itemClass)) { innerText = text; airSyncDataObject = schemaCacheItem2.AirSyncDataObject; serverDataObject = schemaCacheItem2.MailboxDataObject; break; } } if (airSyncDataObject != null) { if (this.searchCriteriaBuilder.DoesMatchCriteria(parentFolderId, objectId)) { num++; if (MailboxSearchProvider.BuildResponseState.BuildingResponse == buildResponseState || (buildResponseState == MailboxSearchProvider.BuildResponseState.Seeking && num >= this.minRange)) { buildResponseState = MailboxSearchProvider.BuildResponseState.BuildingResponse; buildResponseState = MailboxSearchProvider.BuildResponseState.BuildingResponse; Item item = null; try { item = this.BindToItemWithItemClass(objectId, itemClass, serverDataObject.GetPrefetchProperties()); if (this.searchCriteriaBuilder.ExcludedFolders.Contains(item.ParentId)) { num--; } else { XmlNode xmlNode2 = responseNode.OwnerDocument.CreateElement("Result", "Search:"); XmlNode xmlNode3 = responseNode.OwnerDocument.CreateElement("Properties", "Search:"); XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement("Class", "AirSync:"); xmlNode4.InnerText = innerText; XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("LongId", "Search:"); XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("CollectionId", "AirSync:"); xmlNode5.InnerText = HttpUtility.UrlEncode(item.Id.ObjectId.ToBase64String()); if (hasBodyPartPreferences) { if (this.searchCriteriaBuilder.Conversation == null) { throw new InvalidOperationException("Conversation object should not be null here when body part is requested!"); } this.searchCriteriaBuilder.Conversation.LoadItemParts(new List <StoreObjectId> { item.StoreObjectId }); } if (this.mailboxSchemaOptions.RightsManagementSupport) { Command.CurrentCommand.DecodeIrmMessage(item, false); } try { serverDataObject.Bind(item); airSyncDataObject.Bind(xmlNode3); airSyncDataObject.CopyFrom(serverDataObject); } finally { airSyncDataObject.Unbind(); serverDataObject.Unbind(); } if (this.mailboxSchemaOptions.RightsManagementSupport) { Command.CurrentCommand.SaveLicense(item); } xmlNode2.AppendChild(xmlNode4); xmlNode2.AppendChild(xmlNode5); if (this.FolderIdMappingSyncState == null) { throw new SearchNeedToFolderSyncException(); } string text2 = ((FolderIdMapping)this.FolderIdMappingSyncState[CustomStateDatumType.IdMapping])[MailboxSyncItemId.CreateForNewItem(item.ParentId)]; if (text2 == null) { throw new SearchNeedToFolderSyncException(); } xmlNode6.InnerText = text2; xmlNode2.AppendChild(xmlNode6); xmlNode2.AppendChild(xmlNode3); responseNode.AppendChild(xmlNode2); this.numberResponses++; if (this.minRange + this.numberResponses > this.maxRange) { flag = true; buildResponseState = MailboxSearchProvider.BuildResponseState.CountingTotal; } } } catch { num--; throw; } finally { if (item != null) { item.Dispose(); } } } } } } catch (Exception ex) { if (ex is SearchNeedToFolderSyncException) { throw; } if (!SyncCommand.IsItemSyncTolerableException(ex) && !SyncCommand.IsObjectNotFound(ex)) { throw; } } } } if (!flag && this.uncappedResultCount > queryResult.EstimatedRowCount) { this.haveUnretrievableResults = true; } } } if (this.numberResponses == 0) { XmlNode newChild = responseNode.OwnerDocument.CreateElement("Result", "Search:"); responseNode.AppendChild(newChild); if (this.minRange >= GlobalSettings.MaxMailboxSearchResults) { xmlNode.InnerText = 12.ToString(CultureInfo.InvariantCulture); return; } } else if (this.rangeSpecified) { XmlNode xmlNode7 = responseNode.OwnerDocument.CreateElement("Range", "Search:"); XmlNode xmlNode8 = responseNode.OwnerDocument.CreateElement("Total", "Search:"); xmlNode7.InnerText = this.minRange.ToString(CultureInfo.InvariantCulture) + "-" + (this.minRange + this.numberResponses - 1).ToString(CultureInfo.InvariantCulture); responseNode.AppendChild(xmlNode7); if (this.haveUnretrievableResults) { this.totalRowCount = this.uncappedResultCount; xmlNode.InnerText = 12.ToString(CultureInfo.InvariantCulture); } else if (this.uncappedResultCount > num2 || !flag2) { this.totalRowCount = this.uncappedResultCount; } else { this.totalRowCount = num + 1; if (this.minRange + this.numberResponses == GlobalSettings.MaxMailboxSearchResults) { xmlNode.InnerText = 12.ToString(CultureInfo.InvariantCulture); } } xmlNode8.InnerText = this.totalRowCount.ToString(CultureInfo.InvariantCulture); responseNode.AppendChild(xmlNode8); } }