P4.NET - How to specify user workspaces?

I am not an expert in the P4.NET plugin, but I would like to show the existing workspaces for the user in the combo box so that I can install p4.Client in the selected workspace.

using (var p4 = new P4Connection())
            {
                p4.Connect();
                ???               
            }

How to get a list of existing workspaces? I think that to achieve this command line there will be

p4 clients -m 100 -u username
+3
source share
3 answers

Well, I have no choice but to answer my own question, because the code will be too much to embed as comments in the jhwist answer. Sorry jhwist. I had no choice.

@appinger, hope you find this answer helpful. Took me time to understand that this works. :)

cmbBoxPerforceWorkspaceLocation - combobox . , Winforms.

Windows. Windows xxxx\\ . longname shortname. ​​-, , , .

, .

using (var p4 = new P4Connection())
            {
                p4.Connect();
                var longName = WindowsIdentity.GetCurrent().Name;
                var shortname = longName.Substring(longName.IndexOf("\\") + 1);
                var records = p4.Run("clients", "-u", shortname);

                cmbBoxPerforceWorkspaceLocation.Items.Clear();

                foreach (P4Record record in records.Records)
                {
                    cmbBoxPerforceWorkspaceLocation.Items.Add(record["client"]);
                }
            }
+2

P4.Net API Perforce, , , :

p4.Run("clients", "-m 100 -u username")

. P4Ruby.

+4

P4.Net is designed to look like scripting APIs, which in turn are designed around a command line interface. It definitely does not have an intuitive object-oriented interface ... which is turned off first. But if you start from the command line (esp -ztag flag) and combine all the data / actions your application needs, it will be pretty easy for you to use P4.Net. And since it is similar to all scripting APIs, you will find it natural to pick Python or Ruby if you want :-)

0
source

Source: https://habr.com/ru/post/1795718/


All Articles