aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Automation/Developer.cs
blob: 2f0437d4323c57f0435c662933a4be9f64a0809a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.MachineStudio.Common.Automation
{
    public class Developer
    {
        public static String JobsDataGrid { get; set; } = nameof(JobsDataGrid);
        public static String NewJobButton { get; set; } = nameof(NewJobButton);
        public static String DeleteJobButton { get; set; } = nameof(DeleteJobButton);
        public static String DuplicateJobButton { get; set; } = nameof(DuplicateJobButton);
        public static String ToJobsButton { get; set; } = nameof(ToJobsButton);
        public static String SaveJobButton { get; set; } = nameof(SaveJobButton);
        public static String AddSegmentButton { get; set; } = nameof(AddSegmentButton);
        public static String AddBrushStopButton { get; set; } = nameof(AddBrushStopButton);
        public static String SegmentsListBox { get; set; } = nameof(SegmentsListBox);
        public static String BrushStopsListBox { get; set; } = nameof(BrushStopsListBox);
    }
}
an class="p">{ get { return _currentUser; } set { _currentUser = value; CurrentUserChanged?.Invoke(this, _currentUser); RaisePropertyChangedAuto(); } } /// <summary> /// Occurs when the current logged-in user has changed. /// </summary> public event EventHandler<User> CurrentUserChanged; /// <summary> /// Initializes a new instance of the <see cref="DefaultAuthenticationProvider"/> class. /// </summary> /// <param name="machineStudioWebClient">The machine studio web client.</param> public DefaultAuthenticationProvider(MachineStudioWebClient machineStudioWebClient) { _client = machineStudioWebClient; } /// <summary> /// Performs a user login by the specified email and password. /// </summary> /// <param name="email">The email.</param> /// <param name="password">The password.</param> /// <returns></returns> /// <exception cref="AuthenticationException">Login failed for user " + email</exception> public AuthenticationLoginResult Login(string email, string password) { var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); _client.Environment = settings.DeploymentSlot; var response = _client.Login(new LoginRequest() { Email = email, Password = password, Version = AssemblyHelper.GetCurrentAssemblyVersion().ToString(), }).Result; if (settings.Environment == MachineStudioSettings.WorkingEnvironment.Remote) { ObservablesContext.OverrideSettingsDataSource(response.DataSource); } try { ObservablesStaticCollections.Instance.Initialize(); } catch (System.Data.Entity.Core.MetadataException) { ObservablesContext.ClearModelStore(); ObservablesStaticCollections.Instance.Initialize(); } using (ObservablesContext db = ObservablesContext.CreateDefault()) { User user = new UserBuilder(db).Set(x => x.Email.ToLower() == email.ToLower()).WithRolesAndPermissions().WithOrganization().Build(); if (user == null) { throw new AuthenticationException("Invalid credentials for " + email); } if (!response.VersionChangeRequired) { CurrentUser = user; } return new AuthenticationLoginResult() { User = user, Response = response }; } } /// <summary> /// Logs-out the current logged-in user. /// </summary> public void Logout() { CurrentUser = null; } } }