public virtual void LogSuccessfulCompletion() { RTLatencyPoll latencyPoll = RTLatencyPoll.CreateRTLatencyPoll( 0, DateTime.UtcNow, DateTime.UtcNow, 0, 0); // latencyPoll.MigrationSourceReference.Attach(this.RTMigrationSource); latencyPoll.MigrationSource = this.RTMigrationSource; Context.AddToRTLatencyPollSet(latencyPoll); Context.TrySaveChanges(); }
public virtual void Poll() { m_monitorWatcher.LogVerbose(String.Format(CultureInfo.InvariantCulture, MigrationToolkitResources.PollingEndpoint, RTMigrationSource.FriendlyName)); Stopwatch stopWatch = Stopwatch.StartNew(); string lastMigratedChangeName = GetLastMigratedChangeName(); stopWatch.Stop(); m_monitorWatcher.LogVerbose(String.Format(MigrationToolkitResources.TimeForGetLastMigratedChangeName, stopWatch.Elapsed.TotalMilliseconds)); if (string.IsNullOrEmpty(lastMigratedChangeName)) { m_monitorWatcher.LogVerbose(String.Format(CultureInfo.InvariantCulture, MigrationToolkitResources.GetLastMigratedChangeNameReturnedEmpty, RTMigrationSource.FriendlyName)); } else { m_monitorWatcher.LogVerbose(String.Format(MigrationToolkitResources.LastMigratedItemName, lastMigratedChangeName)); DateTime pollTimeUtc = DateTime.UtcNow; Stopwatch stopWatch2 = Stopwatch.StartNew(); ChangeSummary changeSummary = SyncMonitorProvider.GetSummaryOfChangesSince(lastMigratedChangeName, m_filterStrings); stopWatch2.Stop(); m_monitorWatcher.LogVerbose(String.Format(MigrationToolkitResources.TimeForGetSummaryOfChangesSince, stopWatch2.Elapsed.TotalMilliseconds)); TimeSpan latencyTimeSpan = pollTimeUtc - changeSummary.FirstChangeModifiedTimeUtc; if (latencyTimeSpan.TotalSeconds < 0) { latencyTimeSpan = new TimeSpan(0); } if (changeSummary.ChangeCount > 0 && latencyTimeSpan.TotalSeconds > (double)Int32.MaxValue) { // The Latency value is to big to be stored as a 32 bit int and must be wrong; return without storing a LatencyPoll row m_monitorWatcher.LogWarning(String.Format(CultureInfo.InvariantCulture, MigrationToolkitResources.SyncMonitorNotStoringInvalidLatencyPollData, RTMigrationSource.FriendlyName, lastMigratedChangeName)); return; } RTLatencyPoll latencyPoll = RTLatencyPoll.CreateRTLatencyPoll( 0, pollTimeUtc, (changeSummary.ChangeCount == 0) ? DateTime.UtcNow : changeSummary.FirstChangeModifiedTimeUtc, (changeSummary.ChangeCount == 0) ? 0 : Convert.ToInt32(latencyTimeSpan.TotalSeconds), changeSummary.ChangeCount); latencyPoll.LastMigratedChange = lastMigratedChangeName; // latencyPoll.MigrationSourceReference.Attach(this.RTMigrationSource); latencyPoll.MigrationSource = this.RTMigrationSource; Context.AddToRTLatencyPollSet(latencyPoll); Context.TrySaveChanges(); m_monitorWatcher.LogVerbose(String.Format(CultureInfo.InvariantCulture, MigrationToolkitResources.SuccessfullyPolledEndpoint, RTMigrationSource.FriendlyName, latencyPoll.Latency, latencyPoll.BacklogCount)); } }