BacupFunctionality
This commit is contained in:
54
StockInfo/frmBackup.cs
Normal file
54
StockInfo/frmBackup.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using DataDomain;
|
||||
using Helpers;
|
||||
using SqliteBackups.Interfaces;
|
||||
using StockDAL.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace StockInfo
|
||||
{
|
||||
public partial class frmBackup : Form
|
||||
{
|
||||
private readonly IBackupRepository _backupRepository;
|
||||
private readonly IBackupRoutines _backupRoutines;
|
||||
|
||||
public frmBackup(IBackupRepository backupRepository,IBackupRoutines backupRoutines)
|
||||
{
|
||||
InitializeComponent();
|
||||
_backupRepository = backupRepository;
|
||||
_backupRoutines = backupRoutines;
|
||||
}
|
||||
|
||||
private void btnChooseBackupDest_Click(object sender, EventArgs e)
|
||||
{
|
||||
sfdChoosePlaceAndFile.Filter = "Database files (*.db)|*.db|All files (*.*)|*.*";
|
||||
if (sfdChoosePlaceAndFile.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var wholeFile = sfdChoosePlaceAndFile.FileName;
|
||||
var lastBackslash = wholeFile.LastIndexOf('\\') + 1;
|
||||
var dir = wholeFile.Substring(0, lastBackslash);
|
||||
var file = wholeFile.Substring(lastBackslash, wholeFile.Length - lastBackslash);
|
||||
//Debug.WriteLine($"Chosen file:{wholeFile}");
|
||||
//Debug.WriteLine($"Path: {dir} , File {file}");
|
||||
BackupRegister reg = new();
|
||||
reg.BackupDbName = file;
|
||||
reg.BackupPath = dir;
|
||||
reg = _backupRepository.SaveBackupReging(reg);
|
||||
_backupRoutines.BackupSqliteDb(reg.DbName, Path.Combine(dir, file));
|
||||
var cmbItem = new ComboboxItem(wholeFile, reg.Id);
|
||||
lstBackups.Items.Add(cmbItem);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user