Esempio n. 1
0
 public StableBackupsManager(WaBackupsViewModel waBackupsViewModel) 
     : base(waBackupsViewModel)
 {
     DataDirPath = AppContext.StableDataDir;
     BackupDirPath = AppContext.WaBackupStableDir;
     BuildType = AppContext.StableKey;
 }
Esempio n. 2
0
 public BetaBackupsManager(WaBackupsViewModel waBackupsViewModel)
     : base(waBackupsViewModel)
 {
     DataDirPath = AppContext.BetaDataDir;
     BackupDirPath = AppContext.WaBackupBetaDir;
     BuildType = AppContext.BetaKey;
 }
Esempio n. 3
0
 protected BackupsManager(WaBackupsViewModel waBackupsViewModel)
 {
     this.waBackupsViewModel = waBackupsViewModel;
 }
 public ManageWaBackups(WaBackupsViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
Esempio n. 5
0
        public WaBackup(string filePath, string verificationBuildType, BackupsManager manager, WaBackupsViewModel baseViewModel)
        {
            this.manager = manager;
            this.baseViewModel = baseViewModel;
            FilePath = filePath;
            SetNames(verificationBuildType);

            RestoreCommand = new DelegateCommand(() =>
            {
                try
                {
                    Restore();
                }
                catch (Exception exception)
                {
                    ErrorManager.ShowWarning(exception.Message, exception);
                }
            });

            DeleteCommand = new DelegateCommand(() =>
            {
                try
                {
                    Delete();
                }
                catch (Exception exception)
                {
                    ErrorManager.ShowWarning(exception.Message, exception);
                }
            });
        }
Esempio n. 6
0
        public static WaBackup Create(string backupName, string buildType, string sourceDirPath, string targetDirPath, BackupsManager manager, WaBackupsViewModel baseViewModel)
        {
            ValidateName(backupName);

            using (new WurmAssistantGateway(AppContext.WaGatewayErrorMessage))
            {
                using (var tempDirMan = new TempDirManager())
                {
                    var tempDir = tempDirMan.GetHandle();

                    string tempArchiveFilePath = Path.Combine(
                        tempDir.FullName,
                        string.Format("{0}_{1}_{2}.7z",
                            backupName ?? "WurmAssistantBackup",
                            buildType,
                            DateTime.Now.ToStringFormattedForFileEx(highPrecision: true)));

                    var compressor = new SevenZipCompressor()
                    {
                        ArchiveFormat = OutArchiveFormat.SevenZip,
                        CompressionMode = CompressionMode.Create
                    };
                    compressor.CompressDirectory(sourceDirPath, tempArchiveFilePath);

                    var newBackup = new WaBackup(tempArchiveFilePath, buildType, manager, baseViewModel);

                    var targetFile = new FileInfo(newBackup.FilePath);
                    var targetArchiveFile = new FileInfo(Path.Combine(targetDirPath, targetFile.Name));

                    if (targetArchiveFile.Exists)
                    {
                        throw new LauncherException("backup with this file name already exists");
                    }

                    newBackup.MoveInto(targetDirPath);

                    return newBackup;
                }
            }
        }