/// <summary> /// Constructs an instance. /// </summary> /// <param name="mode"></param> /// <param name="trackProgress"></param> /// <param name="cancellationToken"></param> internal TrackProgressParameters(TrackProgressMode mode, ITrackProgress trackProgress, CancellationToken cancellationToken) { if (trackProgress == null) { throw new ArgumentNullException("trackProgress"); } TrackProgressMode = mode; TrackProgress = trackProgress; CancellationToken = cancellationToken; }
internal WaitForBackgroundActionDialog(ITrackProgress progressTracker, CancellationTokenSource cancelToken, Task task) { InitializeComponent(); ProgressTracker = progressTracker; CancelToken = cancelToken; Task = task; Timer = new DispatcherTimer(DispatcherPriority.Render); Timer.Interval = TimeSpan.FromMilliseconds(50); Timer.Tick += TimerTick; Timer.Start(); this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; }
/// <summary> /// Removes a progress reporter from the collection of reporters /// that are being tracked. /// </summary> /// <param name="reporterToRemove">The reporter.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="reporterToRemove"/> is <see langword="null" />. /// </exception> public void RemoveReporter(ITrackProgress reporterToRemove) { { Lokad.Enforce.Argument(() => reporterToRemove); } lock (m_Lock) { if (!m_ReporterToProgressMap.ContainsKey(reporterToRemove)) { return; } reporterToRemove.OnProgress -= ProcessNewProgress; m_ReporterToProgressMap.Remove(reporterToRemove); } }
/// <summary> /// Adds a progress reporter to the collection of reporters that /// are being tracked. /// </summary> /// <param name="reporterToAdd">The reporter.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="reporterToAdd"/> is <see langword="null" />. /// </exception> public void AddReporter(ITrackProgress reporterToAdd) { { Lokad.Enforce.Argument(() => reporterToAdd); } lock (m_Lock) { if (m_ReporterToProgressMap.ContainsKey(reporterToAdd)) { return; } reporterToAdd.OnStartProgress += ProcessStartProgress; reporterToAdd.OnProgress += ProcessNewProgress; reporterToAdd.OnStopProgress += ProcessStopProgress; m_ReporterToProgressMap.Add(reporterToAdd, new Tuple <int, string, bool>(-1, string.Empty, false)); } }
/// <summary> /// Adds a progress reporter to the collection of reporters that /// are being tracked. /// </summary> /// <param name="reporterToAdd">The reporter.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="reporterToAdd"/> is <see langword="null" />. /// </exception> public void AddReporter(ITrackProgress reporterToAdd) { { Lokad.Enforce.Argument(() => reporterToAdd); } lock (m_Lock) { if (m_ReporterToProgressMap.ContainsKey(reporterToAdd)) { return; } reporterToAdd.OnStartProgress += ProcessStartProgress; reporterToAdd.OnProgress += ProcessNewProgress; reporterToAdd.OnStopProgress += ProcessStopProgress; m_ReporterToProgressMap.Add(reporterToAdd, new Tuple<int, string, bool>(-1, string.Empty, false)); } }
public TrackProgressWithoutIncrementsWrapper(ITrackProgress wrapped) { Wrapped = wrapped; }
public IEnumerable <TfsChangesetWrapper> QueryChangesets(IEnumerable <TfsWorkItemWrapper> workItems, ITrackProgress trackProgress, CancellationToken cancelled = default(CancellationToken)) { var results = new System.Collections.Concurrent.ConcurrentBag <TfsChangesetWrapper>(); Parallel.ForEach(workItems, (workItem, state) => { if (Repository.Instance.TfsConnectionInfo.Uri == null) { state.Stop(); return; } if (cancelled.IsCancellationRequested) { state.Stop(); return; } trackProgress.Increment(); foreach (var changeset in workItem.RelatedChangesets) { trackProgress.ProgressInfo = String.Format("Processing work item #{0} ({1} related changesets)", workItem.TfsWorkItem.Id, workItem.RelatedChangesetCount); results.Add(UpdateChangesetFromCache(new TfsChangesetWrapper(changeset))); } }); cancelled.ThrowIfCancellationRequested(); var resultList = results .GroupBy(item => item.TfsChangeset.Changeset.ChangesetId) .Select(item => item.First()); return(resultList.ToList().AsEnumerable()); }
public IEnumerable <TfsWorkItemWrapper> QueryWorkItems(IEnumerable <TfsChangesetWrapper> changesets, ITrackProgress trackProgress, CancellationToken cancelled = default(CancellationToken)) { var results = new System.Collections.Concurrent.ConcurrentBag <TfsWorkItemWrapper>(); Parallel.ForEach(changesets, (changeset, state) => { if (Repository.Instance.TfsConnectionInfo.Uri == null) { state.Stop(); return; } if (cancelled.IsCancellationRequested) { state.Stop(); return; } foreach (var workItem in changeset.TfsChangeset.RelatedWorkItems) { results.Add(UpdateWorkItemFromCache(new TfsWorkItemWrapper(workItem))); } trackProgress.Increment(); }); cancelled.ThrowIfCancellationRequested(); var resultList = results .GroupBy(item => item.TfsWorkItem.Id) .Select(item => item.First()); return(resultList.ToList().AsEnumerable()); }
/// <summary> /// Removes a progress reporter from the collection of reporters /// that are being tracked. /// </summary> /// <param name="reporterToRemove">The reporter.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="reporterToRemove"/> is <see langword="null" />. /// </exception> public void RemoveReporter(ITrackProgress reporterToRemove) { { Lokad.Enforce.Argument(() => reporterToRemove); } lock (m_Lock) { if (!m_ReporterToProgressMap.ContainsKey(reporterToRemove)) { return; } reporterToRemove.OnProgress -= ProcessNewProgress; m_ReporterToProgressMap.Remove(reporterToRemove); } }
public bool Merge(ITfsBranch targetBranch, string pathFilter, IEnumerable <ITfsChangeset> changesetsAsEnumerable, ITrackProgress trackProgress = null) { SimpleLogger.Checkpoint("Merge: {0}, {1}", targetBranch != null ? targetBranch.Name : null, pathFilter); if (pathFilter != null && !SourceBranch.Name.StartsWith(pathFilter, StringComparison.InvariantCultureIgnoreCase)) { throw new ArgumentException("If a PathFilter is provided, it needs to be below the SourceBranch"); } var changesets = new List <ITfsChangeset>(changesetsAsEnumerable); var files = new List <string>(); if (trackProgress != null) { trackProgress.MaxProgress = changesets.Count * 2 + 2; trackProgress.CurrentProgress = 0; trackProgress.ProgressInfo = "Acquiring file list ..."; } foreach (var changeset in changesets) { SimpleLogger.Checkpoint("Merge: Processing changeset #{0}", changeset != null ? changeset.Changeset.ChangesetId : -1); foreach (var change in changeset.Changes.Select(c => c.Change)) { SimpleLogger.Checkpoint("Merge: change {0}, filter {1}", change.Item.ServerItem, pathFilter); if (pathFilter != null && change.Item.ServerItem.StartsWith(pathFilter, StringComparison.InvariantCultureIgnoreCase) == false) { continue; } files.Add(change.Item.ServerItem); } ++trackProgress.CurrentProgress; } GetRequest[] getRequests = files.Distinct().Select(file => new GetRequest(file, RecursionType.None, VersionSpec.Latest)).ToArray(); if (trackProgress != null) { trackProgress.ProgressInfo = "Getting files ..."; ++trackProgress.CurrentProgress; } SimpleLogger.Checkpoint("Merge: Getting files"); GetStatus gs = TfsWorkspace.Get(getRequests, GetOptions.None); if (trackProgress != null) { trackProgress.ProgressInfo = "Performing merges ..."; ++trackProgress.CurrentProgress; } var resultingConflicts = new List <ITfsMergeConflict>(); foreach (var changeset in changesets) { if (trackProgress != null) { ++trackProgress.CurrentProgress; } var csvs = new ChangesetVersionSpec(changeset.Changeset.ChangesetId); SimpleLogger.Checkpoint("Merge: Performing merge on CS# {0}", changeset != null ? changeset.Changeset.ChangesetId : -1); var mergeResult = TfsWorkspace.Merge( pathFilter ?? SourceBranch.Name, targetBranch.Name, csvs, csvs, LockLevel.None, RecursionType.Full, MergeOptions.ForceMerge); if (mergeResult.NumFailures > 0) { foreach (var failure in mergeResult.GetFailures()) { if (failure.Code == "TF14078" || failure.Message.Contains("TF14078")) { throw new LocalPathTooLongException(failure.Message); } throw new InvalidOperationException(failure.Message); } } } if (trackProgress != null) { trackProgress.CurrentProgress = trackProgress.MaxProgress; } SimpleLogger.Checkpoint("Merge: Refreshing conflicts"); RefreshConflictsWorker(default(CancellationToken)); SimpleLogger.Checkpoint("Merge: Finished"); return(Conflicts.Count != 0); }