Esempio n. 1
0
        private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            if (e.ColumnIndex == 5)
            {
                var jobDataInfo = dataGridView1.Rows[e.RowIndex].DataBoundItem as JobDataInfo;
                if (jobDataInfo.FinishedAt == null || jobDataInfo.AddedFrom != _clientName)
                {
                    return;
                }

                var logsF = new LogsF();
                logsF.SetTitle("Build job logs");
                logsF.SetLogs(string.Join(Environment.NewLine, jobDataInfo.Log));
                logsF.ShowDialog();
            }
            else if (e.ColumnIndex == 6)
            {
                var jobDataInfo = dataGridView1.Rows[e.RowIndex].DataBoundItem as JobDataInfo;
                if (jobDataInfo.FinishedAt == null || jobDataInfo.Status != JobDataInfoType.Success || jobDataInfo.AddedFrom != _clientName)
                {
                    return;
                }

                SendToServerCommand(new CopyToPatchesFolderCommand(jobDataInfo.Solution));
            }
        }
Esempio n. 2
0
        public void SendToClientCommand(CommandData data)
        {
            switch (data.Command)
            {
            case CommandsIndex.PONG:
                var silentPong = Convert.ToBoolean(data.Payload);
                if (!silentPong)
                {
                    MessageBox.Show("Pong");
                }
                break;

            case CommandsIndex.DROP_CLIENT_CONNECTION:
                _loginF.RegisterClient();
                break;

            case CommandsIndex.CLIENT_REGISTER_OK:
                _loginF.DialogResult = DialogResult.OK;
                var clientRegistration = new JavaScriptSerializer().Deserialize <ClientRegistration>(data.Payload);
                _clientName = clientRegistration.ClientName;
                menuConnectionStatus.Text = $"{MENU_CONNECTION_STATUS} - {_clientName}";
                Text = $"{TITLE} - {clientRegistration.ServerName}";
                _pingTimer.Start();
                break;

            case CommandsIndex.CLIENT_NAME_EXISTS:
                _loginF.EnableControls();
                MessageBox.Show("Client name already exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case CommandsIndex.GET_SOLUTIONS:
                var solutionInfo = new JavaScriptSerializer {
                    MaxJsonLength = int.MaxValue
                }.Deserialize <SolutionInfo>(data.Payload);
                FillTreeSolutions(solutionInfo);
                break;

            case CommandsIndex.GET_JOBS:
            {
                var jobs = new JavaScriptSerializer {
                    MaxJsonLength = int.MaxValue
                }.Deserialize <List <BuildResult> >(data.Payload);
                RefreshJobs(jobs);
            }
            break;

            case CommandsIndex.JOB_STATUS:
            {
                var jobStatus = new JavaScriptSerializer().Deserialize <JobStatus>(data.Payload);
                var job       = (_jobsBs.DataSource as List <JobDataInfo>).Find(p => p.JobID == jobStatus.JobID.ToString());
                if (job != null)
                {
                    job.Status = JobDataInfoType.BuildStarted;
                    dataGridView1.Refresh();
                }
            }
            break;

            case CommandsIndex.COPY_TO_PATCHES_FOLDER_RESULT:
                var logsF = new LogsF();
                logsF.SetTitle("Copy to patches folder");
                logsF.SetLogs(data.Payload);
                logsF.ShowDialog();
                break;
            }
        }