private bool DoSync(IEnumerable <IResource> resources) { if (!CanUseSourceControl) { return(false); } using (new ProgressBarWrapper("Syncing...")) { foreach (var resource in resources) { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Syncing: {1}", SourceControlText, GetUriRelPath(resource)); if (!SourceControlService.IsSynched(resource.Uri)) { SourceControlService.GetLatestVersion(resource.Uri); } } } return(true); }
private bool DoCheckOut(IEnumerable <IResource> resources) { if (!CanUseSourceControl) { return(false); } var lstNeedResolves = new List <IResource>(); using (new ProgressBarWrapper("Checking out...")) { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Refreshing {1} item(s)...", SourceControlText, resources.Count()); SourceControlService.RefreshStatus(resources.Select(r => r.Uri)); foreach (var resource in resources) { if (!SourceControlService.IsSynched(resource.Uri)) { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Need user resolution: {1}", SourceControlText, GetUriRelPath(resource)); lstNeedResolves.Add(resource); } else { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Checking out: {1}", SourceControlText, GetUriRelPath(resource)); SourceControlService.CheckOut(resource.Uri); } } } if (lstNeedResolves.Count <= 0) { return(true); } foreach (var resource in lstNeedResolves) { using (var dialog = new SledSourceControlResolutionForm()) { // Default action var choice = SledSourceControlResolutionForm.UserChoice.EditCurrent; dialog.Uri = resource.Uri; if (dialog.ShowDialog(m_mainForm) == DialogResult.OK) { choice = dialog.Choice; } // Do something based off of choice switch (choice) { case SledSourceControlResolutionForm.UserChoice.EditCurrent: { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Checking out: {1}", SourceControlText, GetUriRelPath(resource)); SourceControlService.CheckOut(resource.Uri); } break; case SledSourceControlResolutionForm.UserChoice.GetLatest: DoSync(new[] { resource }); break; } } } return(true); }