Exemple #1
0
        protected override void Dispose(bool disposing)
        {
            logger.Trace("Entering Dispose() of: {0}", this.ToString());

            SccService.Dispose();

            base.Dispose(disposing);
        }
Exemple #2
0
        // Used to open a connection to a Perforce depot
        public void OpenConnection(string Port, string User, string Workspace)
        {
#if DB_DEBUG
            P4VsOutputWindow.AppendMessage(string.Format("Opening connection, CurrentScm scm ID:{0}",
                                                         CurrentScm != null?CurrentScm.__Id:-1));
#endif

            P4ScmProvider scm = new P4ScmProvider(SccService);
            scm.LoadingSolution = !string.IsNullOrEmpty(SccService.LoadingControlledSolutionLocation);

#if DB_DEBUG
            P4VsOutputWindow.AppendMessage(string.Format("Opening connection, new scm ID:{0}", scm.__Id));
#endif
            bool noUi = InCommandLineMode() || (Port != null) && (User != null) && (Workspace != null);

            // trigger the connection dialog
            scm.Connection.Connect(Port, User, Workspace, noUi, null);
            if (scm.Connected)
            {
#if DB_DEBUG
                P4VsOutputWindow.AppendMessage(string.Format("Opening connection user clicked OK, new scm ID:{0}", scm.__Id));
#endif
                if (SccService.ScmProvider != null)
                {
                    BroadcastNewConnection(null);
                    SccService.Dispose();
                    SccService.ScmProvider = null;
                }
                SccService.ScmProvider = scm;

                createActiveChangelists(SccService);

                if (string.IsNullOrEmpty(SccService.ScmProvider.SolutionFile))
                {
                    string solutionFile = GetSolutionFileName();
                    if (string.IsNullOrEmpty(solutionFile) == false)
                    {
                        SccService.ScmProvider.SolutionFile = GetSolutionFileName();

                        if (Preferences.LocalSettings.GetBool("TagSolutionProjectFiles", false))
                        {
                            // Need to tag sln file if tagging is enabled, so mark dirty props so
                            // it'll get tagged
                            SolutionHasDirtyProps = true;
                        }
                    }

                    if (!SccService.IsProjectControlled(null))
                    {
                        SccService.OnAfterOpenSolution(null, 0);
                    }
                }
                Cursor oldCursor = Cursor.Current;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    // now refresh the selected nodes' glyphs
                    if (Preferences.LocalSettings.GetBool("LazyLoadStatus", false) == false)
                    {
                        Glyphs.RefreshNodesGlyphs(null, null);
                    }
                }
                finally
                {
                    Cursor.Current = oldCursor;
                }

                BroadcastNewConnection(SccService.ScmProvider);

                MRUList recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"];
                currentConnectionDropDownComboChoice = recentConnections[0].ToString();

                SuppressConnection            = true;
                LastConnectionInfo            = new ConnectionData();
                LastConnectionInfo.ServerPort = SccService.ScmProvider.Connection.Port;
                LastConnectionInfo.UserName   = SccService.ScmProvider.Connection.User;
                LastConnectionInfo.Workspace  = SccService.ScmProvider.Connection.Workspace;

#if _DBB_DEBUG
                // How to set a setting for the ide (Generally from tool/options dialog)
                // The category and page values are listed on MSDN at:
                // http://msdn.microsoft.com/en-us/library/ms165643(v=vs.100).aspx
                // The category and pages no longer follow the layout in the options dialog,
                // they seem to still follow the old layout fro VS 2003. There's a general
                // discussion on MSDN about properties here:
                // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.100).aspx
                // and:
                // http://msdn.microsoft.com/en-us/library/awdwz11a(v=vs.100).aspx
                // The Property object is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.property(v=vs.100).aspx
                // The Properties interface is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.properties(v=vs.100).aspx
                try
                {
                    EnvDTE.DTE dte2;
                    dte2 = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
                    EnvDTE.Properties generalPnS = dte2.DTE.Properties["Environment", "ProjectsAndSolution"];

                    EnvDTE.Property prop2 = generalPnS.Item("ProjectsLocation");
                    string          val   = prop2.Value as string;

                    //dynamic v2 = val + "\\temp";
                    prop2.Value = val;

                    val = prop2.Value as string;
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                    MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
#endif
                // How to set a setting for the ide (Generally from tool/options dialog)
                // The category and page values are listed on MSDN at:
                // http://msdn.microsoft.com/en-us/library/ms165643(v=vs.100).aspx
                // The category and pages no longer follow the layout in the options dialog,
                // they seem to still follow the old layout fro VS 2003. There's a general
                // discussion on MSDN about properties here:
                // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.100).aspx
                // and:
                // http://msdn.microsoft.com/en-us/library/awdwz11a(v=vs.100).aspx
                // The Property object is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.property(v=vs.100).aspx
                // The Properties interface is documented here:
                // http://msdn.microsoft.com/en-us/library/envdte.properties(v=vs.100).aspx

                if (Preferences.LocalSettings.GetBool("SetProjectFileLocation", true) &&
                    !string.IsNullOrEmpty(scm.Connection.WorkspaceRoot))
                {
                    try
                    {
                        EnvDTE.Property prop = null;
                        EnvDTE.DTE      dte2;
                        dte2 = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));

                        EnvDTE.Properties generalPnS = dte2.get_Properties("Environment", "ProjectsAndSolution");
                        foreach (EnvDTE.Property temp in generalPnS)
                        {
                            prop = temp;
                            if (prop.Name == "ProjectsLocation")
                            {
                                if (Directory.Exists(scm.Connection.WorkspaceRoot))
                                {
                                    prop.Value = scm.Connection.WorkspaceRoot.Replace("/", "\\");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                        MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
#if DB_DEBUG
            P4VsOutputWindow.AppendMessage(string.Format("Leaving open connection, CurrentScm scm ID:{0}",
                                                         CurrentScm != null ? CurrentScm.__Id : -1));
#endif
        }