| ofs | hex dump | ascii |
|---|
| 0000 | ff d8 ff e1 20 93 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 07 01 12 00 03 00 00 00 01 00 01 | ......Exif..MM.*................ |
| 0020 | 00 00 01 1a 00 05 00 00 00 01 00 00 00 62 01 1b 00 05 00 00 00 01 00 00 00 6a 01 28 00 03 00 00 | .............b...........j.(.... |
| 0040 | 00 01 00 02 00 00 01 31 00 02 00 00 00 22 00 00 00 72 01 32 00 02 00 00 00 14 00 00 00 94 87 69 | .......1....."...r.2...........i |
| 0060 | 00 04 00 00 00 01 00 00 00 a8 00 00 00 d4 00 0a fc 80 00 00 27 10 00 0a fc 80 00 00 27 10 41 64 | ....................'.......'.Ad |
| 0080 | 6f 62 65 20 50 68 6f 74 6f 73 68 6f 70 20 43 43 20 32 30 31 39 20 28 57 69 6e 64 6f 77 73 29 00 | obe.Photoshop.CC.2019.(Windows). |
| 00a0 | 32 30 31 39 3a 30 35 3a 31 32 20 31 32 3a 35 36 3a 32 31 00 00 03 a0 01 00 03 00 00 00 01 ff ff | 2019:05:12.12:56:21............. |
| 00c0 | 00 00 a0 02 00 04 00 00 00 01 00 00 03 3c a0 03 00 04 00 00 00 01 00 00 03 29 00 00 00 00 00 00 | .............<...........)...... |
| 00e0 | 00 06 01 03 00 03 00 00 00 01 00 06 00 00 01 1a 00 05 00 00 00 01 00 00 01 22 01 1b 00 05 00 00 | ........................."...... |
| 0100 | 00 01 00 00 01 2a 01 28 00 03 00 00 00 01 00 02 00 00 02 01 00 04 00 00 00 01 00 00 01 32 02 02 | .....*.(.....................2.. |
| 0120 | 00 04 00 00 00 01 00 00 1f 59 00 00 00 00 00 00 00 48 00 00 00 01 00 00 00 48 00 00 00 01 ff d8 | .........Y.......H.......H...... |
| 0140 | ff ed 00 0c 41 64 6f 62 65 5f 43 4d 00 02 ff ee 00 0e 41 64 6f 62 65 00 64 80 00 00 00 01 ff db | ....Adobe_CM......Adobe.d....... |
| 0160 | 00 84 00 0c 08 08 08 09 08 0c 09 09 0c 11 0b 0a 0b 11 15 0f 0c 0c 0f 15 18 13 13 15 13 13 18 11 | ................................ |
| 0180 | 0c 0c 0c 0c 0c 0c 11 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c | ................................ |
| 01a0 | 0c 0c 0c 01 0d 0b 0b 0d 0e 0d 10 0e 0e 10 14 0e 0e 0e 14 14 0e 0e 0e 0e 14 11 0c 0c 0c 0c 0c 11 | ................................ |
| 01c0 | 11 0c 0c 0c 0c 0c 0c 11 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c 0c | ................................ |
| 01e0 | 0c 0c 0c 0c ff c0 00 11 08 00 9c 00 a0 03 01 22 00 02 11 01 03 11 01 ff dd 00 04 00 0a ff c4 01 | ..............."................ |
| 0200 | 3f 00 00 01 05 01 01 01 01 01 01 00 00 00 00 00 00 00 03 00 01 02 04 05 06 07 08 09 0a 0b 01 00 | ?............................... |
| 0220 | 01 05 01 01 01 01 01 01 00 00 00 00 00 00 00 01 00 02 03 04 05 06 07 08 09 0a 0b 10 00 01 04 01 | ................................ |
| 0240 | 03 02 04 02 05 07 06 08 05 03 0c 33 01 00 02 11 03 04 21 12 31 05 41 51 61 13 22 71 81 32 06 14 | ...........3......!.1.AQa."q.2.. |
| 0260 | 91 a1 b1 42 23 24 15 52 c1 62 33 34 72 82 d1 43 07 25 92 53 f0 e1 f1 63 73 35 16 a2 b2 83 26 44 | ...B#$.R.b34r..C.%.S...cs5....&D |
| 0280 | 93 54 64 45 c2 a3 74 36 17 d2 55 e2 65 f2 b3 84 c3 d3 75 e3 f3 46 27 94 a4 85 b4 95 c4 d4 e4 f4 | .TdE..t6..U.e.....u..F'......... |
| 02a0 | a5 b5 c5 d5 e5 f5 56 66 76 86 96 a6 b6 c6 d6 e6 f6 37 47 57 67 77 87 97 a7 b7 c7 d7 e7 f7 11 00 | ......Vfv........7GWgw.......... |
| 02c0 | 02 02 01 02 04 04 03 04 05 06 07 07 06 05 35 01 00 02 11 03 21 31 12 04 41 51 61 71 22 13 05 32 | ..............5.....!1..AQaq"..2 |
| 02e0 | 81 91 14 a1 b1 42 23 c1 52 d1 f0 33 24 62 e1 72 82 92 43 53 15 63 73 34 f1 25 06 16 a2 b2 83 07 | .....B#.R..3$b.r..CS.cs4.%...... |
| 0300 | 26 35 c2 d2 44 93 54 a3 17 64 45 55 36 74 65 e2 f2 b3 84 c3 d3 75 e3 f3 46 94 a4 85 b4 95 c4 d4 | &5..D.T..dEU6te......u..F....... |
| 0320 | e4 f4 a5 b5 c5 d5 e5 f5 56 66 76 86 96 a6 b6 c6 d6 e6 f6 27 37 47 57 67 77 87 97 a7 b7 c7 ff da | ........Vfv........'7GWgw....... |
| 0340 | 00 0c 03 01 00 02 11 03 11 00 3f 00 f5 54 92 49 25 29 24 92 49 4a 49 33 9c d6 34 b9 c4 35 ad 12 | ..........?..T.I%)$.IJI3..4..5.. |
| 0360 | e7 1d 00 03 b9 5c b7 58 fa fd 83 88 e3 47 4d af ed d6 ea 0d a0 ed a1 a4 4b 4f e9 3d ce bf 63 bf | .....\.X.....GM.........KO.=..c. |
| 0380 | d1 7e 8f fe 1d 09 48 44 59 34 bf 1e 29 e4 97 0c 22 64 7c 1e a9 66 66 7d 65 e8 38 4e 2c c8 ce a8 | .~....HDY4..)..."d|..ff}e.8N,... |
| 03a0 | 58 d7 6d 35 31 de a5 81 da fb 4d 54 ef b1 bf 41 df 9a bc bf ab fd 6b ea 3d 40 9f b6 65 b9 cc 0e | X.m51.....MT...A......k.=@..e... |
| 03c0 | 91 45 47 d3 ac 03 ed 7b 1c da ff 00 9e 66 df f4 ee bd 61 d7 d4 5f 73 db 8d 89 51 b5 d1 b1 b4 d4 | .EG....{.....f....a.._s...Q..... |
| 03e0 | d3 63 b4 3e c0 2b a8 39 de df ea 28 4e 72 7e 48 93 e6 dc 8f c3 c4 75 cd 96 30 fe ac 7d 5f f3 9f | .c.>.+.9...(Nr~H......u..0..}_.. |
| 0400 | 55 bf fc 62 f4 66 36 68 a3 26 f2 58 5e d8 63 6b 12 dd 1d 59 f5 ec ae cd ff 00 f5 b5 4a cf f1 99 | U..b.f6h.&.X^.ck...Y........J... |
| 0420 | 50 93 57 4e 73 9b b3 70 dd 73 5a ed ff 00 e8 b6 b5 96 ff 00 d5 ae 26 8f ab 3f 5d 73 5b 35 74 ab | P.WNs..p.sZ...........&..?]s[5t. |
| 0440 | c0 2d 07 f4 e6 ba 74 3f f8 62 ca 9f ff 00 47 7a bf 57 f8 ba fa e5 69 26 ca f1 ea 03 51 be f9 24 | .-....t?.b....Gz.W....i&....Q..$ |
| 0460 | 81 2d fa 15 5b f9 e9 71 66 3d 00 4f b7 c8 47 79 4a 5f 5f fb d8 bd 3d 7f e3 36 a7 38 6f e9 ee 0d | .-..[..qf=.O..GyJ__...=..6.8o... |
| 0480 | db b8 96 dc 09 07 5f d1 c3 ab af f9 3f 9e ad e3 ff 00 8c 8e 89 61 0d b6 8c 9a 64 34 92 58 c7 81 | ......_.....?........a....d4.X.. |
| 04a0 | bc ed 1f cc 5b 6d 8e f7 7d 2f d1 ae 2e ef f1 79 f5 ce a6 b5 ec a2 9c 8b 35 91 5d e0 40 11 b7 f9 | ....[m..}/.....y........5.].@... |
| 04c0 | e6 53 ee 76 e7 ac fc cf ab bf 5a ba 78 07 2b a5 e4 86 90 49 7d 6d 6e 43 47 77 39 df 63 7e 46 cd | .S.v......Z.x.+....I}mnCGw9.c~F. |
| 04e0 | bf cb 4b 8b 30 dc 02 af 6f 91 96 d3 94 7e bf f7 cf ae f4 ff 00 ac dd 07 a9 38 33 0f 36 a7 da 5c | ..K.0...o....~...........83.6..\ |
| 0500 | 5a 29 71 35 d8 48 80 ed b4 5e 2b b9 df 4b f7 16 9a f9 f9 b9 cc b0 86 c8 3b 0e ad 70 92 d2 0e ef | Z)q5.H...^+..K..........;..p.... |
| 0520 | a0 ff 00 e5 ad ce 8d f5 b7 ad f4 b7 30 63 65 3e cc 76 10 0e 36 49 75 d5 6c 0d da d6 55 bc fa f4 | ............0ce>.v..6Iu.l...U... |
| 0540 | ec fc cf b3 dd e9 ef ff 00 02 88 cf d2 43 85 13 f8 79 ab c5 31 31 d8 ee fb 2a 4b 95 e8 3f e3 07 | .............C...y..11...*K..?.. |
| 0560 | a4 f5 22 da 33 87 ec dc a7 3b 63 45 8e dd 4b dc 77 43 6a ca 86 37 7f b7 f9 ac 86 63 d9 fe 8b d5 | ..".3....;cE..K.wCj..7.....c.... |
| 0580 | 5d 52 94 10 45 83 6d 29 c2 50 3c 32 06 27 b1 52 49 24 8a d5 24 92 49 29 ff d0 f5 54 92 49 25 29 | ]R..E.m).P<2.'.RI$..$.I)...T.I%) |
| 05a0 | 55 ea 3d 4b 0f a6 62 bb 2b 2d e1 8c 1a 35 bf 9c f7 41 2d a6 96 7f 84 b5 fb 7d 95 a9 67 e7 63 f4 | U.=K..b.+-...5...A-......}..g.c. |
| 05c0 | fc 3b 73 32 49 6d 34 b7 73 a0 49 3e 0d 63 7f 39 ee 5e 49 f5 97 eb 26 47 50 c9 39 79 30 d2 01 6e | .;s2Im4.s.I>.c.9.^I...&GP.9y0..n |
| 05e0 | 3d 2d 27 65 75 13 3e ed c0 35 ef dc dd f6 bd cd fa 7f e8 ea 65 69 99 32 08 0e f2 3b 06 c7 2d cb | =-'eu.>..5..........ei.2...;..-. |
| 0600 | 1c d2 24 9e 1c 71 f9 e7 ff 00 73 1f eb 36 fe b3 7d 6f cc ea 8c 2d bb f5 7c 3d 0b 31 2b 7c 17 10 | ..$..q....s..6..}o...-..|=.1+|.. |
| 0620 | 79 c9 7f b7 d6 db fb 9f cc 7f 22 cb 3f 48 b1 ba 77 4c eb df 59 32 9d 57 4a a4 9a 98 76 db 7b dc | y.........".?H..wL..Y2.WJ...v.{. |
| 0640 | 59 4b 3b 7e 96 cf 76 fb 1b fe 8a a6 59 7a da fa a1 f5 0f 23 ad 9a ba c7 57 2e a7 a6 d8 1b 65 34 | YK;~..v.....Yz.....#....W.....e4 |
| 0660 | 6a db 6f 1e 36 ee fa 18 57 33 fe bd 91 4f fa 2a be 9f a9 62 e2 e3 e1 e3 d7 8b 8b 5b 69 a2 96 86 | j.o.6...W3...O.*...b.......[i... |
| 0680 | 57 5b 04 35 ad 1d 9a 14 71 c4 64 78 b2 1b 2d 8c bc dc 71 c7 da e5 c7 0c 46 f2 eb 23 dd e3 7a 3f | W[.5....q.dx..-...q.....F..#..z? |
| 06a0 | f8 ab e8 d8 c0 59 d5 ed 77 53 bf 9d 9a d5 40 d4 38 7e 86 b7 7a 96 ed ff 00 86 bb d3 7f fa 15 d8 | .....Y..wS....@.8~..z........... |
| 06c0 | 62 61 61 e0 d2 31 f0 a8 af 1a 96 f1 5d 2c 6b 1a 3f b1 58 6b 51 d2 53 00 06 cd 19 4e 52 37 22 4a | baa..1......],k.?.XkQ.S....NR7"J |
| 06e0 | 92 49 24 56 a9 25 1b 2c 6d 75 be c7 90 d6 b1 a5 ce 73 8c 34 00 26 5c ef cd 6a 16 16 43 f2 71 99 | .I$V.%.,mu.......s.4.&\..j..C.q. |
| 0700 | 7b d9 e9 97 c9 0d 99 d2 4e c7 6a d6 3b f4 8c f7 ed 7b 19 63 3f c2 24 a6 bf 54 e8 5d 1f ab d7 b3 | {.......N.j.;....{.c?.$..T.].... |
| 0720 | a9 e1 d5 95 00 b5 af 7b 46 f6 83 f4 bd 1b c4 5d 4f fd 69 ec 5c 37 5b ff 00 15 97 d5 bf 23 a0 64 | .......{F......]O.i.\7[......#.d |
| 0740 | fa 80 4b be c5 94 7d df 9c e2 da 73 7f cc 65 75 e4 d7 fd 7c a5 6f eb 4f f8 c0 c8 a7 29 f8 1d 09 | ..K...}....s..eu...|.o.O....)... |
| 0760 | d5 91 49 db 91 9c e1 ea 00 f1 f4 a9 a2 bf a0 ef 4f fc 2d ff 00 a4 67 f8 2f 4f f7 03 f5 4b fc 62 | ..I.............O.-...g./O...K.b |
| 0780 | e5 64 75 3a 7a 4f 59 2d bb ed 67 d3 c7 cc ad a1 84 5b ac 53 91 53 7d 9b 2d fa 14 db 57 f8 4f e7 | .du:zOY-..g......[.S.S}.-...W.O. |
| 07a0 | 19 fe 1a b7 cb 97 91 87 1c 87 a7 f1 56 3e 64 c2 75 09 11 2f 0d 9e 16 da f2 31 2e b3 0f 2a 97 51 | ............V>d.u../.....1...*.Q |
| 07c0 | 7d 50 db a8 b5 b0 40 23 db 2c 7e e6 d8 df f4 76 7b ea b7 f3 17 4d f5 5f eb d6 6f 47 2c c3 cd dd | }P....@#.,~....v{....M._..oG,... |
| 07e0 | 99 d3 18 36 b5 a2 5d 75 51 1b 1b 43 de ef d6 2a 6f bb f5 6b 7f 4b 5f fd a7 b7 f4 7f 65 5e 87 d7 | ...6..]uQ..C...*o..k.K_.....e^.. |
| 0800 | fe ae 74 ce bd 8c 29 cd 64 5b 58 3e 86 4b 34 b6 a2 e1 b5 de 9b ff 00 71 ff 00 e1 69 7f e8 6d ff | ..t...).d[X>.K4........q...i..m. |
| 0820 | 00 08 c5 e4 7d 73 a0 f5 1e 81 9f f6 3c d0 1c d7 49 c6 ca 60 21 97 30 1d 5c c0 ef e6 ef 67 fd a8 | ....}s......<...I..`!.0.\....g.. |
| 0840 | c7 dd fa 1f a7 5f ab 47 e9 15 43 09 63 3c 51 d4 75 74 b1 e6 c7 cc c7 db ca 04 67 fa 32 ff 00 bd | ....._.G..C.c<Q.ut........g.2... |
| 0860 | 7d ab 13 2f 1b 37 1a bc bc 4b 1b 76 3d cd 0e ae c6 19 04 14 65 e3 9f 54 be b4 dd f5 7f 2f 6f ba | }../.7...K.v=.......e..T...../o. |
| 0880 | cc 0b df 39 94 cc c1 30 df b5 e3 30 4f eb 0c 6f f3 d5 33 fa 5d 5f f0 cb d8 29 ba ab e9 65 f4 3d | ...9...0...0O..o..3.]_...)...e.= |
| 08a0 | b6 d3 6b 43 eb b1 84 16 b9 ae 1b 9using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.Core.DI;
using Tango.Logging;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.Synchronization.Navigation;
using Tango.MachineStudio.Synchronization.Properties;
using Tango.Settings;
using Tango.SharedUI;
using Tango.Synchronization;
using Tango.Synchronization.Local;
namespace Tango.MachineStudio.Synchronization.ViewModels
{
/// <summary>
/// Represents the 'Local Synchronization' view model.
/// </summary>
/// <seealso cref="Tango.SharedUI.ViewModel" />
public class LocalSynchronizationViewVM : ViewModel
{
private SyncNavigationManager _navigation;
private String _masterDBFile;
private String _slaveDBFile;
private LocalDBComparer _comparer;
private INotificationProvider _notification;
private bool _isWorking;
private MainViewVM _mainView;
private SynchronizationModuleSettings _settings;
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="LocalSynchronizationViewVM"/> class.
/// </summary>
/// <param name="navigation">The navigation.</param>
/// <param name="notification">The notification.</param>
public LocalSynchronizationViewVM(SyncNavigationManager navigation, INotificationProvider notification)
{
_settings = SettingsManager.Default.GetOrCreate<SynchronizationModuleSettings>();
_navigation = navigation;
_notification = notification;
BackCommand = new RelayCommand(() => _navigation.NavigateTo(NavigationView.MenuView));
Differences = new ObservableCollection<Diff>();
BrowseMasterDBCommand = new RelayCommand(BrowseMasterDB, (x) => !_isWorking);
BrowseSlaveDBCommand = new RelayCommand(BrowseSlaveDB, (x) => !_isWorking);
CompareCommand = new RelayCommand(Compare, (x) => MasterDBFile != null && SlaveDBFile != null && !_isWorking);
CommitCommand = new RelayCommand(Commit, (x) => SelectedDifference != null && !_isWorking);
CommitAllCommand = new RelayCommand(CommitAll, (x) => Differences.Count > 0 && !_isWorking);
CleanCommand = new RelayCommand(CleanSlave, (x) => !_isWorking && SlaveDBFile != null);
if (File.Exists(_settings.LocalMasterDBFile))
{
MasterDBFile = _settings.LocalMasterDBFile;
MasterDBName = Path.GetFileName(MasterDBFile);
}
if (File.Exists(_settings.LocalSlaveDBFile))
{
SlaveDBFile = _settings.LocalSlaveDBFile;
SlaveDBName = Path.GetFileName(SlaveDBFile);
}
}
#endregion
#region Commands
/// <summary>
/// Gets or sets the back command.
/// </summary>
public RelayCommand BackCommand { get; set; }
/// <summary>
/// Gets or sets the browse master database command.
/// </summary>
public RelayCommand BrowseMasterDBCommand { get; set; }
/// <summary>
/// Gets or sets the browse slave database command.
/// </summary>
public RelayCommand BrowseSlaveDBCommand { get; set; }
/// <summary>
/// Gets or sets the compare command.
/// </summary>
public RelayCommand CompareCommand { get; set; }
/// <summary>
/// Gets or sets the commit command.
/// </summary>
public RelayCommand CommitCommand { get; set; }
/// <summary>
/// Gets or sets the commit all command.
/// </summary>
public RelayCommand CommitAllCommand { get; set; }
/// <summary>
/// Gets or sets the clean command.
/// </summary>
public RelayCommand CleanCommand { get; set; }
#endregion
#region Properties
private ObservableCollection<Diff> _differences;
/// <summary>
/// Gets or sets the differences.
/// </summary>
public ObservableCollection<Diff> Differences
{
get { return _differences; }
set { _differences = value; RaisePropertyChanged(nameof(Differences)); }
}
private Diff _selectedDifference;
/// <summary>
/// Gets or sets the selected difference.
/// </summary>
public Diff SelectedDifference
{
get { return _selectedDifference; }
set { _selectedDifference = value; RaisePropertyChanged(nameof(SelectedDifference)); InvalidateRelayCommands(); }
}
private String _masterDBName;
/// <summary>
/// Gets or sets the name of the master database.
/// </summary>
public String MasterDBName
{
get { return _masterDBName; }
set { _masterDBName = value; RaisePropertyChanged(nameof(MasterDBName)); }
}
private String _slaveDBName;
/// <summary>
/// Gets or sets the name of the slave database.
/// </summary>
public String SlaveDBName
{
get { return _slaveDBName; }
set { _slaveDBName = value; RaisePropertyChanged(nameof(SlaveDBName)); }
}
/// <summary>
/// Gets or sets the slave database file.
/// </summary>
public String SlaveDBFile
{
get { return _slaveDBFile; }
set { _slaveDBFile = value; RaisePropertyChangedAuto(); }
}
/// <summary>
/// Gets or sets the master database file.
/// </summary>
public String MasterDBFile
{
get { return _masterDBFile; }
set { _masterDBFile = value; RaisePropertyChangedAuto(); }
}
#endregion
#region Event Handlers
private void Comparer_Progress(object sender, string e)
{
if (_mainView == null)
{
_mainView = TangoIOC.Default.GetInstance<MainViewVM>();
_mainView.Log = String.Empty;
}
_mainView.Log += ("[" + DateTime.Now.ToTimeString() + "] " + e + Environment.NewLine);
}
#endregion
#region Private Methods
/// <summary>
/// Cleans the slave database.
/// </summary>
private async void CleanSlave()
{
if (_notification.ShowQuestion("Are you sure you want to erase all data on slave database?"))
{
using (_notification.PushTaskItem("Clearing database..."))
{
try
{
_isWorking = true;
await Task.Factory.StartNew(() =>
{
SQLiteDataBase localDB = new SQLiteDataBase(SlaveDBFile);
localDB.LoadTables();
localDB.ClearDataBase();
try
{
localDB.Dispose();
}
catch { }
});
Differences.Clear();
}
catch (Exception ex)
{
ShowError(LogManager.Log(ex).Message);
}
finally
{
_isWorking = false;
InvalidateRelayCommands();
SelectedDifference = null;
}
}
}
}
/// <summary>
/// Compares the master and slave database files.
/// </summary>
private void Compare()
{
_comparer = new LocalDBComparer(new SQLiteDataBase(MasterDBFile), new SQLiteDataBase(SlaveDBFile));
_comparer.Progress += Comparer_Progress;
Task.Factory.StartNew(() =>
{
using (_notification.PushTaskItem("Comparing Databases..."))
{
try
{
_isWorking = true;
InvalidateRelayCommands();
Thread.Sleep(1500);
var diffs = _comparer.Compare();
Differences = new ObservableCollection<Diff>(diffs);
if (diffs.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() > 0)
{
ShowInfo("Found " + Differences.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() + " differences.");
}
else
{
ShowInfo("The master and slave databases are synchronized.");
}
}
catch (Exception ex)
{
ShowError(ex.Message);
}
finally
{
_isWorking = false;
SelectedDifference = null;
InvalidateRelayCommands();
_settings.LocalMasterDBFile = MasterDBFile;
_settings.LocalSlaveDBFile = SlaveDBFile;
_settings.Save();
}
}
});
}
/// <summary>
/// Commits the selected difference.
/// </summary>
private void Commit()
{
Task.Factory.StartNew(() =>
{
using (_notification.PushTaskItem("Committing difference..."))
{
try
{
_isWorking = true;
InvalidateRelayCommands();
Thread.Sleep(1500);
SelectedDifference.Commit();
InvokeUINow(() => Differences.Remove(SelectedDifference));
}
catch (Exception ex)
{
ShowError(ex.Message);
}
finally
{
_isWorking = false;
SelectedDifference = null;
InvalidateRelayCommands();
}
}
});
}
/// <summary>
/// Commits all the differences.
/// </summary>
private void CommitAll()
{
Task.Factory.StartNew(() =>
{
using (_notification.PushTaskItem("Committing all differences..."))
{
try
{
_isWorking = true;
InvalidateRelayCommands();
Thread.Sleep(1500);
for (int i = 0; i < Differences.Count; i++)
{
var diff = Differences[i];
using (_notification.PushTaskItem("Committing difference " + (Differences.IndexOf(diff) + 1) + "..."))
{
diff.Commit();
InvokeUINow(() => Differences.Remove(diff));
i--;
}
}
}
catch (Exception ex)
{
ShowError(ex.Message);
}
finally
{
_isWorking = false;
SelectedDifference = null;
InvalidateRelayCommands();
}
}
});
}
/// <summary>
/// Browse for slave database file.
/// </summary>
private void BrowseSlaveDB()
{
String file = BrowseForFilePath();
if (file != null)
{
SlaveDBFile = file;
SlaveDBName = Path.GetFileName(file);
InvalidateRelayCommands();
}
}
/// <summary>
/// Browse for master database file.
/// </summary>
private void BrowseMasterDB()
{
String file = BrowseForFilePath();
if (file != null)
{
MasterDBFile = file;
MasterDBName = Path.GetFileName(file);
InvalidateRelayCommands();
}
}
/// <summary>
/// Browse for database file.
/// </summary>
private String BrowseForFilePath()
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Select SQLite Database File";
dlg.Filter = "SQLite Database|*.db";
if (dlg.ShowDialog().Value)
{
return dlg.FileName;
}
return null;
}
/// <summary>
/// Displays an error message.
/// </summary>
/// <param name="message">The message.</param>
private void ShowError(String message)
{
InvokeUINow(() => _notification.ShowError(message));
}
/// <summary>
/// Displays an information message.
/// </summary>
/// <param name="message">The message.</param>
private void ShowInfo(String message)
{
InvokeUINow(() => _notification.ShowInfo(message));
}
#endregion
}
}
|