aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs4
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs50
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs34
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs15
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs47
5 files changed, 60 insertions, 90 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs
index e8d33b0ca..c05ce9982 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
using Tango.Core;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.StudioApplication;
@@ -19,11 +20,14 @@ namespace Tango.MachineStudio.UI.ViewModels
public MachineStudioSettings MachineStudioSettings { get; set; }
+ public DataSource DataSource { get; set; }
+
public AboutViewVM(IStudioApplicationManager applicationManager)
{
ApplicationManager = applicationManager;
Settings = SettingsManager.Default.GetOrCreate<CoreSettings>();
MachineStudioSettings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>();
+ DataSource = ObservablesContext.GetActualDataSource();
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
index 4032c946c..283ea3637 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
@@ -69,6 +69,9 @@ namespace Tango.MachineStudio.UI.ViewModels
_notificationProvider = notificationProvider;
}
+ /// <summary>
+ /// Called when the application has been started
+ /// </summary>
public override void OnApplicationStarted()
{
base.OnApplicationStarted();
@@ -88,48 +91,6 @@ namespace Tango.MachineStudio.UI.ViewModels
{
try
{
- Status = "Checking for critical updates...";
-
- LogManager.Log("Checking for forced update...");
- var service = UpdateServiceHelper.GetUpdateServiceChannel();
- var client = service.CreateChannel();
-
- CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest()
- {
- Email = "ForceUpdate",
- Password = "ForceUpdate",
- Version = ApplicationManager.Version.ToString(),
- });
-
- if (response.IsUpdateAvailable && response.ForcedUpdate)
- {
- LogManager.Log("Forced update found, Navigating to update view!");
-
- InvokeUI(() =>
- {
- if (_notificationProvider.ShowQuestion("Machine Studio has detected a critical update which must be installed in order for the application to run properly. Do you wish to download and install this update?"))
- {
- TangoMessenger.Default.Send(new Messages.ForcedUpdateMessage() { UpdateResponse = response });
- _navigationManager.NavigateTo(NavigationView.UpdateView);
- }
- else
- {
- ApplicationManager.ShutDown();
- }
-
- IsLoading = false;
- });
-
- return;
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error checking for forced update!");
- }
-
- try
- {
Status = "Connecting to Team Foundation Services...";
_tfs.Initialize();
Thread.Sleep(500);
@@ -141,9 +102,8 @@ namespace Tango.MachineStudio.UI.ViewModels
Status = "Loading, please wait...";
- ObservablesStaticCollections.Instance.Initialize();
-
- _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
+ //ObservablesStaticCollections.Instance.Initialize();
+ //_eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
Status = "Starting application...";
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
index a37879a5e..492e23963 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
@@ -6,6 +6,8 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Enumerations;
using Tango.Core.Commands;
using Tango.Core.Cryptography;
using Tango.MachineStudio.Common;
@@ -15,6 +17,7 @@ using Tango.MachineStudio.Common.Navigation;
using Tango.MachineStudio.Common.Notifications;
using Tango.Settings;
using Tango.SharedUI;
+using Tango.Web;
namespace Tango.MachineStudio.UI.ViewModels
{
@@ -44,6 +47,9 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private String _password;
+ /// <summary>
+ /// Gets or sets the password.
+ /// </summary>
[Required(ErrorMessage = "Password is required")]
public String Password
{
@@ -51,6 +57,16 @@ namespace Tango.MachineStudio.UI.ViewModels
set { _password = value; RaisePropertyChangedAuto(); }
}
+ private DeploymentSlot _deploymentSlot;
+ /// <summary>
+ /// Gets or sets the deployment slot.
+ /// </summary>
+ public DeploymentSlot DeploymentSlot
+ {
+ get { return _deploymentSlot; }
+ set { _deploymentSlot = value; RaisePropertyChangedAuto(); }
+ }
+
private bool _isLogging;
/// <summary>
/// Gets or sets a value indicating whether this instance is logging.
@@ -90,10 +106,11 @@ namespace Tango.MachineStudio.UI.ViewModels
_navigationManager = navigationManager;
_authenticationProvider = authenticationProvider;
_eventLogger = eventLogger;
- LoginCommand = new RelayCommand(Login,() => !IsLogging);
+ LoginCommand = new RelayCommand(Login, () => !IsLogging);
cryptographer = new Rfc2898Cryptographer();
Email = _settings.LastLoginEmail;
+ DeploymentSlot = _settings.DeploymentSlot;
RememberMe = _settings.RememberMe;
try
@@ -120,21 +137,26 @@ namespace Tango.MachineStudio.UI.ViewModels
await Task.Factory.StartNew(() =>
{
+ _settings.DeploymentSlot = DeploymentSlot;
+
_authenticationProvider.Login(Email, Password);
+
+ _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
+
_navigationManager.NavigateTo(NavigationView.MainView);
+
_settings.LastLoginEmail = Email;
_settings.RememberMe = RememberMe;
-
_settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null;
_settings.Save();
- _eventLogger.Log("User logged in");
+ _eventLogger.Log("User logged in.");
});
}
- catch (Exception)
+ catch (Exception ex)
{
-
- _notificationProvider.ShowError("Invalid credentials. Please try again.");
+ LogManager.Log(ex, "Login Error.");
+ _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.FlattenMessage()}");
}
finally
{
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index 70378a4d5..e3a8b4e7c 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -359,16 +359,14 @@ namespace Tango.MachineStudio.UI.ViewModels
{
if (_authenticationProvider.CurrentUser != null)
{
- var service = UpdateServiceHelper.GetUpdateServiceChannel();
- var client = service.CreateChannel();
+ var client = new MachineStudioUpdateService();
CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest()
{
- Email = _authenticationProvider.CurrentUser.Email,
- Password = _authenticationProvider.CurrentUser.Password,
+ AccessToken = _authenticationProvider.AccessToken,
Version = _applicationManager.Version.ToString(),
AcceptBetaRelease = _settings.AcceptBetaRelease,
- });
+ }).Result;
IsUpdateAvailable = response.IsUpdateAvailable;
LatestVersion = response.Version;
@@ -453,6 +451,13 @@ namespace Tango.MachineStudio.UI.ViewModels
if (x.SelectedMachine.RequiresAuthentication)
{
+ //Check machine exist on my database first
+ if (x.SelectedMachine.Machine == null)
+ {
+ _notificationProvider.ShowError($"The specified machine '{x.SelectedMachine.SerialNumber}' could not be found on the database. Aborting connection.");
+ return;
+ }
+
_notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) =>
{
using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "..."))
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
index a9624da2d..60a023071 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
@@ -24,6 +24,7 @@ using Tango.SharedUI;
using Tango.MachineStudio.UI.Messages;
using Tango.Settings;
using Tango.MachineStudio.Common;
+using Tango.Transport.Web;
namespace Tango.MachineStudio.UI.ViewModels
{
@@ -185,24 +186,20 @@ namespace Tango.MachineStudio.UI.ViewModels
var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>();
- ChannelFactory<IMachineStudioUpdateService> service = null;
-
Task.Factory.StartNew(() =>
{
try
{
Thread.Sleep(2000);
- service = UpdateServiceHelper.GetUpdateServiceChannel();
- var client = service.CreateChannel();
+ var client = new MachineStudioUpdateService();
CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest()
{
- Email = _authentication.CurrentUser.Email,
- Password = _authentication.CurrentUser.Password,
+ AccessToken = _authentication.AccessToken,
Version = _application.Version.ToString(),
AcceptBetaRelease = settings.AcceptBetaRelease,
- });
+ }).Result;
if (response.IsUpdateAvailable)
{
@@ -221,13 +218,6 @@ namespace Tango.MachineStudio.UI.ViewModels
logManager.Log(ex, "Error while checking for version update!");
Status = UpdateStatus.Error;
}
- finally
- {
- if (service != null)
- {
- service.Close();
- }
- }
});
}
@@ -260,29 +250,18 @@ namespace Tango.MachineStudio.UI.ViewModels
{
logManager.Log("Creating temporary file " + tempFile);
- int fileSize = 0;
-
- using (FileStreamWrapper fs = new FileStreamWrapper(tempFile.Path, FileMode.Create, (current) =>
+ using (StorageBlobDownloader downloader = new StorageBlobDownloader(_updateInfo.BlobAddress, tempFile.Path))
{
- InvokeUINow(() =>
+ downloader.Progress += (x, e) =>
{
- Thread.Sleep(10);
- DownloadProgress = ((double)current / (double)fileSize) * 100d;
- });
- }))
- {
- using (FtpClient ftp = new FtpClient(_updateInfo.FtpHost, _updateInfo.UserName, _updateInfo.Password))
- {
- logManager.Log("Connecting to FTP site: " + _updateInfo.FtpHost);
- ftp.ConnectAsync().Wait();
- logManager.Log("Retrieving download size...");
- fileSize = (int)ftp.GetFileSize(_updateInfo.FilePath);
- logManager.Log("Download size: " + fileSize + " bytes.");
- logManager.Log("Starting download...");
- ftp.DownloadAsync(fs, _updateInfo.FilePath).Wait();
- }
- }
+ InvokeUINow(() =>
+ {
+ DownloadProgress = ((double)e.Current / (double)e.Total) * 100d;
+ });
+ };
+ downloader.Download().Wait();
+ }
Status = UpdateStatus.Updating;