/// <summary>
            /// Initializes a new instance of the <see cref="DataUpdateDownloadControl"/> class.
            /// </summary>
            /// <param name="datafile">The datafile.</param>
            internal DataUpdateDownloadControl(SerializableDatafile datafile)
            {
                InitializeComponent();

                m_datafile           = datafile;
                m_label.Text         = $"{datafile.Name}";
                m_progressLabel.Text = @"Downloading update...";
                m_tempFilename       = Path.Combine(EveMonClient.EVEMonDataDir, $"{datafile.Name}.tmp");

                WebClient = HttpWebClientService.GetWebClient();
            }
Exemple #2
0
        /// <summary>
        /// Handles the Shown event of the UpdateDownloadForm control.
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            string urlValidationError;

            if (!HttpWebClientService.IsValidURL(m_url, out urlValidationError))
            {
                throw new ArgumentException(urlValidationError);
            }

            try
            {
                using (m_client = HttpWebClientService.GetWebClient())
                {
                    m_client.DownloadFileCompleted   += DownloadCompleted;
                    m_client.DownloadProgressChanged += ProgressChanged;

                    try
                    {
                        m_client.DownloadFileAsync(m_url, m_fileName);
                    }
                    catch (WebException ex)
                    {
                        throw HttpWebClientServiceException.HttpWebClientException(m_url, ex);
                    }
                    catch (Exception ex)
                    {
                        throw HttpWebClientServiceException.Exception(m_url, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.LogRethrowException(ex);
                throw;
            }
        }