feat: add BOS single-field migration
This commit is contained in:
@@ -16,9 +16,10 @@ namespace henlo_migration.ViewModels
|
||||
{
|
||||
public class MainViewModel : INotifyPropertyChanged
|
||||
{
|
||||
// 四个 Tab 的数据
|
||||
// 五个 Tab 的数据
|
||||
public TabServices TableTab { get; }
|
||||
public TabServices BosTab { get; }
|
||||
public TabServices BosFieldTab { get; }
|
||||
public TabServices PrcTab { get; }
|
||||
public TabServices DataTab { get; }
|
||||
|
||||
@@ -33,6 +34,7 @@ namespace henlo_migration.ViewModels
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(TablesData));
|
||||
OnPropertyChanged(nameof(BosTablesData));
|
||||
OnPropertyChanged(nameof(BosFieldsData));
|
||||
OnPropertyChanged(nameof(StoredProcsData));
|
||||
OnPropertyChanged(nameof(CurrentDataData));
|
||||
}
|
||||
@@ -50,13 +52,15 @@ namespace henlo_migration.ViewModels
|
||||
{
|
||||
0 => TableTab,
|
||||
1 => BosTab,
|
||||
2 => PrcTab,
|
||||
3 => DataTab,
|
||||
2 => BosFieldTab,
|
||||
3 => PrcTab,
|
||||
4 => DataTab,
|
||||
_ => TableTab
|
||||
};
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(TablesData));
|
||||
OnPropertyChanged(nameof(BosTablesData));
|
||||
OnPropertyChanged(nameof(BosFieldsData));
|
||||
OnPropertyChanged(nameof(StoredProcsData));
|
||||
OnPropertyChanged(nameof(CurrentDataData));
|
||||
OnPropertyChanged(nameof(CurrentTabName));
|
||||
@@ -64,9 +68,10 @@ namespace henlo_migration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
// 四个Tab数据源别名(供DataGrid绑定)
|
||||
// 五个Tab数据源别名(供DataGrid绑定)
|
||||
public ObservableCollection<TableRowModel> TablesData => TableTab.List;
|
||||
public ObservableCollection<TableRowModel> BosTablesData => BosTab.List;
|
||||
public ObservableCollection<TableRowModel> BosFieldsData => BosFieldTab.List;
|
||||
public ObservableCollection<TableRowModel> StoredProcsData => PrcTab.List;
|
||||
public ObservableCollection<TableRowModel> CurrentDataData => DataTab.List;
|
||||
|
||||
@@ -74,8 +79,9 @@ namespace henlo_migration.ViewModels
|
||||
{
|
||||
0 => "表配置",
|
||||
1 => "BOS配置",
|
||||
2 => "存储过程",
|
||||
3 => "表数据",
|
||||
2 => "BOS字段配置",
|
||||
3 => "存储过程",
|
||||
4 => "表数据",
|
||||
_ => ""
|
||||
};
|
||||
|
||||
@@ -240,7 +246,6 @@ namespace henlo_migration.ViewModels
|
||||
public ICommand DisconnectDestCommand { get; }
|
||||
public ICommand AddRowCommand { get; }
|
||||
public ICommand OpenDataFolderCommand { get; }
|
||||
public ICommand PreProcessCommand { get; }
|
||||
public ICommand BatchReadCommand { get; }
|
||||
public ICommand BatchWriteCommand { get; }
|
||||
|
||||
@@ -264,13 +269,16 @@ namespace henlo_migration.ViewModels
|
||||
DestUser = SysConfig.GetDestUser();
|
||||
DestPwd = SysConfig.GetDestPwd();
|
||||
|
||||
// 初始化四个 TabServices(索引文件在 from/,内容文件在 data/)
|
||||
// 初始化五个 TabServices(索引文件在 from/,内容文件在 data/)
|
||||
TableTab = new TabServices(new TabConfig(TabsEnum.表, CommonHelper.DataFromPath, CommonHelper.DataPath, "table.txt", CodeExt.creat,
|
||||
DbServices.GetTableSql, (p, c) => SqlCode = c));
|
||||
|
||||
BosTab = new TabServices(new TabConfig(TabsEnum.BOS表配置, CommonHelper.DataFromPath, CommonHelper.DataPath, "bos.txt", CodeExt.bos,
|
||||
DbServices.GetTableBos, (p, c) => SqlCode = c));
|
||||
|
||||
BosFieldTab = new TabServices(new TabConfig(TabsEnum.BOS字段配置, CommonHelper.DataFromPath, CommonHelper.DataPath, "bos_field.txt", CodeExt.bos_field,
|
||||
DbServices.GetTableBosField, (p, c) => SqlCode = c));
|
||||
|
||||
PrcTab = new TabServices(new TabConfig(TabsEnum.存储过程, CommonHelper.DataFromPath, CommonHelper.DataPath, "prc.txt", CodeExt.prc,
|
||||
name => DbServices.GetPrcSql(name), (p, c) => SqlCode = c));
|
||||
|
||||
@@ -278,7 +286,7 @@ namespace henlo_migration.ViewModels
|
||||
DbServices.GetTableData, (p, c) => SqlCode = c));
|
||||
|
||||
// Tab行点击 -> 显示SQL
|
||||
foreach (var tab in new[] { TableTab, BosTab, PrcTab, DataTab })
|
||||
foreach (var tab in new[] { TableTab, BosTab, BosFieldTab, PrcTab, DataTab })
|
||||
{
|
||||
tab.RowClickEvent += (path, code) =>
|
||||
{
|
||||
@@ -297,7 +305,6 @@ namespace henlo_migration.ViewModels
|
||||
DisconnectDestCommand = new RelayCommand(DisconnectDest, () => DestConnected);
|
||||
AddRowCommand = new RelayCommand(AddRow, () => CurrentTab != null && !string.IsNullOrWhiteSpace(InputText));
|
||||
OpenDataFolderCommand = new RelayCommand(OpenDataFolder);
|
||||
PreProcessCommand = new RelayCommand(PreProcess);
|
||||
BatchReadCommand = new RelayCommand(async () => await BatchReadAsync());
|
||||
BatchWriteCommand = new RelayCommand(async () => await BatchWriteAsync());
|
||||
|
||||
@@ -372,7 +379,18 @@ namespace henlo_migration.ViewModels
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(InputText))
|
||||
{
|
||||
CurrentTab?.AddRow(InputText.Trim().ToLower());
|
||||
string itemName = InputText.Trim();
|
||||
if (CurrentTab == BosFieldTab)
|
||||
{
|
||||
if (!DbServices.TryParseBosFieldName(itemName, out string tableName, out string columnName))
|
||||
{
|
||||
HandyControl.Controls.Growl.Warning("BOS 字段配置必须使用 TABLE.COLUMN 格式");
|
||||
return;
|
||||
}
|
||||
itemName = $"{tableName}.{columnName}";
|
||||
}
|
||||
|
||||
CurrentTab?.AddRow(itemName.ToLowerInvariant());
|
||||
InputText = "";
|
||||
}
|
||||
}
|
||||
@@ -396,12 +414,6 @@ namespace henlo_migration.ViewModels
|
||||
Process.Start("explorer.exe", CommonHelper.DataPath);
|
||||
}
|
||||
|
||||
private void PreProcess()
|
||||
{
|
||||
try { DbServices.PreProcess(); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
private async Task BatchReadAsync()
|
||||
{
|
||||
if (CurrentTab == null) return;
|
||||
|
||||
Reference in New Issue
Block a user