private void ProgressLogTask(IProgress <EstimatorBaseProgress> progress, String message, ProgressType type = ProgressType.Information) { var model = new EstimatorLogProgress { Message = message, Type = type }; progress.Report(model); }
private void ShowLogMessage(EstimatorLogProgress model) { if (!_currentProgressType.HasValue || _currentProgressType.Value == model.Type) { var message = String.Format("[{0:yyyy-MM-dd HH:mm:ss}] {1}", model.DateTime, model.Message); rtbLog.SelectionColor = model.Type.ForeColor(); rtbLog.AppendText(rtbLog.TextLength > 0 ? String.Concat(Environment.NewLine, message) : message); if (model.Exception != null) { rtbLog.AppendText(String.Concat(Environment.NewLine, model.Exception.ToString())); } } }
public async Task RunSalesEstimatorToolAsync(IProgress <EstimatorBaseProgress> progress) { try { _salesEstimatorTask = _estimatorService.StartEstimatorTaskAsync(progress); await _salesEstimatorTask; } catch (Exception exception) { var model = new EstimatorLogProgress { Message = exception.Message, Type = ProgressType.Error, Exception = exception }; progress.Report(model); StopCalculator(); } }
private void UpdateLog(EstimatorLogProgress model) { _progressList.Add(model); ShowLogMessage(model); }