Esempio n. 1
0
        public void BackupDatabase()
        {
            using (var ctx = _contextFactory.GetContext().Invoke())
            {
                var databaseFilePath = Directory.GetCurrentDirectory() + ctx.DatabasePath;

                var backupDir  = $@"C:\Backup\CrossStitch\";
                var backupPath = $@"{backupDir}CrossStitchDatabase_{_dateTimeProvider.Now().ToString("yyyyMMddhhmmss")}.db";

                Directory.CreateDirectory(backupDir);
                File.Copy(databaseFilePath, backupPath);
            }
        }
Esempio n. 2
0
        public HomeViewModel(IDatabaseContextService contextFactory, ICurrentDateService dateTimeProvider, IBackupService backupService)
        {
            _contextFactory   = contextFactory;
            _dateTimeProvider = dateTimeProvider;
            _backupService    = backupService;

            // Warm up the terminal
            contextFactory.GetContext().Invoke();

            ManagePatternsCommand  = new RelayCommand(OnManagePatterns);
            ManageProjectsCommand  = new RelayCommand(OnManageProjects);
            ManageOrdersCommand    = new RelayCommand(OnManageOrders);
            ManageInventoryCommand = new RelayCommand(OnManageInventory);
            BackupDatabaseCommand  = new RelayCommand(OnBackupDatabase);
        }