public override bool Do() { if (Kind == TFileOperationKind.Loudness) { StartTime = DateTime.UtcNow; OperationStatus = FileOperationStatus.InProgress; try { bool success = false; if (_sourceMedia == null) { throw new ArgumentException("LoudnessOperation: SourceMedia is not of type Media"); } if (_sourceMedia.Directory is IngestDirectory && ((IngestDirectory)_sourceMedia.Directory).AccessType != TDirectoryAccessType.Direct) { using (TempMedia _localSourceMedia = (TempMedia)Owner.TempDirectory.CreateMedia(_sourceMedia)) { if (_sourceMedia.CopyMediaTo(_localSourceMedia, ref _aborted)) { success = _do(_localSourceMedia); if (!success) { TryCount--; } return(success); } else { return(false); } } } else { success = _do(_sourceMedia); if (!success) { TryCount--; } return(success); } } catch { TryCount--; return(false); } } else { return(base.Do()); } }
private bool _do() { bool result = false; _progressDuration = TimeSpan.FromTicks(_exportMediaList.Sum(e => e.Duration.Ticks)); AddOutputMessage("Refreshing destination directory content"); var destDirectory = DestDirectory as IngestDirectory; if (destDirectory == null) { throw new InvalidOperationException("Can only export to IngestDirectory"); } destDirectory.Refresh(); if (destDirectory.AccessType == TDirectoryAccessType.FTP) { using (TempMedia localDestMedia = (TempMedia)Owner.TempDirectory.CreateMedia(SourceMedia)) { DestMedia = _createDestMedia(destDirectory); DestMedia.PropertyChanged += destMedia_PropertyChanged; try { result = _encode(destDirectory, localDestMedia.FullPath); if (result) { _progressFileSize = (UInt64)(new FileInfo(localDestMedia.FullPath)).Length; AddOutputMessage($"Transfering file to device as {DestMedia.FileName}"); result = localDestMedia.CopyMediaTo((Media)DestMedia, ref _aborted); } } finally { DestMedia.PropertyChanged -= destMedia_PropertyChanged; } } } else { DestMedia = _createDestMedia(destDirectory); result = _encode(destDirectory, ((Media)DestMedia).FullPath); } if (result) { DestMedia.MediaStatus = result ? TMediaStatus.Available : TMediaStatus.CopyError; } if (result) { OperationStatus = FileOperationStatus.Finished; } return(result); }
internal override bool Execute() { if (Kind == TFileOperationKind.Loudness) { StartTime = DateTime.UtcNow; OperationStatus = FileOperationStatus.InProgress; try { bool success; if (!(Source is MediaBase source)) { throw new ArgumentException("LoudnessOperation: Source is not of type MediaBase"); } if (source.Directory is IngestDirectory && ((IngestDirectory)source.Directory).AccessType != TDirectoryAccessType.Direct) { using (TempMedia localSourceMedia = (TempMedia)OwnerFileManager.TempDirectory.CreateMedia(source)) { if (source.CopyMediaTo(localSourceMedia, ref Aborted)) { success = InternalExecute(localSourceMedia); if (!success) { TryCount--; } return(success); } return(false); } } success = InternalExecute(source); if (!success) { TryCount--; } return(success); } catch { TryCount--; return(false); } } return(base.Execute()); }
public override bool Do() { if (Kind == TFileOperationKind.Convert) { StartTime = DateTime.UtcNow; OperationStatus = FileOperationStatus.InProgress; IsIndeterminate = true; try { Media sourceMedia = SourceMedia as IngestMedia; if (sourceMedia == null) { throw new ArgumentException("ConvertOperation: SourceMedia is not of type IngestMedia"); } bool success = false; if (((IngestDirectory)sourceMedia.Directory).AccessType != TDirectoryAccessType.Direct) { using (TempMedia _localSourceMedia = (TempMedia)Owner.TempDirectory.CreateMedia(sourceMedia)) { AddOutputMessage($"Copying to local file {_localSourceMedia.FullPath}"); _localSourceMedia.PropertyChanged += _localSourceMedia_PropertyChanged; if (sourceMedia.CopyMediaTo(_localSourceMedia, ref _aborted)) { AddOutputMessage("Verifing local file"); _localSourceMedia.Verify(); try { if (DestMediaProperties.MediaType == TMediaType.Still) { success = _convertStill(_localSourceMedia); } else { success = _convertMovie(_localSourceMedia, _localSourceMedia.StreamInfo); } } finally { _localSourceMedia.PropertyChanged -= _localSourceMedia_PropertyChanged; } if (!success) { TryCount--; } return(success); } return(false); } } else { if (sourceMedia is IngestMedia && sourceMedia.IsVerified) { if (DestMediaProperties.MediaType == TMediaType.Still) { success = _convertStill(sourceMedia); } else { success = _convertMovie(sourceMedia, ((IngestMedia)sourceMedia).StreamInfo); } if (!success) { TryCount--; } } else { AddOutputMessage("Waiting for media to verify"); } return(success); } } catch (Exception e) { Debug.WriteLine(e.Message); AddOutputMessage(e.Message); TryCount--; return(false); } } else { return(base.Do()); } }