Пример #1
0
        public DownloadResultList DownloadWithoutDialog(DownloadRequestList objDownloadRequests)
        {
            if (objDownloadRequests == null)
            {
                throw new ArgumentNullException("objDownloadRequests", "A valid non-null DownloadRequestList is expected");
            }

            _objJobResult = null;
            IEnumerable <ITask> objTasks = objDownloadRequests.GetTasks();

            Job objDownloadJob = new Job(objTasks);

            objDownloadJob.JobEnd += new Job.OnJobEndDelegate(objDownloadJob_JobEnd);
            objDownloadJob.Start();
            objDownloadJob.Wait();

            DownloadResultList objDownloadResults = new DownloadResultList();

            if (_objJobResult != null)
            {
                foreach (ITaskResult objTaskResult in _objJobResult.TaskResults)
                {
                    DownloadResult objDownloadResult = (DownloadResult)objTaskResult;
                    objDownloadResults.Add(objDownloadResult);
                }
            }

            return(objDownloadResults);
        }
Пример #2
0
        private TaskActionType ShowDialogWithResult(ITaskResult objTaskResult)
        {
            if (objTaskResult is DownloadResult)
            {
                DownloadResult objDownloadResult = (DownloadResult)objTaskResult;
                textBoxDetails.Text = objDownloadResult.ToString();
            }
            else
            {
                StringBuilder objText = new StringBuilder();
                objText.AppendLine("Result: " + objTaskResult.Result.ToString());
                objText.AppendLine("Details: " + objTaskResult.Details);
                textBoxDetails.Text = objText.ToString();
            }

            this.ShowDialog();
            return(_enuTaskActionType);
        }
Пример #3
0
        public ITaskResult Execute(JobTicket objJobTicket)
        {
            TaskResultType         enuTaskResult             = TaskResultType.Completed;
            DownloadResult         objDownloadResult         = null;
            DownloadRequestSession objDownloadRequestSession = new DownloadRequestSession(this, objJobTicket);

            try
            {
                enuTaskResult     = Execute(objDownloadRequestSession);
                objDownloadResult = new DownloadResult(this, enuTaskResult, objDownloadRequestSession.DownloadStats);
            }
            catch (Exception objException)
            {
                ErrorMessage objErrorMessage = new ErrorMessage(objException);
                ApplicationManager.Logs.WriteMessage(objErrorMessage);

                string strErrorMessage = objException.ToString();
                objDownloadResult = new DownloadResult(this, TaskResultType.Failed, objDownloadRequestSession.DownloadStats, strErrorMessage);
            }

            return(objDownloadResult);
        }