Ejemplo n.º 1
0
        public UploadResultList UploadWithoutDialog(UploadRequestList objUploadRequests)
        {
            if (objUploadRequests == null)
            {
                throw new ArgumentNullException("objUploadRequests", "A valid non-null UploadRequestList is expected");
            }

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

            Job objUploadJob = new Job(objTasks);

            objUploadJob.JobEnd += new Job.OnJobEndDelegate(objUploadJob_JobEnd);
            objUploadJob.Start();
            objUploadJob.Wait();

            UploadResultList objUploadResults = new UploadResultList();

            if (_objJobResult != null)
            {
                foreach (ITaskResult objTaskResult in _objJobResult.TaskResults)
                {
                    UploadResult objUploadResult = (UploadResult)objTaskResult;
                    objUploadResults.Add(objUploadResult);
                }
            }

            return(objUploadResults);
        }
Ejemplo n.º 2
0
        private void UploadThread()
        {
            Thread.Sleep(10);

            this.ThreadSafe(new MethodInvoker(delegate()
            {
                listViewStatus.Items.Clear();
                foreach (UploadRequest objUploadRequest in _objUploadRequests)
                {
                    string strFileName           = Path.GetFileName(objUploadRequest.Source);
                    ListViewItem objListViewItem = new ListViewItem(objUploadRequest.Source);
                    objListViewItem.SubItems.Add("Queued");
                    listViewStatus.Items.Add(objListViewItem);
                }

                buttonCancel.Enabled        = _objUploadDialogSettings.AllowCancel;
                buttonPauseContinue.Enabled = _objUploadDialogSettings.AllowPause;
                this.Refresh();
            }));

            _intTaskIndex = 0;
            _intTaskCount = _objUploadRequests.Count;
            _objJobResult = null;

            IEnumerable <ITask> objTasks = _objUploadRequests.GetTasks();

            _objJob                      = new Job(objTasks);
            _objJob.TaskBegin           += new Job.OnTaskBeginDelegate(objUploadJob_TaskBegin);
            _objJob.TaskEnd             += new Job.OnTaskEndDelegate(objUploadJob_TaskEnd);
            _objJob.JobEnd              += new Job.OnJobEndDelegate(objUploadJob_JobEnd);
            _objJob.TaskProgressChanged += new Job.TaskProgressChangedDelegate(objUploadJob_TaskProgressChanged);
            _objJob.Start();
            _objJob.Wait();

            _objUploadResults = new UploadResultList();
            if (_objJobResult != null)
            {
                _objUploadResults = new UploadResultList(_objJobResult.TaskResults);
            }

            Thread.Sleep(10);

            this.ThreadSafe(new MethodInvoker(delegate()
            {
                this.Close();
            }));
        }