コード例 #1
0
		private void RecreateUniqueItemHashMap()
		{
			SourceInformation sourceInformation = this.AllSourceInformation.Values.FirstOrDefault((SourceInformation source) => source.ServiceClient != null);
			foreach (SourceInformation sourceInformation2 in this.AllSourceInformation.Values)
			{
				if (this.progressController.IsStopRequested)
				{
					Tracer.TraceInformation("ItemListGenerator.RecreateUniqueItemHashMap: Stop requested point 1", new object[0]);
					break;
				}
				if (sourceInformation2.Status.ItemCount > 0)
				{
					IItemIdList itemIdList = this.target.CreateItemIdList(sourceInformation2.Configuration.Id, false);
					this.AddItemIdListToUniqueItemHashMap(itemIdList, sourceInformation.ServiceClient);
				}
				if (sourceInformation2.Status.UnsearchableItemCount > 0)
				{
					IItemIdList itemIdList2 = this.target.CreateItemIdList(sourceInformation2.Configuration.Id, true);
					this.AddItemIdListToUniqueItemHashMap(itemIdList2, sourceInformation.ServiceClient);
				}
			}
		}
コード例 #2
0
 private bool IsServiceClientNeededForSource(SourceInformation source)
 {
     return(source.ServiceClient == null);
 }
コード例 #3
0
 private bool IsServiceEndpointNeededForSource(SourceInformation source)
 {
     return(source.ServiceClient == null && source.Configuration.ServiceEndpoint == null);
 }
コード例 #4
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
				});
			}
		}
コード例 #5
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);
			}
		}
コード例 #6
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);
			}
		}
コード例 #7
0
        private void ExportSourceMailbox(IContextualBatchDataWriter <List <ItemInformation> > dataWriter, SourceInformation source, bool isUnsearchable)
        {
            Tracer.TraceInformation("ProgressController.ExportSourceMailbox: Source Id: {0}; isUnsearchable: {1}", new object[]
            {
                source.Configuration.Id,
                isUnsearchable
            });
            this.ItemListGenerator.DoUnSearchable = isUnsearchable;
            bool flag = (!isUnsearchable && source.Status.ItemCount <= 0) || (isUnsearchable && source.Status.UnsearchableItemCount <= 0);

            if ((!isUnsearchable && source.Status.ItemCount > source.Status.ProcessedItemCount) || (isUnsearchable && source.Status.UnsearchableItemCount > source.Status.ProcessedUnsearchableItemCount) || !this.target.ExportContext.IsResume || flag)
            {
                IItemIdList   itemIdList    = this.target.CreateItemIdList(source.Configuration.Id, isUnsearchable);
                DataContext   dataContext   = new DataContext(source, itemIdList);
                DataRetriever dataRetriever = new DataRetriever(dataContext, this);
                dataRetriever.DataWriter              = dataWriter;
                this.ItemListGenerator.DataRetriever  = dataRetriever;
                this.ItemListGenerator.DataBatchRead += this.ItemListGenerator.WriteDataBatchItemListGen;
                dataRetriever.DataBatchRead          += this.ItemListGenerator.WriteDataBatchDataRetriever;
                ExportException ex = null;
                try
                {
                    this.ItemListGenerator.DoExportForSourceMailbox(dataRetriever.DataContext.SourceInformation);
                }
                finally
                {
                    ex = AsynchronousTaskHandler.WaitForAsynchronousTask(this.ItemListGenerator.WritingTask);
                    this.ItemListGenerator.WritingTask   = null;
                    this.ItemListGenerator.DataRetriever = null;
                }
                if (ex != null)
                {
                    throw ex;
                }
            }
        }
コード例 #8
0
        private void EnsureStatusLogValid()
        {
            if (this.statusLog == null)
            {
                Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: initializing status log in memory", new object[0]);
                try
                {
                    this.statusLog = this.target.GetStatusLog();
                    SourceInformationCollection sourceInformationCollection = null;
                    OperationStatus             currentStatus = OperationStatus.None;
                    ExportSettings exportSettings             = this.statusLog.LoadStatus(out sourceInformationCollection, out currentStatus);
                    if (sourceInformationCollection == null)
                    {
                        Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: creating status log since no existing log found", new object[0]);
                        if (this.target.ExportContext.IsResume)
                        {
                            throw new ExportException(ExportErrorType.StatusNotFoundToResume, "This is a resume request of previous job. But there is no corresponding previous job found.");
                        }
                        this.ResetStatusToDefault();
                        this.target.ExportSettings = new ExportSettings
                        {
                            ExportTime               = this.target.ExportContext.ExportMetadata.ExportStartTime,
                            IncludeDuplicates        = this.target.ExportContext.ExportMetadata.IncludeDuplicates,
                            IncludeSearchableItems   = this.target.ExportContext.ExportMetadata.IncludeSearchableItems,
                            IncludeUnsearchableItems = this.target.ExportContext.ExportMetadata.IncludeUnsearchableItems,
                            RemoveRms = this.target.ExportContext.ExportMetadata.RemoveRms
                        };
                        this.statusLog.ResetStatusLog(this.AllSourceInformation, this.CurrentStatus, this.target.ExportSettings);
                    }
                    else
                    {
                        Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Using existing status log", new object[0]);
                        if (!this.target.ExportContext.IsResume)
                        {
                            throw new ExportException(ExportErrorType.ExistingStatusMustBeAResumeOperation, "This operation has previous job status so it must be a resume operation this time.");
                        }
                        if (exportSettings == null)
                        {
                            throw new ExportException(ExportErrorType.CorruptedStatus, "The export settings in the status log is missing or corrupted.");
                        }
                        this.target.ExportSettings = exportSettings;
                        bool flag = false;
                        if (this.target.ExportContext.ExportMetadata.IncludeDuplicates == this.target.ExportSettings.IncludeDuplicates && this.target.ExportContext.ExportMetadata.IncludeSearchableItems == this.target.ExportSettings.IncludeSearchableItems && this.target.ExportContext.ExportMetadata.IncludeUnsearchableItems == this.target.ExportSettings.IncludeUnsearchableItems && this.target.ExportContext.ExportMetadata.RemoveRms == this.target.ExportSettings.RemoveRms && this.target.ExportContext.Sources.Count == sourceInformationCollection.Count)
                        {
                            using (IEnumerator <ISource> enumerator = this.target.ExportContext.Sources.GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    ISource source = enumerator.Current;
                                    try
                                    {
                                        SourceInformation sourceInformation = sourceInformationCollection[source.Id];
                                        if (sourceInformation.Configuration.Name != source.Name || sourceInformation.Configuration.SourceFilter != source.SourceFilter || sourceInformation.Configuration.LegacyExchangeDN != source.LegacyExchangeDN)
                                        {
                                            Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Configuration changed for source '{0}'", new object[]
                                            {
                                                source.Id
                                            });
                                            flag = true;
                                            break;
                                        }
                                    }
                                    catch (KeyNotFoundException)
                                    {
                                        Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Configuration changed(new source detected) for source '{0}'", new object[]
                                        {
                                            source.Id
                                        });
                                        flag = true;
                                        break;
                                    }
                                }
                                goto IL_37E;
                            }
                        }
                        Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Configuration changed(source count doesn't match). Original source count: {0}; New source count: {1}", new object[]
                        {
                            sourceInformationCollection.Count,
                            this.target.ExportContext.Sources.Count
                        });
                        flag = true;
IL_37E:
                        if (flag)
                        {
                            throw new ExportException(ExportErrorType.CannotResumeWithConfigurationChange);
                        }
                        this.AllSourceInformation = sourceInformationCollection;
                        this.CurrentStatus        = currentStatus;
                        if (StatusManager.IsTransientStatus(this.CurrentStatus))
                        {
                            Tracer.TraceInformation("StatusManager.EnsureStatusLogValid: Recovering on status: {0}", new object[]
                            {
                                this.CurrentStatus
                            });
                            this.Recover();
                        }
                    }
                    this.target.CheckInitialStatus(this.AllSourceInformation, this.CurrentStatus);
                }
                catch (Exception ex)
                {
                    Tracer.TraceError("StatusManager.EnsureStatusLogValid: Exception happend, closing status log. Exception: {0}", new object[]
                    {
                        ex
                    });
                    this.CloseStatusLog();
                    throw;
                }
            }
        }
コード例 #9
0
ファイル: DataContext.cs プロジェクト: YHZX2013/exchange_diff
 public DataContext(SourceInformation sourceInformation, IItemIdList itemIdList)
 {
     this.sourceInformation = sourceInformation;
     this.ItemIdList        = itemIdList;
 }