Exemple #1
0
        private void btnEditStep_Click(object sender, EventArgs e)
        {
            btnEditStep.Enabled = false;
            try
            {
                DataGridViewRow selectedRow = rgvSteps.dataGridView.SelectedRows.OfType <DataGridViewRow>().FirstOrDefault();
                if (selectedRow == null)
                {
                    selectedRow = rgvSteps.dataGridView.SelectedRows.OfType <DataGridViewRow>().FirstOrDefault();
                    if (selectedRow == null)
                    {
                        return;
                    }
                }

                int stepId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
                var viewShedulerStepModel   = rgvSteps.DataSource.OfType <ViewShedulerStepModel>().First(f => f.Id == stepId);
                var stepsGridList           = rgvSteps.DataSource.OfType <ViewShedulerStepModel>().ToList();
                var newEditShedulerStepForm = new NewEditShedulerStepForm(stepsGridList, viewShedulerStepModel);
                newEditShedulerStepForm.ShowDialog();
                if (newEditShedulerStepForm.OutViewShedulerStepModel == null)
                {
                    return;
                }
                var editingStep = stepsGridList.First(f => f.Id == stepId);

                editingStep.OnOperationCompleteStep  = newEditShedulerStepForm.OutViewShedulerStepModel.OnOperationCompleteStep;
                editingStep.OnOperationErrorStep     = newEditShedulerStepForm.OutViewShedulerStepModel.OnOperationErrorStep;
                editingStep.nameVisCountCompleteStep = newEditShedulerStepForm.OutViewShedulerStepModel.nameVisCountCompleteStep;
                editingStep.nameVisCountErrorStep    = newEditShedulerStepForm.OutViewShedulerStepModel.nameVisCountErrorStep;

                stepsGridList.Where(w => w.OnOperationCompleteStep == editingStep.Id)
                .ForEach(f =>
                {
                    f.nameVisCountCompleteStep = $"[{editingStep.Step}] {editingStep.nameVis}";
                });

                stepsGridList.Where(w => w.OnOperationErrorStep == editingStep.Id)
                .ForEach(f =>
                {
                    f.nameVisCountErrorStep = $"[{editingStep.Step}] {editingStep.nameVis}";
                });

                rgvSteps.DataSource = stepsGridList.ToArray();
            }
            finally
            {
                btnEditStep.Enabled = true;
            }
        }
Exemple #2
0
        private void btnNewStep_Click(object sender, EventArgs e)
        {
            btnNewStep.Enabled = false;
            try
            {
                object cbStartStepSelectedValue = cbStartStep.SelectedValue;
                var    stepsGridList            = rgvSteps.DataSource?.OfType <ViewShedulerStepModel>().ToList();
                var    newEditShedulerStepForm  = new NewEditShedulerStepForm(stepsGridList);
                newEditShedulerStepForm.ShowDialog();

                if (newEditShedulerStepForm.OutViewShedulerStepModel == null)
                {
                    return;
                }

                int  newStepId   = -1;
                long newStepStep = 1;

                if (stepsGridList == null)
                {
                    stepsGridList = new List <ViewShedulerStepModel>();
                }

                if (stepsGridList.Count > 0)
                {
                    var lastAddedStep = stepsGridList.OrderBy(o => o.Id).FirstOrDefault(f => f.Id < 0);
                    newStepId = lastAddedStep == null ? -1 : lastAddedStep.Id - 1;

                    var maxStepStep = stepsGridList.OrderByDescending(o => o.Step).FirstOrDefault();
                    newStepStep = maxStepStep.Step.HasValue ? maxStepStep.Step.Value + 1 : 1;
                }

                var newViewShedulerStepModel = new ViewShedulerStepModel
                {
                    Id   = newStepId,
                    Step = newStepStep,
                    OnOperationCompleteStep = newEditShedulerStepForm.OutViewShedulerStepModel.OnOperationCompleteStep,
                    OnOperationErrorStep    = newEditShedulerStepForm.OutViewShedulerStepModel.OnOperationErrorStep,
                    OperationType           = newEditShedulerStepForm.OutViewShedulerStepModel.OperationType,
                    OperationAttributes     = newEditShedulerStepForm.OutViewShedulerStepModel.OperationAttributes,
                    RepeatCount             = newEditShedulerStepForm.OutViewShedulerStepModel.RepeatCount,
                    RepeatTimeout           = newEditShedulerStepForm.OutViewShedulerStepModel.RepeatTimeout,
                    OrderId = newEditShedulerStepForm.OutViewShedulerStepModel.OrderId,
                    TaskId  = newEditShedulerStepForm.OutViewShedulerStepModel.TaskId,
                    OperationCheckIntervalMs = newEditShedulerStepForm.OutViewShedulerStepModel.OperationCheckIntervalMs,
                    nameVis = newEditShedulerStepForm.OutViewShedulerStepModel.nameVis,
                    nameVisCountCompleteStep = newEditShedulerStepForm.OutViewShedulerStepModel.nameVisCountCompleteStep,
                    nameVisCountErrorStep    = newEditShedulerStepForm.OutViewShedulerStepModel.nameVisCountErrorStep,
                    nameVisCount             = $"[{newStepStep}] {newEditShedulerStepForm.OutViewShedulerStepModel.nameVis}"
                };

                stepsGridList.Add(newViewShedulerStepModel);

                cbStartStep.DataSource = stepsGridList.ToArray();
                rgvSteps.DataSource    = stepsGridList.ToArray();
                if (cbStartStepSelectedValue != null)
                {
                    cbStartStep.SelectedValue = cbStartStepSelectedValue;
                }
            }
            finally
            {
                btnNewStep.Enabled = true;
            }
        }