aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2017-12-26 21:16:15 +0200
committerRoy <roy.mail.net@gmail.com>2017-12-26 21:16:15 +0200
commit2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc (patch)
treea21ff27fff08876e835df82c5242def1f0d09c17 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization
parent6450fc175114a6f8d0b75cb21386d1bb0c902711 (diff)
downloadTango-2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc.tar.gz
Tango-2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc.zip
MERGE
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config15
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj31
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs274
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml200
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml77
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config7
7 files changed, 538 insertions, 68 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config
index 00d1c3941..158702ed3 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config
@@ -12,4 +12,19 @@
</providers>
</entityFramework>
+ <runtime>
+
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+
+ <dependentAssembly>
+
+ <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" />
+
+ <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
+
+ </dependentAssembly>
+
+ </assemblyBinding>
+
+ </runtime>
</configuration> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj
index 19eecc2e1..bc47bbb0b 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj
@@ -51,6 +51,9 @@
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
+ <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath>
+ </Reference>
<Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath>
</Reference>
@@ -66,6 +69,22 @@
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
+ <Reference Include="System.Reactive.Core, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reactive.Interfaces, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reactive.Linq, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reactive.PlatformServices, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reactive.Windows.Threading, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Windows" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
@@ -150,6 +169,10 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
+ <Content Include="..\..\..\..\DB\Tango.db">
+ <Link>Tango.db</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
@@ -186,6 +209,10 @@
<Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project>
<Name>Tango.Logging</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\..\Tango.PMR\Tango.PMR.csproj">
+ <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project>
+ <Name>Tango.PMR</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\..\Tango.Settings\Tango.Settings.csproj">
<Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project>
<Name>Tango.Settings</Name>
@@ -198,6 +225,10 @@
<Project>{7ada4e86-cad7-4968-a210-3a8a9e5153ab}</Project>
<Name>Tango.Synchronization</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\..\Tango.Transport\Tango.Transport.csproj">
+ <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project>
+ <Name>Tango.Transport</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\Tango.MachineStudio.Common\Tango.MachineStudio.Common.csproj">
<Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project>
<Name>Tango.MachineStudio.Common</Name>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs
index ba3521009..f265fafe7 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs
@@ -1,20 +1,286 @@
-using System;
+using Google.Protobuf;
+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.Helpers;
+using Tango.DAL.Observables;
using Tango.Integration.Services;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.MachineStudio.Common.StudioApplication;
+using Tango.MachineStudio.Synchronization.Navigation;
+using Tango.PMR.Integration;
using Tango.SharedUI;
+using Tango.Synchronization;
+using Tango.Synchronization.Local;
+using Tango.Synchronization.Remote;
namespace Tango.MachineStudio.Synchronization.ViewModels
{
public class DirectSynchronizationViewVM : ViewModel
{
- public ExternalBridgeScanner Scanner { get; set; }
+ private SyncNavigationManager _navigation;
+ private String _slaveDBFile;
+ private String _masterDBFile;
+ private LocalDBComparer _comparer;
+ private INotificationProvider _notification;
+ private bool _isWorking;
- public DirectSynchronizationViewVM(ExternalBridgeScanner scanner)
+ public IStudioApplicationManager ApplicationManager { get; set; }
+
+ public DirectSynchronizationViewVM(IStudioApplicationManager applicationManager, SyncNavigationManager navigation, INotificationProvider notification)
+ {
+ ApplicationManager = applicationManager;
+
+ _navigation = navigation;
+ _notification = notification;
+
+ BackCommand = new RelayCommand(() => _navigation.NavigateTo(NavigationView.MenuView));
+
+ Differences = new ObservableCollection<Diff>();
+
+ CompareCommand = new RelayCommand(Compare, (x) => !_isWorking && SelectedMachine != null);
+ CommitAllCommand = new RelayCommand(Synchronize, (x) => Differences.Count > 0 && !_isWorking && SelectedMachine != null);
+ }
+
+ #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 bool _isClearMachine;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is clear machine.
+ /// </summary>
+ public bool IsClearMachine
+ {
+ get { return _isClearMachine; }
+ set
+ {
+ _isClearMachine = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ 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 Machine _selectedMachine;
+ /// <summary>
+ /// Gets or sets the selected machine.
+ /// </summary>
+ public Machine SelectedMachine
+ {
+ get { return _selectedMachine; }
+ set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+ #endregion
+
+ private void Compare()
+ {
+ if (SelectedMachine.SerialNumber != ApplicationManager.ConnectedMachine.SerialNumber)
+ {
+ if (!_notification.ShowQuestion("The selected machine serial number does not match the connected machine. Are you sure you want to continue?"))
+ {
+ return;
+ }
+ }
+
+ Task.Factory.StartNew(async () =>
+ {
+ using (_notification.PushTaskItem("Downloading machine database..."))
+ {
+ try
+ {
+ _isWorking = true;
+ InvalidateRelayCommands();
+ Thread.Sleep(1500);
+
+ ApplicationManager.ConnectedMachine.RequestTimeout = TimeSpan.FromSeconds(10);
+ var response = await ApplicationManager.ConnectedMachine.SendRequest<DirectSynchronizationRequest, DirectSynchronizationResponse>(new DirectSynchronizationRequest());
+
+ using (_notification.PushTaskItem("Generating temporary files..."))
+ {
+ String tempFolder = PathHelper.GetTempFolderPath();
+
+ //File path for the reflected remote data base SQLite.
+ _masterDBFile = Path.Combine(tempFolder, "Remote.db");
+ //File path for the received machine SQLite db.
+ _slaveDBFile = Path.Combine(tempFolder, "Local.db");
+
+ //Save the machine db to file.
+ File.WriteAllBytes(_slaveDBFile, response.Message.LocalDB.ToByteArray());
+
+ //Copy the SQLite db template.
+ File.Copy(Path.Combine(PathHelper.GetStartupPath(), "Tango.db"), _masterDBFile);
+
+ //Synchronize the SQL Server db with the new SQLite template. (Overwrite basically)
+ RemoteDBSynchronizer.Synchronize(_masterDBFile, SelectedMachine.SerialNumber, true);
+
+ using (_notification.PushTaskItem("Comparing database..."))
+ {
+ _comparer = new LocalDBComparer(new SQLiteDataBase(_masterDBFile), new SQLiteDataBase(_slaveDBFile));
+
+ 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 machine database is synchronized.");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ShowError(ex.Message);
+ }
+ finally
+ {
+ _isWorking = false;
+ SelectedDifference = null;
+ InvalidateRelayCommands();
+ }
+ }
+ });
+ }
+
+ private void Synchronize()
+ {
+ if (IsClearMachine)
+ {
+ if (!_notification.ShowQuestion("This will erase and override the existing machine database. Do you want to proceed?"))
+ {
+ return;
+ }
+ }
+
+ Task.Factory.StartNew(async () =>
+ {
+ using (_notification.PushTaskItem("Synchronizing..."))
+ {
+ try
+ {
+ _isWorking = true;
+ InvalidateRelayCommands();
+ Thread.Sleep(1500);
+
+ for (int i = 0; i < Differences.Count; i++)
+ {
+ var diff = Differences[i];
+
+ diff.Commit();
+ InvokeUINow(() => Differences.Remove(diff));
+ i--;
+ }
+
+ _comparer.Dispose();
+
+ byte[] remoteDbBytes = IsClearMachine ? File.ReadAllBytes(_masterDBFile) : File.ReadAllBytes(_slaveDBFile);
+
+ var response = await ApplicationManager.ConnectedMachine.SendRequest<OverrideDataBaseRequest, OverrideDataBaseResponse>(new OverrideDataBaseRequest()
+ {
+ RemoteDB = ByteString.CopyFrom(remoteDbBytes)
+ });
+
+ if (!response.Message.Successful)
+ {
+ ShowError("The remote machine has reported some error while trying to override the database.");
+ }
+ else
+ {
+ PathHelper.TryDeleteFile(_slaveDBFile);
+ PathHelper.TryDeleteFile(_masterDBFile);
+ _slaveDBFile = null;
+ _masterDBFile = null;
+ InvalidateRelayCommands();
+ }
+ }
+ catch (Exception ex)
+ {
+ ShowError(ex.Message);
+ }
+ finally
+ {
+ _isWorking = false;
+ SelectedDifference = null;
+ InvalidateRelayCommands();
+ }
+ }
+ });
+ }
+
+ private void ShowError(String message)
+ {
+ InvokeUINow(() => _notification.ShowError(message));
+ }
+
+ private void ShowInfo(String message)
{
- Scanner = scanner;
+ InvokeUINow(() => _notification.ShowInfo(message));
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml
index 7dc0cdacc..4c5a719b5 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml
@@ -5,29 +5,199 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:synchronization="clr-namespace:Tango.Synchronization;assembly=Tango.Synchronization"
+ xmlns:providers="clr-namespace:Tango.MachineStudio.Synchronization.AutoComplete"
+ xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
xmlns:global="clr-namespace:Tango.MachineStudio.Synchronization"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
xmlns:local="clr-namespace:Tango.MachineStudio.Synchronization.Views"
mc:Ignorable="d"
- d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.DirectSynchronizationViewVM}">
+ d:DesignHeight="720" d:DesignWidth="1280" DataContext="{x:Static global:ViewModelLocator.DirectSynchronizationViewVM}">
+
+ <UserControl.Resources>
+ <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter"></converters:BooleanToVisibilityInverseConverter>
+
+ <providers:MachinesProvider x:Key="MachinesProvider"></providers:MachinesProvider>
+
+ <VisualBrush x:Key="badgeBackground">
+ <VisualBrush.Visual>
+ <Border>
+ <Path Stretch="Fill" RenderTransformOrigin="0.5,0.5">
+ <Path.RenderTransform>
+ <ScaleTransform ScaleX="-1"></ScaleTransform>
+ </Path.RenderTransform>
+ <Path.Fill>
+ <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
+ <GradientStop Color="#EEEEEE" Offset="0.4" />
+ <GradientStop Color="White" Offset="1"/>
+ </LinearGradientBrush>
+ </Path.Fill>
+ <Path.Data>
+ <PathGeometry Figures="M 53.868 43.913 H 19.511 c -0.444 0 -0.875 -0.151 -1.221 -0.428 L 0.734 29.439 c -0.978 -0.783 -0.978 -2.271 0 -3.053 L 18.29 12.341 c 0.347 -0.277 0.777 -0.428 1.221 -0.428 h 34.356 c 1.081 0 1.958 0.877 1.958 1.958 v 28.084 c 0 1.081 -0.876 1.958 -1.957 1.958 z" FillRule="NonZero"/>
+ </Path.Data>
+ </Path>
+ </Border>
+ </VisualBrush.Visual>
+ </VisualBrush>
+ </UserControl.Resources>
+
<Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="100" />
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+
<Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="300"/>
- <ColumnDefinition Width="1*"/>
- </Grid.ColumnDefinitions>
+ <StackPanel Orientation="Horizontal" Margin="20">
+ <Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Margin="0 5 0 0" VerticalAlignment="Center" Command="{Binding BackCommand}">
+ <materialDesign:PackIcon Kind="ArrowLeft" Foreground="#303030" ToolTip="Back" VerticalAlignment="Center" Width="40" Height="40"></materialDesign:PackIcon>
+ </Button>
+ <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="30">Direct Database Synchronization</TextBlock>
+ </StackPanel>
+ </Grid>
+
+ <Grid Margin="20" Grid.Row="1">
+ <GroupBox Header="Compare &amp; Synchronize">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="57*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition MaxWidth="250" />
+ <ColumnDefinition/>
+ </Grid.ColumnDefinitions>
+
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+
+ <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Margin="20 0 0 0">
+ <Image Source="../Images/remote-db.png" Width="100" Margin="10" Opacity="0.8" HorizontalAlignment="Left" RenderOptions.BitmapScalingMode="Fant"></Image>
+ <TextBlock Background="{StaticResource badgeBackground}" Padding="5" Width="200" FontSize="14" HorizontalAlignment="Left">Remote Database</TextBlock>
+ <StackPanel Orientation="Horizontal" Margin="0 5 0 0">
+ <fa:ImageAwesome Icon="Key" Width="16" Height="16"></fa:ImageAwesome>
+ <autoComplete:AutoCompleteTextBox Margin="5 0 0 0" Width="170" materialDesign:HintAssist.Hint="Enter machine serial number" DisplayMember="SerialNumber" Provider="{StaticResource ResourceKey=MachinesProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
+ <autoComplete:AutoCompleteTextBox.ItemTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding SerialNumber}"></TextBlock>
+ </DataTemplate>
+ </autoComplete:AutoCompleteTextBox.ItemTemplate>
+ <autoComplete:AutoCompleteTextBox.LoadingContent>
+ <TextBlock Text="Loading..." Margin="5" FontSize="14" />
+ </autoComplete:AutoCompleteTextBox.LoadingContent>
+ </autoComplete:AutoCompleteTextBox>
+ </StackPanel>
+ </StackPanel>
- <ListBox ItemsSource="{Binding Scanner.AvailableMachines}" SelectedItem="{Binding SelectedMachine}">
- <ListBox.ItemTemplate>
- <DataTemplate>
- <StackPanel>
- <TextBlock Text="{Binding SerialNumber}"></TextBlock>
- <TextBlock Text="{Binding Organization}"></TextBlock>
+ <StackPanel Margin="20 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Row="1" >
+ <Image Source="../Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant" Width="110"></Image>
+ <TextBlock Margin="0 20 0 0">
+ <Run FontWeight="Bold">IP Address:</Run>
+ <Run Text="{Binding ApplicationManager.ConnectedMachine.IPAddress,Mode=OneWay}"></Run>
+ </TextBlock>
+ <TextBlock Margin="0 5 0 0">
+ <Run FontWeight="Bold">Serial Number:</Run>
+ <Run Text="{Binding ApplicationManager.ConnectedMachine.SerialNumber,Mode=OneWay}"></Run>
+ </TextBlock>
+ <TextBlock Margin="0 5 0 0">
+ <Run FontWeight="Bold">Organization:</Run>
+ <Run Text="{Binding ApplicationManager.ConnectedMachine.Organization,Mode=OneWay}"></Run>
+ </TextBlock>
</StackPanel>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
-
+
+ </Grid>
+
+ <Button Margin="20 10" Grid.Row="1" Width="200" Height="40" HorizontalAlignment="Left" Command="{Binding CompareCommand}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMPARE</TextBlock>
+ <fa:ImageAwesome Icon="LongArrowRight" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
+ </StackPanel>
+ </Button>
+
+ <Grid Grid.Column="1">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="625*"/>
+ <ColumnDefinition Width="347*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="20"/>
+ <RowDefinition Height="205*"/>
+ </Grid.RowDefinitions>
+ <TextBlock Margin="10 5 0 0" FontSize="14">Differences</TextBlock>
+ <ListBox Margin="10" Background="#F1F1F1" Grid.Row="1" ItemsSource="{Binding Differences}" SelectedItem="{Binding SelectedDifference,Mode=TwoWay}">
+ <ListBox.ItemTemplate>
+ <DataTemplate>
+ <Border Padding="10">
+ <StackPanel Orientation="Horizontal">
+ <fa:ImageAwesome Icon="Cog" Width="20" Height="20" Foreground="Gray"></fa:ImageAwesome>
+ <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Text="{Binding Description}">
+ <TextBlock.Style>
+ <Style TargetType="TextBlock">
+ <Setter Property="Foreground" Value="Red"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Action}" Value="ReplaceTableDataInSlave">
+ <Setter Property="Foreground" Value="#404040"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ </TextBlock>
+ </StackPanel>
+ </Border>
+ </DataTemplate>
+ </ListBox.ItemTemplate>
+ </ListBox>
+
+ <TextBlock Margin="10 0 0 0" VerticalAlignment="Bottom" Grid.Column="1">SQL Command</TextBlock>
+ <TextBox Grid.Column="1" Margin="10" Style="{x:Null}" BorderThickness="0" Foreground="Gray" FontSize="14" Text="{Binding SelectedDifference.Command,Mode=OneWay}" IsReadOnly="True" Background="#F1F1F1" Padding="5" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" AcceptsReturn="True" Grid.Row="1"></TextBox>
+ </Grid>
+
+ <Grid Grid.Row="1" Grid.Column="1">
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
+ <StackPanel VerticalAlignment="Center" Orientation="Horizontal" Margin="0 0 20 0">
+ <TextBlock>Clear Machine Before Synchronization</TextBlock>
+ <ToggleButton Margin="10 0 0 0" IsChecked="{Binding IsClearMachine}" Foreground="Red" Style="{StaticResource MaterialDesignSwitchToggleButton}" ></ToggleButton>
+ </StackPanel>
+ <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitAllCommand}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">SYNCHRONIZE</TextBlock>
+ <fa:ImageAwesome Icon="SortAmountAsc" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
+ </StackPanel>
+ </Button>
+ </StackPanel>
+ </Grid>
+ </Grid>
+ </GroupBox>
+ </Grid>
+
+ <Grid Grid.Row="1" Visibility="Hidden">
+ <Grid.Background>
+ <SolidColorBrush Color="White" Opacity="0.8"></SolidColorBrush>
+ </Grid.Background>
+
+ <TextBlock Foreground="Silver" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="40">
+ <TextBlock.Style>
+ <Style TargetType="TextBlock">
+ <Style.Triggers>
+ <EventTrigger RoutedEvent="Loaded">
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Duration="00:00:01" RepeatBehavior="Forever">
+ <LinearDoubleKeyFrame Value="0" KeyTime="00:00:00"></LinearDoubleKeyFrame>
+ <LinearDoubleKeyFrame Value="1" KeyTime="00:00:0.5"></LinearDoubleKeyFrame>
+ </DoubleAnimationUsingKeyFrames>
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ No Machine Connection
+ </TextBlock>
</Grid>
</Grid>
</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml
index 72297e2cb..e5a4aac5a 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml
@@ -43,18 +43,14 @@
<Grid>
<StackPanel Orientation="Horizontal" Margin="20">
<Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Margin="0 5 0 0" VerticalAlignment="Center" Command="{Binding BackCommand}">
- <materialDesign:PackIcon Kind="Backburger" Foreground="#303030" ToolTip="Back" VerticalAlignment="Center" Width="40" Height="40"></materialDesign:PackIcon>
+ <materialDesign:PackIcon Kind="ArrowLeft" Foreground="#303030" ToolTip="Back" VerticalAlignment="Center" Width="40" Height="40"></materialDesign:PackIcon>
</Button>
<TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="30">Local Database Synchronization</TextBlock>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="800"/>
- <ColumnDefinition Width="1*"/>
- </Grid.ColumnDefinitions>
<Grid Margin="20">
- <GroupBox Header="Compare">
+ <GroupBox Header="Compare &amp; Synchronize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="57*"/>
@@ -102,6 +98,10 @@
</Button>
<Grid Grid.Column="1">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="671*"/>
+ <ColumnDefinition Width="301*"/>
+ </Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="205*"/>
@@ -130,51 +130,32 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
- </Grid>
-
- <Button Margin="10 10" Grid.Column="1" Grid.Row="1" Width="160" Height="40" Background="#FF4F4F" BorderBrush="#FF4F4F" HorizontalAlignment="Right" Command="{Binding CleanCommand}">
- <StackPanel Orientation="Horizontal">
- <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">CLEAN SLAVE</TextBlock>
- <fa:ImageAwesome Icon="TrashOutline" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
- </StackPanel>
- </Button>
- </Grid>
- </GroupBox>
- </Grid>
- <Grid Grid.Column="1" Margin="20">
- <GroupBox Header="Synchronize">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="1*"/>
- <RowDefinition Height="Auto"/>
- </Grid.RowDefinitions>
-
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="20"/>
- <RowDefinition Height="71*"/>
- </Grid.RowDefinitions>
- <TextBlock Margin="10 0 0 0" VerticalAlignment="Bottom">SQL Command</TextBlock>
- <TextBox Margin="10" Style="{x:Null}" BorderThickness="0" Foreground="Gray" FontSize="14" Text="{Binding SelectedDifference.Command,Mode=OneWay}" IsReadOnly="True" Background="#F1F1F1" Padding="5" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" AcceptsReturn="True" Grid.Row="1"></TextBox>
+ <TextBlock Grid.Column="1" Margin="10 0 0 0" VerticalAlignment="Bottom">SQL Command</TextBlock>
+ <TextBox Grid.Column="1" Margin="10" Style="{x:Null}" BorderThickness="0" Foreground="Gray" FontSize="14" Text="{Binding SelectedDifference.Command,Mode=OneWay}" IsReadOnly="True" Background="#F1F1F1" Padding="5" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" AcceptsReturn="True" Grid.Row="1"></TextBox>
</Grid>
- <Grid Grid.Row="1">
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
- <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitCommand}">
- <StackPanel Orientation="Horizontal">
- <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT</TextBlock>
- <fa:ImageAwesome Icon="Bolt" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
- </StackPanel>
- </Button>
- <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitAllCommand}">
- <StackPanel Orientation="Horizontal">
- <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT ALL</TextBlock>
- <fa:ImageAwesome Icon="SortAmountAsc" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
- </StackPanel>
- </Button>
- </StackPanel>
- </Grid>
+ <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right" Grid.Column="1">
+ <Button Margin="10 10" Width="160" Height="40" Background="#FF4F4F" BorderBrush="#FF4F4F" Command="{Binding CleanCommand}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">CLEAN SLAVE</TextBlock>
+ <fa:ImageAwesome Icon="TrashOutline" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
+ </StackPanel>
+ </Button>
+ <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitCommand}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT</TextBlock>
+ <fa:ImageAwesome Icon="Bolt" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
+ </StackPanel>
+ </Button>
+ <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitAllCommand}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT ALL</TextBlock>
+ <fa:ImageAwesome Icon="SortAmountAsc" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome>
+ </StackPanel>
+ </Button>
+ </StackPanel>
+
</Grid>
</GroupBox>
</Grid>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml
index 2487aab64..9bb995bd8 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml
@@ -48,7 +48,7 @@
<Grid>
<StackPanel Orientation="Horizontal" Margin="20">
<Button Style="{StaticResource MaterialDesignFlatButton}" Padding="0" Margin="0 5 0 0" VerticalAlignment="Center" Command="{Binding BackCommand}">
- <materialDesign:PackIcon Kind="Backburger" Foreground="#303030" ToolTip="Back" VerticalAlignment="Center" Width="40" Height="40"></materialDesign:PackIcon>
+ <materialDesign:PackIcon Kind="ArrowLeft" Foreground="#303030" ToolTip="Back" VerticalAlignment="Center" Width="40" Height="40"></materialDesign:PackIcon>
</Button>
<TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="30">Local Database Synchronization</TextBlock>
</StackPanel>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config
index 8d8f972d1..1fa8e3268 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config
@@ -3,8 +3,15 @@
<package id="CommonServiceLocator" version="1.3" targetFramework="net46" />
<package id="EntityFramework" version="6.0.0" targetFramework="net46" />
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" />
+ <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net46" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" />
<package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" />
<package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net46" />
+ <package id="System.Reactive" version="3.1.1" targetFramework="net46" />
+ <package id="System.Reactive.Core" version="3.1.1" targetFramework="net46" />
+ <package id="System.Reactive.Interfaces" version="3.1.1" targetFramework="net46" />
+ <package id="System.Reactive.Linq" version="3.1.1" targetFramework="net46" />
+ <package id="System.Reactive.PlatformServices" version="3.1.1" targetFramework="net46" />
+ <package id="System.Reactive.Windows.Threading" version="3.1.1" targetFramework="net46" />
</packages> \ No newline at end of file