105040 Update 优化登录功能
This commit is contained in:
parent
5bd1f06409
commit
d10a53773e
|
|
@ -10,6 +10,7 @@
|
||||||
Width="320"
|
Width="320"
|
||||||
Height="280"
|
Height="280"
|
||||||
d:DataContext="{d:DesignInstance Type=viewmodel:LoginViewModel}"
|
d:DataContext="{d:DesignInstance Type=viewmodel:LoginViewModel}"
|
||||||
|
Loaded="Window_Loaded"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,11 @@
|
||||||
using Sinvo.EplanHpD.Plugin.Service;
|
using EPLAN.Harness.Core.Settings;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Sinvo.EplanHpD.Plugin.Service;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
{
|
{
|
||||||
|
|
@ -68,22 +61,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
|
|
||||||
private async Task LoadData()
|
private async Task LoadData()
|
||||||
{
|
{
|
||||||
//if (viewModel.User != null)
|
var userInfoJson = FormUISettings.Instance.GetValue("UserInfo") as string;
|
||||||
//{
|
var user = JsonConvert.DeserializeObject<UserLoginModel>(userInfoJson);
|
||||||
// viewModel.GetGroup();
|
if (user != null && !string.IsNullOrEmpty(user.UserName))
|
||||||
//}
|
{
|
||||||
//if (viewModel.IsRemember)
|
viewModel.User = user;
|
||||||
//{
|
viewModel.IsRemember = true;
|
||||||
// var groupIndex = viewModel.Groups.IndexOf(viewModel.Groups.FirstOrDefault(x => x.ID == viewModel.User.UserGroupId));
|
_ = this.Dispatcher.BeginInvoke(() =>
|
||||||
// this.groupCbx.SelectedIndex = groupIndex;
|
{
|
||||||
// var roleIndex = viewModel.Roles.IndexOf(viewModel.Roles.FirstOrDefault(x => x.ID == viewModel.User.UserRoleId));
|
this.PasswordTxt.Password = user.UserPassword;
|
||||||
// this.roleCbx.SelectedIndex = roleIndex;
|
LoadGroupAndRole();
|
||||||
//}
|
});
|
||||||
//if (EplSession.Current.Config != null)
|
}
|
||||||
//{
|
|
||||||
// var serverIndex = viewModel.Servers.IndexOf(viewModel.Servers.FirstOrDefault(x => x.ServerUrl == EplSession.Current.Config.CurrentServer.ServerUrl));
|
|
||||||
// this.serverCbx.SelectedIndex = serverIndex;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loginBtn_Click(object sender, RoutedEventArgs e)
|
private void loginBtn_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
@ -130,6 +119,17 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
ID = result.ID,
|
ID = result.ID,
|
||||||
Name = result.Name
|
Name = result.Name
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (viewModel.IsRemember)
|
||||||
|
{
|
||||||
|
FormUISettings.Instance.SetValue("UserInfo", JsonConvert.SerializeObject(viewModel.User));
|
||||||
|
FormUISettings.Instance.SaveSingleton();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FormUISettings.Instance.SetValue("UserInfo", "{}");
|
||||||
|
FormUISettings.Instance.SaveSingleton();
|
||||||
|
}
|
||||||
this.DialogResult = true;
|
this.DialogResult = true;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
@ -137,6 +137,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
{
|
{
|
||||||
MessageBox.Show("登录失败,请检查用户名和密码是否正确!");
|
MessageBox.Show("登录失败,请检查用户名和密码是否正确!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if (result)
|
// if (result)
|
||||||
// {
|
// {
|
||||||
// //MessageBox.Show("")
|
// //MessageBox.Show("")
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,10 @@
|
||||||
using Sinvo.EplanHpD.Plugin.DynaClient;
|
using Sinvo.EplanHpD.Plugin.DynaClient;
|
||||||
using Sinvo.EplanHpD.Plugin.DynaClient.Model;
|
using Sinvo.EplanHpD.Plugin.DynaClient.Model;
|
||||||
using Sinvo.EplanHpD.Plugin.Service;
|
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
|
|
@ -75,6 +70,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _isRemember;
|
||||||
|
|
||||||
|
public bool IsRemember
|
||||||
|
{
|
||||||
|
get { return _isRemember; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isRemember = value;
|
||||||
|
OnPropertyChanged(nameof(IsRemember));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<UserGroup>> GetUserGroup()
|
public async Task<List<UserGroup>> GetUserGroup()
|
||||||
{
|
{
|
||||||
return await Task.Run(() =>
|
return await Task.Run(() =>
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,8 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
|
|
||||||
public void Execute(HpdApi api)
|
public void Execute(HpdApi api)
|
||||||
{
|
{
|
||||||
|
bool isLogin = PluginServices.IsLogin;
|
||||||
bool isLogin = false;
|
if (!isLogin)
|
||||||
if (!PluginServices.IsLogin)
|
|
||||||
{
|
{
|
||||||
var LoginWindow = new LoginWindow();
|
var LoginWindow = new LoginWindow();
|
||||||
if(LoginWindow.ShowDialog() == true)
|
if(LoginWindow.ShowDialog() == true)
|
||||||
|
|
@ -69,11 +68,9 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
isLogin = PluginServices.IsLogin;
|
isLogin = PluginServices.IsLogin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new DBHelper().CodeFirst();
|
|
||||||
|
|
||||||
if (isLogin)
|
if (isLogin)
|
||||||
{
|
{
|
||||||
|
new DBHelper().CodeFirst();
|
||||||
var doc = api.CurrentProject.GetActiveDocument();
|
var doc = api.CurrentProject.GetActiveDocument();
|
||||||
if (window == null)
|
if (window == null)
|
||||||
{
|
{
|
||||||
|
|
@ -96,9 +93,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
window.Activate();
|
window.Activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
if (!AppDomainDllLoader.isLoaded)
|
if (!AppDomainDllLoader.isLoaded)
|
||||||
|
|
@ -106,11 +101,8 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
AppDomainDllLoader.SetLaoder();
|
AppDomainDllLoader.SetLaoder();
|
||||||
ApplicationExt.InitApplication();
|
ApplicationExt.InitApplication();
|
||||||
Consts.InitConfigs();
|
Consts.InitConfigs();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Terminate()
|
public void Terminate()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ using EPLAN.Harness.API.Plugins.Core;
|
||||||
using EPLAN.Harness.Core.Controls;
|
using EPLAN.Harness.Core.Controls;
|
||||||
using EPLAN.Harness.ProjectCore;
|
using EPLAN.Harness.ProjectCore;
|
||||||
using Sinvo.EplanHpD.Plugin.DynaClient;
|
using Sinvo.EplanHpD.Plugin.DynaClient;
|
||||||
|
using Sinvo.EplanHpD.Plugin.Service;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI;
|
using Sinvo.EplanHpD.Plugin.WPFUI;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.View;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -59,6 +61,18 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
private MainWindow window;
|
private MainWindow window;
|
||||||
public void Execute(HpdApi api)
|
public void Execute(HpdApi api)
|
||||||
{
|
{
|
||||||
|
bool isLogin = PluginServices.IsLogin;
|
||||||
|
if (!isLogin)
|
||||||
|
{
|
||||||
|
var LoginWindow = new LoginWindow();
|
||||||
|
if (LoginWindow.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
isLogin = PluginServices.IsLogin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isLogin)
|
||||||
|
{
|
||||||
|
|
||||||
bool isUpdated = false;
|
bool isUpdated = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -85,10 +99,6 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
isUpdated = true;
|
isUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 取可见的列
|
|
||||||
//var columns = flexReport.Reporter.Formater.RepColumns;
|
|
||||||
//var datas = flexReport.GetAllReportEntries();
|
|
||||||
//var window = new MainWindow(datas, columns);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -116,7 +126,6 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
window.Show();
|
window.Show();
|
||||||
window.Activate();
|
window.Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
@ -125,8 +134,6 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
ElementHost.EnableModelessKeyboardInterop(window);
|
ElementHost.EnableModelessKeyboardInterop(window);
|
||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -137,7 +144,6 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FlexMessageBox.Error("请打开一个报表后再使用!");
|
FlexMessageBox.Error("请打开一个报表后再使用!");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -145,6 +151,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
FlexMessageBox.Error(ex.ToString());
|
FlexMessageBox.Error(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue