Ejemplo n.º 1
0
		private void GenerateItemListForSourceMailbox(SourceInformation sourceMailbox)
		{
			Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: Generating item list for mailbox '{0}'", new object[]
			{
				sourceMailbox.Configuration.Id
			});
			ErrorRecord errorRecord = null;
			bool flag = sourceMailbox.Configuration.Id.StartsWith("\\");
			ScenarioData.Current["PM"] = sourceMailbox.Configuration.LegacyExchangeDN.GetHashCode().ToString();
			if (sourceMailbox.Status.ItemCount < 0)
			{
				sourceMailbox.Status.ItemCount = 0;
			}
			if (sourceMailbox.Status.UnsearchableItemCount < 0)
			{
				sourceMailbox.Status.UnsearchableItemCount = 0;
			}
			try
			{
				Dictionary<string, string> dictionary = null;
				if (!flag)
				{
					dictionary = ItemListGenerator.PrepareAllFolders(sourceMailbox.ServiceClient, sourceMailbox.Configuration.Id);
				}
				bool flag2 = false;
				bool flag3 = false;
				bool isUnsearchable = false;
				if (this.target.ExportContext.ExportMetadata.IncludeSearchableItems)
				{
					Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer for primary for mailbox: '{0}'", new object[]
					{
						sourceMailbox.Configuration.Id
					});
					this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, isUnsearchable, false, ref flag2, out flag3);
				}
				if (this.target.ExportContext.ExportMetadata.IncludeSearchableItems && dictionary != null && dictionary.Values.Contains("\\archive"))
				{
					Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer for archive for mailbox: '{0}'", new object[]
					{
						sourceMailbox.Configuration.Id
					});
					this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, isUnsearchable, true, ref flag2, out flag3);
				}
				isUnsearchable = true;
				if (this.target.ExportContext.ExportMetadata.IncludeUnsearchableItems)
				{
					flag2 = false;
					Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer isunsearchable for primary for mailbox: '{0}'", new object[]
					{
						sourceMailbox.Configuration.Id
					});
					this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, isUnsearchable, false, ref flag2, out flag3);
					if (!flag3)
					{
						Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer isunsearchable for newschemafailed for mailbox: '{0}'", new object[]
						{
							sourceMailbox.Configuration.Id
						});
						this.GetAllItemIdsFromServer<UnsearchableItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<UnsearchableItemId>(this.GetUnsearchableItemIdPageFromServer), dictionary, isUnsearchable, false, ref flag2, out flag3);
					}
					else if (dictionary != null && dictionary.Values.Contains("\\archive"))
					{
						Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer isunsearchable for archive for mailbox: '{0}'", new object[]
						{
							sourceMailbox.Configuration.Id
						});
						this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, isUnsearchable, true, ref flag2, out flag3);
					}
				}
			}
			catch (ExportException ex)
			{
				Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: Error for mailbox '{0}'. Exception: {1}", new object[]
				{
					sourceMailbox.Configuration.Id,
					ex
				});
				errorRecord = new ErrorRecord
				{
					SourceId = sourceMailbox.Configuration.Id,
					Item = null,
					ErrorType = ex.ErrorType,
					DiagnosticMessage = ex.Message,
					Time = DateTime.UtcNow
				};
			}
			if (ScenarioData.Current.ContainsKey("PM"))
			{
				ScenarioData.Current.Remove("PM");
			}
			if (errorRecord != null)
			{
				this.AbortForSourceMailbox(errorRecord);
			}
		}
Ejemplo n.º 2
0
		private void GetAllItemIdsFromServer<T>(SourceInformation sourceMailbox, ItemListGenerator.GetItemIdPageFromServerDelegate<T> serverCall, Dictionary<string, string> allFolders, bool isUnsearchable, bool isArchive, ref bool isContextEntered, out bool newSchemaSearchSucceeded) where T : ItemId, new()
		{
			string text = null;
			string text2 = null;
			List<T> list = null;
			bool flag = true;
			newSchemaSearchSucceeded = false;
			while (flag)
			{
				list = serverCall(sourceMailbox, ref text, out newSchemaSearchSucceeded, isUnsearchable, isArchive);
				if (isUnsearchable && !newSchemaSearchSucceeded)
				{
					return;
				}
				if (list != null && list.Count > 0)
				{
					string a = text2;
					T t = list[0];
					if (a == t.Id)
					{
						list.RemoveAt(0);
					}
					if (list.Count > 0)
					{
						T t2 = list[list.Count - 1];
						text2 = t2.Id;
						string id = sourceMailbox.Configuration.Id;
						foreach (T t3 in list)
						{
							ItemId itemId = t3;
							ItemListGenerator.UpdateItemId(allFolders, itemId, id);
						}
						ItemListGenerator.ItemIdsDataBatch itemIdsDataBatch = new ItemListGenerator.ItemIdsDataBatch
						{
							ItemIds = list.Cast<ItemId>(),
							IsUnsearchable = isUnsearchable
						};
						IList<ItemId> list2 = null;
						this.SaveItemIdListToCache(itemIdsDataBatch);
						if (itemIdsDataBatch.IsUnsearchable)
						{
							if (this.unsearchableItemListCache.ContainsKey(id))
							{
								list2 = this.unsearchableItemListCache[id].MemoryCache;
							}
						}
						else if (this.itemListCache.ContainsKey(id))
						{
							list2 = this.itemListCache[id].MemoryCache;
						}
						if (!isContextEntered && this.DataRetriever != null && this.DataRetriever.DataWriter != null)
						{
							this.DataRetriever.DataWriter.EnterDataContext(this.DataRetriever.DataContext);
							if (this.DataRetriever.DataContext.ItemCount > 0)
							{
								isContextEntered = true;
							}
						}
						if (this.DataRetriever != null && list2 != null)
						{
							int count = list2.Count;
							bool flag2 = false;
							List<ItemId> list3 = new List<ItemId>(list2.Count);
							list3.AddRange(list2);
							while (count-- > 0 && list3.Count > 0)
							{
								this.DataRetriever.ProcessItems(ref list3);
								List<ItemInformation> items = this.DataRetriever.ProcessBatchData();
								if (!flag2)
								{
									this.OnDataBatchRead(itemIdsDataBatch);
									flag2 = true;
								}
								if (this.progressController.IsStopRequested)
								{
									Tracer.TraceInformation("ItemListGenerator.GetAllItemIdsFromServer: Stop requested for mailbox '{0}'", new object[]
									{
										sourceMailbox.Configuration.Id
									});
									break;
								}
								this.DataRetriever.OnDataBatchRead(items);
							}
							if (count <= 0 && list3.Count > 0)
							{
								Tracer.TraceError("ItemListGenerator.GetAllItemIdsFromServer: error: count <= 0 && tempBatch.Count > 0, count: {0}; tempBatch.Count: {1}", new object[]
								{
									count,
									list3.Count
								});
							}
						}
					}
					else
					{
						Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: Reset pageItemReference to null because there is only one item in the page and it is the same one as the last of the last page. pageItemReference was '{0}'.", new object[]
						{
							text ?? "null"
						});
						text = null;
					}
				}
				flag = (text != null);
				Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: pageItemReference='{0}' for mailbox '{1}'; current item count in page: {2}.", new object[]
				{
					text ?? "null",
					sourceMailbox.Configuration.Id,
					(list == null) ? 0 : list.Count
				});
			}
		}
Ejemplo n.º 3
0
		public void DoExportForSourceMailbox(SourceInformation sourceMailbox)
		{
			Tracer.TraceInformation("ItemListGenerator.DoExportForSourceMailbox: Generating item list for mailbox '{0}'", new object[]
			{
				sourceMailbox.Configuration.Id
			});
			ErrorRecord errorRecord = null;
			sourceMailbox.Configuration.Id.StartsWith("\\");
			ScenarioData.Current["PM"] = sourceMailbox.Configuration.LegacyExchangeDN.GetHashCode().ToString();
			if (sourceMailbox.Status.ItemCount < 0)
			{
				sourceMailbox.Status.ItemCount = 0;
			}
			if (sourceMailbox.Status.UnsearchableItemCount < 0)
			{
				sourceMailbox.Status.UnsearchableItemCount = 0;
			}
			try
			{
				bool flag = this.target.ExportContext.ExportMetadata.IncludeSearchableItems && !this.DoUnSearchable;
				bool flag2 = this.target.ExportContext.ExportMetadata.IncludeUnsearchableItems && this.DoUnSearchable;
				bool flag3 = false;
				Dictionary<string, string> dictionary = null;
				dictionary = ItemListGenerator.PrepareAllFolders(sourceMailbox.ServiceClient, sourceMailbox.Configuration.Id);
				if (flag)
				{
					bool errorHappened = false;
					try
					{
						bool flag4 = false;
						Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer for primary for mailbox: '{0}'", new object[]
						{
							sourceMailbox.Configuration.Id
						});
						this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, !flag, false, ref flag4, out flag3);
						if (dictionary != null && dictionary.Values.Contains("\\archive"))
						{
							Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer for archive for mailbox: '{0}'", new object[]
							{
								sourceMailbox.Configuration.Id
							});
							this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, !flag, true, ref flag4, out flag3);
						}
						ExportException ex = AsynchronousTaskHandler.WaitForAsynchronousTask(this.writingTask);
						if (ex != null)
						{
							errorHappened = true;
							throw ex;
						}
					}
					finally
					{
						this.DataRetriever.DataWriter.ExitDataContext(errorHappened);
					}
				}
				bool isUnsearchable = true;
				if (flag2)
				{
					bool errorHappened2 = false;
					try
					{
						bool flag5 = false;
						Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer isunsearchable for primary for mailbox: '{0}'", new object[]
						{
							sourceMailbox.Configuration.Id
						});
						this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, isUnsearchable, false, ref flag5, out flag3);
						if (!flag3)
						{
							Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer isunsearchable for newschemafailed for mailbox: '{0}'", new object[]
							{
								sourceMailbox.Configuration.Id
							});
							this.GetAllItemIdsFromServer<UnsearchableItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<UnsearchableItemId>(this.GetUnsearchableItemIdPageFromServer), dictionary, isUnsearchable, false, ref flag5, out flag3);
						}
						else if (dictionary != null && dictionary.Values.Contains("\\archive"))
						{
							Tracer.TraceInformation("ItemListGenerator.GenerateItemListForSourceMailbox: call GetAllItemIdsFromServer isunsearchable for archive for mailbox: '{0}'", new object[]
							{
								sourceMailbox.Configuration.Id
							});
							this.GetAllItemIdsFromServer<ItemId>(sourceMailbox, new ItemListGenerator.GetItemIdPageFromServerDelegate<ItemId>(this.GetItemIdPageFromServer), dictionary, isUnsearchable, true, ref flag5, out flag3);
						}
						ExportException ex2 = AsynchronousTaskHandler.WaitForAsynchronousTask(this.writingTask);
						if (ex2 != null)
						{
							errorHappened2 = true;
							throw ex2;
						}
					}
					finally
					{
						this.DataRetriever.DataWriter.ExitDataContext(errorHappened2);
					}
				}
			}
			catch (ExportException ex3)
			{
				Tracer.TraceInformation("ItemListGenerator.DoExportForSourceMailbox: Error for mailbox '{0}'. Exception: {1}", new object[]
				{
					sourceMailbox.Configuration.Id,
					ex3
				});
				errorRecord = new ErrorRecord
				{
					SourceId = sourceMailbox.Configuration.Id,
					Item = null,
					ErrorType = ex3.ErrorType,
					DiagnosticMessage = ex3.Message,
					Time = DateTime.UtcNow
				};
			}
			if (ScenarioData.Current.ContainsKey("PM"))
			{
				ScenarioData.Current.Remove("PM");
			}
			if (errorRecord != null)
			{
				this.AbortForSourceMailbox(errorRecord);
			}
		}