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

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

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