public static bool ValidateWorkspace(IWin32Window Owner, PerforceConnection Perforce, string WorkspaceName, string StreamName, TextWriter Log, out WorkspaceInfo SelectedWorkspaceInfo)
        {
            ValidateWorkspaceTask ValidateWorkspace = new ValidateWorkspaceTask(WorkspaceName, StreamName);

            string          ErrorMessage;
            ModalTaskResult Result = PerforceModalTask.Execute(Owner, Perforce, ValidateWorkspace, "Checking workspace", "Checking workspace, please wait...", Log, out ErrorMessage);

            if (Result == ModalTaskResult.Failed)
            {
                MessageBox.Show(ErrorMessage);
            }
            else if (Result == ModalTaskResult.Succeeded)
            {
                if (ValidateWorkspace.bRequiresStreamSwitch)
                {
                    string Message;
                    if (ValidateWorkspace.bHasOpenFiles)
                    {
                        Message = String.Format("You have files open for edit in this workspace. If you switch this workspace to {0}, you will not be able to submit them until you switch back.\n\nContinue switching streams?", StreamName);
                    }
                    else
                    {
                        Message = String.Format("Switch this workspace to {0}?", StreamName);
                    }
                    if (MessageBox.Show(Message, "Switch Streams", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        SelectedWorkspaceInfo = null;
                        return(false);
                    }
                }

                SelectedWorkspaceInfo = new WorkspaceInfo()
                {
                    ServerAndPort = ValidateWorkspace.ServerAndPort, UserName = ValidateWorkspace.UserName, WorkspaceName = ValidateWorkspace.WorkspaceName, bRequiresStreamSwitch = ValidateWorkspace.bRequiresStreamSwitch
                };
                return(true);
            }

            SelectedWorkspaceInfo = null;
            return(false);
        }
Esempio n. 2
0
        private void OkBtn_Click(object sender, EventArgs e)
        {
            ValidateWorkspaceTask ValidateWorkspace = new ValidateWorkspaceTask(WorkspaceNameTextBox.Text, StreamName);

            string          ErrorMessage;
            ModalTaskResult Result = PerforceModalTask.Execute(Owner, Perforce, ValidateWorkspace, "Checking workspace", "Checking workspace, please wait...", Log, out ErrorMessage);

            if (Result == ModalTaskResult.Failed)
            {
                MessageBox.Show(ErrorMessage);
            }
            else if (Result == ModalTaskResult.Succeeded)
            {
                if (ValidateWorkspace.bRequiresStreamSwitch)
                {
                    string Message;
                    if (ValidateWorkspace.bHasOpenFiles)
                    {
                        Message = String.Format("You have files open for edit in this workspace. If you switch this workspace to {0}, you will not be able to submit them until you switch back.\n\nContinue switching streams?", StreamName);
                    }
                    else
                    {
                        Message = String.Format("Switch this workspace to {0}?", StreamName);
                    }
                    if (MessageBox.Show(Message, "Switch Streams", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                SelectedWorkspaceInfo = new WorkspaceInfo()
                {
                    ServerAndPort = ValidateWorkspace.ServerAndPort, UserName = ValidateWorkspace.UserName, WorkspaceName = ValidateWorkspace.WorkspaceName, bRequiresStreamSwitch = ValidateWorkspace.bRequiresStreamSwitch
                };

                DialogResult = DialogResult.OK;
                Close();
            }
        }