private void bindingNavigatorMoveLastItem_Click(object sender, EventArgs e) { if (move()) { OperatorBindingSource.MoveLast(); } }
/// <summary> /// Adds log files to the bound data source for display in the interface /// </summary> /// <param name="filesArray"></param> private void AddLogFiles(IEnumerable <string> filesArray) { foreach (string file in filesArray) { if (_logsFiles.Contains(file)) { //Don't add doubles continue; } _logsFiles.Add(file); AddTraceMessage("Added " + file); var operation = new FormOperationController(file, "Ready to parse", DgvFiles); OperatorBindingSource.Add(operation); if (Properties.Settings.Default.AutoParse) { QueueOrRunOperation(operation); } } if (_fileNameSorting != 0) { SortDgvFiles(); } BtnParse.Enabled = !_anyRunning && filesArray.Any(); }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { if (OperatorBindingSource.Current == null) { OperatorBindingSource.DataSource = from opt in context.OPERATOR where opt.CODE == "KJM9" select opt; OperatorBindingSource.AddNew(); TextEditCode.Focus(); setReadOnly(false); setValues(); newRec = true; return; } TextEditCode.Focus(); //bindingNavigatorPositionItem.Focus(); //trigger field leave event GridViewOper.CloseEditor(); temp = newRec; if (checkForms()) { errorProvider1.Clear(); if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( OPERATOR)OperatorBindingSource.Current); } OperatorBindingSource.AddNew(); TextEditCode.Focus(); setReadOnly(false); setValues(); newRec = true; } }
private void ButtonDelRowContact_Click(object sender, System.EventArgs e) { int handle = GridViewAdditionalContacts.FocusedRowHandle; GridViewAdditionalContacts.DeleteRow(handle); OperatorBindingSource.EndEdit(); context.SaveChanges(); contactNewRowRec = false; modified = false; }
private void ButtonContactSave_Click(object sender, System.EventArgs e) { GridViewAdditionalContacts.FocusedColumn = GridViewAdditionalContacts.Columns["RECTYPE"]; if (GridViewAdditionalContacts.UpdateCurrentRow()) { OperatorBindingSource.EndEdit(); oPERATORBindingNavigatorSaveItem_Click(sender, e); contactNewRowRec = false; modified = false; } }
private void BtnClearFailedClick(object sender, EventArgs e) { for (int i = OperatorBindingSource.Count - 1; i >= 0; i--) { var operation = OperatorBindingSource[i] as FormOperationController; if (!operation.IsBusy() && operation.State == OperationState.UnComplete) { OperatorBindingSource.RemoveAt(i); } } }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (OperatorBindingSource.Current == null) { return; } GridViewOper.CloseEditor(); if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes) { modified = false; newRec = false; IEnumerable <CONTACT> contactRecs = from contact in context.CONTACT where contact.LINK_VALUE == TextEditCode.Text select contact; foreach (CONTACT rec in contactRecs) { context.DeleteObject(rec); } IEnumerable <RptContact> rptContactRecs = from contact in context.RptContact where contact.Code == TextEditCode.Text select contact; foreach (RptContact rec in rptContactRecs) { context.DeleteObject(rec); } OperatorBindingSource.RemoveCurrent(); errorProvider1.Clear(); context.SaveChanges(); setReadOnly(true); panelControlStatus.Visible = true; LabelStatus.Text = "Record Deleted"; rowStatusDelete = new Timer(); rowStatusDelete.Interval = 3000; rowStatusDelete.Start(); rowStatusDelete.Tick += new EventHandler(TimedEventDelete); } TextEditCode.Focus(); currentVal = TextEditCode.Text; modified = false; newRec = false; }
/// <summary> /// Invoked when the 'Clear All' button is clicked. Cancels pending operations and clears completed & un-started operations. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnClearAllClick(object sender, EventArgs e) { BtnCancelAll.Enabled = false; BtnParse.Enabled = false; //Clear the queue so that cancelled workers don't invoke queued workers _logQueue.Clear(); _logsFiles.Clear(); for (int i = OperatorBindingSource.Count - 1; i >= 0; i--) { var operation = OperatorBindingSource[i] as FormOperationController; if (operation.IsBusy()) { operation.ToCancelAndClearState(); } else { OperatorBindingSource.RemoveAt(i); } } }
private void SortDgvFiles() { if (_fileNameSorting == 0) { _fileNameSorting = 1; } var auxList = new List <FormOperationController>(); foreach (FormOperationController val in OperatorBindingSource) { auxList.Add(val); } auxList.Sort((form1, form2) => { string right = new FileInfo(form2.InputFile).Name; string left = new FileInfo(form1.InputFile).Name; return(_fileNameSorting * string.Compare(left, right)); }); OperatorBindingSource.Clear(); foreach (FormOperationController val in auxList) { OperatorBindingSource.Add(val); } }
private void _RunOperation(FormOperationController operation) { _runningCount++; _settingsForm.ConditionalSettingDisable(_anyRunning); operation.ToQueuedState(); AddTraceMessage("Queued " + operation.InputFile); var cancelTokenSource = new CancellationTokenSource();// Prepare task Task task = Task.Run(() => { operation.ToRunState(); AddTraceMessage("Parsing " + operation.InputFile); ProgramHelper.DoWork(operation); }, cancelTokenSource.Token).ContinueWith(t => { cancelTokenSource.Dispose(); _runningCount--; AddTraceMessage("Parsed " + operation.InputFile); // Exception management if (t.IsFaulted) { if (t.Exception != null) { if (t.Exception.InnerExceptions.Count > 1) { operation.UpdateProgress("Something terrible has happened"); } else { Exception ex = t.Exception.InnerExceptions[0]; if (!(ex is ProgramException)) { operation.UpdateProgress("Something terrible has happened"); } if (!(ex.InnerException is OperationCanceledException)) { operation.UpdateProgress(ex.InnerException.Message); } else { operation.UpdateProgress("Operation Aborted"); } } } else { operation.UpdateProgress("Something terrible has happened"); } } if (operation.State == OperationState.ClearOnCancel) { OperatorBindingSource.Remove(operation); } else { if (t.IsFaulted) { operation.ToUnCompleteState(); } else if (t.IsCanceled) { operation.UpdateProgress("Operation Aborted"); operation.ToUnCompleteState(); } else if (t.IsCompleted) { operation.ToCompleteState(); } else { operation.UpdateProgress("Something terrible has happened"); operation.ToUnCompleteState(); } } ProgramHelper.GenerateTraceFile(operation); if (operation.State != OperationState.Complete) { operation.Reset(); } _RunNextOperation(); }, TaskScheduler.FromCurrentSynchronizationContext()); operation.SetContext(cancelTokenSource, task); }