Commit 682d3e2c authored by 潘栩锋's avatar 潘栩锋 🚴

优化 initparam 保存的不再是 数据库文件名路径,而且数据库文件夹路径。 确保数据库名字不会改变

parent d1eb223d
......@@ -216,7 +216,7 @@ namespace FLY.Thick.Base.UI
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HVelocity1), this, nameof(HVelocity1));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HVelocity2), this, nameof(HVelocity2));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DBKeepMonth), this, nameof(DBKeepMonth));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DbPath), this, nameof(DbPath));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DbDirPath), this, nameof(DbPath));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.PunchOffset), this, nameof(PunchOffset));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasPunch), this, nameof(HasPunch));
......@@ -256,7 +256,7 @@ namespace FLY.Thick.Base.UI
initParamService.HVelocity1 = this.HVelocity1;
initParamService.HVelocity2 = this.HVelocity2;
initParamService.DBKeepMonth = this.DBKeepMonth;
initParamService.DbPath = this.DbPath;
initParamService.DbDirPath = this.DbPath;
initParamService.HasPunch = this.HasPunch;
initParamService.PunchOffset = this.PunchOffset;
......@@ -275,29 +275,14 @@ namespace FLY.Thick.Base.UI
private void SelectDbPath()
{
System.Windows.Forms.FileDialog open = new System.Windows.Forms.OpenFileDialog();
open.Filter = "sqlite3文件|*.sqlite3|所有文件|*.*";
open.Title = "打开音乐文件";
if (System.IO.Path.IsPathRooted(DbPath))
open.InitialDirectory = System.IO.Path.GetDirectoryName(DbPath);
else
open.InitialDirectory = System.Environment.CurrentDirectory;
System.Windows.Forms.FolderBrowserDialog open = new System.Windows.Forms.FolderBrowserDialog();
open.SelectedPath = DbPath;
if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string currentDirectory = System.Environment.CurrentDirectory.ToLower();
string filename = open.FileName.ToLower();
if (filename.StartsWith(currentDirectory))
{
//CurrentDirectory没有最后的\ 需要+1
DbPath = open.FileName.Substring(System.Environment.CurrentDirectory.Length + 1);
}
else
{
DbPath = open.FileName;
}
DbPath = open.SelectedPath;
}
}
}
......
......@@ -206,7 +206,7 @@ namespace FLY.Thick.Base.Client
/// <summary>
/// 数据库路径
/// </summary>
public string DbPath { get; set; }
public string DbDirPath { get; set; }
#endregion
public void Apply()
......
......@@ -166,7 +166,7 @@ namespace FLY.Thick.Base.IService
/// <summary>
/// 数据库路径
/// </summary>
string DbPath { get; set; }
string DbDirPath { get; set; }
/// <summary>
/// 参数应用
......
......@@ -193,7 +193,7 @@ namespace FLY.Thick.Base.Server
/// <summary>
/// 数据库路径
/// </summary>
public string DbPath { get; set; } = @"D:\flydata\history.sqlite3";
public string DbDirPath { get; set; } = @"D:\flydata";
#endregion
......@@ -242,7 +242,7 @@ namespace FLY.Thick.Base.Server
/// </summary>
void Save()
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(param_path, json);
}
......
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