Exemplo n.º 1
0
        private void Panel1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                if (listView_Customers.SelectedItems.Count == 0)
                {
                    MessageBox.Show("Select Customer first.");
                    return;
                }

                string[] filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));
                foreach (string file in filePaths)
                {
                    try
                    {
                        ArchiveHandler archiveHandler = new ArchiveHandler(file);
                        Console.WriteLine(archiveHandler);
                        StoreFile(archiveHandler);
                    }
                    catch (InvalidDataException ex)
                    {
                        return;
                    }
                }
                Fin();
            }
        }
        private static void LoadDataSets(FormatHandlerProvider formatHandlerProvider, string blockPath)
        {
            var archiveHandler = new ArchiveHandler <FpkFile>();

            var fpkPath  = blockPath.Substring(0, blockPath.Length - 1);
            var archives = new[] { fpkPath, blockPath };

            foreach (var archivePath in archives)
            {
                using (var input = new FileStream(archivePath, FileMode.Open))
                {
                    var archive = archiveHandler.Import(input, archivePath);
                    Parallel.ForEach(archive.ExportFiles(input),
                                     delegate(FileDataStreamContainer container)
                    {
                        // Check if extension is supported.
                        if (!formatHandlerProvider.IsExtensionSupported(Path.GetExtension(container.FileName)
                                                                        .Replace(".", "")))
                        {
                            return;
                        }

                        // Import the file.
                        using (var output = new MemoryStream())
                        {
                            container.DataStream().CopyTo(output);
                            output.Flush();
                            output.Seek(0, SeekOrigin.Begin);
                            formatHandlerProvider.Import(output, container.FileName);
                        }
                    });
                }
            }
        }
Exemplo n.º 3
0
        // Copy the archive into the target directory
        private void StoreFile(ArchiveHandler archiveHandler)
        {
            // build source and target directorys
            string srcFile    = archiveHandler.getPathToArchive();
            string targetDir  = RootCustomerDirPath + "\\" + SelectedCustomer + "\\" + storagePath + "\\" + archiveHandler.IRSerialNr + "_" + archiveHandler.RobName + "\\" + archiveHandler.ArchiveDate;
            string targetFile = targetDir + "\\" + archiveHandler.FileName;

            // Try to create the directory.
            DirectoryInfo di = Directory.CreateDirectory(targetDir);

            // Copy the archive into the target directory
            if (File.Exists(srcFile))
            {
                try{
                    File.Copy(srcFile, targetFile);
                    Console.WriteLine("The archive was coppied successfully at " + Directory.GetCreationTime(targetFile) + Environment.NewLine);
                } catch (IOException e)
                {
                    Console.WriteLine(e);
                    MessageBox.Show(e.Message);
                    return;
                }
            }
            Fin();
        }
Exemplo n.º 4
0
        private static void RunAnalysis(string input, string output)
        {
            IFilesystem         filesystem     = new Filesystem();
            IArchiveHandler     archiveHandler = new ArchiveHandler(filesystem);
            IProcessHandler     processHandler = new ProcessHandler();
            IHttpRequestHandler requestHandler = new HttpRequestHandler(filesystem);

            new CoreDumpAnalyzer(archiveHandler, filesystem, processHandler, requestHandler).AnalyzeAsync(input, output).Wait();
        }
Exemplo n.º 5
0
        // bring up diagloge to select a file
        private void selectArchiveFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (String file in ofd.FileNames)
                {
                    try
                    {
                        ArchiveHandler archiveHandler = new ArchiveHandler(file);
                        Console.WriteLine(archiveHandler);
                        StoreFile(archiveHandler);
                    }
                    catch (InvalidDataException ex)
                    {
                        return;
                    }
                }
                Console.WriteLine("Process Complete.");
            }
        }
Exemplo n.º 6
0
 public RestoreProgramHandler(RunWorkerCompletedEventHandler when_done, Interface new_interface, ArchiveHandler archive)
     : base(when_done, new_interface)
 {
     this.archive = archive;
 }
Exemplo n.º 7
0
        protected override void doWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            base.doWork(sender, e);

            path_candidates = new ObservableCollection<LocationPathHolder>();
            user_candidates = new ObservableCollection<string>();

            ProgressHandler.progress_state = ProgressState.Indeterminate;

            if(archive==null) {
                string[] args = Environment.GetCommandLineArgs();
                if(args.Length>0) {
                    foreach(string arg in args) {
                        if(!arg.StartsWith("-")&&(arg.EndsWith(Core.extension)||arg.EndsWith(Core.extension + "\""))) {
                            archive = new ArchiveHandler(new FileInfo(arg.Trim('\"')));
                        }
                    }
                }
            }

            if(archive==null)
                throw new MException("Nothing To Do","No File Was Selected To Restore",false);

            ProgressHandler.progress_message = "Detecting game for restoration...";

            if (!File.Exists(archive.file_name))
                throw new MException("Not there","The specified backup doesn't exist",false);

            GameID selected_game = archive.id.game;
            string backup_owner = archive.id.owner;
            string archive_type = archive.id.type;

            if(!Core.games.all_games.ContainsObjectWithID(selected_game))
                throw new MException("Unknown","MASGAU doesn't have information for the game: " + selected_game.ToString(),true);

            game_data = Core.games.all_games.GetObjectWithID(selected_game);
            game_data.detect();

            // This adds hypothetical locations
            foreach(LocationPathHolder location in game_data.location_paths) {
                if(game_data.detection_required)
                    break;

                //if(location.path==null)
                    //continue;
                if(location.platform_version!=PlatformVersion.All&&location.platform_version!=Core.locations.platform_version)
                    continue;

                if(location.rel_root==EnvironmentVariable.InstallLocation||
                    location.rel_root==EnvironmentVariable.SteamCommon)
                    continue;

                // Adds user-friendly menu entries to the root selector
                switch(location.rel_root) {
                    case EnvironmentVariable.SteamSourceMods:
                        if(Core.locations.steam_detected)
                            addPathCandidate(location);
                        break;
                    case EnvironmentVariable.SteamUser:
                        if(Core.locations.steam_detected&&Core.locations.getUsers(EnvironmentVariable.SteamUser).Count>0)
                            addPathCandidate(location);
                        break;
                    case EnvironmentVariable.SteamUserData:
                        if(Core.locations.steam_detected&&Core.locations.getUsers(EnvironmentVariable.SteamUserData).Count>0)
                            addPathCandidate(location);
                        break;
                    default:
                        addPathCandidate(location);
                        break;
                }
            }

            // This add already found locations
            foreach(KeyValuePair<string,DetectedLocationPathHolder> location in game_data.detected_locations) {
                location.Value.IsSelected = true;
                switch(location.Value.rel_root) {
                    case EnvironmentVariable.ProgramFiles:
                    case EnvironmentVariable.ProgramFilesX86:
                        // This adds a fake VirtualStore folder, just in case
                        if(Core.locations.uac_enabled) {
                            DetectedLocationPathHolder temp = new DetectedLocationPathHolder(location.Value);
                            temp.abs_root = null;
                            temp.owner = location.Value.owner;
                            temp.path = Path.Combine("VirtualStore", location.Value.full_dir_path.Substring(3));
                            temp.rel_root = EnvironmentVariable.LocalAppData;
                            addPathCandidate(temp);
                        }
                        addPathCandidate(location.Value);
                        break;
                    default:
                        addPathCandidate(location.Value);
                        break;
                }
            }

            if(path_candidates.Count==1) {
                multiple_paths = false;
                NotifyPropertyChanged("only_path");
            } else if(path_candidates.Count>1) {
                multiple_paths = true;
            } else {
                throw new MException("Can't Restore If We Can't Find It","No restore paths detected for " + this.archive.id.ToString(),false);
            }
        }
Exemplo n.º 8
0
 public RestoreWindow(ArchiveHandler archive, AWindow owner)
     : this(owner)
 {
     this.archive = archive;
 }
Exemplo n.º 9
0
        private void setupDone(object sender, RunWorkerCompletedEventArgs e)
        {
            this.archive = restore.archive;
            ProgressHandler.progress_state = ProgressState.None;

            tabControl1.SelectedIndex = 1;
            this.Title = "Confirm Restore Location";

            if(e.Error!=null) {
                this.Close();
                return;
            }
            pathCombo.ItemsSource = restore.path_candidates;
            userCombo.ItemsSource = restore.user_candidates;
            pathLabel.DataContext = restore;
            userLabel.DataContext = restore;

            otherUserButton.Visibility = System.Windows.Visibility.Collapsed;
            selectFilesButton.Visibility = System.Windows.Visibility.Visible;
            restoreButton.Visibility = System.Windows.Visibility.Visible;
            choosePathButton.Visibility = System.Windows.Visibility.Visible;

            if(restore.game_data.restore_comment!=null) {
                restoreDoneText.Text = restore.game_data.restore_comment + Environment.NewLine + Environment.NewLine + "Other than that, the restore is done!";
            }

            refreshPaths();
        }