示例#1
0
        protected virtual void DownloadLeaflet(ILeaflet leaflet)
        {
            try
            {
                if (leaflet.Status == LeafletStatus.Ready)
                {
                    string downloadedFileName = PrepareDownloadFileName(leaflet);

                    _client.DownloadFile(new Uri(leaflet.FileDownloadUrl), downloadedFileName);

                    leaflet.DownloadedFileName = downloadedFileName;
                }
            }
            catch (WebException e)
            {
                HttpWebResponse response = (HttpWebResponse)e.Response;
                leaflet.Status = LeafletStatus.StopProcessing;
                Console.WriteLine("Error downloading file");
            }
            catch (Exception e)
            {
                leaflet.Status = LeafletStatus.StopProcessing;
                Console.WriteLine("Global Error");
            }
        }
示例#2
0
        protected override string PrepareDownloadFileName(ILeaflet leaflet)
        {
            int    week     = (int)leaflet.Values["week"];
            string weekPart = week.ToString().PadLeft(2, '0');

            return($"{weekPart}_Kaufland_{DateTime.Now.ToString("yyyyMMddhhmmss")}.pdf");
        }
示例#3
0
 protected virtual void DownloadLeaflets()
 {
     foreach (var leaflet in _leaflets)
     {
         _currentLeaflet = leaflet;
         DownloadLeaflet(_currentLeaflet);
     }
 }
示例#4
0
 protected abstract string PrepareDownloadFileName(ILeaflet leaflet);