コード例 #1
0
        public async Task <long> CreateRepairTaskAsync(Guid activityId, IRepairTask repairTask)
        {
            repairTask.Validate("repairTask");

            var startTime = DateTimeOffset.UtcNow;

            try
            {
                // TODO, using the overload without timeout and cancellation token for now since there is some max timeout limit
                // being exercised somewhere. if timeout provided is more than that, repair task creation fails
                long result = await repairManager.CreateRepairTaskAsync(Unwrap(repairTask)).ConfigureAwait(false);

                traceType.WriteInfo(
                    "Created repair task. Result: {0}, repair task: {1}",
                    result,
                    repairTask.ToJson());

                activityLogger.LogChangeState(activityId, repairTask, RepairTaskState.Invalid, repairTask.State, TimeSpan.Zero, repairTask.ToJson(), repairTask.TaskId);
                activityLogger.LogOperation(activityId, startTime, OperationResult.Success, null, repairTask.ToJson());

                return(result);
            }
            catch (Exception ex)
            {
                traceType.WriteError("Unable to create repair task. Errors: {0}", ex.GetMessage());
                activityLogger.LogOperation(activityId, startTime, OperationResult.Failure, ex, repairTask.ToJson());
                throw;
            }
        }