Exemplo n.º 1
0
        protected override Core.Services.ServiceOutcome DoPipelineWork()
        {
            // Create a batch and use its progress as the service's progress
            BatchDownloadOperation batch = new BatchDownloadOperation();

            batch.Progressed += new EventHandler((sender, e) =>
            {
                this.ReportProgress(batch.Progress * 0.95);
            });

            foreach (DeliveryFile file in this.Delivery.Files)
            {
                WebRequest request = WebRequest.Create(file.SourceUrl);
                this.Delivery.Save();
                DeliveryFileDownloadOperation download = file.Download(request);
                //download.Ended += new EventHandler(download_Ended);
                batch.Add(download);
            }

            batch.Start();
            batch.Wait();

            this.Delivery.Save();
            return(Core.Services.ServiceOutcome.Success);
        }
Exemplo n.º 2
0
        protected override Core.Services.ServiceOutcome DoPipelineWork()
        {
            // Create a batch and use its progress as the service's progress
            BatchDownloadOperation batch = new BatchDownloadOperation();

            batch.Progressed += new EventHandler((sender, e) =>
            {
                this.Progress = batch.Progress * 0.95;
            });

            foreach (DeliveryFile file in this.Delivery.Files)
            {
                if (String.IsNullOrWhiteSpace(file.SourceUrl))
                {
                    continue;
                }

                DeliveryFileDownloadOperation download = file.Download();
                download.Ended += new EventHandler(download_Ended);
                batch.Add(download);
            }

            batch.Start();
            batch.Wait();


            this.Delivery.Save();

            return(Core.Services.ServiceOutcome.Success);
        }
Exemplo n.º 3
0
        protected override ServiceOutcome DoPipelineWork()
        {
            _progressHandler = new EventHandler <ProgressEventArgs>(this.OperationProgressed);
            _endedHandler    = new EventHandler <EndedEventArgs>(this.OperationEnded);
            _waitForDownload = new AutoResetEvent(false);

            foreach (DeliveryFile file in this.Delivery.Files)
            {
                // Ignore files that have already been downloaded (unless Overwrite is true)
                if (!Overwrite && file.History.Count(entry => entry.Operation == DeliveryOperation.Retrieved) > 0)
                {
                    Log.Write(String.Format("Delivery file '{0}' (1) has already been retrieved.", file.Name, file.FileID), LogMessageType.Information);
                    continue;
                }
                else
                {
                    // Start downloading, and report progress of the download divided by total number of files
                    DeliveryFileDownloadOperation operation = file.Download();
                    operation.Progressed += _progressHandler;
                    operation.Ended      += _endedHandler;
                }
            }

            _waitForDownload.WaitOne();

            return(ServiceOutcome.Success);
        }
Exemplo n.º 4
0
        protected override Core.Services.ServiceOutcome DoPipelineWork()
        {
            // Create a batch and use its progress as the service's progress
            BatchDownloadOperation batch = new BatchDownloadOperation();

            batch.Progressed += new EventHandler((sender, e) =>
            {
                this.ReportProgress(batch.Progress * 0.95);
            });

            foreach (DeliveryFile file in this.Delivery.Files)
            {
                if (String.IsNullOrWhiteSpace(file.SourceUrl))
                {
                    continue;
                }

                WebRequest request = WebRequest.Create(file.SourceUrl);
                request.ContentType = file.Parameters["Content-Type"].ToString();
                request.Method      = "POST";

                byte[] bytes = Encoding.UTF8.GetBytes(file.Parameters["Body"].ToString());
                request.ContentLength = bytes.Length;

                using (var stream = request.GetRequestStream())
                {
                    stream.Write(bytes, 0, bytes.Length);
                }

                //Headers
                request.Headers.Add("SOAPAction", file.Parameters["SOAPAction"].ToString());

                this.Delivery.Save();
                DeliveryFileDownloadOperation download = file.Download(request);
                download.Ended += new EventHandler(download_Ended);
                batch.Add(download);
            }

            batch.Start();
            batch.Wait();

            // Add a retrieved history entry for the entire delivery

            this.Delivery.Save();

            return(ServiceOutcome.Success);
        }
        protected override Core.Services.ServiceOutcome DoPipelineWork()
        {
            // Create a batch and use its progress as the service's progress
            BatchDownloadOperation batch = new BatchDownloadOperation();

            batch.Progressed += new EventHandler((sender, e) =>
            {
                this.ReportProgress(batch.Progress * 0.95);
            });

            foreach (DeliveryFile file in this.Delivery.Files)
            {
                WebRequest request = WebRequest.Create(file.SourceUrl);
                //request.ContentType = file.Parameters["Content-Type"].ToString();
                //request.Method = "POST";

                //byte[] bytes = Encoding.UTF8.GetBytes(string.Empty);
                //request.ContentLength = bytes.Length;

                //using (var stream = request.GetRequestStream())
                //{
                //    stream.Write(bytes, 0, bytes.Length);
                //}

                ////Headers
                //request.Headers.Add("SOAPAction", file.Parameters["SOAPAction"].ToString());

                this.Delivery.Save();
                DeliveryFileDownloadOperation download = file.Download(request);
                //download.Ended += new EventHandler(download_Ended);
                batch.Add(download);
            }

            batch.Start();
            batch.Wait();

            this.Delivery.Save();
            return(Core.Services.ServiceOutcome.Success);
        }