2023-09-14 23:55:38 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using System.Reflection;
|
2023-09-14 23:55:38 +08:00
|
|
|
|
using Aitex.Core.Account;
|
|
|
|
|
using Aitex.Core.RT.Log;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using Caliburn.Micro;
|
|
|
|
|
using MECF.Framework.Common.Account.Extends;
|
2023-09-14 23:55:38 +08:00
|
|
|
|
using MECF.Framework.Common.Utilities;
|
2023-09-20 17:25:51 +08:00
|
|
|
|
using MECF.Framework.UI.Client.CenterViews.Configs.Accounts;
|
2023-09-19 15:52:46 +08:00
|
|
|
|
using MECF.Framework.UI.Client.CenterViews.Configs.Roles;
|
2023-09-20 17:25:51 +08:00
|
|
|
|
using MECF.Framework.UI.Core.Accounts;
|
2023-09-14 23:55:38 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
namespace MECF.Framework.UI.Client.ClientBase
|
|
|
|
|
{
|
|
|
|
|
public class BaseApp
|
|
|
|
|
{
|
2023-09-14 23:55:38 +08:00
|
|
|
|
|
2023-09-19 15:52:46 +08:00
|
|
|
|
#region Variables
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
public ModuleDataMonitor _dataMonitor;
|
|
|
|
|
|
2023-09-19 15:52:46 +08:00
|
|
|
|
#endregion
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-19 15:52:46 +08:00
|
|
|
|
#region Constructors
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
public BaseApp()
|
|
|
|
|
{
|
2023-04-15 13:43:41 +08:00
|
|
|
|
UserMode = UserMode.None;
|
|
|
|
|
Initialized = false;
|
2023-09-14 23:55:38 +08:00
|
|
|
|
|
2023-04-15 13:43:41 +08:00
|
|
|
|
Configure();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 15:52:46 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properites
|
|
|
|
|
|
|
|
|
|
public LoginClientInfo ClientInfo { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UserContext UserContext { get; private set; }
|
|
|
|
|
|
|
|
|
|
public MenuManager MenuManager { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UserMode UserMode { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool Initialized { get; private set; }
|
|
|
|
|
|
|
|
|
|
public static BaseApp Instance { get; set; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
|
|
|
2023-09-14 23:55:38 +08:00
|
|
|
|
public void LoadSystemInfo()
|
|
|
|
|
{
|
|
|
|
|
var myInfo = new LoginClientInfo();
|
|
|
|
|
myInfo.HostName = Environment.MachineName;
|
|
|
|
|
myInfo.UserName = Environment.UserName;
|
|
|
|
|
myInfo.OSVersion = Environment.OSVersion.ToString();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
myInfo.ComputerSystem = SystemInfoHelper.GetComputerSystem();
|
|
|
|
|
myInfo.CpuInfo = SystemInfoHelper.GetCpuInfo();
|
|
|
|
|
myInfo.LogicalDisk = SystemInfoHelper.GetLogicalDiskInfo();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LOG.Error("Unable to get system information.", ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
ClientInfo = myInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public void Initialize(bool force = false)
|
|
|
|
|
{
|
2023-04-15 13:43:41 +08:00
|
|
|
|
if (Initialized && !force)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return;
|
2023-09-20 17:25:51 +08:00
|
|
|
|
|
2023-04-15 13:43:41 +08:00
|
|
|
|
MenuManager = new MenuManager();
|
|
|
|
|
UserContext = new UserContext();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-05 10:20:23 +08:00
|
|
|
|
var file = $"{System.AppDomain.CurrentDomain.BaseDirectory}MECF.Framework.UI.Client.dll";
|
2023-04-13 11:51:03 +08:00
|
|
|
|
if (File.Exists(file))
|
|
|
|
|
{
|
2023-09-05 10:20:23 +08:00
|
|
|
|
var assembly = Assembly.LoadFile(file);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
AssemblySource.Instance.Add(assembly);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-15 13:43:41 +08:00
|
|
|
|
OnInitialize();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
//must be called after specific project initialized
|
2023-04-15 13:43:41 +08:00
|
|
|
|
_dataMonitor = new ModuleDataMonitor();
|
|
|
|
|
Initialized = true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Dispose()
|
|
|
|
|
{
|
2023-09-14 23:55:38 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Configure()
|
|
|
|
|
{
|
|
|
|
|
//config skin/language...
|
2023-04-15 13:43:41 +08:00
|
|
|
|
OnConfiguration();
|
2023-09-14 23:55:38 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void OnInitialize()
|
|
|
|
|
{
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-14 23:55:38 +08:00
|
|
|
|
protected virtual void OnConfiguration()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void SwitchPage(string mainMenu, string subMenu, object parameter)
|
|
|
|
|
{
|
|
|
|
|
}
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-19 15:52:46 +08:00
|
|
|
|
#endregion
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|