private async void ScheduleForm_Load(object sender, EventArgs e) { _isFormLoading = true; try { pckrStartDateTime.Format = DateTimePickerFormat.Custom; pckrStartDateTime.CustomFormat = "Дата: dd/MM/yyyy время: HH:mm:ss"; this.lbTasks.DisplayMember = "Name"; this.lbTasks.ValueMember = "Id"; var allOperationsTypes = MQueryCommand.SelectAllOperationsTypes(); foreach (var operation in allOperationsTypes) { this.stepsTree1.Operations.Add(operation.Id, operation.NameRus); } await InitComputersShedulerGridAsync(); this.UpdateTasksList(); } finally { _isFormLoading = false; } }
protected override void btnDeleteTask_Click(object sender, EventArgs e) { btnDeleteTask.Enabled = false; try { int?selectedKey = rgvTasks.SelectedValue as int?; if (selectedKey.HasValue) { int taskId = Convert.ToInt32(rgvTasks.SelectedRow.Cells["Id"].Value); string taskName = Convert.ToString(rgvTasks.SelectedRow.Cells["Name"].Value); if (MessageBox.Show($"Удалить задание: [{taskName}] ?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var res = MQueryCommand.TryDeletePluginTask(taskId); if (!res.IsComplete) { MessageBox.Show(res.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int oldIndex = rgvTasks.SelectedRow.Index < 0 ? 0 : rgvTasks.SelectedRow.Index; int index = rgvTasks.SelectedRow.Index - 1 < 0 ? 0 : rgvTasks.SelectedRow.Index - 1; rgvTasks.dataGridView.Rows[index].Selected = true; Thread.Sleep(300); RefreshGrid(MQueryCommand.SelectShedulerPluginTasksGrid()); rgvTasks.dataGridView.Invalidate(); } } } } finally { btnDeleteTask.Enabled = true; } }
public bool Run(int computerId) { ComputerId = computerId; try { var res = MQueryCommand.TryInsertNewOperationByShedulerStep(computerId, OperationType, OperationAttributes); if (!res.IsComplete) { MLogger.Error($"1 - {res.Message}"); MQueryCommand.TryInsertShedulerHistory(TaskId, Id, computerId, false, res.Message); return(false); } OperationID = res.ReturnedId; MLogger.Debug($"\"Step Run\", ThreadId: {Thread.CurrentThread.ManagedThreadId}, AddedOperationId: {OperationID}"); MQueryCommand.TryInsertShedulerHistory(TaskId, Id, computerId, true, $"Выполнено. Операция {OperationID} добавлена."); return(true); } catch (Exception ex) { MLogger.Error($"2 - {ex.ToString()}"); MQueryCommand.TryInsertShedulerHistory(TaskId, Id, computerId, true, ex.Message); return(false); } }
static OperationTools() { if (_operationTypes == null) { _operationTypes = MQueryCommand.GetOperationTypes(); } }
private ShedulerStepObj GetStep(int?Id) { if (Id == null) { return(null); } var step = MQueryCommand.SelectShedulerStep(Id); if (step != null) { return(new ShedulerStepObj() { Id = step.Id, OnOperationCompleteStep = step.OnOperationCompleteStep, OnOperationErrorStep = step.OnOperationErrorStep, OperationCheckIntervalMs = step.OperationCheckIntervalMs, OperationType = step.OperationType, OrderId = step.OrderId, ShedulerTask = step.ShedulerTask, ShedulerTasks = step.ShedulerTasks, TaskId = step.TaskId, RepeatCount = step.RepeatCount, RepeatTimeout = step.RepeatTimeout, ShedulerTaskHistories = step.ShedulerTaskHistories, OperationAttributes = step.OperationAttributes }); } else { return(null); } }
private void lbTasks_SelectedIndexChanged(object sender, EventArgs e) { stepsTree1.stepTree.Visible = false; var selectedTaskItem = (ShedulerTask)lbTasks.SelectedItem; if (selectedTaskItem == null) { this.stepsTree1.ClearTree(); return; } DateTime actualDateTime = Constants.DEFAULT_DATE_TIME; if (selectedTaskItem.NextStartTime > Constants.DEFAULT_DATE_TIME) { actualDateTime = selectedTaskItem.NextStartTime; } else if (selectedTaskItem.LastStartTime.HasValue && selectedTaskItem.LastStartTime.Value > Constants.DEFAULT_DATE_TIME) { actualDateTime = selectedTaskItem.LastStartTime.Value; } else if (selectedTaskItem.StartTime > Constants.DEFAULT_DATE_TIME) { actualDateTime = selectedTaskItem.StartTime; } this.edTaskName.Text = selectedTaskItem.Name; this.cmbTaskModes.SelectedIndex = selectedTaskItem.Mode; this.pckrStartDateTime.Value = actualDateTime.Add(_utcOffset); this.chbEnable.Checked = selectedTaskItem.Enabled ?? false; // Заполнение списка компьютеров DataGridViewRow[] rows = rgvComputersForSheduler.dataGridView.Rows.OfType <DataGridViewRow>().ToArray(); foreach (DataGridViewRow row in rows) { row.Cells["Selected"].Value = false; } foreach (DataGridViewRow row in rows) { foreach (var currentComputer in selectedTaskItem.ShedulerTasksComputersLists) { if (currentComputer.ComputerId == Convert.ToInt32(row.Cells["ComputerId"].Value)) { row.Cells["Selected"].Value = true; continue; } } } this.stepsTree1.ClearTree(); var currentTaskSteps = MQueryCommand.GetAllStepsParentChild(selectedTaskItem.Id).OrderBy(x => x.ParentId).ToList(); stepsTree1.PopulateA(currentTaskSteps); this.stepsTree1.ExpandAll(); stepsTree1.stepTree.Visible = true; }
private void LoadOperationGroups() { cbOperationGroup.ValueMember = "Id"; cbOperationGroup.DisplayMember = "Name"; cbOperationGroup.DataSource = MQueryCommand.SelectOperationGroups(); cbOperationGroup.SelectedValue = _currentGroupId; btnSave.Enabled = IsChangeExists(); }
public ShopSettingsForm(int computerId) { _computerId = computerId; InitializeComponent(); btnSave.Click += btnSave_Click; lbShopId.Text = MQueryCommand.GetShopId(computerId) ?? ""; _shopSettingsModel = MQueryCommand.GetShopSettings(computerId); }
private void btnSave_Click(object sender, EventArgs e) { _shopSettingsModel.ShopName = tbName.Text; _shopSettingsModel.ShopRegion = tbRegion.Text; _shopSettingsModel.AddressToConnect = tbAddressToConnect.Text; _shopSettingsModel.Email = tbEmail.Text; _shopSettingsModel.Phone = tbPhone.Text; _shopSettingsModel.IsClosed = chbIsClosed.Checked; MQueryCommand.SetShopSettings(_computerId, _shopSettingsModel); }
private void InitControls() { InitGrids(); tabControl1.Appearance = TabAppearance.FlatButtons; tabControl1.ItemSize = new Size(0, 1); tabControl1.SizeMode = TabSizeMode.Fixed; cbOccurs.DisplayMember = "NameRus"; cbOccurs.ValueMember = "Id"; cbOccurs.DataSource = MQueryCommand.SelectShedulerModes().Where(w => w.Id != 0).ToList(); var stepsGridList = rgvSteps.DataSource?.OfType <ViewShedulerStepModel>().ToList(); cbStartStep.DisplayMember = "nameVisCount"; cbStartStep.ValueMember = "Id"; cbStartStep.DataSource = MQueryCommand.SelectShedulerStepsForGrid(_taskId); if (_shedulerTask.FirstStepId.HasValue) { cbStartStep.SelectedValue = _shedulerTask.FirstStepId.Value; } if (_taskId > 0) { tbTaskName.Text = _shedulerTask.Name; chbTaskEnabled.Checked = _shedulerTask.Enabled ?? false; rtbTaskDescription.Text = _shedulerTask.Description ?? ""; cbSheduleType.SelectedIndex = _shedulerTask.Mode == 0 ? 0 : 1; if (_shedulerTask.FirstStepId.HasValue) { cbStartStep.SelectedValue = _shedulerTask.FirstStepId.Value; } if (_shedulerTask.Mode != 0) { cbOccurs.SelectedValue = _shedulerTask.Mode; dtbDateFrequency.Value = dtbTimeFrequency.Value = _shedulerTask.NextStartTime.ToLocalTime(); nudRecurs.Value = Convert.ToDecimal(_shedulerTask.RepeatValue); } else { dtpDateOnce.Value = dtpTimeOnce.Value = _shedulerTask.NextStartTime.ToLocalTime(); } } CreateDescription(); this.TopMost = true; this.TopMost = false; }
protected override void btnCreateTask_Click(object sender, EventArgs e) { btnCreateTask.Enabled = false; try { new NewEditShedulerPluginTaskForm().ShowDialog(); RefreshGrid(MQueryCommand.SelectShedulerPluginTasksGrid()); } finally { btnCreateTask.Enabled = true; } }
public void SaveAttributes(object model, int userId = 0) { if (userId == 0) { userId = MainForm.UserId; } var res = MQueryCommand.TrySaveOperationAttributesByUser(_operationType, userId, model); if (!res.IsComplete) { MLogger.Error(res.Message); } }
private void ChangeAgentSettingsReadedLabel() { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(() => { toolTip1.RemoveAll(); })); } else { toolTip1.RemoveAll(); } bool flag = MQueryCommand.GetIsAgentSettingsReadedValue(_computerId); if (flag) { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(() => { lbSettingsReadingCheck.Text = "Настройки прочитаны агентом"; lbSettingsReadingCheck.BackColor = Color.PaleGreen; })); } else { lbSettingsReadingCheck.Text = "Настройки прочитаны агентом"; lbSettingsReadingCheck.BackColor = Color.PaleGreen; } } else { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(() => { lbSettingsReadingCheck.Text = "Настройки не прочитаны агентом"; lbSettingsReadingCheck.BackColor = Color.Salmon; toolTip1.SetToolTip(lbSettingsReadingCheck, "Для того чтобы агент прочитал настройки требуется его перезапуск. (Отправить операцию \"Перезапустить агента\")"); })); } else { lbSettingsReadingCheck.Text = "Настройки не прочитаны агентом"; lbSettingsReadingCheck.BackColor = Color.Salmon; toolTip1.SetToolTip(lbSettingsReadingCheck, "Для того чтобы агент прочитал настройки требуется его перезапуск. (Отправить операцию \"Перезапустить агента\")"); } } }
private async void RefreshStepsTimerCallback(object state) { try { await rgvSteps.RefreshDataSourceAsync(await MQueryCommand.SelectShedulerStepsForGridAsync(_taskId)); } catch (Exception ex) { MLogger.Error($"Ошибка обновления таблицы rgvSteps в таймере RefreshComputersTimer. Original: {ex.ToString()}"); } finally { _refreshStepsTimer.Change(GRIDS_REFRESH_TIMEOUT, System.Threading.Timeout.Infinite); } }
private void UpdateTasksList() { this.lbTasks.Items.Clear(); var tasks = MQueryCommand.SelectShedulerTasks(); foreach (var task in tasks) { this.lbTasks.Items.Add(task); } if (this.lbTasks.Items.Count > 0) { this.lbTasks.SelectedIndex = 0; } }
private async void btnRefreshGrid_Click(object sender, EventArgs e) { var button = sender as Button; button.Enabled = false; rgvComputersForSheduler.ShowLoading(true); try { await rgvComputersForSheduler.RefreshDataSourceAsync(await MQueryCommand.SelectShopComputersServerViewGridAsync()); } finally { button.Enabled = true; rgvComputersForSheduler.ShowLoading(false); } }
private StepsProperties GetStepProperties(ShedulerStep step, int parentStepId, bool isPositive) { if (step == null) { return(null); } return(new StepsProperties { Id = step.Id, ParentId = parentStepId, IsPositive = isPositive, OperationId = step.OperationType, OperationName = MQueryCommand.GetOperationNameRusById(step.OperationType), WaitingForSuccessInterval = step.OperationCheckIntervalMs / MILLISECONDS_IN_SECOND, RepeatingIntervalOn1cWaiting = (step.RepeatTimeout ?? 0) / MILLISECONDS_IN_SECOND, RepeatTimesOnLackOf1cResponse = step.RepeatCount ?? 0 }); }
public static List <ShedulerPluginTaskObj> GetShedulerTasks() { var tasks = MQueryCommand.SelectShedulerPluginTasks(); return(tasks.Select(c => new ShedulerPluginTaskObj { Id = c.Id, LastEndTime = c.LastEndTime, LastStartTime = c.LastStartTime, Mode = c.Mode, Name = c.Name, NextStartTime = c.NextStartTime, PluginFileName = c.PluginFileName, Status = c.Status, Enabled = c.Enabled, RepeatValue = c.RepeatValue }).ToList()); }
protected override void btnEditTask_Click(object sender, EventArgs e) { btnEditTask.Enabled = false; try { int?selectedKey = rgvTasks.SelectedValue as int?; if (selectedKey.HasValue) { int taskId = Convert.ToInt32(rgvTasks.SelectedRow.Cells["Id"].Value); new NewEditShedulerPluginTaskForm(taskId).ShowDialog(); RefreshGrid(MQueryCommand.SelectShedulerPluginTasksGrid()); } } finally { btnEditTask.Enabled = true; } }
protected override void InitControls() { rgvTasks.KeyField = "Id"; rgvTasks.IsMultiselect = false; rgvTasks.dataGridView.RowHeadersVisible = false; rgvTasks.IsShowCellExtensionFormByDoubleClick = false; rgvTasks.MappingColumns = Mapping.TasksGridColMap; rgvTasks.DataSource = MQueryCommand.SelectShedulerPluginTasksGrid(); rgvTasks.HideColumns("FirstStepId", "StartTime"); //rgvTasks.DataView.Sort = "CreationDate DESC"; rgvTasks.dataGridView.CellDoubleClick += (sender, e) => { btnEditTask.PerformClick(); }; #region ContextMenuAdd //var miCreateNew = new ToolStripMenuItem(); //miCreateNew.Name = "miCreateNew"; //miCreateNew.Text = "Создать новую задачу"; //miCreateNew.Click += (sender, e) => //{ // new NewEditShedulerTaskForm().ShowDialog(); //}; //rgvTasks.AddMenuItem(miCreateNew); //string miEditText = "Изменить задачу"; //var miEdit = new ToolStripMenuItem(); //miEdit.Name = "miEdit"; //miEdit.Text = miEditText; //miEdit.Click += (sender, e) => //{ // int? selectedKey = rgvTasks.SelectedValue as int?; // if (selectedKey.HasValue) // { // string taskName = Convert.ToString(rgvTasks.SelectedRow.Cells["Name"].Value); // int taskId = Convert.ToInt32(rgvTasks.SelectedRow.Cells["Id"].Value); // miEdit.Text = $"{miEditText} [{taskName}]"; // new NewEditShedulerTaskForm(taskId).ShowDialog(); // } //}; //rgvTasks.AddMenuItem(miEdit); #endregion }
private async Task InitStepsGridAsync() { rgvSteps.KeyField = "Id"; rgvSteps.MappingColumns = Mapping.StepsGridMapping; rgvSteps.DataSource = await MQueryCommand.SelectShedulerStepsForGridAsync(_taskId); rgvSteps.dataGridView.RowHeadersVisible = false; rgvSteps.dataGridView.Columns.OfType <DataGridViewColumn>().ToList().ForEach(f => f.SortMode = DataGridViewColumnSortMode.NotSortable); if (rgvSteps.dataGridView.Rows.Count > 0) { rgvSteps.dataGridView.Rows[0].Selected = true; } rgvSteps.dataGridView.CellDoubleClick += (sender, e) => { btnEditStep.PerformClick(); }; }
public AgentSettingsForm(int computerId) { InitializeComponent(); lbShopId.Text = MQueryCommand.GetShopId(computerId) ?? ""; _computerId = computerId; _sqlLocalSettings = new SqlLocalSettings(); var res = _sqlLocalSettings.LoadSqlLocalSettings(_computerId); if (!res.IsComplete) { MessageBox.Show(res.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } _isLoadingErrorExists = !res.IsComplete || _computerId <= 0; if (!_isLoadingErrorExists) { _agentSettingsIsReadCheckTimer = new System.Threading.Timer(AgentSettingsIsReadCheckTimerCallback, null, AGENT_SETTINGS_ISREADCHECK_TIMER_INTERVAL, Timeout.Infinite); ChangeAgentSettingsReadedLabel(); } }
public NewEditShedulerPluginTaskForm(int pluginTaskId = 0) { _pluginTaskId = pluginTaskId; InitializeComponent(); if (_pluginTaskId > 0) { _shedulerPluginTask = MQueryCommand.SelectShedulerPluginTasks().FirstOrDefault(f => f.Id == _pluginTaskId); if (_shedulerPluginTask == null) { MessageBox.Show("Не найден [ShedulerPluginTask]", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Dispose(); return; } } else { _shedulerPluginTask = new ShedulerPluginTask(); } InitControls(); }
public static List <ShedulerTaskObj> GetShedulerTasks() { var tasks = MQueryCommand.SelectShedulerTasks(); return(tasks.Select(c => new ShedulerTaskObj { Id = c.Id, FirstStepId = c.FirstStepId, LastEndTime = c.LastEndTime, LastStartTime = c.LastStartTime, Mode = c.Mode, Name = c.Name, NextStartTime = c.NextStartTime, ShedulerStep = c.ShedulerStep, ShedulerSteps = c.ShedulerSteps, ShedulerTasksComputersLists = c.ShedulerTasksComputersLists, StartTime = c.StartTime, Status = c.Status, Enabled = c.Enabled, RepeatValue = c.RepeatValue }).ToList()); }
private void InitControls() { tabControl1.Appearance = TabAppearance.FlatButtons; tabControl1.ItemSize = new Size(0, 1); tabControl1.SizeMode = TabSizeMode.Fixed; cbOccurs.DisplayMember = "NameRus"; cbOccurs.ValueMember = "Id"; cbOccurs.DataSource = MQueryCommand.SelectShedulerModes().Where(w => w.Id != 0).ToList(); if (_pluginTaskId > 0) { tbTaskName.Text = _shedulerPluginTask.Name; chbTaskEnabled.Checked = _shedulerPluginTask.Enabled ?? false; rtbTaskDescription.Text = _shedulerPluginTask.Description ?? ""; cbSheduleType.SelectedIndex = _shedulerPluginTask.Mode == 0 ? 0 : 1; tbDllFileName.Text = _shedulerPluginTask.PluginFileName; if (_shedulerPluginTask.Mode != 0) { cbOccurs.SelectedValue = _shedulerPluginTask.Mode; dtbDateFrequency.Value = dtbTimeFrequency.Value = _shedulerPluginTask.NextStartTime.ToLocalTime(); nudRecurs.Value = Convert.ToDecimal(_shedulerPluginTask.RepeatValue); } else { dtpDateOnce.Value = dtpTimeOnce.Value = _shedulerPluginTask.NextStartTime.ToLocalTime(); } } CreateDescription(); this.TopMost = true; this.TopMost = false; }
private void DeleteTask() { this.toolStripButtonAddTask.Enabled = this.toolStripButtonRemoveTask.Enabled = lbTasks.Enabled = false; var selectedTaskItem = (ShedulerTask)lbTasks.SelectedItem; if (selectedTaskItem == null) { MessageBox.Show("Не выбрано ни одного пункта", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show($"Удалить задачу '{selectedTaskItem.Name}'?", "Подтвердите действие", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } // Удаление задачи var result = MQueryCommand.TryDeleteTask(selectedTaskItem.Id); if (result.IsComplete) { this.UpdateTasksList(); if (this.lbTasks.Items.Count > 0) { this.lbTasks.SelectedIndex = this.lbTasks.Items.Count - 1; } MessageBox.Show($"Задача успешно удалена", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show($"Ошибка удаления задачи{Environment.NewLine}{result.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.toolStripButtonAddTask.Enabled = this.toolStripButtonRemoveTask.Enabled = lbTasks.Enabled = true; }
private async void btnOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbShopId.Text)) { lbError.Text = "Не заполнено ShopId"; return; } if (string.IsNullOrEmpty(tbShopRegion.Text)) { lbError.Text = "Не заполнено ShopRegion"; return; } var result = await MQueryCommand.TryInsertNewShopAsync(tbShopId.Text, tbShopRegion.Text); if (result.IsComplete) { DialogResult = DialogResult.OK; } else { lbError.Text = result.Message; } }
private void btnOk_Click(object sender, EventArgs e) { btnOk.Enabled = false; try { DateTime nextStartTime = (cbSheduleType.SelectedIndex == 0 ? dtpDateOnce.Value.Date.Add(dtpTimeOnce.Value.TimeOfDay) : dtbDateFrequency.Value.Date.Add(dtbTimeFrequency.Value.TimeOfDay)).ToUniversalTime(); #region InputChecks if (string.IsNullOrEmpty(tbTaskName.Text)) { MessageBox.Show($"Отсутствует имя задания.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _dontCloseForm = true; return; } if (MQueryCommand.CheckTaskExistsByName(tbTaskName.Text, new int[1] { _pluginTaskId })) { MessageBox.Show($"Задание с именем [{tbTaskName.Text}] уже существует, введите другое имя.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _dontCloseForm = true; return; } if (cbSheduleType.SelectedItem == null) { MessageBox.Show($"Не выбран тип расписания.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _dontCloseForm = true; return; } if (string.IsNullOrEmpty(tbDllFileName.Text)) { MessageBox.Show($"Не указано имя файла плагин-операции [Имя dll - файла с расширением]", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _dontCloseForm = true; return; } else if (!tbDllFileName.Text.Contains(".dll")) { MessageBox.Show($"Не указано расширение в имени файла для плагин-операции [.dll]", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _dontCloseForm = true; return; } if (nextStartTime <= DateTime.UtcNow) { MessageBox.Show($"Дата следующего выполнения должна быть больше текущей даты!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _dontCloseForm = true; return; } if (nextStartTime > DateTime.UtcNow && nextStartTime.AddMinutes(-10) <= DateTime.UtcNow) { if (MessageBox.Show($"Задание будет выполнено менее чем через 10 минут. Продолжить?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { _dontCloseForm = true; return; } } #endregion _shedulerPluginTask.Enabled = chbTaskEnabled.Checked; _shedulerPluginTask.Name = tbTaskName.Text; _shedulerPluginTask.PluginFileName = tbDllFileName.Text; _shedulerPluginTask.Description = rtbTaskDescription.Text; _shedulerPluginTask.Mode = cbSheduleType.SelectedIndex == 0 ? 0 : Convert.ToInt32(cbOccurs.SelectedValue); _shedulerPluginTask.NextStartTime = nextStartTime; _shedulerPluginTask.RepeatValue = Convert.ToInt32(nudRecurs.Value); _shedulerPluginTask.CreatedUserLogin = Environment.UserName; _shedulerPluginTask.CreationDateUtc = DateTime.UtcNow; //TODO var tryDeleteInsertUpdateTaskFromFormRes = MQueryCommand.TryInsertUpdatePluginTaskFromForm(_shedulerPluginTask); if (!tryDeleteInsertUpdateTaskFromFormRes.IsComplete) { MessageBox.Show(tryDeleteInsertUpdateTaskFromFormRes.Message); } } finally { btnOk.Enabled = true; } }
public bool AddSteps(int taskId) { //Добавление шагов if (!this.IsEmpty()) { var allStepNodes = this.GetAllNodes(); int firstStepId = 0; foreach (var stepNode in allStepNodes) { if (stepNode.Tag == null) { return(false); } var currentStep = (StepsProperties)stepNode.Tag; ShedulerStep shedulerStep = MQueryCommand.SelectShedulerStep(currentStep.Id); TrySQLCommand insertStepResult = null; if (shedulerStep == null) { insertStepResult = MQueryCommand.TryInsertNewStep(taskId, currentStep.OperationId, currentStep.RepeatTimesOnLackOf1cResponse, currentStep.RepeatingIntervalOn1cWaiting * MILLISECONDS_IN_SECOND, currentStep.WaitingForSuccessInterval * MILLISECONDS_IN_SECOND); } else { insertStepResult = MQueryCommand.TryUpdateStep(currentStep.Id, currentStep.OperationId, currentStep.RepeatTimesOnLackOf1cResponse, currentStep.RepeatingIntervalOn1cWaiting * MILLISECONDS_IN_SECOND, currentStep.WaitingForSuccessInterval * MILLISECONDS_IN_SECOND); } if (!insertStepResult.IsComplete) { MessageBox.Show($"Ошибка добавления новой задачи{Environment.NewLine}{insertStepResult.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (stepNode.Parent == null) { firstStepId = insertStepResult.ReturnedId; } currentStep.Id = insertStepResult.ReturnedId; } ; var uspdateResult = MQueryCommand.TryUpdateStepFirstStepId(taskId, firstStepId); if (!uspdateResult.IsComplete) { return(false); } // Обновляем Id связей foreach (var stepNode in allStepNodes) { var stepNodeProperties = (StepsProperties)stepNode.Tag; foreach (TreeNode childNode in stepNode.Nodes) { var childNodeProperties = (StepsProperties)childNode.Tag; if (childNodeProperties.IsPositive) { uspdateResult = MQueryCommand.TryUpdateStepPositiveOperationId(stepNodeProperties.Id, childNodeProperties.Id); } else { uspdateResult = MQueryCommand.TryUpdateStepNegativeOperationId(stepNodeProperties.Id, childNodeProperties.Id); } if (!uspdateResult.IsComplete) { return(false); } } } return(true); } else { return(false); } }
public object GetSavedAttributes() { return(MQueryCommand.GetSavedOperationAttributesByUser(_operationType, MainForm.UserId)); }