aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-09-05 17:28:54 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-09-05 17:28:54 +0300
commit5c330a1d78b9d6108544b94e756a6457f162a468 (patch)
tree305c0d6cc05c8f70b2e848f7536a31c54fa0ded3 /Software/Visual_Studio
parent2dff0c785e0ac326d01337b5399a8ab5766e611e (diff)
downloadTango-5c330a1d78b9d6108544b94e756a6457f162a468.tar.gz
Tango-5c330a1d78b9d6108544b94e756a6457f162a468.zip
Added missing event type.
Working on PPC DB update..
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs15
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs14
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs165
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj3
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs78
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml46
-rw-r--r--Software/Visual_Studio/Resources/Events.xlsxbin17108 -> 17123 bytes
-rw-r--r--Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs11
-rw-r--r--Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs160
-rw-r--r--Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs216
-rw-r--r--Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj4
-rw-r--r--Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs5
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs46
13 files changed, 739 insertions, 24 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs
new file mode 100644
index 000000000..fbfc2e08c
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.Synchronization;
+
+namespace Tango.PPC.Common.MachineUpdate
+{
+ public class DbCompareResult
+ {
+ public bool RequiresUpdate { get; set; }
+ public UpdateDBResponse UpdateDBResponse { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs
index fd565b84a..d2be997b5 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs
@@ -49,5 +49,19 @@ namespace Tango.PPC.Common.MachineUpdate
/// <param name="machineServiceAddress">The machine service address.</param>
/// <returns></returns>
Task<CheckForUpdateResponse> CheckForUpdate(String serialNumber, String machineServiceAddress);
+
+ /// <summary>
+ /// Checks whether it is necessary to updates all the "overwrite-able" database tables.
+ /// </summary>
+ /// <param name="serialNumber">The serial number.</param>
+ /// <param name="machineServiceAddress">The machine service address.</param>
+ /// <returns></returns>
+ Task<DbCompareResult> UpdateDBCheck(String serialNumber, String machineServiceAddress);
+
+ /// <summary>
+ /// Updates all the "overwrite-able" database tables.
+ /// </summary>
+ /// <returns></returns>
+ Task UpdateDB(DbCompareResult dbCompareResult);
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs
index b86fb88d4..5c7b7554d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs
@@ -80,6 +80,8 @@ namespace Tango.PPC.Common.MachineUpdate
#endregion
+ #region Constructors
+
/// <summary>
/// Initializes a new instance of the <see cref="MachineUpdateManager"/> class.
/// </summary>
@@ -89,6 +91,8 @@ namespace Tango.PPC.Common.MachineUpdate
_app_manager = applicationManager;
}
+ #endregion
+
#region Public Methods
/// <summary>
@@ -282,6 +286,167 @@ namespace Tango.PPC.Common.MachineUpdate
});
}
+ /// <summary>
+ /// Updates all the "overwrite-able" database tables.
+ /// </summary>
+ /// <param name="serialNumber">The serial number.</param>
+ /// <param name="machineServiceAddress">The machine service address.</param>
+ /// <returns></returns>
+ public Task UpdateDB(DbCompareResult dbCompareResult)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ LogManager.Log("Starting database update...");
+
+ LogManager.Log("Looking for OverrideData script on application path...");
+
+ String config_file = Path.Combine(PathHelper.GetStartupPath(), "Update Scripts", "OverrideData.xml");
+
+ if (!File.Exists(config_file))
+ {
+ config_file = Path.Combine(PathHelper.GetStartupPath(), "Provision Scripts", "OverrideData.xml");
+ }
+
+ if (!File.Exists(config_file))
+ {
+ throw LogManager.Log(new FileNotFoundException("Could not locate OverrideData.xml file on application folder."));
+ }
+
+ UpdateDBResponse update_response = dbCompareResult.UpdateDBResponse;
+
+ String db_name = "Tango";
+ String localAddress = SettingsManager.Default.GetOrCreate<CoreSettings>().DataSource.Address;
+ String remote_address = update_response.DbAddress;
+
+ LogManager.Log($"Overriding database static tables '{remote_address}\\{db_name}' => '{localAddress}\\{db_name}'...");
+
+ ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(config_file);
+ builder.SetSourceServer(remote_address, db_name, false, update_response.DbUserName, update_response.DbPassword);
+ builder.SetTargetServer(localAddress, db_name, true);
+ builder.Synchronize();
+
+ var config = builder.Build();
+
+ ExaminerProcess process = new ExaminerProcess(config, ExaminerProcessType.Data);
+ process.Progress += (x, msg) =>
+ {
+ LogManager.Log(msg);
+ };
+
+ LogManager.Log("Starting synchronization process...");
+
+ try
+ {
+ var result = process.Execute().Result;
+
+ if (result.ExitCode != ExaminerProcessExitCode.Success)
+ {
+ throw LogManager.Log(new InvalidDataException(String.Format("OverrideData script has terminated with exit code '{0}'.", result.ExitCode)));
+ }
+
+ LogManager.Log("Synchronization completed successfully!");
+ }
+ catch (Exception ex)
+ {
+ throw LogManager.Log(ex, "Setup manager error while trying to update the database.");
+ }
+ });
+ }
+
+ /// <summary>
+ /// Checks whether it is necessary to updates all the "overwrite-able" database tables.
+ /// </summary>
+ /// <param name="serialNumber">The serial number.</param>
+ /// <param name="machineServiceAddress">The machine service address.</param>
+ /// <returns></returns>
+ public Task<DbCompareResult> UpdateDBCheck(string serialNumber, string machineServiceAddress)
+ {
+ return Task.Factory.StartNew<DbCompareResult>(() =>
+ {
+ LogManager.Log($"Checking if database update is required for serial number {serialNumber}...");
+
+ LogManager.Log("Looking for OverrideData script on application path...");
+
+ String config_file = Path.Combine(PathHelper.GetStartupPath(), "Update Scripts", "OverrideData.xml");
+
+ if (!File.Exists(config_file))
+ {
+ config_file = Path.Combine(PathHelper.GetStartupPath(), "Provision Scripts", "OverrideData.xml");
+ }
+
+ if (!File.Exists(config_file))
+ {
+ throw LogManager.Log(new FileNotFoundException("Could not locate OverrideData.xml file on application folder."));
+ }
+
+ LogManager.Log($"Connecting to machine service on {machineServiceAddress}...");
+
+ UpdateDBRequest request = new UpdateDBRequest();
+ request.SerialNumber = serialNumber;
+
+ UpdateDBResponse update_response = null;
+
+ using (var http = new ProtoWebClient())
+ {
+ update_response = http.Post<UpdateDBRequest, UpdateDBResponse>(machineServiceAddress + "/api/Synchronization/UpdateDB", request).Result;
+ }
+
+ LogManager.Log($"Update DB response received: {Environment.NewLine}{update_response.ToJsonString()}");
+
+ String db_name = "Tango";
+ String localAddress = SettingsManager.Default.GetOrCreate<CoreSettings>().DataSource.Address;
+ String remote_address = update_response.DbAddress;
+
+ LogManager.Log($"Comparing database static tables '{remote_address}\\{db_name}' => '{localAddress}\\{db_name}'...");
+
+ var report_file = TemporaryManager.CreateFile(".xml");
+
+ ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(config_file);
+ builder.SetSourceServer(remote_address, db_name, false, update_response.DbUserName, update_response.DbPassword);
+ builder.SetTargetServer(localAddress, db_name, true);
+ builder.SetReportFile(report_file);
+
+ var config = builder.Build();
+
+ ExaminerProcess process = new ExaminerProcess(config, ExaminerProcessType.Data);
+ process.Progress += (x, msg) =>
+ {
+ LogManager.Log(msg);
+ };
+
+ LogManager.Log("Starting comparison process...");
+ LogManager.Log("Generating report on " + report_file);
+
+ try
+ {
+ var result = process.Execute().Result;
+
+ if (result.ExitCode != ExaminerProcessExitCode.Success)
+ {
+ throw LogManager.Log(new InvalidDataException(String.Format("OverrideData script has terminated with exit code '{0}'.", result.ExitCode)));
+ }
+
+ LogManager.Log("Comparison completed successfully!");
+ LogManager.Log("Loading report file...");
+
+ ExaminerDataReport report = ExaminerDataReport.FromFile(report_file);
+ report_file.Delete();
+
+ LogManager.Log("Comparison summary: \n" + report.Totals.ToJsonString());
+
+ return new DbCompareResult()
+ {
+ RequiresUpdate = report.HasDifferences,
+ UpdateDBResponse = update_response,
+ };
+ }
+ catch (Exception ex)
+ {
+ throw LogManager.Log(ex, "Setup manager error while trying to compare the database.");
+ }
+ });
+ }
+
#endregion
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
index 35a79d497..22ef11178 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
@@ -126,6 +126,7 @@
<Compile Include="MachineSetup\MachineSetupManager.cs" />
<Compile Include="MachineSetup\MachineSetupResult.cs" />
<Compile Include="MachineSetup\MachineSetupSteps.cs" />
+ <Compile Include="MachineUpdate\DbCompareResult.cs" />
<Compile Include="MachineUpdate\IMachineUpdateManager.cs" />
<Compile Include="MachineUpdate\MachineUpdateManager.cs" />
<Compile Include="MachineUpdate\MachineUpdateResult.cs" />
@@ -303,7 +304,7 @@
</Target>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
index 84e65e516..2bdeffadf 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
@@ -23,11 +23,13 @@ namespace Tango.PPC.UI.ViewModels
UpdateAvailableView,
UpToDateView,
UpdateProgressView,
+ UpdateDbProgressView,
UpdateCompletedView,
UpdateFailedView,
}
private MachineUpdateResult _update_result;
+ private DbCompareResult _db_compare_result;
#region Properties
@@ -46,6 +48,16 @@ namespace Tango.PPC.UI.ViewModels
set { _latestVersion = value; RaisePropertyChangedAuto(); }
}
+ private bool _isDbUpdate;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is database update.
+ /// </summary>
+ public bool IsDbUpdate
+ {
+ get { return _isDbUpdate; }
+ set { _isDbUpdate = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Commands
@@ -70,6 +82,11 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
public RelayCommand CloseCommand { get; set; }
+ /// <summary>
+ /// Gets or sets to application command.
+ /// </summary>
+ public RelayCommand ToApplicationCommand { get; set; }
+
#endregion
#region Constructors
@@ -86,6 +103,12 @@ namespace Tango.PPC.UI.ViewModels
NavigationManager.NavigateTo(Common.Navigation.NavigationView.HomeModule);
NavigateTo(MachineUpdateView.UpdateCheckView);
});
+
+ ToApplicationCommand = new RelayCommand(() =>
+ {
+ NavigationManager.NavigateTo(Common.Navigation.NavigationView.HomeModule);
+ NavigateTo(MachineUpdateView.UpdateCheckView);
+ });
}
#endregion
@@ -98,6 +121,8 @@ namespace Tango.PPC.UI.ViewModels
try
{
+ IsDbUpdate = false;
+
var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
if (response.IsUpdateAvailable)
@@ -107,7 +132,17 @@ namespace Tango.PPC.UI.ViewModels
}
else
{
- await NavigateTo(MachineUpdateView.UpToDateView);
+ _db_compare_result = await MachineUpdateManager.UpdateDBCheck(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
+
+ if (_db_compare_result.RequiresUpdate)
+ {
+ IsDbUpdate = true;
+ await NavigateTo(MachineUpdateView.UpdateAvailableView);
+ }
+ else
+ {
+ await NavigateTo(MachineUpdateView.UpToDateView);
+ }
}
}
catch (Exception ex)
@@ -119,20 +154,41 @@ namespace Tango.PPC.UI.ViewModels
private async void Update()
{
- await NavigateTo(MachineUpdateView.UpdateProgressView);
+ if (!IsDbUpdate)
+ {
+ await NavigateTo(MachineUpdateView.UpdateProgressView);
- LogManager.Log("Starting machine update...");
+ LogManager.Log("Starting machine update...");
- try
- {
- _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
- LogManager.Log("Machine update completed.");
- await NavigateTo(MachineUpdateView.UpdateCompletedView);
+ try
+ {
+ _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
+ LogManager.Log("Machine update completed.");
+ await NavigateTo(MachineUpdateView.UpdateCompletedView);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Machine update failed.");
+ await NavigateTo(MachineUpdateView.UpdateFailedView);
+ }
}
- catch (Exception ex)
+ else
{
- LogManager.Log(ex, "Machine update failed.");
- await NavigateTo(MachineUpdateView.UpdateFailedView);
+ await NavigateTo(MachineUpdateView.UpdateDbProgressView);
+
+ LogManager.Log("Starting database update...");
+
+ try
+ {
+ await MachineUpdateManager.UpdateDB(_db_compare_result);
+ LogManager.Log("Database update completed.");
+ await NavigateTo(MachineUpdateView.UpToDateView);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Database update failed.");
+ await NavigateTo(MachineUpdateView.UpdateFailedView);
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml
index ce1cee424..06343814d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml
@@ -32,14 +32,35 @@
<Grid controls:NavigationControl.NavigationName="UpdateAvailableView">
<StackPanel HorizontalAlignment="Center" Margin="0 40 0 0">
- <TextBlock FontSize="{StaticResource TangoHeaderFontSize}">
- <Run>Version</Run>
- <Run Foreground="{StaticResource TangoPrimaryAccentBrush}" Text="{Binding LatestVersion}"></Run>
- <Run>is available</Run>
- </TextBlock>
+ <ContentControl>
+ <ContentControl.Style>
+ <Style TargetType="ContentControl">
+ <Setter Property="Content">
+ <Setter.Value>
+ <TextBlock FontSize="{StaticResource TangoHeaderFontSize}">
+ <Run>Version</Run>
+ <Run Foreground="{StaticResource TangoPrimaryAccentBrush}" Text="{Binding LatestVersion}"></Run>
+ <Run>is available</Run>
+ </TextBlock>
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsDbUpdate}" Value="True">
+ <Setter Property="Content">
+ <Setter.Value>
+ <TextBlock FontSize="{StaticResource TangoHeaderFontSize}">
+ Database update is available
+ </TextBlock>
+ </Setter.Value>
+ </Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ContentControl.Style>
+ </ContentControl>
<TextBlock FontSize="{StaticResource TangoTitleFontSize}" Margin="0 40 0 0">
- Updating you machine can improve the following:
+ Updating your machine can improve the following:
</TextBlock>
<StackPanel Margin="0 40 0 0">
@@ -87,6 +108,8 @@
<TextBlock VerticalAlignment="Center" Width="600" TextWrapping="Wrap" TextAlignment="Center" Margin="0 10 0 0" Foreground="{StaticResource TangoErrorBrush}" FontSize="{StaticResource TangoTitleFontSize}">An error occurred while trying to check for updates. Please check your internet connection and try again.</TextBlock>
<touch:TouchButton Margin="0 200 0 0" Padding="20" Width="300" CornerRadius="35" Command="{Binding RestartCommand}">TRY AGAIN</touch:TouchButton>
+
+ <touch:TouchButton Style="{StaticResource TangoFlatButton}" Margin="0 200 0 0" Padding="20" Width="300" HorizontalContentAlignment="Center" CornerRadius="35" Command="{Binding ToApplicationCommand}">Back To Application</touch:TouchButton>
</StackPanel>
</Grid>
@@ -105,6 +128,15 @@
</StackPanel>
</Grid>
+ <Grid controls:NavigationControl.NavigationName="UpdateDbProgressView">
+ <StackPanel HorizontalAlignment="Center" Margin="0 200 0 0">
+ <touch:TouchBusyIndicator Width="250" Height="250" IsIndeterminate="{Binding IsVisible}" />
+ <TextBlock DockPanel.Dock="Top" Margin="0 100" FontSize="{StaticResource TangoHeaderFontSize}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">
+ Updating database...
+ </TextBlock>
+ </StackPanel>
+ </Grid>
+
<Grid controls:NavigationControl.NavigationName="UpdateCompletedView">
<StackPanel HorizontalAlignment="Center" Margin="0 50 0 0">
<touch:TouchIcon Icon="Check" Foreground="{StaticResource TangoPrimaryAccentBrush}" Width="70" Height="70" />
@@ -120,6 +152,8 @@
<TextBlock VerticalAlignment="Center" Margin="0 10 0 0" Foreground="{StaticResource TangoErrorBrush}" FontSize="{StaticResource TangoTitleFontSize}">An error occurred while trying to update the machine.</TextBlock>
<touch:TouchButton Margin="0 200 0 0" Padding="20" Width="300" CornerRadius="35" Command="{Binding RestartCommand}">TRY AGAIN</touch:TouchButton>
+
+ <touch:TouchButton Style="{StaticResource TangoFlatButton}" Margin="0 200 0 0" Padding="20" Width="300" HorizontalContentAlignment="Center" CornerRadius="35" Command="{Binding ToApplicationCommand}">Back To Application</touch:TouchButton>
</StackPanel>
</Grid>
diff --git a/Software/Visual_Studio/Resources/Events.xlsx b/Software/Visual_Studio/Resources/Events.xlsx
index 0f33f3d16..99d2c4a5c 100644
--- a/Software/Visual_Studio/Resources/Events.xlsx
+++ b/Software/Visual_Studio/Resources/Events.xlsx
Binary files differ
diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs
index d5c1f81d7..cafee9719 100644
--- a/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs
+++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs
@@ -22,7 +22,7 @@ namespace Tango.PMR.Diagnostics {
static EventTypeReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
- "Cg9FdmVudFR5cGUucHJvdG8SFVRhbmdvLlBNUi5EaWFnbm9zdGljcyq5HwoJ",
+ "Cg9FdmVudFR5cGUucHJvdG8SFVRhbmdvLlBNUi5EaWFnbm9zdGljcyrbHwoJ",
"RXZlbnRUeXBlEggKBE5vbmUQABIPCgtUaHJlYWRCcmVhaxABEh8KG1RocmVh",
"ZFRlbnNpb25Db250cm9sRmFpbHVyZRACEhoKFkZlZWRlckNvbmVJbnN1ZmZp",
"Y2lhbnQQAxIWChJXaW5kZXJHZW5lcmFsRXJyb3IQBBIXChNXaW5kZXJDb25l",
@@ -112,8 +112,9 @@ namespace Tango.PMR.Diagnostics {
"cjNVbmRlclZvbHRhZ2UQlwESIAobTW90b3JEaXNwZW5zZXI0VW5kZXJWb2x0",
"YWdlEJgBEiAKG01vdG9yRGlzcGVuc2VyNVVuZGVyVm9sdGFnZRCZARIgChtN",
"b3RvckRpc3BlbnNlcjZVbmRlclZvbHRhZ2UQmgESIAobTW90b3JEaXNwZW5z",
- "ZXI3VW5kZXJWb2x0YWdlEJsBQiEKH2NvbS50d2luZS50YW5nby5wbXIuZGlh",
- "Z25vc3RpY3NiBnByb3RvMw=="));
+ "ZXI3VW5kZXJWb2x0YWdlEJsBEiAKG01vdG9yRGlzcGVuc2VyOFVuZGVyVm9s",
+ "dGFnZRCcAUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmRpYWdub3N0aWNzYgZw",
+ "cm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Diagnostics.EventType), }, null));
@@ -715,6 +716,10 @@ namespace Tango.PMR.Diagnostics {
/// Motor Dispenser 7 Under Voltage (Group = Ink Delivery System, Category = Error, Actions = )
/// </summary>
[pbr::OriginalName("MotorDispenser7UnderVoltage")] MotorDispenser7UnderVoltage = 155,
+ /// <summary>
+ /// Motor Dispenser 8 Under Voltage (Group = Ink Delivery System, Category = Error, Actions = )
+ /// </summary>
+ [pbr::OriginalName("MotorDispenser8UnderVoltage")] MotorDispenser8UnderVoltage = 156,
}
#endregion
diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs
new file mode 100644
index 000000000..b55b41571
--- /dev/null
+++ b/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBRequest.cs
@@ -0,0 +1,160 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: UpdateDBRequest.proto
+#pragma warning disable 1591, 0612, 3021
+#region Designer generated code
+
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
+using scg = global::System.Collections.Generic;
+namespace Tango.PMR.Synchronization {
+
+ /// <summary>Holder for reflection information generated from UpdateDBRequest.proto</summary>
+ public static partial class UpdateDBRequestReflection {
+
+ #region Descriptor
+ /// <summary>File descriptor for UpdateDBRequest.proto</summary>
+ public static pbr::FileDescriptor Descriptor {
+ get { return descriptor; }
+ }
+ private static pbr::FileDescriptor descriptor;
+
+ static UpdateDBRequestReflection() {
+ byte[] descriptorData = global::System.Convert.FromBase64String(
+ string.Concat(
+ "ChVVcGRhdGVEQlJlcXVlc3QucHJvdG8SGVRhbmdvLlBNUi5TeW5jaHJvbml6",
+ "YXRpb24iJwoPVXBkYXRlREJSZXF1ZXN0EhQKDFNlcmlhbE51bWJlchgBIAEo",
+ "CUIlCiNjb20udHdpbmUudGFuZ28ucG1yLnN5bmNocm9uaXphdGlvbmIGcHJv",
+ "dG8z"));
+ descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
+ new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.UpdateDBRequest), global::Tango.PMR.Synchronization.UpdateDBRequest.Parser, new[]{ "SerialNumber" }, null, null, null)
+ }));
+ }
+ #endregion
+
+ }
+ #region Messages
+ public sealed partial class UpdateDBRequest : pb::IMessage<UpdateDBRequest> {
+ private static readonly pb::MessageParser<UpdateDBRequest> _parser = new pb::MessageParser<UpdateDBRequest>(() => new UpdateDBRequest());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<UpdateDBRequest> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Tango.PMR.Synchronization.UpdateDBRequestReflection.Descriptor.MessageTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public UpdateDBRequest() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public UpdateDBRequest(UpdateDBRequest other) : this() {
+ serialNumber_ = other.serialNumber_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public UpdateDBRequest Clone() {
+ return new UpdateDBRequest(this);
+ }
+
+ /// <summary>Field number for the "SerialNumber" field.</summary>
+ public const int SerialNumberFieldNumber = 1;
+ private string serialNumber_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string SerialNumber {
+ get { return serialNumber_; }
+ set {
+ serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as UpdateDBRequest);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(UpdateDBRequest other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (SerialNumber != other.SerialNumber) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (SerialNumber.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(SerialNumber);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (SerialNumber.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(UpdateDBRequest other) {
+ if (other == null) {
+ return;
+ }
+ if (other.SerialNumber.Length != 0) {
+ SerialNumber = other.SerialNumber;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ SerialNumber = input.ReadString();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ #endregion
+
+}
+
+#endregion Designer generated code
diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs
new file mode 100644
index 000000000..9ab596bc2
--- /dev/null
+++ b/Software/Visual_Studio/Tango.PMR/Synchronization/UpdateDBResponse.cs
@@ -0,0 +1,216 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: UpdateDBResponse.proto
+#pragma warning disable 1591, 0612, 3021
+#region Designer generated code
+
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
+using scg = global::System.Collections.Generic;
+namespace Tango.PMR.Synchronization {
+
+ /// <summary>Holder for reflection information generated from UpdateDBResponse.proto</summary>
+ public static partial class UpdateDBResponseReflection {
+
+ #region Descriptor
+ /// <summary>File descriptor for UpdateDBResponse.proto</summary>
+ public static pbr::FileDescriptor Descriptor {
+ get { return descriptor; }
+ }
+ private static pbr::FileDescriptor descriptor;
+
+ static UpdateDBResponseReflection() {
+ byte[] descriptorData = global::System.Convert.FromBase64String(
+ string.Concat(
+ "ChZVcGRhdGVEQlJlc3BvbnNlLnByb3RvEhlUYW5nby5QTVIuU3luY2hyb25p",
+ "emF0aW9uIk0KEFVwZGF0ZURCUmVzcG9uc2USEQoJRGJBZGRyZXNzGAEgASgJ",
+ "EhIKCkRiVXNlck5hbWUYAiABKAkSEgoKRGJQYXNzd29yZBgDIAEoCUIlCiNj",
+ "b20udHdpbmUudGFuZ28ucG1yLnN5bmNocm9uaXphdGlvbmIGcHJvdG8z"));
+ descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
+ new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.UpdateDBResponse), global::Tango.PMR.Synchronization.UpdateDBResponse.Parser, new[]{ "DbAddress", "DbUserName", "DbPassword" }, null, null, null)
+ }));
+ }
+ #endregion
+
+ }
+ #region Messages
+ public sealed partial class UpdateDBResponse : pb::IMessage<UpdateDBResponse> {
+ private static readonly pb::MessageParser<UpdateDBResponse> _parser = new pb::MessageParser<UpdateDBResponse>(() => new UpdateDBResponse());
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pb::MessageParser<UpdateDBResponse> Parser { get { return _parser; } }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Tango.PMR.Synchronization.UpdateDBResponseReflection.Descriptor.MessageTypes[0]; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public UpdateDBResponse() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public UpdateDBResponse(UpdateDBResponse other) : this() {
+ dbAddress_ = other.dbAddress_;
+ dbUserName_ = other.dbUserName_;
+ dbPassword_ = other.dbPassword_;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public UpdateDBResponse Clone() {
+ return new UpdateDBResponse(this);
+ }
+
+ /// <summary>Field number for the "DbAddress" field.</summary>
+ public const int DbAddressFieldNumber = 1;
+ private string dbAddress_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string DbAddress {
+ get { return dbAddress_; }
+ set {
+ dbAddress_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "DbUserName" field.</summary>
+ public const int DbUserNameFieldNumber = 2;
+ private string dbUserName_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string DbUserName {
+ get { return dbUserName_; }
+ set {
+ dbUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "DbPassword" field.</summary>
+ public const int DbPasswordFieldNumber = 3;
+ private string dbPassword_ = "";
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public string DbPassword {
+ get { return dbPassword_; }
+ set {
+ dbPassword_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override bool Equals(object other) {
+ return Equals(other as UpdateDBResponse);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public bool Equals(UpdateDBResponse other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (DbAddress != other.DbAddress) return false;
+ if (DbUserName != other.DbUserName) return false;
+ if (DbPassword != other.DbPassword) return false;
+ return true;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override int GetHashCode() {
+ int hash = 1;
+ if (DbAddress.Length != 0) hash ^= DbAddress.GetHashCode();
+ if (DbUserName.Length != 0) hash ^= DbUserName.GetHashCode();
+ if (DbPassword.Length != 0) hash ^= DbPassword.GetHashCode();
+ return hash;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (DbAddress.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(DbAddress);
+ }
+ if (DbUserName.Length != 0) {
+ output.WriteRawTag(18);
+ output.WriteString(DbUserName);
+ }
+ if (DbPassword.Length != 0) {
+ output.WriteRawTag(26);
+ output.WriteString(DbPassword);
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public int CalculateSize() {
+ int size = 0;
+ if (DbAddress.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(DbAddress);
+ }
+ if (DbUserName.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(DbUserName);
+ }
+ if (DbPassword.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(DbPassword);
+ }
+ return size;
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(UpdateDBResponse other) {
+ if (other == null) {
+ return;
+ }
+ if (other.DbAddress.Length != 0) {
+ DbAddress = other.DbAddress;
+ }
+ if (other.DbUserName.Length != 0) {
+ DbUserName = other.DbUserName;
+ }
+ if (other.DbPassword.Length != 0) {
+ DbPassword = other.DbPassword;
+ }
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ DbAddress = input.ReadString();
+ break;
+ }
+ case 18: {
+ DbUserName = input.ReadString();
+ break;
+ }
+ case 26: {
+ DbPassword = input.ReadString();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ #endregion
+
+}
+
+#endregion Designer generated code
diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj
index 014085ac9..508e8ad54 100644
--- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj
+++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj
@@ -187,6 +187,8 @@
<Compile Include="Printing\UploadProcessParametersResponse.cs" />
<Compile Include="Printing\WindingMethod.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Synchronization\UpdateDBRequest.cs" />
+ <Compile Include="Synchronization\UpdateDBResponse.cs" />
<Compile Include="TangoMessage.cs" />
<Compile Include="Common\ErrorCode.cs" />
<Compile Include="Common\MessageContainer.cs" />
@@ -216,7 +218,7 @@
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs
index e4fc911ec..e85a3e2ad 100644
--- a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs
@@ -8,6 +8,7 @@ using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Core.Helpers;
using Tango.Documents;
+using System.Data.Entity;
namespace Tango.EventsTypesGenerator
{
@@ -40,7 +41,7 @@ namespace Tango.EventsTypesGenerator
using (ObservablesContext db = ObservablesContext.CreateDefault())
{
- var eventTypes = db.EventTypes.ToList();
+ var eventTypes = db.EventTypes.Include(x => x.EventTypesCategory).Include(x => x.EventTypesGroup).ToList();
foreach (var evType in eventTypes)
{
@@ -70,7 +71,7 @@ namespace Tango.EventsTypesGenerator
}
- Console.WriteLine("Saving changed...");
+ Console.WriteLine("Saving changes...");
db.SaveChanges();
}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
index d713be97b..b817d5dcd 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
@@ -221,7 +221,53 @@ namespace Tango.MachineService.Controllers
return response;
}
+ [HttpPost]
+ public UpdateDBResponse UpdateDB(UpdateDBRequest request)
+ {
+ UpdateDBResponse response = new UpdateDBResponse();
+
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault(GetLocalServerAddress()))
+ {
+ db.Configuration.LazyLoadingEnabled = false;
+ String serial_number = request.SerialNumber;
+
+ var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number);
+
+ if (machine == null)
+ {
+ OnError(HttpStatusCode.NotFound, "The specified serial number could not be found.");
+ }
+
+ DbCredentials credentials = new DbCredentials();
+
+ using (DbManager manager = DbManager.FromAddressAndName(GetDbAddress(), "Tango"))
+ {
+ credentials = manager.CreateRandomLoginAndUser("Tango");
+ Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) =>
+ {
+ using (DbManager m = DbManager.FromAddressAndName(GetDbAddress(), "Tango"))
+ {
+ m.DeleteLoginAndUser(credentials.UserName, "Tango");
+ }
+ });
+ }
+
+ response.DbAddress = GetDbAddress();
+ response.DbUserName = credentials.UserName;
+ response.DbPassword = credentials.Password;
+ }
+ }
+ catch (Exception ex)
+ {
+ OnError(HttpStatusCode.InternalServerError, ex.Message);
+ }
+
+ return response;
+ }
+
#region Helpers
private void OnError(HttpStatusCode code, String message)