コード例 #1
0
        public void Execute(object parameter)
        {
            try
            {
                UiArchives archives = _archivesProvider();
                if (archives == null)
                    return;

                UiGameFileCommanderSettingsWindow settingsDlg = new UiGameFileCommanderSettingsWindow(true);
                if (settingsDlg.ShowDialog() != true)
                    return;

                Stopwatch sw = new Stopwatch();
                sw.Start();

                Wildcard wildcard = new Wildcard(settingsDlg.Wildcard, false);
                bool? conversion = settingsDlg.Convert;

                FileSystemExtractionTarget target = new FileSystemExtractionTarget();

                foreach (IUiLeafsAccessor accessor in archives.AccessToCheckedLeafs(wildcard, conversion, null))
                    accessor.Extract(target);

                sw.Stop();
                if (sw.ElapsedMilliseconds / 1000 > 2)
                    MessageBox.Show($"Распаковка завершена за {sw.Elapsed.ToString(@"d\.hh\:mm\:ss")}.", Lang.Message.Done.Title, MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Lang.Message.Error.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #2
0
        public void Execute(object parameter)
        {
            try
            {
                UiArchives archives = _archivesProvider();
                if (archives == null)
                    return;

                UiGameFileCommanderSettingsWindow settingsDlg = new UiGameFileCommanderSettingsWindow(false);
                if (settingsDlg.ShowDialog() != true)
                    return;

                Stopwatch sw = new Stopwatch();
                sw.Start();

                Wildcard wildcard = new Wildcard(settingsDlg.Wildcard, false);
                bool? compression = settingsDlg.Compression;
                bool? conversion = settingsDlg.Convert;

                UiInjectionManager manager = new UiInjectionManager();
                FileSystemInjectionSource source = new FileSystemInjectionSource();
                foreach (IUiLeafsAccessor accessor in archives.AccessToCheckedLeafs(wildcard, conversion, compression))
                    accessor.Inject(source, manager);
                manager.WriteListings();

                if (sw.ElapsedMilliseconds / 1000 > 2)
                    MessageBox.Show(String.Format("Упаковка завершена за {0}.", sw.Elapsed.ToString(@"d\.hh\:mm\:ss")), "Готово!", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: akimoto-akira/Pulse
        private void Update(string destination)
        {
            Thread.Sleep(1000);
            string source = AppDomain.CurrentDomain.BaseDirectory;
            try
            {
                List<string> sourceFiles = new List<string>(256);
                List<string> targetFiles = new List<string>(256);
                CreateFileTree(source, destination, sourceFiles, targetFiles);

                Process[] lockers = RestartManagerHelper.GetFileLockers(targetFiles.ToArray());
                if (!lockers.IsNullOrEmpty())
                {
                    Wildcard wildcard = new Wildcard("*Pulse.Patcher*");
                    List<Process> processes = new List<Process>(lockers.Length);
                    foreach (Process locker in lockers)
                    {
                        if (wildcard.IsMatch(locker.ProcessName))
                            locker.Kill();
                        else
                            processes.Add(locker);
                    }

                    if (!processes.IsNullOrEmpty())
                    {
                        StringBuilder sb = new StringBuilder(512);
                        sb.AppendLine("Следующие процессы блокируют обновление. Уничтожить их?");
                        foreach (Process locker in processes)
                        {
                            sb.Append(locker.ProcessName);
                            sb.Append(": ");
                            sb.AppendLine(locker.GetExecutablePath());
                        }

                        if (MessageBox.Show(sb.ToString(), "Внимание!", MessageBoxButton.YesNo, MessageBoxImage.Error) != MessageBoxResult.Yes)
                            throw new OperationCanceledException();

                        foreach (Process locker in processes)
                            locker.Kill();
                    }
                }

                for (int i = 0; i < sourceFiles.Count; i++)
                    File.Copy(sourceFiles[i], targetFiles[i], true);

                ProcessStartInfo procInfo = new ProcessStartInfo(Path.Combine(destination, "Pulse.Patcher.exe"), $"/d \"{source.TrimEnd('\\')}\"")
                {
                    CreateNoWindow = true,
                    UseShellExecute = false,
                    WorkingDirectory = destination
                };
                Process.Start(procInfo);
                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                StringBuilder sb = new StringBuilder(512);
                sb.AppendLine("Не удалось установить обновление программы установки.");
                sb.AppendLine("Пожалуйста, скопируйте содержимое каталога:");
                sb.AppendLine(source);
                sb.AppendLine("В каталог:");
                sb.AppendLine(destination);
                sb.AppendLine("С заменой всех файлов. Приносим извинения за доставленные неудобства.");
                sb.AppendLine();
                sb.AppendLine("Принична ошибки:");
                sb.AppendLine(ex.ToString());
                MessageBox.Show(sb.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }