public string getStream() { try { if (_StreamclientChecked) { return(_Streamclient); } _StreamclientChecked = true; P4ScmProvider scm = P4VsProvider.CurrentScm; if (scm.Connection.Disconnected) { _Streamclient = null; return(_Streamclient); } P4.Client current = scm.getClient(scm.Connection.Workspace.ToString(), null); if (current.Stream != null) { _Streamclient = current.Stream; return(_Streamclient); } } catch (Exception ex) { logger.Trace("Error in P4Vversion(), {0}: \r\n{1}", ex.Message, ex.StackTrace); } _Streamclient = null; return(_Streamclient); }
public static P4.Repository get(String Port, String User, String Workspace) { // Verify Paramiters if (string.IsNullOrEmpty(Port)) { throw new P4.P4Exception(P4.ErrorSeverity.E_FATAL, "P4PORT is invalid or not set"); } // Set connection options P4.Options options = new P4.Options(); options["ProgramName"] = "P4VS"; options["ProgramVersion"] = Versions.product(); // Get Server connection P4.Server server = new P4.Server(new P4.ServerAddress(Port)); // Create new Repository Repository = new P4.Repository(server); // set User if (!string.IsNullOrEmpty(User)) { Repository.Connection.UserName = User; } // set Client if (!string.IsNullOrEmpty(Workspace)) { P4.Client client = new P4.Client(); client.Name = Workspace; Repository.Connection.Client = client; } // Connect... try { logger.Debug("AsyncConnectToRepository - Connect"); bool connectResults = Repository.Connection.Connect(options); logger.Debug("AsyncConnectToRepository, result {0}", connectResults); } catch (P4.P4Exception ex) { // Look for trust errors checkTrust(ex); } // Set Command Timeout limits TimeSpan defCmdTimeout = TimeSpan.FromSeconds(30); TimeSpan cmdTimeout = Preferences.LocalSettings.GetTimeSpan("CommandTimeOut", defCmdTimeout); Repository.Connection.CommandTimeout = cmdTimeout; return(Repository); }
private void path1BrowseBtn_Click(object sender, EventArgs e) { if (specifier1stCB.SelectedIndex == 1) // changelist { string path = path1TB.Text; SubmittedChangelistsBrowserDlg dlg = new SubmittedChangelistsBrowserDlg(_scm, "diff_" + path); if (DialogResult.Cancel != dlg.ShowDialog()) { _changelistToAdd = dlg.SelectedChangelist; if (_changelistToAdd != null) { Text = _changelistToAdd.Id.ToString(); } } } if (specifier1stCB.SelectedIndex == 3) // label { LabelsBrowserDlg dlg = new LabelsBrowserDlg(); if (DialogResult.OK == dlg.ShowDialog(this)) { P4.Label label = dlg.Label; if (label != null) { path1ValueTB.Text = label.Id; } } } if (specifier1stCB.SelectedIndex == 4) // workspace { WorkspacesBrowserDlg dlg = new WorkspacesBrowserDlg(_scm, "diff_against", null, null); if (DialogResult.Cancel != dlg.ShowDialog()) { _workspaceToAdd = dlg.SelectedWorkspace; if (_workspaceToAdd != null) { path1ValueTB.Text = _workspaceToAdd.Name.ToString(); } } } }
public static P4.Client EditWorkspace(P4ScmProvider scm, P4.Client workspace) { P4.Client updatedClient = null; while (updatedClient == null) { P4.Client editedWorkspace = DlgEditWorkspace.Show(scm, workspace); if (editedWorkspace != null) { try { updatedClient = scm.createClient(workspace, null); // if the current client is being updated, update the connection with the changed client if (updatedClient != null) { if ((scm != null) && (scm.Connection.Repository != null) && (scm.Connection.Repository.Connection != null)) { if ((scm.Connection.Repository.Connection.Client == null) || (updatedClient.Name == scm.Connection.Repository.Connection.Client.Name)) { scm.Connection.Repository.Connection.Client = updatedClient; } } return(updatedClient); } } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.PerforceSCM, MessageBoxButtons.OK); } } else { updatedClient = new P4.Client(); return(null); } } return(updatedClient); }
private void NewWorkspaceBtn_Click(object sender, EventArgs e) { this.TopMost = false; P4ScmProvider _scm = new P4ScmProvider(null); _scm.Connection.Port = ServerPort; _scm.Connection.User = UserName; _scm.Connection.Connect(true, null, true); if (_scm.Connected && _scm.Connection.isLoggedIn()) { P4.Client workspace = null; P4.Client clientInfo = new P4.Client(); string newName = GetStringDlg.Show(Resources.OpenConnectionDlg_NewWorkspaceDlgTitle, Resources.OpenConnectionDlg_NewWorkspaceDlgPrompt, null); if ((newName != null) && (newName != string.Empty)) { if (newName.Contains(" ")) { MessageBox.Show(Resources.OpenConnectionDlg_NameContainsSpacesWarning, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); } IList <P4.Client> checkExisting = _scm.getClients(P4.ClientsCmdFlags.None, null, newName, 1, null); if (checkExisting == null) { clientInfo = _scm.getClient(newName, null); if (clientInfo != null) { // adjust root here based on users dir string root = Environment.GetFolderPath(Environment.SpecialFolder.Personal); int idx = root.LastIndexOf(@"\"); root = root.Remove(idx + 1); root += newName; clientInfo.Root = root; workspace = DlgEditWorkspace.EditWorkspace(_scm, clientInfo); } } else { MessageBox.Show(string.Format(Resources.OpenConnectionDlg_WorkspaceExistsWarning, newName), Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); NewWorkspaceBtn_Click(null, null); } } else { if (newName == string.Empty) { MessageBox.Show(Resources.OpenConnectionDlg_EmptyWorkspaceNameWarning, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); NewWorkspaceBtn_Click(null, null); } } if (workspace != null) { WorkspaceTB.Text = workspace.Name; } } this.TopMost = true; }
public static P4.Client Show(P4ScmProvider scm, P4.Client workspace) { if (workspace == null) { return(null); } DlgEditWorkspace dlg = new DlgEditWorkspace(); if (dlg.DialogResult == DialogResult.Cancel) { return(null); } dlg.Text = string.Format(Resources.DlgEditWorkspace_Title, workspace.Name, scm.Connection.Port, scm.Connection.User); dlg.workspaceFormNameTB.Text = workspace.Name; if (Preferences.LocalSettings.GetBool("P4Date_format", true)) { dlg.workspaceUpdatedFormTB.Text = workspace.Updated.ToString("yyyy/MM/dd HH:mm:ss"); dlg.workspaceLastAccessedFormTB.Text = workspace.Accessed.ToString("yyyy/MM/dd HH:mm:ss"); } else { dlg.workspaceUpdatedFormTB.Text = workspace.Updated.ToString(); dlg.workspaceLastAccessedFormTB.Text = workspace.Accessed.ToString(); } if (workspace.Updated == DateTime.MinValue) { dlg.workspaceUpdatedFormTB.Text = string.Empty; } if (workspace.Accessed == DateTime.MinValue) { dlg.workspaceLastAccessedFormTB.Text = string.Empty; } dlg.workspaceOwnerNameFormTB.Text = workspace.OwnerName; if (workspace.Description != null) { dlg.workspaceDescriptionFormRTB.Text = workspace.Description; } dlg.workspaceRootFormTB.Text = workspace.Root; if (workspace.AltRoots != null) { foreach (string altRoot in workspace.AltRoots) { dlg.workspaceAltRootsFormRTB.AppendText(altRoot + "\r\n"); } } if (workspace.Host != null) { dlg.hostFormTB.Text = workspace.Host; } string selectedOpts = workspace.SubmitOptions; dlg.submitOptionsFormCB.Text = selectedOpts; string selectedLineEnd = workspace.LineEnd.ToString(); dlg.lineEndingsFormCB.Text = selectedLineEnd; dlg.workspaceStreamRootFormTB.Enabled = false; dlg.workspacesStreamAtChangeFormTB.Enabled = false; dlg.workspacesServerIDFormTB.Enabled = false; // try to populate the spec with existing entries if (workspace.Stream != null) { dlg.workspaceStreamRootFormTB.Text = workspace.Stream; dlg.workspaceStreamRootFormTB.Enabled = true; } if (workspace.StreamAtChange != null) { dlg.workspacesStreamAtChangeFormTB.Text = workspace.StreamAtChange; dlg.workspacesStreamAtChangeFormTB.Enabled = true; } if (workspace.ServerID != null) { dlg.workspacesServerIDFormTB.Text = workspace.ServerID; dlg.workspacesServerIDFormTB.Enabled = true; } List <KeyValuePair <string, string> > clientSpec = scm.GetClientSpec(); if (clientSpec != null) { foreach (var pair in clientSpec) { if (pair.Key.Contains("Values2")) { dlg.lineEndingsFormCB.Items.Clear(); string lineEnds = pair.Value; lineEnds = lineEnds.Remove(0, lineEnds.LastIndexOf(" ") + 1); string[] lineEndsArray = lineEnds.Split('/'); foreach (string lineEnd in lineEndsArray) { dlg.lineEndingsFormCB.Items.Add(lineEnd); } selectedLineEnd = workspace.LineEnd.ToString(); dlg.lineEndingsFormCB.Text = selectedLineEnd; } if (pair.Value.Contains("Stream line 64 optional")) { dlg.workspaceStreamRootFormTB.Text = workspace.Stream; dlg.workspaceStreamRootFormTB.Enabled = true; } if (pair.Value.Contains("StreamAtChange line 64 optional")) { dlg.workspacesStreamAtChangeFormTB.Text = workspace.StreamAtChange; dlg.workspacesStreamAtChangeFormTB.Enabled = true; } if (pair.Value.Contains("ServerID line 64 always")) { dlg.workspacesServerIDFormTB.Text = workspace.ServerID; dlg.workspacesServerIDFormTB.Enabled = true; } } } if (workspace.ViewMap != null) { dlg.workspaceViewMapFormRTB.Text = workspace.ViewMap.ToString(); } dlg.allwriteFormChk.Checked = ((workspace.Options & P4.ClientOption.AllWrite) != 0); dlg.clobberFormChk.Checked = ((workspace.Options & P4.ClientOption.Clobber) != 0); dlg.compressFormChk.Checked = ((workspace.Options & P4.ClientOption.Compress) != 0); dlg.lockedFormChk.Checked = ((workspace.Options & P4.ClientOption.Locked) != 0); dlg.modtimeFormChk.Checked = ((workspace.Options & P4.ClientOption.ModTime) != 0); dlg.rmdirFormChk.Checked = ((workspace.Options & P4.ClientOption.RmDir) != 0); if (dlg.ShowDialog() != DialogResult.Cancel) { if (dlg.DialogResult == DialogResult.OK) { workspace.Name = dlg.workspaceFormNameTB.Text; //workspace.Updated.ToShortDateString() = dlg.workspaceUpdatedFormTB.Text; //workspace.Accessed.ToShortDateString() = dlg.workspaceLastAccessedFormTB.Text; workspace.OwnerName = dlg.workspaceOwnerNameFormTB.Text; workspace.Description = dlg.workspaceDescriptionFormRTB.Text; workspace.Root = dlg.workspaceRootFormTB.Text; string[] alt = Regex.Split(dlg.workspaceAltRootsFormRTB.Text, "\r\n"); workspace.AltRoots = alt.ToList(); workspace.Host = dlg.hostFormTB.Text; workspace.SubmitOptions = dlg.submitOptionsFormCB.Text; workspace.LineEnd = (P4.LineEnd)Enum.Parse(typeof(P4.LineEnd), dlg.lineEndingsFormCB.Text, true); string mapLines = dlg.workspaceViewMapFormRTB.Text.Trim(); List <string> map = new List <string>(mapLines.Split('\n')); if (clientSpec != null) { foreach (var pair in clientSpec) { if (pair.Value.Contains("Stream line 64 optional")) { workspace.Stream = dlg.workspaceStreamRootFormTB.Text; } if (pair.Value.Contains("StreamAtChange line 64 optional")) { workspace.StreamAtChange = dlg.workspacesStreamAtChangeFormTB.Text; } if (pair.Value.Contains("ServerID line 64 always")) { workspace.ServerID = dlg.workspacesServerIDFormTB.Text; } } } P4.ViewMap vm = new P4.ViewMap(map); workspace.ViewMap = vm; workspace.Options = P4.ClientOption.None; if (dlg.allwriteFormChk.Checked) { workspace.Options |= P4.ClientOption.AllWrite; } if (dlg.clobberFormChk.Checked) { workspace.Options |= P4.ClientOption.Clobber; } if (dlg.compressFormChk.Checked) { workspace.Options |= P4.ClientOption.Compress; } if (dlg.lockedFormChk.Checked) { workspace.Options |= P4.ClientOption.Locked; } if (dlg.modtimeFormChk.Checked) { workspace.Options |= P4.ClientOption.ModTime; } if (dlg.rmdirFormChk.Checked) { workspace.Options |= P4.ClientOption.RmDir; } return(workspace); } if (dlg.DialogResult == DialogResult.OK) { return(workspace); } } return(null); }
public static P4.Client EditWorkspace(P4ScmProvider scm, string workspaceName, P4.Options options) { P4.Client workspace = scm.getClient(workspaceName, options); return(EditWorkspace(scm, workspace)); }
public static P4.Client EditWorkspace(P4ScmProvider scm, string workspaceName) { P4.Client workspace = scm.getClient(workspaceName, null); return(EditWorkspace(scm, workspace)); }