/// <summary>Get Perforce Connection details from Config file or Environment</summary> /// <param name="path">Path to P4CONFIG file</param> private void getConfiguration(string path) { string msg; if ((Port == null) && (User == null) && (Workspace == null)) { try { P4.P4Server sslCheck = new P4.P4Server(path); } catch (P4Exception ex) { if (ex.ErrorCode == P4.P4ClientError.MsgRpc_HostKeyUnknown) { string[] message = ex.Message.Split('\''); string port = "ssl:" + message[1]; RepositoryFactory.get(port, null, null); } } using (P4.P4Server ps = new P4.P4Server(path)) { Port = ps.Port; User = ps.User; Workspace = ps.Client; string config = ps.Config; if ((string.IsNullOrEmpty(config) == false) && (config != "noconfig")) { // api is using a config file msg = String.Format(Resources.P4ScmProvider_UsingConfigSettingsToConnect, Port, User, Workspace, config); } else { msg = String.Format(Resources.P4ScmProvider_UsingEnvironmentSettingsToConnect, Port, User, Workspace); } } } else { msg = String.Format(Resources.P4ScmProvider_ConnectingToPerforceServer, Port, User, Workspace); } // Log configuration settings P4VsOutputWindow.AppendMessage(msg); logger.Trace("scm ID:{0}", ID); FileLogger.LogMessage(3, "P4API.NET", msg); }
public bool StartQueryCancel(P4.P4Server server, uint cmdId, Thread runCmdThread, string cmdLine) { EnvDTE.DTE dte = P4VsProvider.GetDTE(); try { const int _maxChars = 77; //int progressCnt = 0; string progressMsg = string.Format("P4 {0}", cmdLine); if (progressMsg.Length > _maxChars) { progressMsg = string.Format("{0}...", progressMsg.Substring(0, _maxChars)); } if (dte != null) { dte.StatusBar.Text = progressMsg; //dte.StatusBar.Progress(true, progressMsg, progressCnt, 10); dte.StatusBar.Animate(true, EnvDTE.vsStatusAnimation.vsStatusAnimationSync); } CmdMap[cmdId] = CommandState.Running; SvrMap[cmdId] = server; DateTime start = DateTime.Now; // if on the UI thread only wait a millisecond to keep the UI alive while (runCmdThread.IsAlive && (CmdMap[cmdId] == CommandState.Running)) { Application.DoEvents(); } return(CmdMap[cmdId] == CommandState.Canceled); } catch (Exception ex) { logger.Trace(ex.Message); } finally { CmdMap.Remove(cmdId); SvrMap.Remove(cmdId); if (dte != null) { dte.StatusBar.Clear(); //dte.StatusBar.Progress(false); dte.StatusBar.Animate(false, EnvDTE.vsStatusAnimation.vsStatusAnimationSync); } } return(false); }