Ejemplo n.º 1
0
        private void CmdDownloadContent_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var episode = e.Parameter as XEpisode;

            if (episode == null)
            {
                MessageBox.Show("Error Episode is NULL!");
                return;
            }

            //this.DownloadInfoCollection.Add(new EpisodeContentDownloadInfo("-----------------------", new Uri("http://voa4.us"))
            //{
            //    Result = DownloadFileResult.Fail,
            //    Persentage = 0
            //});
            this.DownloadInfoCollection.Clear();

            var activity = new ActivityDownloadEpisode();

            IDictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("target", this.CurrentTarget);
            dictionary.Add(nameof(episode), episode);

            this.WorkFlowApp = new WorkflowApplication(activity, dictionary)
            {
                Completed = new Action <WorkflowApplicationCompletedEventArgs>((args) =>
                {
                    const string key = "result";
                    if (args.Outputs.ContainsKey(key))
                    {
                        var result   = args.Outputs[key].ToString();
                        this.Message = "Download Episode Completed! Result:" + result;
                    }
                    this.WorkFlowApp = null;
                    this.CurrentWindow.Dispatcher.Invoke(new Action(() => {
                        CommandManager.InvalidateRequerySuggested();
                    }));
                }),
                OnUnhandledException = new Func <WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction>((args) =>
                {
                    this.Message     = "Workflow Error:" + args.UnhandledException.Message;
                    this.WorkFlowApp = null;
                    this.CurrentWindow.Dispatcher.Invoke(new Action(() =>
                    {
                        CommandManager.InvalidateRequerySuggested();
                    }));
                    return(UnhandledExceptionAction.Cancel);
                }),
            };

            WorkFlowApp.Extensions.Add(this);

            this.Message = "Downloading Episode:" + episode.ID;

            WorkFlowApp.Run();
        }
Ejemplo n.º 2
0
        public void RunWorkflow()
        {
            this.Message = "Recognizing Episode:" + this.Episode.ID;

            WorkFlowApp.Run(TimeSpan.FromSeconds(1));
        }