Pokaż
Ignoruj:
Data:
2009-04-21 17:45:38 (17 years ago)
Autor:
marek
Opis:

re #165

Pliki:
1 zmodyfikowane

Legenda:

Bez zmian
Dodane
Usunięte
  • trunk/BazaReklam/FormBadVer.cs

    r65 r597  
    11using System; 
    2 using System.Collections.Generic; 
    32using System.ComponentModel; 
    4 using System.Data; 
    5 using System.Drawing; 
    6 using System.Text; 
    73using System.Windows.Forms; 
    84using System.Net; 
    95using System.Diagnostics; 
     6 
    107using Baza_Reklam.Classes; 
    118 
     
    1411    public partial class FormBadVer : Form 
    1512    { 
    16         private WebClient webClient; 
    17         private bool isBusy = false; 
    18         const string strUrl = "http://www.infocity.pl/baza_reklam/files/Updater.exe"; 
     13        const string UPDATER_URL = "http://www.infocity.pl/baza_reklam/update/updater.exe"; 
     14        const string ZIP_URL = "http://www.infocity.pl/baza_reklam/update/BazaReklam.zip"; 
     15 
     16        private readonly WebClient webClient; 
    1917 
    2018        public FormBadVer() 
    2119        { 
    2220            InitializeComponent(); 
    23              
     21 
    2422            webClient = new WebClient(); 
    25             webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted); 
     23            webClient.DownloadFileCompleted += DownloadFileCompleted; 
    2624        } 
    2725 
    2826        private void button1_Click(object sender, EventArgs e) 
    2927        { 
    30             string updater = Environment.CurrentDirectory + "\\Updater.exe"; 
     28            button1.Enabled = false; 
     29            Cursor = Cursors.WaitCursor; 
     30            button1.Cursor = Cursors.WaitCursor; 
     31            webClient.DownloadFileAsync(new Uri(UPDATER_URL), Environment.CurrentDirectory + "\\Updater.exe"); 
     32            return; 
    3133 
    32             if (System.IO.File.Exists(updater)) 
    33             { 
    34                 StartUpdater(); 
    35             } 
    36             else 
    37             { 
    38                 isBusy = true; 
    39                 webClient.DownloadFileAsync(new Uri(strUrl), Environment.CurrentDirectory + "\\Updater.exe");             
    40             } 
     34            //TODO: Uncomment after every user will get updated version of the Updater 
     35            //string updater = Environment.CurrentDirectory + "\\Updater.exe"; 
     36 
     37            //if (System.IO.File.Exists(updater)) 
     38            //    StartUpdater(); 
     39            //else 
     40            //    webClient.DownloadFileAsync(new Uri(UPDATER_URL), Environment.CurrentDirectory + "\\Updater.exe"); 
    4141        } 
    4242 
    4343        private void DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) 
    4444        { 
    45             isBusy = false; 
    46                       
    4745            if (e.Error == null) 
    4846            { 
     
    5250            { 
    5351                MessageBox.Show("B³¹d aktualizacji oprogramowania: " + e.Error.Message, "Aktualizacja oprogramowania", MessageBoxButtons.OK, MessageBoxIcon.Error); 
     52                Logger.LogException(e.Error, "[aktualizacja]", DateTime.Now); 
    5453                Close(); 
    5554            } 
     
    5958        { 
    6059            string updater = Environment.CurrentDirectory + "\\Updater.exe"; 
    61  
     60            Cursor = Cursors.Default; 
     61            button1.Cursor = Cursors.Default; 
    6262            Close(); 
    63             ProcessStartInfo startInfo = new ProcessStartInfo(); 
    64             startInfo.Arguments = "1"; 
    65             startInfo.FileName = updater; 
    66             Process.Start(startInfo); 
     63            Process.Start(updater, string.Format(" \"{0}\" {1}", "Baza Reklam", ZIP_URL)); 
    6764        } 
    68  
    69         private void Extract(string zipFileName, string destinationPath) 
    70         { 
    71             Shell32.ShellClass sc = new Shell32.ShellClass(); 
    72             Shell32.Folder SrcFlder = sc.NameSpace(zipFileName); 
    73             Shell32.Folder DestFlder = sc.NameSpace(destinationPath); 
    74             Shell32.FolderItems items = SrcFlder.Items(); 
    75             DestFlder.CopyHere(items, 20);         
    76         } 
    77  
    78  
    7965    } 
    8066}