public void Error(TaskExecutionErrorRequest taskExecutionErrorRequest)
        {
            if (taskExecutionErrorRequest.TreatTaskAsFailed)
                SetTaskExecutionAsFailed(taskExecutionErrorRequest.TaskId, taskExecutionErrorRequest.TaskExecutionId);

            RegisterEvent(taskExecutionErrorRequest.TaskId, taskExecutionErrorRequest.TaskExecutionId, EventType.Error, taskExecutionErrorRequest.Error);
        }
        public void Failed(string message)
        {
            Failed();

            string errorMessage = string.Empty;
            if (_block.RangeType == BlockType.DateRange)
            {
                errorMessage = string.Format("BlockId {0} From: {1} To: {2} Error: {3}",
                    _block.RangeBlockId,
                    _block.RangeBeginAsDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
                    _block.RangeEndAsDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
                    message);
            }
            else
            {
                errorMessage = string.Format("BlockId {0} From: {1} To: {2} Error: {3}",
                        _block.RangeBlockId,
                        _block.RangeBeginAsLong(),
                        _block.RangeEndAsLong(),
                        message);
            }


            var errorRequest = new TaskExecutionErrorRequest()
            {
                TaskId = new TaskId(_applicationName, _taskName),
                TaskExecutionId = _taskExecutionId,
                TreatTaskAsFailed = false,
                Error = errorMessage
            };
            _taskExecutionRepository.Error(errorRequest);
        }