private void WaitAndProcessProbeResponses(MapiFolder folder, string fromAddress, Dictionary <string, string> subjectTargets, ExDateTime probeSentTime) { List <byte[]> list = new List <byte[]>(); List <string> list2 = new List <string>(); for (int i = 0; i < base.Task.ExecutionTimeout; i++) { foreach (KeyValuePair <string, string> keyValuePair in subjectTargets) { if (!string.IsNullOrEmpty(keyValuePair.Value)) { using (MapiMessage deliveryReceipt = TestMailFlowHelper.GetDeliveryReceipt(folder, keyValuePair.Key, false)) { if (deliveryReceipt != null) { PropValue prop = deliveryReceipt.GetProp(PropTag.MessageDeliveryTime); PropValue prop2 = deliveryReceipt.GetProp(PropTag.EntryId); PropValue prop3 = deliveryReceipt.GetProp(PropTag.Subject); if (!prop.IsError() && prop.Value != null && prop3.Value != null) { string text = prop3.Value.ToString(); if (text.StartsWith("RSP: CrossPremiseMailFlowMonitoring-", StringComparison.OrdinalIgnoreCase)) { EnhancedTimeSpan latency = ((ExDateTime)prop.GetDateTime() > probeSentTime) ? ((ExDateTime)prop.GetDateTime() - probeSentTime) : EnhancedTimeSpan.Zero; base.OutputResult(Strings.TestMailflowSucceeded(fromAddress, keyValuePair.Value), latency, base.IsRemoteTest); } else if (text.StartsWith("Undeliverable: CrossPremiseMailFlowMonitoring-", StringComparison.OrdinalIgnoreCase)) { EnhancedTimeSpan latency2 = EnhancedTimeSpan.FromSeconds(0.0); string info = (string)deliveryReceipt.GetProp(PropTag.Body).Value; base.OutputResult(Strings.CrossPremiseProbeNdred(fromAddress, keyValuePair.Value, info), latency2, base.IsRemoteTest); } list2.Add(keyValuePair.Key); list.Add(prop2.GetBytes()); } } } } } foreach (string key in list2) { subjectTargets.Remove(key); } list2.Clear(); if (subjectTargets.Count == 0) { break; } Thread.Sleep(1000); } foreach (KeyValuePair <string, string> keyValuePair2 in subjectTargets) { if (!string.IsNullOrEmpty(keyValuePair2.Value)) { EnhancedTimeSpan latency3 = EnhancedTimeSpan.FromSeconds(0.0); base.OutputResult(Strings.MapiTransactionResultFailure, latency3, base.IsRemoteTest); } } folder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, list.ToArray()); }
// Token: 0x06001577 RID: 5495 RVA: 0x0007A018 File Offset: 0x00078218 public static List <MailboxData> GetMailboxTable(PropTag[] requiredMailboxTableProperties, DatabaseInfo databaseInfo) { PropValue[][] mailboxes; try { mailboxes = MailboxTableQuery.GetMailboxes("Client=TBA", databaseInfo, requiredMailboxTableProperties); } catch (MapiRetryableException innerException) { throw new SkipException(innerException); } catch (MapiPermanentException innerException2) { throw new SkipException(innerException2); } List <MailboxData> list = new List <MailboxData>(); foreach (PropValue[] array2 in mailboxes) { if (array2 != null) { PropValue mailboxProperty = MailboxTableQuery.GetMailboxProperty(array2, PropTag.UserGuid); PropValue mailboxProperty2 = MailboxTableQuery.GetMailboxProperty(array2, PropTag.MailboxNumber); if (mailboxProperty.PropTag.Id() == PropTag.UserGuid.Id() && mailboxProperty2.PropTag.Id() == PropTag.MailboxNumber.Id()) { Guid mailboxGuid = new Guid(mailboxProperty.GetBytes()); int @int = mailboxProperty2.GetInt(); list.Add(new MailboxProcessorMailboxData(databaseInfo, mailboxGuid, @int, array2)); } } } return(list); }
private static string GetFolderLegacyDistinguishedName(MapiEntryId abEntryId, MapiFolder folder) { string result; try { if (null == abEntryId) { if (folder == null) { throw new ArgumentNullException("folder"); } PropValue prop = folder.GetProp(PropTag.AddressBookEntryId); if (PropType.Error == prop.PropType) { return(null); } abEntryId = new MapiEntryId(prop.GetBytes()); } result = MapiMessageStoreSession.GetLegacyDNFromAddressBookEntryId(abEntryId); } catch (MapiPermanentException) { result = null; } catch (MapiRetryableException) { result = null; } return(result); }
internal static MapiEntryId GetEntryIdentity(MapiProp mapiObject) { MapiEntryId result; try { if (mapiObject == null) { throw new ArgumentNullException("mapiObject"); } PropValue prop = mapiObject.GetProp(PropTag.EntryId); if (PropType.Error == prop.PropType) { result = null; } else { result = new MapiEntryId(prop.GetBytes()); } } catch (MapiPermanentException) { result = null; } catch (MapiRetryableException) { result = null; } return(result); }
public override void RunNow(Guid mailboxGuid, string parameters) { StoreMailboxData mailboxData; using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=TBA", null, null, null, null)) { try { PropValue[][] mailboxTableInfo = exRpcAdmin.GetMailboxTableInfo(base.DatabaseInfo.Guid, mailboxGuid, new PropTag[] { PropTag.MailboxType, PropTag.PersistableTenantPartitionHint, PropTag.LastLogonTime }); if (mailboxTableInfo.Length != 1 || mailboxTableInfo[0].Length < 1) { throw new InvalidOperationException("Failed to get the mailbox property"); } PropValue mailboxProperty = MailboxTableQuery.GetMailboxProperty(mailboxTableInfo[0], PropTag.PersistableTenantPartitionHint); TenantPartitionHint tenantPartitionHint = null; if (mailboxProperty.PropTag == PropTag.PersistableTenantPartitionHint) { byte[] bytes = mailboxProperty.GetBytes(); if (bytes != null && bytes.Length != 0) { tenantPartitionHint = TenantPartitionHint.FromPersistablePartitionHint(bytes); } } if (string.IsNullOrEmpty(parameters)) { MailboxInformation mailboxInformation = MailboxInformation.Create(mailboxGuid.ToByteArray(), base.DatabaseInfo.Guid, mailboxGuid.ToString(), ControlData.Empty, mailboxTableInfo[0], MailboxInformation.GetLastLogonTime(mailboxTableInfo[0]), tenantPartitionHint); mailboxData = mailboxInformation.MailboxData; } else { mailboxData = new MailboxDataForDemandJob(mailboxGuid, base.DatabaseInfo.Guid, null, parameters, tenantPartitionHint); } } catch (MapiExceptionNotFound arg) { ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedStoreDatabaseDriver, MapiExceptionNotFound>((long)this.GetHashCode(), "{0}: Mailbox does not exist on the store: {1}", this, arg); if (string.IsNullOrEmpty(parameters)) { mailboxData = new StoreMailboxData(mailboxGuid, base.DatabaseInfo.Guid, mailboxGuid.ToString(), null); } else { mailboxData = new MailboxDataForDemandJob(mailboxGuid, base.DatabaseInfo.Guid, null, parameters); } } } ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug <TimeBasedStoreDatabaseDriver, Guid>((long)this.GetHashCode(), "{0}: RunNow: about to start processing mailbox {1} on this database.", this, mailboxGuid); base.RunNow(mailboxData); }
// Token: 0x06001561 RID: 5473 RVA: 0x00079BAC File Offset: 0x00077DAC public MailboxProcessorMailboxData(DatabaseInfo databaseInfo, Guid mailboxGuid, int mailboxNumber, PropValue[] row) : base(mailboxGuid, mailboxNumber, databaseInfo.Guid) { MailboxProcessorAssistantType.TraceInformation(0L, "Retrieving mailbox information for database {0}", new object[] { databaseInfo.Guid }); this.DatabaseName = databaseInfo.DatabaseName; PropValue mailboxProperty = MailboxTableQuery.GetMailboxProperty(row, PropTag.MailboxMiscFlags); if (mailboxProperty.PropTag == PropTag.MailboxMiscFlags) { MailboxMiscFlags @int = (MailboxMiscFlags)mailboxProperty.GetInt(); this.IsMoveDestination = ((@int & MailboxMiscFlags.CreatedByMove) == MailboxMiscFlags.CreatedByMove); this.IsArchive = ((@int & MailboxMiscFlags.ArchiveMailbox) == MailboxMiscFlags.ArchiveMailbox); } else { MailboxProcessorAssistantType.TraceInformation(0L, "Cannot retrieve property MailboxMiscFlags for Mailbox with GUID {0}", new object[] { mailboxGuid }); this.IsMoveDestination = false; this.IsArchive = false; } PropValue mailboxProperty2 = MailboxTableQuery.GetMailboxProperty(row, PropTag.PersistableTenantPartitionHint); this.TenantPartitionHint = null; if (mailboxProperty2.PropTag == PropTag.PersistableTenantPartitionHint) { byte[] bytes = mailboxProperty2.GetBytes(); if (bytes != null && bytes.Length != 0) { this.TenantPartitionHint = TenantPartitionHint.FromPersistablePartitionHint(bytes); } } else { MailboxProcessorAssistantType.TraceInformation(0L, "Cannot retrieve property PersistableTenantPartitionHint for Mailbox with GUID {0}", new object[] { mailboxGuid }); } MailboxProcessorAssistantType.TraceInformation(0L, "Found mailbox with GUID {0}. Is archive: {1}", new object[] { mailboxGuid, this.IsArchive }); }
// Token: 0x06000155 RID: 341 RVA: 0x00006A38 File Offset: 0x00004C38 private MailboxInformation GetMailboxInformation(PropValue[] mailboxPropValue) { PropValue mailboxProperty = MailboxTableQuery.GetMailboxProperty(mailboxPropValue, PropTag.UserGuid); PropValue mailboxProperty2 = MailboxTableQuery.GetMailboxProperty(mailboxPropValue, PropTag.DisplayName); PropValue mailboxProperty3 = MailboxTableQuery.GetMailboxProperty(mailboxPropValue, PropTag.DateDiscoveredAbsentInDS); DateTime lastLogonTime = MailboxInformation.GetLastLogonTime(mailboxPropValue); if (mailboxProperty.PropTag != PropTag.UserGuid || mailboxProperty2.PropTag != PropTag.DisplayName) { return(null); } if (mailboxProperty3.PropTag == PropTag.DateDiscoveredAbsentInDS) { return(null); } return(MailboxInformation.Create(mailboxProperty.GetBytes(), this.Guid, mailboxProperty2.GetString(), null, mailboxPropValue, lastLogonTime, null)); }
public static byte[] GetDumpsterEntryIdFromFolderRec(FolderRec folderRec) { ArgumentValidator.ThrowIfNull("folderRec", folderRec); if (folderRec.AdditionalProps != null) { foreach (PropValueData data in folderRec.AdditionalProps) { PropValue native = DataConverter <PropValueConverter, PropValue, PropValueData> .GetNative(data); if (!native.IsNull() && !native.IsError() && native.PropTag == PropTag.IpmWasteBasketEntryId) { return(native.GetBytes()); } } } return(null); }
public static object ExtractIpV4StringFromIpV6Bytes(PropValue value, MapiPropertyDefinition propertyDefinition) { if (!(typeof(string) == propertyDefinition.Type)) { throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa); } byte[] bytes = value.GetBytes(); if (16 == bytes.Length) { return(string.Format("{0}.{1}.{2}.{3}", new object[] { bytes[4], bytes[5], bytes[6], bytes[7] })); } throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ErrorByteArrayLength(16.ToString(), bytes.Length.ToString())); }
public static object ExtractMacAddressStringFromBytes(PropValue value, MapiPropertyDefinition propertyDefinition) { if (!(typeof(string) == propertyDefinition.Type)) { throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa); } byte[] bytes = value.GetBytes(); if (6 == bytes.Length) { return(string.Format("{0:X2}-{1:X2}-{2:X2}-{3:X2}-{4:X2}-{5:X2}", new object[] { bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5] })); } throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ErrorByteArrayLength(6.ToString(), bytes.Length.ToString())); }
public static object ExtractMultiAnsiStringsFromBytes(PropValue value, MapiPropertyDefinition propertyDefinition) { if (typeof(string) == propertyDefinition.Type && propertyDefinition.IsMultivalued) { byte[] bytes = value.GetBytes(); List <string> list = new List <string>(); int num = 0; int num2 = 0; while (bytes.Length > num2) { if (bytes[num2] == 0) { list.Add(Encoding.ASCII.GetString(bytes, num, num2 - num)); num = 1 + num2; } num2++; } return(new MultiValuedProperty <string>(propertyDefinition.IsReadOnly, propertyDefinition, list)); } throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa); }
protected override List <MailboxData> GetMailboxesForCurrentWindow(out int totalMailboxOnDatabaseCount, out int notInterestingMailboxCount, out int filteredMailboxCount, out int failedFilteringCount) { Guid activityId = Guid.NewGuid(); PropTag[] mailboxProperties = this.GetMailboxProperties(); PropValue[][] mailboxes = MailboxTableQuery.GetMailboxes("Client=TBA", base.DatabaseInfo, mailboxProperties); totalMailboxOnDatabaseCount = ((mailboxes == null) ? 0 : mailboxes.Length); notInterestingMailboxCount = 0; filteredMailboxCount = 0; failedFilteringCount = 0; AssistantsLog.LogGetMailboxesQueryEvent(activityId, base.Assistant.NonLocalizedName, totalMailboxOnDatabaseCount, base.Assistant as AssistantBase); if (mailboxes == null) { return(new List <MailboxData>()); } List <MailboxInformation> list3 = new List <MailboxInformation>(mailboxes.Length); Guid mailboxGuid = Guid.Empty; VariantConfigurationSnapshot snapshot = VariantConfiguration.GetSnapshot(DatabaseSettingsContext.Get(base.DatabaseInfo.Guid), null, null); TimeSpan notInterestingLogInterval = snapshot.MailboxAssistants.GetObject <IMailboxAssistantSettings>(base.AssistantType.Identifier, new object[0]).MailboxNotInterestingLogInterval; int filteredMailboxCountLocal = 0; int notInterestingMailboxCountLocal = 0; string traceMessage; foreach (PropValue[] propertiesForDelegateClosure2 in mailboxes) { try { PropValue[] propertiesForDelegateClosure = propertiesForDelegateClosure2; List <MailboxInformation> list = list3; base.CatchMeIfYouCan(delegate { PropValue mailboxProperty = MailboxTableQuery.GetMailboxProperty(propertiesForDelegateClosure, PropTag.UserGuid); PropValue mailboxProperty2 = MailboxTableQuery.GetMailboxProperty(propertiesForDelegateClosure, PropTag.DisplayName); string mailboxDisplayNameTracingOnlyUsage = (mailboxProperty2.IsNull() || mailboxProperty2.Value == null) ? string.Empty : mailboxProperty2.Value.ToString(); if (mailboxProperty.PropTag != PropTag.UserGuid || mailboxProperty2.PropTag != PropTag.DisplayName) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxNoGuidFilter, MailboxSlaFilterReasonType.NoGuid, new object[] { mailboxProperty.Value }); filteredMailboxCountLocal++; return; } byte[] bytes = mailboxProperty.GetBytes(); if (bytes != null && bytes.Length == 16) { mailboxGuid = new Guid(bytes); } if (MailboxTableQuery.GetMailboxProperty(propertiesForDelegateClosure, PropTag.DateDiscoveredAbsentInDS).PropTag == PropTag.DateDiscoveredAbsentInDS) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxNotInDirectoryFilter, MailboxSlaFilterReasonType.NotInDirectory, new object[0]); filteredMailboxCountLocal++; return; } PropValue mailboxProperty3 = MailboxTableQuery.GetMailboxProperty(propertiesForDelegateClosure, PropTag.MailboxMiscFlags); MailboxMiscFlags @int = (MailboxMiscFlags)mailboxProperty3.GetInt(0); if ((@int & MailboxMiscFlags.CreatedByMove) == MailboxMiscFlags.CreatedByMove) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxMoveDestinationFilter, MailboxSlaFilterReasonType.MoveDestination, new object[0]); filteredMailboxCountLocal++; return; } MailboxMiscFlags mailboxMiscFlags = @int & (MailboxMiscFlags.DisabledMailbox | MailboxMiscFlags.SoftDeletedMailbox | MailboxMiscFlags.MRSSoftDeletedMailbox); if (mailboxMiscFlags != MailboxMiscFlags.None) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxInaccessibleFilter, MailboxSlaFilterReasonType.Inaccessible, new object[] { mailboxMiscFlags }); filteredMailboxCountLocal++; return; } IMailboxFilter mailboxFilter = this.AssistantType as IMailboxFilter; if (mailboxFilter != null && mailboxProperty3.PropTag == PropTag.MailboxMiscFlags) { MailboxMiscFlags int2 = (MailboxMiscFlags)mailboxProperty3.GetInt(); bool flag = (int2 & MailboxMiscFlags.ArchiveMailbox) == MailboxMiscFlags.ArchiveMailbox; if (flag && !mailboxFilter.MailboxType.Contains(MailboxType.Archive)) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxArchiveFilter, MailboxSlaFilterReasonType.Archive, new object[0]); filteredMailboxCountLocal++; return; } } ControlData controlData = ControlData.Empty; if (this.AssistantType.ControlDataPropertyDefinition != null) { PropValue mailboxProperty4 = MailboxTableQuery.GetMailboxProperty(propertiesForDelegateClosure, (PropTag)this.AssistantType.ControlDataPropertyDefinition.PropertyTag); if (mailboxProperty4.PropTag == (PropTag)this.AssistantType.ControlDataPropertyDefinition.PropertyTag) { controlData = ControlData.CreateFromByteArray(mailboxProperty4.GetBytes()); } } TenantPartitionHint tenantPartitionHint = null; PropValue mailboxProperty5 = MailboxTableQuery.GetMailboxProperty(propertiesForDelegateClosure, PropTag.PersistableTenantPartitionHint); if (mailboxProperty5.PropTag == PropTag.PersistableTenantPartitionHint) { byte[] bytes2 = mailboxProperty5.GetBytes(); if (bytes2 != null && bytes2.Length != 0) { tenantPartitionHint = TenantPartitionHint.FromPersistablePartitionHint(bytes2); } } MailboxInformation mailboxInformation2 = MailboxInformation.Create(mailboxProperty.GetBytes(), this.DatabaseInfo.Guid, mailboxProperty2.GetString(), controlData, propertiesForDelegateClosure, MailboxInformation.GetLastLogonTime(propertiesForDelegateClosure), tenantPartitionHint); if (!this.DatabaseInfo.IsUserMailbox(mailboxInformation2.MailboxGuid)) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxNotUserFilter, MailboxSlaFilterReasonType.NotUser, new object[0]); filteredMailboxCountLocal++; return; } if (mailboxInformation2.MailboxData.IsPublicFolderMailbox && (mailboxFilter == null || !mailboxFilter.MailboxType.Contains(MailboxType.PublicFolder))) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxPublicFolderFilter, MailboxSlaFilterReasonType.PublicFolder, new object[0]); filteredMailboxCountLocal++; return; } if (this.IsMailboxInDemandJob(mailboxInformation2.MailboxData)) { this.LogStoreDriverMailboxFilterEvent(notInterestingLogInterval, activityId, mailboxGuid, mailboxDisplayNameTracingOnlyUsage, Strings.MailboxInDemandJobFilter, MailboxSlaFilterReasonType.InDemandJob, new object[0]); filteredMailboxCountLocal++; return; } if (this.AssistantType.MailboxExtendedProperties != null) { if (!this.AssistantType.IsMailboxInteresting(mailboxInformation2)) { traceMessage = string.Format("{0}: {1} is not interesting for the assistant {2}.", this, mailboxGuid, this.Assistant.NonLocalizedName); ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug((long)this.GetHashCode(), traceMessage); DateTime utcNow = DateTime.UtcNow; if (!this.notInterestingEventsLastLogDateTimes.ContainsKey(this.Assistant.NonLocalizedName) || utcNow - this.notInterestingEventsLastLogDateTimes[this.Assistant.NonLocalizedName] >= notInterestingLogInterval) { AssistantsLog.LogMailboxNotInterestingEvent(activityId, this.Assistant.NonLocalizedName, this.Assistant as AssistantBase, mailboxGuid, mailboxDisplayNameTracingOnlyUsage); this.notInterestingEventsLastLogDateTimes[this.Assistant.NonLocalizedName] = utcNow; } notInterestingMailboxCountLocal++; return; } } else { traceMessage = string.Format("{0}: {1} mailbox properties are null, IsMailboxInteresting was not called.", this, mailboxGuid); ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug((long)this.GetHashCode(), traceMessage); } traceMessage = string.Format("{0}: {1} is interesting for the assistant {2}.", this, mailboxGuid, this.Assistant.NonLocalizedName); ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug((long)this.GetHashCode(), traceMessage); AssistantsLog.LogMailboxInterestingEvent(activityId, this.Assistant.NonLocalizedName, this.Assistant as AssistantBase, null, mailboxGuid, mailboxDisplayNameTracingOnlyUsage); list.Add(mailboxInformation2); }, base.AssistantType.NonLocalizedName); } catch (AIException exception) { failedFilteringCount++; AssistantsLog.LogErrorEnumeratingMailboxes(base.Assistant, mailboxGuid, exception, true); } catch (Exception exception2) { AssistantsLog.LogErrorEnumeratingMailboxes(base.Assistant, mailboxGuid, exception2, false); throw; } } traceMessage = string.Format("{0}: {1} mailboxes after filtering", this, list3.Count); ExTraceGlobals.TimeBasedDatabaseDriverTracer.TraceDebug((long)this.GetHashCode(), traceMessage); if (this.firstIteration || base.AssistantType.WorkCycleCheckpoint < base.AssistantType.WorkCycle) { int count = list3.Count; list3 = list3.FindAll((MailboxInformation mailbox) => DateTime.UtcNow - mailbox.LastProcessedDate > base.AssistantType.WorkCycle - base.AssistantType.WorkCycleCheckpoint); this.firstIteration = false; filteredMailboxCountLocal += count - list3.Count; } list3.Sort((MailboxInformation m1, MailboxInformation m2) => m1.LastProcessedDate.CompareTo(m2.LastProcessedDate)); List <MailboxData> list2 = new List <MailboxData>(); foreach (MailboxInformation mailboxInformation in list3) { list2.Add(mailboxInformation.MailboxData); } AssistantsLog.LogEndGetMailboxesEvent(activityId, base.Assistant.NonLocalizedName, list2.Count, base.Assistant as AssistantBase); filteredMailboxCount = filteredMailboxCountLocal; notInterestingMailboxCount = notInterestingMailboxCountLocal; return(list2); }
private static MapiFolderPath GetFolderPath(MapiEntryId folderEntryId, MapiFolder mapiFolder, MapiStore mapiStore) { MapiFolderPath result; try { if (null == folderEntryId) { if (mapiFolder == null) { throw new ArgumentNullException("mapiFolder"); } PropValue prop = mapiFolder.GetProp(PropTag.EntryId); if (PropType.Error == prop.PropType) { return(null); } folderEntryId = new MapiEntryId(prop.GetBytes()); } if (mapiStore == null) { throw new ArgumentNullException("mapiStore"); } MapiEntryId operand; using (MapiFolder rootFolder = mapiStore.GetRootFolder()) { operand = new MapiEntryId(rootFolder.GetProp(PropTag.EntryId).GetBytes()); } MapiEntryId operand2 = new MapiEntryId(mapiStore.GetIpmSubtreeFolderEntryId()); MapiEntryId operand3 = new MapiEntryId(mapiStore.GetNonIpmSubtreeFolderEntryId()); MapiFolderPath mapiFolderPath = null; MapiEntryId mapiEntryId = folderEntryId; MapiEntryId mapiEntryId2 = null; string parentFolderName = null; while (!(operand2 == mapiEntryId)) { if (operand3 == mapiEntryId || operand == mapiEntryId) { mapiFolderPath = MapiFolderPath.GenerateFolderPath("NON_IPM_SUBTREE", mapiFolderPath, true); } else { using (MapiFolder mapiFolder2 = (MapiFolder)mapiStore.OpenEntry((byte[])mapiEntryId)) { PropValue[] props = mapiFolder2.GetProps(new PropTag[] { PropTag.ParentEntryId, PropTag.DisplayName }); if (PropType.Error == props[0].PropType || PropType.Error == props[1].PropType) { return(null); } mapiEntryId2 = new MapiEntryId(props[0].GetBytes()); parentFolderName = props[1].GetString(); } if (!(mapiEntryId2 == mapiEntryId)) { mapiFolderPath = MapiFolderPath.GenerateFolderPath(parentFolderName, mapiFolderPath, false); mapiEntryId = mapiEntryId2; continue; } } IL_19C: return(mapiFolderPath); } mapiFolderPath = MapiFolderPath.GenerateFolderPath("IPM_SUBTREE", mapiFolderPath, true); goto IL_19C; } catch (MapiPermanentException) { result = null; } catch (MapiRetryableException) { result = null; } return(result); }
public static T GetValue <T>(PropValue pv, T defaultValue) { object obj = null; PropType propType = pv.PropType; if (propType <= PropType.String) { if (propType != PropType.Int) { if (propType != PropType.Boolean) { if (propType == PropType.String) { obj = pv.GetString(); } } else { obj = pv.GetBoolean(); } } else { obj = pv.GetInt(); } } else if (propType != PropType.SysTime) { if (propType != PropType.Guid) { if (propType == PropType.Binary) { obj = pv.GetBytes(); if (typeof(T) == typeof(Guid)) { byte[] array = obj as byte[]; if (array != null && array.Length == 16) { obj = new Guid(array); } else { obj = null; } } } } else { obj = pv.GetGuid(); } } else { obj = pv.GetDateTime(); } if (obj == null) { return(defaultValue); } T result; try { result = (T)((object)obj); } catch (InvalidCastException) { result = defaultValue; } return(result); }
public static object Extract(PropValue value, MapiPropertyDefinition propertyDefinition) { bool isReadOnly = propertyDefinition.IsReadOnly; Type type = propertyDefinition.Type; Type underlyingType = Nullable.GetUnderlyingType(type); if (null != underlyingType) { type = underlyingType; } if (propertyDefinition.PropertyTag.Id() != value.PropTag.Id()) { throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ExceptionUnmatchedPropTag(propertyDefinition.PropertyTag.ToString(), value.PropTag.ToString())); } if (PropType.Binary == value.PropType) { if (typeof(Guid) == type) { return(new Guid(value.GetBytes())); } if (typeof(Schedule) == type) { return(Schedule.FromByteArray(value.GetBytes())); } if (typeof(MapiEntryId) == type) { return(new MapiEntryId(value.GetBytes())); } } if (typeof(short) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <short>(isReadOnly, propertyDefinition, value.GetShortArray())); } return(value.GetShort()); } else if (typeof(int) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <int>(isReadOnly, propertyDefinition, value.GetIntArray())); } return(value.GetInt()); } else if (typeof(long) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <long>(isReadOnly, propertyDefinition, value.GetLongArray())); } return(value.GetLong()); } else if (typeof(float) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <float>(isReadOnly, propertyDefinition, value.GetFloatArray())); } return(value.GetFloat()); } else if (typeof(double) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <double>(isReadOnly, propertyDefinition, value.GetDoubleArray())); } return(value.GetDouble()); } else if (typeof(DateTime) == type) { if (propertyDefinition.IsMultivalued) { DateTime[] dateTimeArray = value.GetDateTimeArray(); List <DateTime> list = new List <DateTime>(dateTimeArray.Length); foreach (DateTime dateTime in dateTimeArray) { list.Add(dateTime.ToLocalTime()); } return(new MultiValuedProperty <DateTime>(isReadOnly, propertyDefinition, list.ToArray())); } return(value.GetDateTime().ToLocalTime()); } else if (typeof(bool) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <bool>(isReadOnly, propertyDefinition, value.GetBoolArray())); } return(value.GetBoolean()); } else if (typeof(string) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <string>(isReadOnly, propertyDefinition, value.GetStringArray())); } return(value.GetString()); } else if (typeof(Guid) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <Guid>(isReadOnly, propertyDefinition, value.GetGuidArray())); } return(value.GetGuid()); } else if (typeof(byte[]) == type) { if (propertyDefinition.IsMultivalued) { return(new MultiValuedProperty <byte[]>(isReadOnly, propertyDefinition, value.GetBytesArray())); } return(value.GetBytes()); } else { if (typeof(short[]) == type) { return(value.GetShortArray()); } if (typeof(int[]) == type) { return(value.GetIntArray()); } if (typeof(long[]) == type) { return(value.GetLongArray()); } if (typeof(float[]) == type) { return(value.GetFloatArray()); } if (typeof(double[]) == type) { return(value.GetDoubleArray()); } if (typeof(DateTime[]) == type) { DateTime[] dateTimeArray2 = value.GetDateTimeArray(); List <DateTime> list2 = new List <DateTime>(dateTimeArray2.Length); foreach (DateTime dateTime2 in dateTimeArray2) { list2.Add(dateTime2.ToLocalTime()); } return(list2.ToArray()); } if (typeof(bool[]) == type) { return(value.GetBoolArray()); } if (typeof(string[]) == type) { return(value.GetStringArray()); } if (typeof(Guid[]) == type) { return(value.GetGuidArray()); } if (typeof(byte[][]) == type) { return(value.GetBytesArray()); } if (type.IsAssignableFrom(MapiPropValueConvertor.TypeFromPropType(value.PropType, false))) { return(value.RawValue); } object result = null; if (MapiPropValueConvertor.TryCastValueToExtract(value, type, out result)) { return(result); } throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa); } }
internal static PropertyValue ConvertFromMapiPropValue(PropValue mapiPropValue, int codePage) { PropertyValue result; try { PropertyTag propertyTag = new PropertyTag((uint)mapiPropValue.PropTag); object obj = null; PropertyType propertyType = propertyTag.PropertyType; if (propertyType <= PropertyType.Guid) { if (propertyType <= PropertyType.Object) { switch (propertyType) { case PropertyType.Null: goto IL_2E7; case PropertyType.Int16: obj = mapiPropValue.GetShort(); goto IL_2E7; case PropertyType.Int32: obj = mapiPropValue.GetInt(); goto IL_2E7; default: switch (propertyType) { case PropertyType.Error: obj = (ErrorCode)mapiPropValue.GetErrorValue(); goto IL_2E7; case PropertyType.Bool: obj = mapiPropValue.GetBoolean(); goto IL_2E7; case PropertyType.Object: goto IL_2E7; } break; } } else { switch (propertyType) { case PropertyType.String8: obj = ConvertHelper.ConvertMapiPtString8ToString8(mapiPropValue.Value, codePage); goto IL_2E7; case PropertyType.Unicode: obj = mapiPropValue.GetString(); goto IL_2E7; default: if (propertyType == PropertyType.SysTime) { DateTime dateTime = mapiPropValue.GetDateTime(); obj = (ExDateTime)dateTime; goto IL_2E7; } if (propertyType == PropertyType.Guid) { obj = mapiPropValue.GetGuid(); goto IL_2E7; } break; } } } else if (propertyType <= PropertyType.MultiValueUnicode) { if (propertyType == PropertyType.Binary) { obj = mapiPropValue.GetBytes(); goto IL_2E7; } switch (propertyType) { case PropertyType.MultiValueInt16: obj = mapiPropValue.GetShortArray(); goto IL_2E7; case PropertyType.MultiValueInt32: obj = mapiPropValue.GetIntArray(); goto IL_2E7; default: switch (propertyType) { case PropertyType.MultiValueString8: if (mapiPropValue.Value is string[]) { string[] array = (string[])mapiPropValue.Value; String8[] array2 = new String8[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = ConvertHelper.ConvertMapiPtString8ToString8(array[i], codePage); } obj = array2; goto IL_2E7; } if (mapiPropValue.Value is byte[][]) { byte[][] array3 = (byte[][])mapiPropValue.Value; String8[] array4 = new String8[array3.Length]; for (int j = 0; j < array3.Length; j++) { array4[j] = ConvertHelper.ConvertMapiPtString8ToString8(array3[j], codePage); } obj = array4; goto IL_2E7; } goto IL_2E7; case PropertyType.MultiValueUnicode: obj = mapiPropValue.GetStringArray(); goto IL_2E7; } break; } } else if (propertyType != PropertyType.MultiValueSysTime) { if (propertyType == PropertyType.MultiValueGuid) { obj = mapiPropValue.GetGuidArray(); goto IL_2E7; } if (propertyType == PropertyType.MultiValueBinary) { obj = mapiPropValue.GetBytesArray(); goto IL_2E7; } } else { DateTime[] dateTimeArray = mapiPropValue.GetDateTimeArray(); if (dateTimeArray != null) { ExDateTime[] array5 = new ExDateTime[dateTimeArray.Length]; for (int k = 0; k < dateTimeArray.Length; k++) { array5[k] = (ExDateTime)dateTimeArray[k]; } obj = array5; goto IL_2E7; } goto IL_2E7; } throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert unsupported property type {0} on property {1}.", propertyTag.PropertyType, propertyTag)); IL_2E7: if (obj == null) { result = PropertyValue.NullValue(propertyTag); } else { result = new PropertyValue(propertyTag, obj); } } catch (InvalidPropertyValueTypeException inner) { throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert invalid PropValue on property {0}.", mapiPropValue), inner); } catch (NotSupportedException inner2) { throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert invalid PropValue as it contains unsupported PropType on property {0}.", mapiPropValue), inner2); } return(result); }
private object ConvertValue(ADPropertyDefinition propertyDefinition, PropValue propValue) { if (propValue.IsError() || propValue.IsNull()) { return(null); } PropType propType = propValue.PropType; object[] values; if (propType <= PropType.SysTime) { if (propType <= PropType.Boolean) { if (propType != PropType.Int && propType != PropType.Boolean) { goto IL_174; } } else { switch (propType) { case PropType.AnsiString: values = new object[] { this.encoding.GetString(propValue.GetBytes()) }; goto IL_18F; case PropType.String: break; default: if (propType != PropType.SysTime) { goto IL_174; } break; } } } else if (propType <= PropType.Binary) { if (propType != PropType.Guid) { if (propType != PropType.Binary) { goto IL_174; } values = new object[] { propValue.RawValue }; goto IL_18F; } } else { switch (propType) { case PropType.AnsiStringArray: values = Array.ConvertAll <byte[], object>(propValue.GetBytesArray(), (byte[] bytesValue) => this.encoding.GetString(bytesValue)); goto IL_18F; case PropType.StringArray: values = Array.ConvertAll <string, object>(propValue.GetStringArray(), (string stringValue) => stringValue); goto IL_18F; default: if (propType != PropType.BinaryArray) { goto IL_174; } values = Array.ConvertAll <byte[], object>(propValue.GetBytesArray(), (byte[] bytesValue) => bytesValue); goto IL_18F; } } values = new object[] { propValue.RawValue.ToString() }; goto IL_18F; IL_174: throw new InvalidOperationException(string.Format("Property type {0} is not supported", propValue.GetType())); object result; try { IL_18F: result = ADValueConvertor.GetValueFromDirectoryAttributeValues(propertyDefinition, values); } catch (DataValidationException arg) { NspiPropertyMap.Tracer.TraceWarning <string, DataValidationException>((long)this.GetHashCode(), "Unable to handle property {0} because it has invalid value, exception: {1}", propertyDefinition.Name, arg); result = null; } return(result); }