Example #1
0
        /// <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);

                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();
        }
Example #2
0
 /// <summary>
 /// Queues an operation. If the 'MultipleLogs' setting is true, operations are run asynchronously
 /// </summary>
 /// <param name="operation"></param>
 private void QueueOrRunOperation(FormOperationController operation)
 {
     btnClearAll.Enabled  = false;
     btnParse.Enabled     = false;
     btnCancelAll.Enabled = true;
     if (Properties.Settings.Default.ParseMultipleLogs)
     {
         _RunOperation(operation);
     }
     else
     {
         if (_anyRunning)
         {
             _logQueue.Enqueue(operation);
             operation.ToPendingState();
         }
         else
         {
             _RunOperation(operation);
         }
     }
 }
 /// <summary>
 /// Queues an operation. If the 'MultipleLogs' setting is true, operations are run asynchronously
 /// </summary>
 /// <param name="operation"></param>
 private void QueueOrRunOperation(FormOperationController operation)
 {
     BtnClearAll.Enabled     = false;
     BtnParse.Enabled        = false;
     BtnCancelAll.Enabled    = true;
     BtnDiscordBatch.Enabled = false;
     if (Properties.Settings.Default.ParseMultipleLogs && _runningCount < ProgramHelper.GetMaxParallelRunning())
     {
         _RunOperation(operation);
     }
     else
     {
         if (_anyRunning)
         {
             _logQueue.Enqueue(operation);
             operation.ToPendingState();
         }
         else
         {
             _RunOperation(operation);
         }
     }
 }
Example #4
0
        /// <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);

                var operation = new FormOperationController(ProgramHelper.ParserVersion, file, "Ready to parse", dgvFiles);
                operatorBindingSource.Add(operation);

                if (Properties.Settings.Default.AutoParse)
                {
                    QueueOrRunOperation(operation);
                }
            }

            btnParse.Enabled     = !Properties.Settings.Default.AutoParse;
            btnCancelAll.Enabled = Properties.Settings.Default.AutoParse;
        }
Example #5
0
        private void _RunOperation(FormOperationController operation)
        {
            _runningCount++;
            _settingsForm.ConditionalSettingDisable(_anyRunning);
            operation.ToQueuedState();
            var  cancelTokenSource = new CancellationTokenSource();// Prepare task
            Task task = Task.Run(() =>
            {
                operation.ToRunState();
                ProgramHelper.DoWork(operation);
            }, cancelTokenSource.Token).ContinueWith(t =>
            {
                cancelTokenSource.Dispose();
                _runningCount--;
                // 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 EncompassException))
                            {
                                operation.UpdateProgress("Something terrible has happened");
                            }
                            if (!(ex.InnerException is OperationCanceledException))
                            {
                                operation.UpdateProgress(ex.GetFinalException().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);
                RunNextOperation();
            }, TaskScheduler.FromCurrentSynchronizationContext());

            operation.SetContext(cancelTokenSource, task);
        }