Beispiel #1
0
        public FfmpegJobModel Get(Guid id)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentOutOfRangeException(nameof(id), "ID must be a valid GUID");
            }

            FFmpegJobDto job = _repository.Get(id);

            if (job == null)
            {
                throw new ArgumentException($"No job found with id {id:B}", "id");
            }

            var result = MapDtoToModel(job);

            return(result);
        }
Beispiel #2
0
 private static FfmpegJobModel MapDtoToModel(FFmpegJobDto dto)
 {
     return(new FfmpegJobModel
     {
         JobCorrelationId = dto.JobCorrelationId,
         Needed = dto.Needed,
         Created = dto.Created,
         Tasks = dto.Tasks.Select(j => new FfmpegTaskModel
         {
             Started = j.Started,
             Heartbeat = j.Heartbeat,
             HeartbeatMachine = j.HeartbeatMachineName,
             State = j.State,
             Progress = Math.Round(Convert.ToDecimal(j.Progress / j.DestinationDurationSeconds * 100), 2, MidpointRounding.ToEven),
             VerifyProgres = j.VerifyProgress == null ? (decimal?)null : Math.Round(Convert.ToDecimal(j.VerifyProgress.Value / j.DestinationDurationSeconds * 100), 2, MidpointRounding.ToEven),
             DestinationFilename = j.DestinationFilename,
             LogPath = j.Started != null ?  $@"{_logPath}{j.Started.Value.Date:yyyy\\MM\\dd}\task_{j.Id}_output.txt" : string.Empty
         }),
     });
 }