コード例 #1
0
ファイル: FrmUpdate.cs プロジェクト: leha-bot/srcrepair
        /// <summary>
        /// Finalizes update checking procedure.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Completion arguments and results.</param>
        private void WrkChkApp_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (e.Error == null)
                {
                    // Checking for application update...
                    if (UpMan.CheckAppUpdate())
                    {
                        UpdAppImg.Image   = Properties.Resources.upd_av;
                        UpdAppStatus.Text = String.Format(AppStrings.UPD_AppUpdateAvail, UpMan.AppUpdateVersion);
                    }
                    else
                    {
                        UpdAppImg.Image   = Properties.Resources.upd_nx;
                        UpdAppStatus.Text = AppStrings.UPD_AppNoUpdates;
                        UpdateTimeSetApp();
                    }
                }
                else
                {
                    // Changing controls texts...
                    UpdAppImg.Image   = Properties.Resources.upd_err;
                    UpdAppStatus.Text = AppStrings.UPD_AppCheckFailure;

                    // Writing issue to log...
                    Logger.Warn(e.Error);
                }
            }
            catch (Exception Ex)
            {
                Logger.Warn(Ex);
            }
        }
コード例 #2
0
ファイル: FrmUpdate.cs プロジェクト: leha-bot/srcrepair
 /// <summary>
 /// "Install app update" button click event handler.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 private void UpdAppStatus_Click(object sender, EventArgs e)
 {
     if (!WrkChkApp.IsBusy)
     {
         if (UpMan.CheckAppUpdate())
         {
             if (Platform.OS == CurrentPlatform.OSType.Windows)
             {
                 if (InstallBinaryUpdate(UpMan.AppUpdateURL))
                 {
                     Platform.Exit(ReturnCodes.AppUpdatePending);
                 }
             }
             else
             {
                 MessageBox.Show(String.Format(AppStrings.UPD_AppOtherPlatform, Platform.OSFriendlyName), Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             MessageBox.Show(AppStrings.UPD_LatestInstalled, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show(AppStrings.DB_WrkInProgress, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #3
0
 private void UpdHUDStatus_Click(object sender, EventArgs e)
 {
     if (!WrkChkApp.IsBusy)
     {
         // Проверяем наличие обновлений...
         if (UpMan.CheckHUDUpdate())
         {
             // Запускаем процесс установки обновления...
             if (InstallDatabaseUpdate(Properties.Resources.HUDDbFile, UpMan.HUDUpdateURL, UpMan.HUDUpdateHash))
             {
                 // Обновляем дату последней проверки обновлений...
                 UpdateTimeSetHUD();
             }
         }
         else
         {
             // Обновление не требуется. Выводим соответствующее сообщение...
             MessageBox.Show(AppStrings.UPD_LatestDBInstalled, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show(AppStrings.DB_WrkInProgress, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #4
0
 private void UpdAppStatus_Click(object sender, EventArgs e)
 {
     if (!WrkChkApp.IsBusy)
     {
         // Проверяем наличие обновлений программы...
         if (UpMan.CheckAppUpdate())
         {
             // Проверяем платформу, на которой запущено приложение...
             if (Platform.OS == CurrentPlatform.OSType.Windows)
             {
                 // Устанавливаем доступное обновление...
                 if (InstallBinaryUpdate(UpMan.AppUpdateURL, UpMan.AppUpdateHash))
                 {
                     // Загрузка завершилась успешно. Завершаем работу приложения для установки...
                     Environment.Exit(9);
                 }
             }
             else
             {
                 // Платформа не Windows, выведем сообщение...
                 MessageBox.Show(String.Format(AppStrings.UPD_AppOtherPlatform, Platform.OSFriendlyName), Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             // Обновление не требуется, поэтому просто выводим сообщение об этом...
             MessageBox.Show(AppStrings.UPD_LatestInstalled, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show(AppStrings.DB_WrkInProgress, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #5
0
        private void WrkChkApp_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                // Проверим статус проверки...
                if (e.Error == null)
                {
                    // Проверим наличие обновлений для приложения...
                    if (UpMan.CheckAppUpdate())
                    {
                        UpdAppImg.Image = Properties.Resources.upd_av; UpdAppStatus.Text = String.Format(AppStrings.UPD_AppUpdateAvail, UpMan.AppUpdateVersion);
                    }
                    else
                    {
                        UpdAppImg.Image = Properties.Resources.upd_nx; UpdAppStatus.Text = AppStrings.UPD_AppNoUpdates; UpdateTimeSetApp();
                    }

                    // Проверим наличие обновлений для базы игр...
                    if (UpMan.CheckGameDBUpdate())
                    {
                        UpdDBImg.Image = Properties.Resources.upd_av; UpdDBStatus.Text = String.Format(AppStrings.UPD_DbUpdateAvail, UpMan.GameUpdateHash.Substring(0, 7));
                    }
                    else
                    {
                        UpdDBImg.Image = Properties.Resources.upd_nx; UpdDBStatus.Text = AppStrings.UPD_DbNoUpdates;
                    }

                    // Проверим наличие обновлений для базы HUD...
                    if (UpMan.CheckHUDUpdate())
                    {
                        UpdHUDDbImg.Image = Properties.Resources.upd_av; UpdHUDStatus.Text = String.Format(AppStrings.UPD_HUDUpdateAvail, UpMan.HUDUpdateHash.Substring(0, 7));
                    }
                    else
                    {
                        UpdHUDDbImg.Image = Properties.Resources.upd_nx; UpdHUDStatus.Text = AppStrings.UPD_HUDNoUpdates; UpdateTimeSetHUD();
                    }
                }
                else
                {
                    // Произошла ошибка...
                    UpdAppImg.Image   = Properties.Resources.upd_err;
                    UpdAppStatus.Text = AppStrings.UPD_AppCheckFailure;
                    UpdDBImg.Image    = Properties.Resources.upd_err;
                    UpdDBStatus.Text  = AppStrings.UPD_DbCheckFailure;
                    UpdHUDDbImg.Image = Properties.Resources.upd_err;
                    UpdHUDStatus.Text = AppStrings.UPD_HUDCheckFailure;

                    // Запишем в журнал...
                    CoreLib.WriteStringToLog(e.Error.Message);
                }
            }
            catch (Exception Ex)
            {
                CoreLib.WriteStringToLog(Ex.Message);
            }
        }
コード例 #6
0
 private void UpdDBStatus_Click(object sender, EventArgs e)
 {
     if (!WrkChkApp.IsBusy)
     {
         if (UpMan.CheckGameDBUpdate())
         {
             InstallDatabaseUpdate(Properties.Resources.GameListFile, UpMan.GameUpdateURL, UpMan.GameUpdateHash);
         }
         else
         {
             MessageBox.Show(AppStrings.UPD_LatestDBInstalled, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show(AppStrings.DB_WrkInProgress, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #7
0
ファイル: FrmUpdate.cs プロジェクト: leha-bot/srcrepair
        /// <summary>
        /// Installs standalone update.
        /// </summary>
        /// <param name="UpdateURL">Full download URL.</param>
        /// <returns>Result of operation.</returns>
        private bool InstallBinaryUpdate(string UpdateURL)
        {
            // Setting default value for result...
            bool Result = false;

            // Generating full paths to files...
            string UpdateFileName = UpdateManager.GenerateUpdateFileName(Path.Combine(AppUpdateDir, Path.GetFileName(UpdateURL)));

            // Downloading update from server...
            GuiHelpers.FormShowDownloader(UpMan.AppUpdateURL, UpdateFileName);

            // Checking if downloaded file exists...
            if (File.Exists(UpdateFileName))
            {
                // Checking hashes...
                if (UpMan.CheckAppHash(FileManager.CalculateFileSHA512(UpdateFileName)))
                {
                    // Setting last update check date...
                    UpdateTimeSetApp();

                    // Showing message about successful download...
                    MessageBox.Show(AppStrings.UPD_UpdateSuccessful, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Installing standalone update...
                    try
                    {
                        // Checking if app's installation directory is writable...
                        if (FileManager.IsDirectoryWritable(FullAppPath))
                        {
                            // Running installer with current access rights...
                            Platform.StartRegularProcess(UpdateFileName);
                        }
                        else
                        {
                            // Running installer with UAC access rights elevation...
                            Platform.StartElevatedProcess(UpdateFileName);
                        }
                        Result = true;
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show(AppStrings.UPD_UpdateFailure, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Logger.Error(Ex, DebugStrings.AppDbgExUpdBinInst);
                    }
                }
                else
                {
                    // Hash missmatch. File was damaged. Removing it...
                    try
                    {
                        File.Delete(UpdateFileName);
                    }
                    catch (Exception Ex)
                    {
                        Logger.Warn(Ex);
                    }

                    // Showing message about hash missmatch...
                    MessageBox.Show(AppStrings.UPD_HashFailure, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                // Showing error about update failure...
                MessageBox.Show(AppStrings.UPD_UpdateFailure, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // Returning result...
            return(Result);
        }