Ejemplo n.º 1
0
        //Metoda, która może zostać wykorzystana w przyszłości, ponawiająca połączenie.

        /*public static class Retry
         * {
         *  public static void Do(
         *      Action action,
         *      TimeSpan retryInterval,
         *      int retryCount = 3)
         *  {
         *      Do<object>(() =>
         *      {
         *          action();
         *          return null;
         *      }, retryInterval, retryCount);
         *  }
         *
         *  public static T Do<T>(
         *      Func<T> action,
         *      TimeSpan retryInterval,
         *      int retryCount = 3)
         *  {
         *      var exceptions = new List<Exception>();
         *
         *      for (int retry = 0; retry < retryCount; retry++)
         *      {
         *          try
         *          {
         *              if (retry > 0)
         *                  Thread.Sleep(retryInterval);
         *              return action();
         *          }
         *          catch (Exception ex)
         *          {
         *              exceptions.Add(ex);
         *          }
         *      }
         *
         *      throw new AggregateException(exceptions);
         *  }
         * }
         *
         * Metoda sprawdzająca wersje aplikacji.
         */
        private void VersionChecking()
        {
            var    versionInfo = FileVersionInfo.GetVersionInfo(path + "\\SmartSell.exe");
            string ver         = versionInfo.ProductVersion;

            DownloadCompletedtxt.Visible = false;
            WebClient request = new WebClient();
            string    url     = "ftp://serwer1585870.home.pl/SB/" + "wersja.txt";

            request.Credentials = new NetworkCredential("pz1-isk1-sggw", "ppz1-isk1-sggw");
            try
            {
                byte[] newFileData = request.DownloadData(url);
                string fileString  = System.Text.Encoding.UTF8.GetString(newFileData);
                if (ver != fileString)
                {
                    /*DialogResult dialog = MessageBox.Show("Istnije nowsza wersja: " + fileString +
                     *                       "\n Czy pobrać ją teraz ?", "Aktualizacja", MessageBoxButtons.YesNo,
                     *                       MessageBoxIcon.Information);
                     * if (dialog == DialogResult.Yes)
                     * {*/
                    BGworkersWithData.Add(BackgroungWorker);
                    BackgroungWorker.RunWorkerAsync();
                    CheckAllThreadsHaveFinishedWorking();
                }
                else
                {
                    CHCKUPD.Text = "Your version is up to date!";
                    UpToDateRun.Start();
                }
            }
            catch (WebException)
            {
                MessageBox.Show("Sprwadź połączenie sieciowe, nie ma możliwości połączenia się z hostem!");
            }
        }
Ejemplo n.º 2
0
 private void UpToDateRun_Tick(object sender, EventArgs e)
 {
     UpToDateRun.Stop();
     CHCKUPD.Text = "Running SmartSell...";
     RunApp();
 }