| ofs | hex dump | ascii |
|---|
| 0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 04 3d 00 00 02 c8 08 06 00 00 00 7c 7b 8b | .PNG........IHDR...=.........|{. |
| 0020 | e8 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 04 67 41 4d 41 00 00 b1 8f 0b fc 61 05 00 00 | .....sRGB.........gAMA......a... |
| 0040 | 00 09 70 48 59 73 00 00 0e c3 00 00 0e c3 01 c7 6f a8 64 00 00 00 18 74 45 58 74 53 6f 66 74 77 | ..pHYs..........o.d....tEXtSoftw |
| 0060 | 61 72 65 00 70 61 69 6e 74 2e 6e 65 74 20 34 2e 30 2e 39 6c 33 7e 4e 00 00 ff 81 49 44 41 54 78 | are.paint.net.4.0.9l3~N....IDATx |
| 0080 | 5e ec fd 0b f0 25 67 7a de 87 8d 13 72 99 58 66 a4 98 5c 4a 32 43 5a 52 64 89 92 48 8a 97 dd e5 | ^....%gz....r.Xf..\J2CZRd..H.... |
| 00a0 | 6d 49 49 94 44 49 36 53 b2 ab 52 2a 59 b2 75 49 4a b2 14 59 72 54 ba c5 0b 2c 15 45 76 ec c4 2e | mII.DI6S..R*Y.uIJ..YrT...,.Ev... |
| 00c0 | 57 e2 c8 72 25 b6 93 2a 9b 8c 68 96 a8 24 8a 2a fe f3 a2 5d 2c b0 58 dc 2f 33 c0 dc 07 0b 2c 30 | W..r%..*..h..$.*...],.X./3....,0 |
| 00e0 | 00 66 31 18 ec 0d c0 2e 06 18 4c be a7 f7 3c ff 79 fe ef bc 5f 77 9f 3e 7d ce e9 ee f3 4c d5 af | .f1.......L...<.y..._w.>}....L.. |
| 0100 | fa fd de f7 fd be af cf f9 f7 39 a7 df 67 be ee 3e 75 74 74 64 fa f3 cf 18 63 8c 31 c6 18 63 8c | ..........9..g..>uttd....c.1..c. |
| 0120 | 31 7b 24 ab 55 4d 85 d4 69 d2 03 6b 5d fe 7b c6 18 63 8c 31 c6 18 63 cc 1a 64 b5 e5 3a 64 f5 ed | 1{$.UM..i..k].{..c.1..c..d..:d.. |
| 0140 | 41 93 3a 0f 90 ec 60 e9 43 76 90 fe f7 8d 31 c6 18 63 8c 31 c6 98 81 64 75 26 c8 6a d2 36 b2 da | A.:...`.Cv....1..c.1...du&.j.6.. |
| 0160 | f7 e0 48 9d 07 40 3c 10 b4 ad f0 e0 ca 0e 44 f0 0d c2 37 1a 63 8c 31 c6 18 63 8c 31 23 a1 f5 26 | ..H..@<.......D...7.c.1..c.1#..& |
| 0180 | 88 f5 68 97 18 92 d5 ba 5a 17 1f 04 a9 f3 00 88 7f 78 50 13 38 32 41 e3 9b 02 ff 83 15 ff 43 63 | ..h.....Z........xP.82A.......Cc |
| 01a0 | 8c 31 c6 18 63 8c 31 66 43 58 63 c6 da f3 03 05 d6 a5 6d 62 48 56 f3 82 ac 3e 5e 34 a9 73 a1 64 | .1..c.1fCXc.......mbHV...>^4.s.d |
| 01c0 | 7f 70 10 85 0e 8a 1c 38 98 00 45 0d 1e 7c ff 6c e1 d7 ac f8 e7 56 7c f3 8a ff 91 31 c6 18 63 8c | .p.....8..E..|.l.....V|....1..c. |
| 01e0 | 31 c6 18 b3 21 ac 31 59 73 b2 06 45 3d aa c2 08 ea 55 8a 20 14 42 b4 be e5 7f ee 67 42 48 56 37 | 1...!.1Ys..E=....U...B.....gBHV7 |
| 0200 | 2f 8e d4 b9 10 e2 1f 94 f0 0f ce 83 80 07 47 14 38 70 30 51 e0 c0 41 86 03 ef d7 16 7e 9d f0 3f | /.............G.8p0Q..A.....~..? |
| 0220 | 2e fc f3 2b be a5 f0 ad c6 18 63 8c 31 c6 18 63 cc 86 a0 be 64 ad 89 ba 93 35 28 6a 52 8a 22 14 | ...+......c.1..c....d....5(jR.". |
| 0240 | 43 28 82 64 42 88 8a 20 99 f0 41 b2 9a 7a 11 a4 ce 99 93 fd 01 41 26 74 c4 55 1c 99 c0 41 61 03 | C(.dB.....A..z.......A&t.U...Aa. |
| 0260 | 07 de b7 ad f8 0d 2b 7e 63 e1 5f 58 f1 ed 85 ff 49 e0 3b 8c 31 c6 18 63 8c 31 c6 98 1e 68 2d 89 | ......+~c._X....I.;.1..c.1...h-. |
| 0280 | fa 92 b5 26 ea 4e d4 9f bf be 80 7a f4 83 05 8a 22 14 44 b8 42 04 f5 2c 57 83 64 2b 41 28 7e d4 | ...&.N.....z....".D.B..,W.d+A(~. |
| 02a0 | 04 90 ac c6 9e 35 a9 73 a6 c4 3f 16 ff 90 14 3b a0 70 65 ab 39 28 72 00 15 38 70 20 e1 a0 c2 c1 | .....5.s..?....;.pe.9(r..8p..... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.PPC.Common;
using Tango.PPC.Common.Navigation;
using SimpleValidator.Extensions;
using System.ComponentModel.DataAnnotations;
using Tango.SharedUI.Helpers;
using Tango.PPC.Common.Authentication;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Logging;
namespace Tango.PPC.UI.ViewModels
{
/// <summary>
/// Represents the PPC login view ViewModel.
/// </summary>
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class LoginViewVM : PPCViewModel
{
public RelayCommand LoginCommand { get; set; }
#region Properties
private String _email;
/// <summary>
/// Gets or sets the email.
/// </summary>
[Required(ErrorMessage = "Email is required")]
[EmailAddress(ErrorMessage = "Please enter a valid email address")]
public String Email
{
get { return _email; }
set { _email = value; RaisePropertyChangedAuto(); }
}
private String _password;
/// <summary>
/// Gets or sets the password.
/// </summary>
[Required(ErrorMessage = "Password is required")]
public String Password
{
get { return _password; }
set { _password = value; RaisePropertyChangedAuto(); }
}
private bool _isLoading;
/// <summary>
/// Gets or sets a value indicating whether the application is busy with loading modules.
/// </summary>
public bool IsLoading
{
get { return _isLoading; }
set { _isLoading = value; RaisePropertyChangedAuto(); }
}
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="LoginViewVM"/> class.
/// </summary>
public LoginViewVM()
{
LoginCommand = new RelayCommand(Login);
Email = "roy@twine-s.com";
Password = "1234";
}
#endregion
#region Override Methods
/// <summary>
/// Called when the application has been started.
/// </summary>
public override void OnApplicationStarted()
{
AuthenticationProvider.CurrentUserChanged += AuthenticationProvider_CurrentUserChanged;
}
public override async void OnApplicationReady()
{
base.OnApplicationReady();
await Task.Delay(500);
if (!AuthenticationProvider.AuthenticationRequired)
{
LogManager.Log("Application is ready! Navigating to home module...");
await NavigationManager.NavigateTo(NavigationView.HomeModule);
IsLoading = false;
}
else if (AuthenticationProvider.CurrentUser != null && AuthenticationProvider.CurrentUser.HasPermission(Permissions.RunPPC))
{
LogManager.Log("Application is ready! Navigating to home module...");
await NavigationManager.NavigateTo(NavigationView.HomeModule);
IsLoading = false;
}
else
{
LogManager.Log("Application is ready! The logged in user does not have permission to run the application!", LogCategory.Warning);
await NavigationManager.NavigateTo(NavigationView.NoPermissionsView);
IsLoading = false;
}
}
#endregion
#region Event Handlers
/// <summary>
/// Handles the <see cref="IAuthenticationProvider.CurrentUserChanged"/> event.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="user">The user.</param>
private void AuthenticationProvider_CurrentUserChanged(object sender, User user)
{
if (user == null)
{
Password = String.Empty;
}
}
#endregion
#region Private Methods
/// <summary>
/// Login to the application using the user name and password.
/// </summary>
private async void Login()
{
LogManager.Log("Login command pressed.");
if (Validate())
{
IsLoading = true;
UIHelper.DoEvents();
var user = await AuthenticationProvider.Login(Email, Password);
if (user == null)
{
IsLoading = false;
await NotificationProvider.ShowWarning("Email or password are incorrect.");
}
}
else
{
LogManager.Log("Invalid user credentials.");
}
}
#endregion
}
}
|