aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs
blob: 1d49a535a4d090378330071a175d3a064c5e7bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Transport.Web;

namespace Tango.PPC.Common.Web
{
    public class CheckForUpdateResponse : WebResponseMessage
    {
        public bool IsUpdateAvailable { get; set; }
        public String Version { get; set; }
    }
}
ackground-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.BL;
using Tango.Core;
using Tango.Core.DI;
using Tango.Core.Helpers;
using Tango.PPC.Common;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Authentication;
using Tango.PPC.Common.MachineSetup;
using Tango.PPC.Common.Modules;
using Tango.PPC.Common.Navigation;
using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Notifications.NotificationItems;
using Tango.PPC.Jobs;
using Tango.SharedUI;
using System.Data.Entity;
using Tango.BL.Enumerations;
using Tango.BL.Builders;

namespace Tango.PPC.UI.ViewModels
{
    /// <summary>
    /// Represents the PPC loading splash screen view model.
    /// </summary>
    /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
    public class LoadingViewVM : PPCViewModel
    {
        /// <summary>
        /// Gets or sets the module loader.
        /// </summary>
        [TangoInject]
        public IPPCModuleLoader ModuleLoader { get; set; }

        private bool _isLoading;
        /// <summary>
        /// Gets or sets a value indicating whether this instance is loading.
        /// </summary>
        public bool IsLoading
        {
            get { return _isLoading; }
            set { _isLoading = value; RaisePropertyChangedAuto(); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="LoadingViewVM"/> class.
        /// </summary>
        public LoadingViewVM(IPPCApplicationManager applicationManager)
        {
            if (!DesignMode)
            {
                Task.Delay(1000).ContinueWith((x) => { IsLoading = true; });
            }

            applicationManager.ApplicationInitializationError += ApplicationManager_ApplicationInitializationError;
        }

        private void ApplicationManager_ApplicationInitializationError(object sender, Exception ex)
        {
            InvokeUI(() =>
            {
                NavigationManager.NavigateWithObject<Exception>(NavigationView.LoadingErrorView, ex);
                IsLoading = false;
            });
        }

        /// <summary>
        /// Called when the application has been started.
        /// </summary>
        public async override void OnApplicationStarted()
        {
            //We don't use authentication!

            //using (ObservablesContext db = ObservablesContext.CreateDefault())
            //{
            //    var machine = await db.Machines.FirstAsync();

            //    if (db.Users.Count() == 1 || machine.AutoLogin)
            //    {
            //        var user = await new UserBuilder(db).SetFirst().WithRolesAndPermissions().BuildAsync();

            //        if (!user.HasRole(Roles.PPCUser))
            //        {
            //            var role = db.Roles.Single(x => x.Code == (int)Roles.PPCUser);
            //            user.Roles.Add(role);
            //            db.UsersRoles.Add(new BL.Entities.UsersRole()
            //            {
            //                User = user,
            //                Role = role,
            //            });
            //            await db.SaveChangesAsync();
            //        }

            //        LogManager.Log($"Application started. Single user/Auto login detected ({user.Email}). Skipping LoginView...");
            //        await AuthenticationProvider.Login(user.Email, user.Password, false);
            //        await Task.Delay(1000);
            //        IsLoading = false;
            //    }
            //    else
            //    {
            //        LogManager.Log("Application started. Navigating to LoginView...");
            //        await NavigationManager.NavigateTo(NavigationView.LoginView);
            //        await Task.Delay(1000);
            //        IsLoading = false;
            //    }
            //}

            LogManager.Log($"Application started with no authentication mode...");
            await AuthenticationProvider.Login();
            await Task.Delay(1000);
            IsLoading = false;
        }
    }
}