void m_worker_DoWork(object sender, DoWorkEventArgs e) { if (e.Argument is ClearCaseViewViewModel) { ClearCaseViewViewModel view = e.Argument as ClearCaseViewViewModel; if (!view.IsLoaded) { view.IsLoading = true; view.ViewType = view.CCView.IsSnapShot ? ClearCaseViewViewModel.ViewTypeEnum.Snapshot : ClearCaseViewViewModel.ViewTypeEnum.Dynamic; if (view.ViewType == ClearCaseViewViewModel.ViewTypeEnum.Snapshot) { view.ParseStoragePaths(s_clearCaseTool.CmdExec("lsview -long " + view.TagName)); } try { view.PrimaryVob = view.CCView.Stream.ProjectVOB.TagName; } catch { view.CanEditVob = true; } view.IsLoaded = true; view.IsLoading = false; } } else { m_worker.ReportProgress(0); ApplicationClass applicationClass = new ApplicationClass(); m_worker.ReportProgress(33); CCViews views = applicationClass.get_Views(true, string.Empty); List <ClearCaseViewViewModel> viewsList = new List <ClearCaseViewViewModel>(); foreach (CCView view in views) { viewsList.Add(new ClearCaseViewViewModel(view, this)); } m_worker.ReportProgress(67); CCVOBs vobs = applicationClass.get_VOBs(true, string.Empty); List <ClearCaseVOBViewModel> vobsList = new List <ClearCaseVOBViewModel>(); foreach (CCVOB vob in vobs) { vobsList.Add(new ClearCaseVOBViewModel(vob)); } m_worker.ReportProgress(100); object[] objs = new object[] { viewsList.OrderBy(x => x.TagName), vobsList.OrderBy(x => x.Name) }; e.Result = objs; } }
void m_worker_DoWork(object sender, DoWorkEventArgs e) { if (e.Argument is ClearCaseViewViewModel) { ClearCaseViewViewModel view = e.Argument as ClearCaseViewViewModel; if (!view.IsLoaded) { view.IsLoading = true; view.ViewType = view.CCView.IsSnapShot ? ClearCaseViewViewModel.ViewTypeEnum.Snapshot : ClearCaseViewViewModel.ViewTypeEnum.Dynamic; if (view.ViewType == ClearCaseViewViewModel.ViewTypeEnum.Snapshot) { view.ParseStoragePaths(s_clearCaseTool.CmdExec("lsview -long " + view.TagName)); } try { view.PrimaryVob = view.CCView.Stream.ProjectVOB.TagName; } catch { view.CanEditVob = true; } view.IsLoaded = true; view.IsLoading = false; } } else { m_worker.ReportProgress(0); ApplicationClass applicationClass = new ApplicationClass(); m_worker.ReportProgress(33); string originalWorkingDirectory = Environment.CurrentDirectory; try { // The call to get_Views sometimes throws a COMException with the message "No view is set, and current working directory is not in a view." // This is a bit of a hack to work-around that unusual ClearCase API behavior: // We wil try to change the CurrentDirectory to any drive that exists and call get_Views() from that directory until it succeeds // If it never succeeds, we'll throw an exception with a message the user should make sure one drive is mapped to a CC view and try again. string[] driveLetters = new string[] { "z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c" }; CCViews views = null; foreach (string driveLetter in driveLetters) { string driveRoot = driveLetter + @":\"; if (Directory.Exists(driveRoot)) { try { Environment.CurrentDirectory = driveRoot; views = applicationClass.get_Views(true, string.Empty); // break out, but stay in the current directory that worked for the call get_VOBs below break; } catch { } } } if (views == null) { throw new MigrationException(Properties.Resources.CCViewsCannotBeListed); } List <ClearCaseViewViewModel> viewsList = new List <ClearCaseViewViewModel>(); foreach (CCView view in views) { viewsList.Add(new ClearCaseViewViewModel(view, this)); } m_worker.ReportProgress(67); CCVOBs vobs = applicationClass.get_VOBs(true, string.Empty); List <ClearCaseVOBViewModel> vobsList = new List <ClearCaseVOBViewModel>(); foreach (CCVOB vob in vobs) { vobsList.Add(new ClearCaseVOBViewModel(vob)); } m_worker.ReportProgress(100); object[] objs = new object[] { viewsList.OrderBy(x => x.TagName), vobsList.OrderBy(x => x.Name) }; e.Result = objs; } finally { Environment.CurrentDirectory = originalWorkingDirectory; } } }