public void HandleEvent(ProcessingCompleted eventHandled)
        {
            #region Logging
            if (null != log)
            {
                log.LogDebug($"HandleEvent( ProcessingCompleted )",
                             nameof(Command_Summary_Projection));
            }
            #endregion

            if (null != eventHandled)
            {
                // Set the status as "processed"
                base.AddOrUpdateValue <CommandState>(nameof(CurrentState), 0, CommandState.Processed);
            }
            else
            {
                #region Logging
                if (null != log)
                {
                    log.LogWarning($"HandleEvent( ProcessingCompleted ) - parameter was null",
                                   nameof(Command_Summary_Projection));
                }
                #endregion
            }
        }
예제 #2
0
        private void OnProcessingCompleted(object sender, ProcessingCompletedEventArgs e)
        {
            var status = JobStatus.Complete;

            WriteStatus(e.ProcessingRequest, status, e.ResultBody);
            ProcessingCompleted?.Invoke(this, e);
        }
 protected virtual void OnProcessingCompleted(Bitmap processedImage)
 {
     ProcessingCompleted?.Invoke(this, new ImageProcessingEventArgs()
     {
         Image = processedImage
     });
 }
예제 #4
0
 public void Subscribe(string subscriber, EventHandler <TEvent> action)
 {
     if (ProcessingCompleted == null || !ProcessingCompleted.GetInvocationList().Contains(action))
     {
         ProcessingCompleted += action;
         Console.WriteLine($"'{subscriber}' subscribed");
     }
 }
예제 #5
0
        public async Task <IAsyncActionWithProgress <double> > StartTranscodeMedia(StorageFile inputFile, StorageFile outFile, MediaEncodingProfile profile)
        {
            MediaTranscoder        transcoder = new MediaTranscoder();
            PrepareTranscodeResult prepareOp  = await transcoder.PrepareFileTranscodeAsync(inputFile, outFile, profile);

            if (prepareOp.CanTranscode)
            {
                var transcodeOp = prepareOp.TranscodeAsync();

                transcodeOp.Progress += new AsyncActionProgressHandler <double>((asyncInfo, e) =>
                {
                    ProcessingProgressChanged?.Invoke(this, e);
                });
                transcodeOp.Completed += new AsyncActionWithProgressCompletedHandler <double>((asyncInfo, status) =>
                {
                    asyncInfo.GetResults();
                    switch (status)
                    {
                    case AsyncStatus.Canceled:
                        ProcessingCanceled?.Invoke(this, new EventArgs());
                        break;

                    case AsyncStatus.Completed:
                        ProcessingCompleted?.Invoke(this, new EventArgs());
                        break;

                    case AsyncStatus.Started:
                        break;

                    case AsyncStatus.Error:
                    default:
                        ProcessingError?.Invoke(this, "转码失败");
                        break;
                    }
                });
                return(transcodeOp);
            }
            else
            {
                switch (prepareOp.FailureReason)
                {
                case TranscodeFailureReason.CodecNotFound:
                    ProcessingError?.Invoke(this, "转码失败:找不到编解码器");
                    break;

                case TranscodeFailureReason.InvalidProfile:
                    ProcessingError?.Invoke(this, "转码失败:配置文件无效");
                    break;

                default:
                    ProcessingError?.Invoke(this, "转码失败:未知错误");
                    break;
                }
                return(null);
            }
        }
예제 #6
0
        public async Task <IAsyncOperationWithProgress <TranscodeFailureReason, double> > StartCompositionDashMedia(IList <StorageFile> inputFiles, StorageFile outFile, MediaEncodingProfile profile = null)
        {
            MediaComposition composition = new MediaComposition();

            var clip = await MediaClip.CreateFromFileAsync(inputFiles.FirstOrDefault(x => x.Name == "video.m4s"));

            composition.Clips.Add(clip);

            var backgroundTrack = await BackgroundAudioTrack.CreateFromFileAsync(inputFiles.FirstOrDefault(x => x.Name == "audio.m4s"));

            composition.BackgroundAudioTracks.Add(backgroundTrack);

            IAsyncOperationWithProgress <TranscodeFailureReason, double> saveOperation = null;

            if (profile != null)
            {
                saveOperation = composition.RenderToFileAsync(outFile, MediaTrimmingPreference.Fast, profile);
            }
            else
            {
                saveOperation = composition.RenderToFileAsync(outFile, MediaTrimmingPreference.Fast);
            }
            saveOperation.Progress = new AsyncOperationProgressHandler <TranscodeFailureReason, double>((info, progress) =>
            {
                ProcessingProgressChanged?.Invoke(this, progress);
            });
            saveOperation.Completed = new AsyncOperationWithProgressCompletedHandler <TranscodeFailureReason, double>((info, status) =>
            {
                if (status == AsyncStatus.Canceled)
                {
                    ProcessingCanceled?.Invoke(this, new EventArgs());
                    return;
                }
                var results = info.GetResults();
                if (results != TranscodeFailureReason.None || status != AsyncStatus.Completed)
                {
                    ProcessingError?.Invoke(this, "合并失败:未知错误");
                }
                else
                {
                    ProcessingCompleted?.Invoke(this, new EventArgs());
                }
            });

            return(saveOperation);
        }
예제 #7
0
        public CrawlingQueueItem ChangeStatus(CrawlingStatuses status)
        {
            if (Status != status)
            {
                Status = status;
                switch (status)
                {
                case CrawlingStatuses.InProxyQueue:
                    QueuedInProxyQueue?.Invoke();
                    break;

                case CrawlingStatuses.InLocalQueue:
                    QueuedInLocalQueue?.Invoke();
                    break;

                case CrawlingStatuses.Downloading:
                    DownloadStarted?.Invoke();
                    break;

                case CrawlingStatuses.Downloaded:
                    DownloadCompleted?.Invoke();
                    break;

                case CrawlingStatuses.Processing:
                    ProcessingStarted?.Invoke();
                    break;

                case CrawlingStatuses.Processed:
                    ProcessingCompleted?.Invoke();
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            return(this);
        }
예제 #8
0
 protected virtual void OnProcessingCompleted(TEvent e)
 {
     ProcessingCompleted?.Invoke(this, e);
 }
예제 #9
0
 void IDisposable.Dispose()
 {
     ProcessingCompleted?.Invoke(this, EventArgs.Empty);
 }
예제 #10
0
 /// <summary>
 /// Invoked when the processing of a <see cref="ProcessingRequest"/> completes successfully
 /// </summary>
 /// <param name="request"><see cref="ProcessingRequest"/> provided to <see cref="ProcessAsync(ProcessingRequest, CancellationToken)"/></param>
 /// <param name="result">Optional result of processing</param>
 protected virtual void OnProcessingCompleted(ProcessingRequest request, string result = null)
 {
     ProcessingCompleted?.Invoke(this, new ProcessingCompletedEventArgs(request, result));
 }