Commit f6bf79a1 authored by 潘栩锋's avatar 潘栩锋 🚴

优化 只有 一执行ParamDictionary.SetValue 就会Save() 不再需要主动调用 Save()

parent 540d14b2
......@@ -30,6 +30,7 @@ namespace Misc
cell.IsConverted = true;
cells.Add(cell);
ValueChanged?.Invoke(this, new ParamDictionaryValueChangedEventArgs() { Key = key, Value = value });
Save();
}
else
{
......@@ -37,8 +38,8 @@ namespace Misc
if (cell.Value != value)
{
cell.Value = value;
//cell.Type = value.GetType();
ValueChanged?.Invoke(this, new ParamDictionaryValueChangedEventArgs() { Key = key, Value = value });
Save();
}
}
}
......@@ -181,7 +182,7 @@ namespace Misc
this.path = path;
Load();
}
public void Load()
void Load()
{
if (!File.Exists(path))
return;
......
......@@ -148,20 +148,24 @@ namespace FLY.Thick.Base.UI
{
this.jsonDist.SetValue(JSONDIST_KEY, JObject.FromObject(db));
}
/// <summary>
/// 输入密码,确认密码权限是否满足要求, level越大,要求权限越大
/// </summary>
/// <param name="pw"></param>
/// <param name="level"></param>
/// <param name="pw">密码</param>
/// <param name="level">要求级别</param>
/// <param name="pw_lv">输入密码的级别</param>
/// <returns></returns>
public AUTHORIZE_RESULT Authorize(string pw, int level)
public AUTHORIZE_RESULT Authorize(string pw, int level, out int pw_lv)
{
pw_lv = 0;
if (level <= 0)
return AUTHORIZE_RESULT.OK;
var v = from p in Db.Pws where p.Password == pw select p;
if (v.Count() > 0)
{
pw_lv = v.First().Level;
if (v.First().Level >= level)
return AUTHORIZE_RESULT.OK;
else
......@@ -175,9 +179,9 @@ namespace FLY.Thick.Base.UI
/// <param name="pw"></param>
/// <param name="uiName">界面名称</param>
/// <returns></returns>
public AUTHORIZE_RESULT Authorize(string pw, string uiName)
public AUTHORIZE_RESULT Authorize(string pw, string uiName, out int pw_lv)
{
return Authorize(pw, GetLv(uiName));
return Authorize(pw, GetLv(uiName),out pw_lv);
}
/// <summary>
/// 获取授权级别, 0级不需要密码就能通过
......
......@@ -28,7 +28,5 @@
<StackPanel x:Name="spSections">
</StackPanel>
</ScrollViewer>
<Button Style="{StaticResource ButtonStyle_apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
Click="btnApplyClick"/>
</Grid>
</Page>
......@@ -45,12 +45,5 @@ namespace FLY.Thick.Base.UI
spSections.Children.Add(uc);
}
}
private void btnApplyClick(object sender, RoutedEventArgs e)
{
paramDictionary.Save();
FLY.ControlLibrary.Window_Tip.Show("成功", "",
TimeSpan.FromSeconds(2));
return;
}
}
}
......@@ -51,12 +51,12 @@ namespace FLY.Thick.Base.UI
//窗口显示数据条数
int windowSize = this.paramDictionary.GetValue<int>(ParamDistItemKeys.WindowSize, 30);
mWindow = new BufferWindow<FlyData_WarningHistory>(this.warningService.NewestList, windowSize);
mWindow.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "Size")
{
this.paramDictionary.SetValue(ParamDistItemKeys.WindowSize, mWindow.Size);
this.paramDictionary.Save();
}
};
......
......@@ -38,6 +38,10 @@ namespace FLY.Thick.Base.UI
/// </summary>
int Level = 0;
/// <summary>
/// 输入密码,查询到的级别
/// </summary>
public int PwLv { get; private set; }
/// <summary>
///
/// </summary>
......@@ -45,6 +49,18 @@ namespace FLY.Thick.Base.UI
/// <returns></returns>
public static bool Authorize(string uiName)
{
return Authorize(uiName, out int pwLv);
}
/// <summary>
///
/// </summary>
/// <param name="uiName">界面</param>
/// <param name="pwLv">当密码正确时,密码的级别</param>
/// <returns></returns>
public static bool Authorize(string uiName, out int pwLv)
{
pwLv = 0;
//从容器获取
var container = Application.Current.Properties["container"] as IUnityContainer;
if (container == null)
......@@ -52,13 +68,41 @@ namespace FLY.Thick.Base.UI
var passwordAuthorize = container.Resolve<PasswordAuthorize>();
int level = passwordAuthorize.GetLv(uiName);
if (level <= 0)
if (level <= 0)
return true;
WdPassword w = new WdPassword();
w.Init(passwordAuthorize, level);
w.Owner = Application.Current.MainWindow;
bool ret = (bool)w.ShowDialog();
pwLv = w.PwLv;
return ret;
}
/// <summary>
///
/// </summary>
/// <param name="level">要求的级别</param>
/// <param name="pwLv">当密码正确时,密码的级别</param>
/// <returns></returns>
public static bool Authorize(int level, out int pwLv)
{
pwLv = 0;
//从容器获取
var container = Application.Current.Properties["container"] as IUnityContainer;
if (container == null)
return true;
var passwordAuthorize = container.Resolve<PasswordAuthorize>();
if (level <= 0)
return true;
WdPassword w = new WdPassword();
w.Init(passwordAuthorize,level);
w.Init(passwordAuthorize, level);
w.Owner = Application.Current.MainWindow;
return (bool)w.ShowDialog();
bool ret = (bool)w.ShowDialog();
pwLv = w.PwLv;
return ret;
}
private void button_apply_Click(object sender, RoutedEventArgs e)
{
......@@ -70,7 +114,8 @@ namespace FLY.Thick.Base.UI
}
AUTHORIZE_RESULT r = passwordAuthorize.Authorize(passwordbox.Password, Level);
AUTHORIZE_RESULT r = passwordAuthorize.Authorize(passwordbox.Password, Level, out int pwLv);
PwLv = pwLv;
switch (r)
{
case AUTHORIZE_RESULT.OK:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment