Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
 private void LoadQueued()
 {
     lock (m_lockObject)
     {
         if (m_queuedView != null && !m_worker.IsBusy)
         {
             ClearCaseViewViewModel nextView = m_queuedView;
             m_queuedView = null;
             Debug.WriteLine("Loading view: " + nextView.TagName);
             m_worker.RunWorkerAsync(nextView);
         }
     }
 }
Ejemplo n.º 3
0
 public void QueueLoad(ClearCaseViewViewModel view)
 {
     lock (m_lockObject)
     {
         m_queuedView = view;
         Debug.WriteLine("Queueing view: " + m_queuedView.TagName);
         if (!m_worker.IsBusy)
         {
             Debug.WriteLine("Timer started: " + m_queuedView.TagName);
             m_timer.Stop();
             m_timer.Start();
         }
     }
 }
Ejemplo n.º 4
0
        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;
                }
            }
        }