// Запуск обработки private void BeginProcessing_Click(object sender, EventArgs e) { // Контроль if (dataTables.Count < 2) { MessageBox.Show(Localization.GetText("NotEnoughFilesToMerge", al), ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Подготовка AddFiles.Enabled = ClearFiles.Enabled = MergeType.Enabled = BeginProcessing.Enabled = SaveResult.Enabled = BExit.Enabled = success = false; dataRows.Clear(); mergedTable.Clear(); mergedColumnNames.Clear(); mergeType = MergeType.SelectedIndex; // Запуск HardWorkExecutor hwe = new HardWorkExecutor(ExecuteMerge, null, " ", true, true); // Завершено AddFiles.Enabled = ClearFiles.Enabled = MergeType.Enabled = BeginProcessing.Enabled = BExit.Enabled = true; if (success) { ProcessingResults.Items.Add(string.Format(Localization.GetText("TablesMergeCompleted", al), mergedTable.Count, mergedTable[0].Count)); ProcessingResults.SelectedIndex = ProcessingResults.Items.Count - 1; SaveResult.Enabled = true; } }
// Основной метод запуска окна private int LaunchForm(bool StartupMode, bool AcceptMode) { // Запрос последней версии string helpShownAt = ""; if (StartupMode || AcceptMode) { try { // Исправлен некорректный порядок вызовов adpRevision = Registry.GetValue(ADPRevisionPath, ADPRevisionKey, "").ToString(); helpShownAt = Registry.GetValue(ProgramDescription.AssemblySettingsKey, LastShownVersionKey, "").ToString(); } catch { } // Если поле пустое, устанавливается минимальное значение if (adpRevision == "") { adpRevision = "rev. 8!"; try { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision); } catch { } } } // Контроль if (StartupMode && (helpShownAt == ProgramDescription.AssemblyVersion) || // Справка уже отображалась AcceptMode && (!adpRevision.EndsWith("!"))) // Политика уже принята { return(1); } // Настройка контролов switch (al) { case SupportedLanguages.ru_ru: UserManualButton.Text = "&Руководство"; ProjectPageButton.Text = "&О проекте"; UpdatesPageButton.Text = "Поиск обновлений..."; ADPButton.Text = AcceptMode ? "Открыть в &браузере" : "&Политика и EULA"; ExitButton.Text = AcceptMode ? "&Принять" : "&ОК"; AskDeveloper.Text = "Спросить ра&зработчика"; MisacceptButton.Text = "О&тклонить"; DescriptionBox.Text = AcceptMode ? "Не удалось получить текст Политики. " + "Попробуйте использовать кнопку перехода в браузер" : description; policyLoaderCaption = "Подготовка к запуску..."; this.Text = AcceptMode ? "Политика разработки и соглашение пользователя" : "О программе"; break; default: // en_us UserManualButton.Text = "&User manual"; ProjectPageButton.Text = "Project &webpage"; UpdatesPageButton.Text = "Checking updates..."; ADPButton.Text = AcceptMode ? "Open in &browser" : "&Policy and EULA"; ExitButton.Text = AcceptMode ? "&Accept" : "&OK"; AskDeveloper.Text = "Ask &developer"; MisacceptButton.Text = "&Decline"; DescriptionBox.Text = AcceptMode ? "Failed to get Policy text. Try button to open it in browser" : description; policyLoaderCaption = "Preparing for launch..."; this.Text = AcceptMode ? "Development policy and user agreement" : "About application"; break; } ToLaboratory.Text = "Free development lab"; // Запуск проверки обновлений HardWorkExecutor hwe; if (!AcceptMode) { hwe = new HardWorkExecutor(UpdatesChecker, null, ""); UpdatesTimer.Enabled = true; } // Получение Политики else { hwe = new HardWorkExecutor(PolicyLoader, null, policyLoaderCaption); string html = hwe.Result.ToString(); if (html != "") { DescriptionBox.Text = html; int left = html.IndexOf("rev"); int right = html.IndexOf("\r", left); if ((left >= 0) && (right >= 0)) { adpRevision = html.Substring(left, right - left); } } } // Настройка контролов UserManualButton.Visible = ProjectPageButton.Visible = UpdatesPageButton.Visible = AskDeveloper.Visible = ToLaboratory.Visible = !AcceptMode; MisacceptButton.Visible = AcceptMode; // Запуск this.ShowDialog(); // Запись версий по завершению try { if (StartupMode) { Registry.SetValue(ProgramDescription.AssemblySettingsKey, LastShownVersionKey, ProgramDescription.AssemblyVersion); } if (AcceptMode && accepted) { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision.Replace("!", "")); } // В случае невозможности загрузки Политики признак необходимости принятия до этого момента // не удаляется из строки версии. Поэтому требуется страховка } catch { } // Завершение return(accepted ? 0 : -1); }
// Загрузка пакета обновления изнутри приложения private void UpdatesPageButton_Click(object sender, EventArgs e) { // Контроль наличия DPModule string dpmv = ""; try { dpmv = Registry.GetValue(RDGenerics.AssemblySettingsStorage + "DPModule", LastShownVersionKey, "").ToString(); } catch { } string downloadLink = RDGenerics.DPModuleStorageLink; string packagePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\"; if (string.IsNullOrWhiteSpace(dpmv)) { // Выбор варианта обработки switch (MessageBox.Show(dpModuleAbsence, ProgramDescription.AssemblyTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { case DialogResult.Cancel: return; case DialogResult.No: try { Process.Start(RDGenerics.DPModuleUserManualLink); } catch { } return; } downloadLink = RDGenerics.DPModuleDirectLink; packagePath += "DPModule.sfx.exe"; } else { if (MessageBox.Show(startDownload, ProgramDescription.AssemblyTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } downloadLink += ("/raw/master/Packages/" + ProgramDescription.AssemblyMainName + ".dp"); packagePath += (ProgramDescription.AssemblyMainName + ".dp"); } // Запуск загрузки HardWorkExecutor hwe = new HardWorkExecutor(PackageLoader, downloadLink, packagePath, "0"); // Разбор ответа string msg = ""; switch (hwe.ExecutionResult) { case 0: break; case -1: case -2: msg = packageFail; break; case -3: msg = fileWriteFail; break; default: // Отмена try { File.Delete(packagePath); } catch { } return; } if (!string.IsNullOrWhiteSpace(msg)) { MessageBox.Show(msg, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Запуск пакета try { Process.Start(packagePath); } catch { } }
// Основной метод запуска окна private int LaunchForm(bool StartupMode, bool AcceptMode) { // Запрос последней версии string helpShownAt = ""; if (StartupMode || AcceptMode) { try { // Исправлен некорректный порядок вызовов adpRevision = Registry.GetValue(ADPRevisionPath, ADPRevisionKey, "").ToString(); helpShownAt = Registry.GetValue(RDGenerics.AssemblySettingsKey, LastShownVersionKey, "").ToString(); } catch { } // Если поле пустое, устанавливается минимальное значение if (adpRevision == "") { adpRevision = "rev. 8!"; try { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision); } catch { } } } // Контроль if (StartupMode && (helpShownAt == ProgramDescription.AssemblyVersion) || // Справка уже отображалась AcceptMode && (!adpRevision.EndsWith("!"))) // Политика уже принята { return(1); } // Настройка контролов switch (al) { case SupportedLanguages.ru_ru: UserManualButton.Text = "&Руководство"; ProjectPageButton.Text = "&О проекте"; UpdatesPageButton.Text = "Поиск обновлений..."; ADPButton.Text = AcceptMode ? "Открыть в &браузере" : "&Политика и EULA"; ExitButton.Text = AcceptMode ? "&Принять" : "&ОК"; AskDeveloper.Text = "Спросить ра&зработчика"; MisacceptButton.Text = "О&тклонить"; if (!desciptionHasBeenUpdated) { DescriptionBox.Text = AcceptMode ? "Не удалось получить текст Политики. " + "Попробуйте использовать кнопку перехода в браузер" : "[Проверка обновлений...]\r\n\r\n" + description; } policyLoaderCaption = "Подготовка к запуску..."; registryFail = ProgramDescription.AssemblyMainName + " не может сохранить настройки в реестре Windows. Оно не будет работать корректно.\n\n" + "Попробуйте выполнить следующие изменения в свойствах исполняемого файла:\n" + "• разблокируйте приложение в общих свойствах (кнопка «Разблокировать»);\n" + "• включите запуск от имени администратора для всех пользователей в настройках совместимости.\n\n" + "После этого перезапустите программу и повторите попытку"; dpModuleAbsence = "Инструмент развёртки пакетов DPModule не найден на этом ПК. Перейти к его загрузке?" + "\n\nВы можете обновить этот продукт прямо из DPModule или вернуться сюда после его установки. " + "Также Вы можете ознакомиться с презентацией DPModule на YouTube, нажав кнопку «Нет»"; packageFail = "Не удалось загрузить пакет развёртки. Проверьте Ваше подключение к Интернету"; fileWriteFail = "Не удалось сохранить пакет развёртки. Проверьте Ваши права доступа"; startDownload = "Начать загрузку пакета?\n\nПакет развёртки будет сохранён на Рабочем столе " + "и запущен автоматически"; ToLaboratoryCombo.Items.AddRange(RDGenerics.GetCommunitiesNames(false)); ToLaboratoryCombo.SelectedIndex = 0; this.Text = AcceptMode ? "Политика разработки и соглашение пользователя" : "О приложении"; break; default: // en_us UserManualButton.Text = "&User manual"; ProjectPageButton.Text = "Project’s &webpage"; UpdatesPageButton.Text = "Checking updates..."; ADPButton.Text = AcceptMode ? "Open in &browser" : "&Policy and EULA"; ExitButton.Text = AcceptMode ? "&Accept" : "&OK"; AskDeveloper.Text = "Ask the &developer"; MisacceptButton.Text = "&Decline"; if (!desciptionHasBeenUpdated) { DescriptionBox.Text = AcceptMode ? "Failed to get Policy text. Try button to open it in browser" : "[Checking for updates...]\r\n\r\n" + description; } policyLoaderCaption = "Preparing for launch..."; registryFail = ProgramDescription.AssemblyMainName + " cannot save settings in the Windows registry. It will not work properly.\n\n" + "Try the following changes to properties of the executable file:\n" + "• unblock the app in general properties (“Unblock” button);\n" + "• enable running as administrator for all users in compatibility settings.\n\n" + "Then restart the program and try again"; dpModuleAbsence = "DPModule, the packages deployment tool isn’t installed on this PC. " + "Download it?\n\nYou can update this product directly from DPModule or come back here " + "after installing it. Also you can view the DPModule presentation on YouTube by pressing “No” button"; packageFail = "Failed to download deployment package. Check your internet connection"; fileWriteFail = "Failed to save deployment package. Check your user access rights"; startDownload = "Download the package?\n\nThe deployment package will be saved on the Desktop " + "and started automatically"; ToLaboratoryCombo.Items.AddRange(RDGenerics.GetCommunitiesNames(true)); ToLaboratoryCombo.SelectedIndex = 0; this.Text = AcceptMode ? "Development policy and user agreement" : "About the application"; break; } // Запуск проверки обновлений HardWorkExecutor hwe; if (!AcceptMode) { UpdatesPageButton.Enabled = false; #if DPMODULE hwe = new HardWorkExecutor(UpdatesChecker, null, null, false, false, false); #else hwe = new HardWorkExecutor(UpdatesChecker, null, null, false, false); #endif UpdatesTimer.Enabled = true; } // Получение Политики else { #if DPMODULE hwe = new HardWorkExecutor(PolicyLoader, null, policyLoaderCaption, true, false, true); #else hwe = new HardWorkExecutor(PolicyLoader, null, policyLoaderCaption, true, false); #endif string html = hwe.Result.ToString(); if (!string.IsNullOrWhiteSpace(html)) { DescriptionBox.Text = html; int left = html.IndexOf("rev"); int right = html.IndexOf("\n", left); if ((left >= 0) && (right >= 0)) { adpRevision = html.Substring(left, right - left); } } } // Настройка контролов UserManualButton.Visible = ProjectPageButton.Visible = UpdatesPageButton.Visible = AskDeveloper.Visible = ToLaboratory.Visible = !AcceptMode; #if DPMODULE UpdatesPageButton.Visible = false; #endif MisacceptButton.Visible = AcceptMode; // Запуск this.ShowDialog(); // Запись версий по завершению try { if (StartupMode) { Registry.SetValue(RDGenerics.AssemblySettingsKey, LastShownVersionKey, ProgramDescription.AssemblyVersion); // Контроль доступа к реестру WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); if (!principal.IsInRole(WindowsBuiltInRole.Administrator)) { MessageBox.Show(registryFail, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // В случае невозможности загрузки Политики признак необходимости принятия до этого момента // не удаляется из строки версии. Поэтому требуется страховка if (AcceptMode && accepted) { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision.Replace("!", "")); } } catch { MessageBox.Show(registryFail, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // Завершение return(accepted ? 0 : -1); }
// Основной метод запуска окна private int LaunchForm(bool StartupMode, bool AcceptMode) { // Запрос последней версии string helpShownAt = ""; if (StartupMode || AcceptMode) { try { // Исправлен некорректный порядок вызовов adpRevision = Registry.GetValue(ADPRevisionPath, ADPRevisionKey, "").ToString(); helpShownAt = Registry.GetValue(RDGenerics.AssemblySettingsKey, LastShownVersionKey, "").ToString(); } catch { } // Если поле пустое, устанавливается минимальное значение if (adpRevision == "") { adpRevision = "rev. 8!"; try { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision); } catch { } } } // Контроль if (StartupMode && (helpShownAt == ProgramDescription.AssemblyVersion) || // Справка уже отображалась AcceptMode && (!adpRevision.EndsWith("!"))) // Политика уже принята { return(1); } // Настройка контролов UserManualButton.Text = locale[(int)al][0]; ProjectPageButton.Text = locale[(int)al][1]; UpdatesPageButton.Text = locale[(int)al][2]; ADPButton.Text = locale[(int)al][AcceptMode ? 3 : 4]; ExitButton.Text = locale[(int)al][AcceptMode ? 5 : 6]; AskDeveloper.Text = locale[(int)al][7]; MisacceptButton.Text = locale[(int)al][8]; if (!desciptionHasBeenUpdated) { DescriptionBox.Text = locale[(int)al][AcceptMode ? 9 : 10] + description; } policyLoaderCaption = locale[(int)al][11]; registryFail = ProgramDescription.AssemblyMainName + locale[(int)al][12]; dpModuleAbsence = locale[(int)al][13]; packageFail = locale[(int)al][14]; fileWriteFail = locale[(int)al][15]; startDownload = locale[(int)al][16]; if (ToLaboratoryCombo.Items.Count < 1) { ToLaboratoryCombo.Items.AddRange(RDGenerics.GetCommunitiesNames(al != SupportedLanguages.ru_ru)); } ToLaboratoryCombo.SelectedIndex = 0; this.Text = locale[(int)al][AcceptMode ? 17 : 18]; // Запуск проверки обновлений HardWorkExecutor hwe; if (!AcceptMode) { UpdatesPageButton.Enabled = false; #if DPMODULE hwe = new HardWorkExecutor(UpdatesChecker, null, null, false, false, false); #else hwe = new HardWorkExecutor(UpdatesChecker, null, null, false, false); #endif UpdatesTimer.Enabled = true; } // Получение Политики else { #if DPMODULE hwe = new HardWorkExecutor(PolicyLoader, null, policyLoaderCaption, true, false, true); #else hwe = new HardWorkExecutor(PolicyLoader, null, policyLoaderCaption, true, false); #endif string html = hwe.Result.ToString(); if (!string.IsNullOrWhiteSpace(html)) { DescriptionBox.Text = html; int left = html.IndexOf("rev"); int right = html.IndexOf("\n", left); if ((left >= 0) && (right >= 0)) { adpRevision = html.Substring(left, right - left); } } } // Настройка контролов UserManualButton.Visible = ProjectPageButton.Visible = UpdatesPageButton.Visible = AskDeveloper.Visible = ToLaboratory.Visible = !AcceptMode; #if DPMODULE UpdatesPageButton.Visible = false; #endif MisacceptButton.Visible = AcceptMode; // Запуск this.ShowDialog(); // Запись версий по завершению try { if (StartupMode) { Registry.SetValue(RDGenerics.AssemblySettingsKey, LastShownVersionKey, ProgramDescription.AssemblyVersion); // Контроль доступа к реестру WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); if (!principal.IsInRole(WindowsBuiltInRole.Administrator)) { MessageBox.Show(registryFail, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // В случае невозможности загрузки Политики признак необходимости принятия до этого момента // не удаляется из строки версии. Поэтому требуется страховка if (AcceptMode && accepted) { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision.Replace("!", "")); } } catch { MessageBox.Show(registryFail, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // Завершение return(accepted ? 0 : -1); }
// Основной метод запуска окна private int LaunchForm(bool StartupMode, bool AcceptMode) { // Запрос последней версии string helpShownAt = ""; if (StartupMode || AcceptMode) { try { // Исправлен некорректный порядок вызовов adpRevision = Registry.GetValue(ADPRevisionPath, ADPRevisionKey, "").ToString(); helpShownAt = Registry.GetValue(RDGenerics.AssemblySettingsKey, LastShownVersionKey, "").ToString(); } catch { } // Если поле пустое, устанавливается минимальное значение if (adpRevision == "") { adpRevision = "rev. 8!"; try { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision); } catch { } } } // Контроль if (StartupMode && (helpShownAt == ProgramDescription.AssemblyVersion) || // Справка уже отображалась AcceptMode && (!adpRevision.EndsWith("!"))) // Политика уже принята { return(1); } // Настройка контролов switch (al) { case SupportedLanguages.ru_ru: UserManualButton.Text = "&Руководство"; ProjectPageButton.Text = "&О проекте"; UpdatesPageButton.Text = "Поиск обновлений..."; ADPButton.Text = AcceptMode ? "Открыть в &браузере" : "&Политика и EULA"; ExitButton.Text = AcceptMode ? "&Принять" : "&ОК"; AskDeveloper.Text = "Спросить ра&зработчика"; MisacceptButton.Text = "О&тклонить"; if (!desciptionHasBeenUpdated) { DescriptionBox.Text = AcceptMode ? "Не удалось получить текст Политики. " + "Попробуйте использовать кнопку перехода в браузер" : "[Проверка обновлений...]\r\n\r\n" + description; } policyLoaderCaption = "Подготовка к запуску..."; registryFail = ProgramDescription.AssemblyMainName + " не может сохранить настройки в реестре Windows. Оно не будет работать корректно.\n\n" + "Попробуйте выполнить следующие изменения в свойствах исполняемого файла:\n" + "• разблокируйте приложение в общих свойствах (кнопка «Разблокировать»);\n" + "• включите запуск от имени администратора для всех пользователей в настройках совместимости.\n\n" + "После этого перезапустите программу и повторите попытку"; this.Text = AcceptMode ? "Политика разработки и соглашение пользователя" : "О программе"; break; default: // en_us UserManualButton.Text = "&User manual"; ProjectPageButton.Text = "Project &webpage"; UpdatesPageButton.Text = "Checking updates..."; ADPButton.Text = AcceptMode ? "Open in &browser" : "&Policy and EULA"; ExitButton.Text = AcceptMode ? "&Accept" : "&OK"; AskDeveloper.Text = "Ask &developer"; MisacceptButton.Text = "&Decline"; if (!desciptionHasBeenUpdated) { DescriptionBox.Text = AcceptMode ? "Failed to get Policy text. Try button to open it in browser" : "[Checking for updates...]\r\n\r\n" + description; } policyLoaderCaption = "Preparing for launch..."; registryFail = ProgramDescription.AssemblyMainName + " cannot save settings in the Windows registry. It will not work properly.\n\n" + "Try the following changes to properties of the executable file:\n" + "• unblock the app in general properties (“Unblock” button);\n" + "• enable running as administrator for all users in compatibility settings.\n\n" + "Then restart the program and try again"; this.Text = AcceptMode ? "Development policy and user agreement" : "About application"; break; } ToLaboratory.Text = "Free development lab"; // Запуск проверки обновлений HardWorkExecutor hwe; if (!AcceptMode) { #if DPMODULE hwe = new HardWorkExecutor(UpdatesChecker, null, null, false, false, false); #else hwe = new HardWorkExecutor(UpdatesChecker, null, null, false, false); #endif UpdatesTimer.Enabled = true; } // Получение Политики else { #if DPMODULE hwe = new HardWorkExecutor(PolicyLoader, null, policyLoaderCaption, true, false, true); #else hwe = new HardWorkExecutor(PolicyLoader, null, policyLoaderCaption, true, false); #endif string html = hwe.Result.ToString(); if (html != "") { DescriptionBox.Text = html; int left = html.IndexOf("rev"); int right = html.IndexOf("\n", left); if ((left >= 0) && (right >= 0)) { adpRevision = html.Substring(left, right - left); } } } // Настройка контролов UserManualButton.Visible = ProjectPageButton.Visible = UpdatesPageButton.Visible = AskDeveloper.Visible = ToLaboratory.Visible = !AcceptMode; MisacceptButton.Visible = AcceptMode; // Запуск this.ShowDialog(); // Запись версий по завершению try { if (StartupMode) { Registry.SetValue(RDGenerics.AssemblySettingsKey, LastShownVersionKey, ProgramDescription.AssemblyVersion); // Контроль доступа к реестру /*if (Registry.GetValue (RDGenerics.AssemblySettingsKey, LastShownVersionKey, "").ToString () != * ProgramDescription.AssemblyVersion) * { * MessageBox.Show (registryFail, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, * MessageBoxIcon.Exclamation); * }*/ WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); if (!principal.IsInRole(WindowsBuiltInRole.Administrator)) { MessageBox.Show(registryFail, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // В случае невозможности загрузки Политики признак необходимости принятия до этого момента // не удаляется из строки версии. Поэтому требуется страховка if (AcceptMode && accepted) { Registry.SetValue(ADPRevisionPath, ADPRevisionKey, adpRevision.Replace("!", "")); } } catch { MessageBox.Show(registryFail, ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // Завершение return(accepted ? 0 : -1); }