|
|
@@ -12,6 +12,7 @@ using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Navigation;
|
|
|
using System.Windows.Shapes;
|
|
|
+using System.Threading;
|
|
|
|
|
|
namespace barry
|
|
|
{
|
|
|
@@ -20,74 +21,98 @@ namespace barry
|
|
|
/// </summary>
|
|
|
public partial class MainWindow : Window
|
|
|
{
|
|
|
+ TextBoxOutputter outputter;
|
|
|
+ Methods methods = new Methods();
|
|
|
+
|
|
|
public MainWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ connect_console();
|
|
|
+
|
|
|
+ displays_barry();
|
|
|
+
|
|
|
+ Console.WriteLine("**** BARRY Backup ****");
|
|
|
|
|
|
- Console.WriteLine(am_i_the_good_source());
|
|
|
+ lbl_cpuname.Content = "CPU Name: " + methods.computer_name();
|
|
|
+ lbl_driveletter.Content = "Current drive: " + methods.current_drive_label() + " (" + methods.current_drive_letter() + ")";
|
|
|
|
|
|
- string cpuname = System.Environment.MachineName;
|
|
|
- Console.WriteLine(cpuname);
|
|
|
|
|
|
- core.FileOp fo = new core.FileOp();
|
|
|
|
|
|
- if (cpuname == "OLINOX-PC")
|
|
|
- {
|
|
|
- string source = String.Format("{0}\\", current_drive_letter());
|
|
|
- string destination = "e:\\backup\\_OMASSOT\\";
|
|
|
|
|
|
- fo.robocopy(source, destination);
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- private string current_drive_letter()
|
|
|
+ private void connect_console()
|
|
|
{
|
|
|
- return System.IO.Path.GetPathRoot(Environment.CurrentDirectory);
|
|
|
+ outputter = new TextBoxOutputter(txt_console);
|
|
|
+ Console.SetOut(outputter);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// control that the program is launched from the source
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- private bool am_i_the_good_source()
|
|
|
+ private void displays_barry()
|
|
|
{
|
|
|
- // current drive letter
|
|
|
- string driveLetter = current_drive_letter();
|
|
|
-
|
|
|
- System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
|
|
|
- //Console.WriteLine("Detected Drives: ");
|
|
|
- for (int i = 0; i < drives.Count(); i++)
|
|
|
- {
|
|
|
-
|
|
|
- //Console.WriteLine("Drive " + i);
|
|
|
- //Console.WriteLine("-" + drives[i].Name);
|
|
|
- //Console.WriteLine("-" + drives[i].DriveType);
|
|
|
- //if (drives[i].IsReady)
|
|
|
- //{
|
|
|
- // Console.WriteLine("-" + drives[i].VolumeLabel);
|
|
|
- // Console.WriteLine("-" + drives[i].DriveFormat);
|
|
|
- //}
|
|
|
-
|
|
|
- if (drives[i].Name == driveLetter)
|
|
|
- {
|
|
|
- if (drives[i].IsReady)
|
|
|
- {
|
|
|
- if (drives[i].VolumeLabel == "_OMASSOT")
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return false;
|
|
|
+ BitmapImage bitmap = new BitmapImage();
|
|
|
+ bitmap.BeginInit();
|
|
|
+ bitmap.UriSource = new Uri("O:\\dev\\barry\\barry\\barrys_head.png");
|
|
|
+ bitmap.EndInit();
|
|
|
+ img_barry.Source = bitmap;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+// *** BACKUP
|
|
|
+// 1- read the configuration file
|
|
|
+// IF NOT: warn, and create an empty, then quit
|
|
|
+// IF INVALID: warn and quit
|
|
|
+
|
|
|
+
|
|
|
+// 2- control media name to see if good source
|
|
|
+// OR check existnce of a file which is nor copied
|
|
|
+// OR mark the destination directory as a backup dir and warn before being launbching from there
|
|
|
+// IF NOT: quit
|
|
|
+
|
|
|
+// 3- check the computer name (or mac adress?)
|
|
|
+// if not found in cpu list: quit
|
|
|
+
|
|
|
+// 4- get the map letter and expand source
|
|
|
+
|
|
|
+// 5- get the destination path in config file
|
|
|
+// expands it
|
|
|
+// if none|inexistent|unauthorized, warn and displays a selection dialog
|
|
|
+// if cancelled, cancel prog and quit
|
|
|
+
|
|
|
+// 6- Displays the ongoing copy operation with source and destination
|
|
|
+
|
|
|
+// ***** to replace robocopy?
|
|
|
+// opt- analyse the source and destination:
|
|
|
+// build a tree of files
|
|
|
+// if source file do not exist in destination: copy
|
|
|
+// if source file is older than destination, replace it
|
|
|
+
|
|
|
+// #renamed file case:
|
|
|
+// if 2 files have same signature but differents names, propose to rename
|
|
|
+// #renamed dir case
|
|
|
+//
|
|
|
+// #moved file case
|
|
|
+//
|
|
|
+// #moved dir case
|
|
|
+//
|
|
|
+// ****
|
|
|
+
|
|
|
+// 8- Waits 14 seconds and propose a key to cancel
|
|
|
+
|
|
|
+// 9- process to copy
|
|
|
+
|
|
|
+// 10- displays results
|
|
|
+
|
|
|
+// END OF BACKUP
|
|
|
+
|
|
|
+// other tools:
|
|
|
+// purge backup: propose to remove or trash destination files which do not exist anymore in source
|
|
|
+// add this computer: add a computer in the list of backup targets
|
|
|
+// enable autorun: copy usbAR on the post, configure and run
|