88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
using DM_Weight.Finger;
|
|
using DM_Weight.Port;
|
|
using Prism.Commands;
|
|
using Prism.Events;
|
|
using Prism.Mvvm;
|
|
using Prism.Regions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
|
|
namespace DM_Weight.ViewModels
|
|
{
|
|
public class BeforeLoginViewModel : BindableBase, IRegionMemberLifetime, IConfirmNavigationRequest
|
|
{
|
|
public bool KeepAlive => false;
|
|
IRegionManager _regionManager;
|
|
IEventAggregator _eventAggregator;
|
|
public BeforeLoginViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
|
|
{
|
|
_regionManager = regionManager;
|
|
_eventAggregator = eventAggregator;
|
|
}
|
|
private NavigationParameters keys = new NavigationParameters();
|
|
/// <summary>
|
|
/// 值班柜柜登录
|
|
/// </summary>
|
|
public DelegateCommand DutyCommand
|
|
{
|
|
get => new DelegateCommand(() =>
|
|
{
|
|
|
|
//_loginWindowViewModel.SingleLogin = true;
|
|
//_loginWindowViewModel.MultiLogin = false;
|
|
|
|
keys.Add("SingleLogin", true);
|
|
App.SingleModel = true;
|
|
_regionManager.RequestNavigate("MainRegion", "LoginWindow",keys);
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 周转柜登录
|
|
/// </summary>
|
|
public DelegateCommand OtherCommand
|
|
{
|
|
get => new DelegateCommand(() =>
|
|
{
|
|
//_loginWindowViewModel.SingleLogin = false;
|
|
//_loginWindowViewModel.MultiLogin = true;
|
|
|
|
keys.Add("SingleLogin", false);
|
|
App.SingleModel = false;
|
|
_regionManager.RequestNavigate("MainRegion", "LoginWindow", keys);
|
|
});
|
|
}
|
|
|
|
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
|
|
{
|
|
continuationCallback(true);
|
|
}
|
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
{
|
|
}
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
{
|
|
}
|
|
//手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
|
|
public string ReadAppSetting(string key)
|
|
{
|
|
string xPath = $"/configuration/appSettings//add[@key='{key}']";
|
|
XmlDocument doc = new XmlDocument();
|
|
string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
|
doc.Load(exeFileName + ".dll.config");
|
|
XmlNode node = doc.SelectSingleNode(xPath);
|
|
return node.Attributes["value"].Value.ToString();
|
|
}
|
|
}
|
|
}
|