完善实现
parent
1e7fb10db2
commit
1dc7e0b84f
|
|
@ -290,7 +290,7 @@ namespace Luban.Job.Cfg.DataCreators
|
||||||
|
|
||||||
private bool TryCreateColumnStream(Sheet.NamedRow x, Sheet.Title title, out ExcelStream stream)
|
private bool TryCreateColumnStream(Sheet.NamedRow x, Sheet.Title title, out ExcelStream stream)
|
||||||
{
|
{
|
||||||
var cells = new List<Sheet.Cell>();
|
var cells = new List<Cell>();
|
||||||
for (int i = title.FromIndex; i <= title.ToIndex; i++)
|
for (int i = title.FromIndex; i <= title.ToIndex; i++)
|
||||||
{
|
{
|
||||||
foreach (var row in x.Rows)
|
foreach (var row in x.Rows)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Luban.Common.Utils;
|
using Bright.Collections;
|
||||||
|
using Luban.Common.Utils;
|
||||||
using Luban.Job.Cfg.Datas;
|
using Luban.Job.Cfg.Datas;
|
||||||
using Luban.Job.Cfg.Defs;
|
using Luban.Job.Cfg.Defs;
|
||||||
using Luban.Job.Cfg.Utils;
|
using Luban.Job.Cfg.Utils;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,11 @@ namespace Luban.Job.Cfg.DataSources
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if !LUBAN_ASSISTANT
|
||||||
string ext = url.Contains('.') ? Path.GetExtension(url)?[1..] : url;
|
string ext = url.Contains('.') ? Path.GetExtension(url)?[1..] : url;
|
||||||
|
#else
|
||||||
|
string ext = url.Contains(".") ? Path.GetExtension(url)?.Substring(1) : url;
|
||||||
|
#endif
|
||||||
AbstractDataSource source;
|
AbstractDataSource source;
|
||||||
switch (ext)
|
switch (ext)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
|
{
|
||||||
|
public struct Cell
|
||||||
|
{
|
||||||
|
public Cell(int row, int column, object value)
|
||||||
|
{
|
||||||
|
this.Row = row;
|
||||||
|
this.Column = column;
|
||||||
|
this.Value = value;
|
||||||
|
}
|
||||||
|
public int Row { get; } // 从 1 开始
|
||||||
|
|
||||||
|
public int Column { get; } // 从 0 开始,考虑改了它?
|
||||||
|
|
||||||
|
public object Value { get; }
|
||||||
|
|
||||||
|
|
||||||
|
private static string ToAlphaString(int column)
|
||||||
|
{
|
||||||
|
int h = column / 26;
|
||||||
|
int n = column % 26;
|
||||||
|
return $"{(h > 0 ? ((char)('A' + h - 1)).ToString() : "")}{(char)('A' + n)}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"[{ToAlphaString(Column)}:{Row + 1}] {Value}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
class ExcelStream
|
class ExcelStream
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly List<Sheet.Cell> _datas;
|
private readonly List<Cell> _datas;
|
||||||
private readonly int _toIndex;
|
private readonly int _toIndex;
|
||||||
private int _curIndex;
|
private int _curIndex;
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool NamedMode { get; set; }
|
public bool NamedMode { get; set; }
|
||||||
|
|
||||||
public ExcelStream(List<Sheet.Cell> datas, int fromIndex, int toIndex, string sep, bool namedMode)
|
public ExcelStream(List<Cell> datas, int fromIndex, int toIndex, string sep, bool namedMode)
|
||||||
{
|
{
|
||||||
NamedMode = namedMode;
|
NamedMode = namedMode;
|
||||||
if (string.IsNullOrWhiteSpace(sep))
|
if (string.IsNullOrWhiteSpace(sep))
|
||||||
|
|
@ -35,14 +35,14 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this._datas = new List<Sheet.Cell>();
|
this._datas = new List<Cell>();
|
||||||
for (int i = fromIndex; i <= toIndex; i++)
|
for (int i = fromIndex; i <= toIndex; i++)
|
||||||
{
|
{
|
||||||
var cell = datas[i];
|
var cell = datas[i];
|
||||||
object d = cell.Value;
|
object d = cell.Value;
|
||||||
if (d is string s)
|
if (d is string s)
|
||||||
{
|
{
|
||||||
this._datas.AddRange(DataUtil.SplitStringByAnySepChar(s, sep).Select(x => new Sheet.Cell(cell.Row, cell.Column, x)));
|
this._datas.AddRange(DataUtil.SplitStringByAnySepChar(s, sep).Select(x => new Cell(cell.Row, cell.Column, x)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -54,24 +54,24 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExcelStream(Sheet.Cell cell, string sep, bool namedMode)
|
public ExcelStream(Cell cell, string sep, bool namedMode)
|
||||||
{
|
{
|
||||||
NamedMode = namedMode;
|
NamedMode = namedMode;
|
||||||
if (string.IsNullOrWhiteSpace(sep))
|
if (string.IsNullOrWhiteSpace(sep))
|
||||||
{
|
{
|
||||||
this._datas = new List<Sheet.Cell> { cell };
|
this._datas = new List<Cell> { cell };
|
||||||
this._toIndex = 0;
|
this._toIndex = 0;
|
||||||
this._curIndex = 0;
|
this._curIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this._datas = new List<Sheet.Cell>();
|
this._datas = new List<Cell>();
|
||||||
object d = cell.Value;
|
object d = cell.Value;
|
||||||
if (!IsSkip(d))
|
if (!IsSkip(d))
|
||||||
{
|
{
|
||||||
if (d is string s)
|
if (d is string s)
|
||||||
{
|
{
|
||||||
this._datas.AddRange(DataUtil.SplitStringByAnySepChar(s, sep).Where(x => !IsSkip(x)).Select(x => new Sheet.Cell(cell.Row, cell.Column, x)));
|
this._datas.AddRange(DataUtil.SplitStringByAnySepChar(s, sep).Where(x => !IsSkip(x)).Select(x => new Cell(cell.Row, cell.Column, x)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -144,7 +144,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
// return nullable ? Read() : ReadSkipNull();
|
// return nullable ? Read() : ReadSkipNull();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public Sheet.Cell ReadCell()
|
public Cell ReadCell()
|
||||||
{
|
{
|
||||||
while (_curIndex <= _toIndex)
|
while (_curIndex <= _toIndex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -79,34 +79,6 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Cell
|
|
||||||
{
|
|
||||||
public Cell(int row, int column, object value)
|
|
||||||
{
|
|
||||||
this.Row = row;
|
|
||||||
this.Column = column;
|
|
||||||
this.Value = value;
|
|
||||||
}
|
|
||||||
public int Row { get; } // 从 1 开始
|
|
||||||
|
|
||||||
public int Column { get; } // 从 0 开始,考虑改了它?
|
|
||||||
|
|
||||||
public object Value { get; }
|
|
||||||
|
|
||||||
|
|
||||||
private static string ToAlphaString(int column)
|
|
||||||
{
|
|
||||||
int h = column / 26;
|
|
||||||
int n = column % 26;
|
|
||||||
return $"{(h > 0 ? ((char)('A' + h - 1)).ToString() : "")}{(char)('A' + n)}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return $"[{ToAlphaString(Column)}:{Row + 1}] {Value}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NamedRow
|
public class NamedRow
|
||||||
{
|
{
|
||||||
public static IEnumerable<NamedRow> CreateMultiRowNamedRow(List<List<Cell>> rows, Title title, TBean bean)
|
public static IEnumerable<NamedRow> CreateMultiRowNamedRow(List<List<Cell>> rows, Title title, TBean bean)
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ namespace Luban.Job.Cfg.Defs
|
||||||
return new DefField(this, (CfgField)f, idOffset);
|
return new DefField(this, (CfgField)f, idOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal DefField GetField(string index)
|
public new DefField GetField(string index)
|
||||||
{
|
{
|
||||||
return (DefField)HierarchyFields.Where(f => f.Name == index).FirstOrDefault();
|
return (DefField)HierarchyFields.Where(f => f.Name == index).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,9 +150,6 @@ namespace Luban.Job.Cfg
|
||||||
|
|
||||||
DefAssemblyBase.LocalAssebmly = ass;
|
DefAssemblyBase.LocalAssebmly = ass;
|
||||||
|
|
||||||
var targetService = ass.CfgTargetService;
|
|
||||||
|
|
||||||
|
|
||||||
List<DefTable> exportTables = ass.GetExportTables();
|
List<DefTable> exportTables = ass.GetExportTables();
|
||||||
List<DefTypeBase> exportTypes = ass.GetExportTypes();
|
List<DefTypeBase> exportTypes = ass.GetExportTypes();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ namespace Luban.Job.Common.Defs
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal DefFieldBase GetField(string index)
|
public DefFieldBase GetField(string index)
|
||||||
{
|
{
|
||||||
return HierarchyFields.Where(f => f.Name == index).FirstOrDefault();
|
return HierarchyFields.Where(f => f.Name == index).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,14 @@ namespace LubanAssistant
|
||||||
{
|
{
|
||||||
this.tab1 = this.Factory.CreateRibbonTab();
|
this.tab1 = this.Factory.CreateRibbonTab();
|
||||||
this.group3 = this.Factory.CreateRibbonGroup();
|
this.group3 = this.Factory.CreateRibbonGroup();
|
||||||
this.SetRootFile = this.Factory.CreateRibbonButton();
|
|
||||||
this.group1 = this.Factory.CreateRibbonGroup();
|
this.group1 = this.Factory.CreateRibbonGroup();
|
||||||
this.load = this.Factory.CreateRibbonButton();
|
|
||||||
this.group2 = this.Factory.CreateRibbonGroup();
|
this.group2 = this.Factory.CreateRibbonGroup();
|
||||||
|
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.SetRootFile = this.Factory.CreateRibbonButton();
|
||||||
|
this.load = this.Factory.CreateRibbonButton();
|
||||||
this.saveAll = this.Factory.CreateRibbonButton();
|
this.saveAll = this.Factory.CreateRibbonButton();
|
||||||
this.saveSelected = this.Factory.CreateRibbonButton();
|
this.saveSelected = this.Factory.CreateRibbonButton();
|
||||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
this.reloadData = this.Factory.CreateRibbonButton();
|
||||||
this.tab1.SuspendLayout();
|
this.tab1.SuspendLayout();
|
||||||
this.group3.SuspendLayout();
|
this.group3.SuspendLayout();
|
||||||
this.group1.SuspendLayout();
|
this.group1.SuspendLayout();
|
||||||
|
|
@ -64,6 +65,22 @@ namespace LubanAssistant
|
||||||
this.group3.Items.Add(this.SetRootFile);
|
this.group3.Items.Add(this.SetRootFile);
|
||||||
this.group3.Name = "group3";
|
this.group3.Name = "group3";
|
||||||
//
|
//
|
||||||
|
// group1
|
||||||
|
//
|
||||||
|
this.group1.Items.Add(this.load);
|
||||||
|
this.group1.Items.Add(this.reloadData);
|
||||||
|
this.group1.Name = "group1";
|
||||||
|
//
|
||||||
|
// group2
|
||||||
|
//
|
||||||
|
this.group2.Items.Add(this.saveAll);
|
||||||
|
this.group2.Items.Add(this.saveSelected);
|
||||||
|
this.group2.Name = "group2";
|
||||||
|
//
|
||||||
|
// openFileDialog1
|
||||||
|
//
|
||||||
|
this.openFileDialog1.FileName = "openFileDialog1";
|
||||||
|
//
|
||||||
// SetRootFile
|
// SetRootFile
|
||||||
//
|
//
|
||||||
this.SetRootFile.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
this.SetRootFile.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
|
|
@ -72,11 +89,6 @@ namespace LubanAssistant
|
||||||
this.SetRootFile.ShowImage = true;
|
this.SetRootFile.ShowImage = true;
|
||||||
this.SetRootFile.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnChooseRootFileClick);
|
this.SetRootFile.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnChooseRootFileClick);
|
||||||
//
|
//
|
||||||
// group1
|
|
||||||
//
|
|
||||||
this.group1.Items.Add(this.load);
|
|
||||||
this.group1.Name = "group1";
|
|
||||||
//
|
|
||||||
// load
|
// load
|
||||||
//
|
//
|
||||||
this.load.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
this.load.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
|
|
@ -85,12 +97,6 @@ namespace LubanAssistant
|
||||||
this.load.ShowImage = true;
|
this.load.ShowImage = true;
|
||||||
this.load.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnLoadClick);
|
this.load.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnLoadClick);
|
||||||
//
|
//
|
||||||
// group2
|
|
||||||
//
|
|
||||||
this.group2.Items.Add(this.saveAll);
|
|
||||||
this.group2.Items.Add(this.saveSelected);
|
|
||||||
this.group2.Name = "group2";
|
|
||||||
//
|
|
||||||
// saveAll
|
// saveAll
|
||||||
//
|
//
|
||||||
this.saveAll.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
this.saveAll.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
|
|
@ -107,9 +113,12 @@ namespace LubanAssistant
|
||||||
this.saveSelected.ShowImage = true;
|
this.saveSelected.ShowImage = true;
|
||||||
this.saveSelected.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnSaveSelectedClick);
|
this.saveSelected.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnSaveSelectedClick);
|
||||||
//
|
//
|
||||||
// openFileDialog1
|
// reloadData
|
||||||
//
|
//
|
||||||
this.openFileDialog1.FileName = "openFileDialog1";
|
this.reloadData.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
|
this.reloadData.Label = "重新加载";
|
||||||
|
this.reloadData.Name = "reloadData";
|
||||||
|
this.reloadData.ShowImage = true;
|
||||||
//
|
//
|
||||||
// AssistantTab
|
// AssistantTab
|
||||||
//
|
//
|
||||||
|
|
@ -140,6 +149,7 @@ namespace LubanAssistant
|
||||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton SetRootFile;
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton SetRootFile;
|
||||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton saveSelected;
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton saveSelected;
|
||||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton reloadData;
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class ThisRibbonCollection
|
partial class ThisRibbonCollection
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,15 @@
|
||||||
using Microsoft.Office.Tools.Ribbon;
|
using Luban.Job.Cfg.Defs;
|
||||||
|
using Luban.Job.Cfg.Utils;
|
||||||
|
using Luban.Job.Common.Defs;
|
||||||
|
using Luban.Server.Common;
|
||||||
|
using Microsoft.Office.Tools.Ribbon;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace LubanAssistant
|
namespace LubanAssistant
|
||||||
|
|
@ -20,21 +26,15 @@ namespace LubanAssistant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DataDir { get; set; }
|
||||||
|
|
||||||
private void AssistantTab_Load(object sender, RibbonUIEventArgs e)
|
private void AssistantTab_Load(object sender, RibbonUIEventArgs e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CheckChooseRootDefineFile()
|
private bool HasSetRootDefineFile()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(RootDefineFile) || !File.Exists(RootDefineFile))
|
return !string.IsNullOrWhiteSpace(RootDefineFile) && File.Exists(RootDefineFile);
|
||||||
{
|
|
||||||
if (TryChooseRootDefineFile(out var rootDefineFile))
|
|
||||||
{
|
|
||||||
RootDefineFile = rootDefineFile;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryChooseRootDefineFile(out string rootDefineFile)
|
private bool TryChooseRootDefineFile(out string rootDefineFile)
|
||||||
|
|
@ -42,7 +42,7 @@ namespace LubanAssistant
|
||||||
var dialog = new OpenFileDialog();
|
var dialog = new OpenFileDialog();
|
||||||
dialog.DefaultExt = "xml";
|
dialog.DefaultExt = "xml";
|
||||||
dialog.Filter = "root file (*.xml)|*.xml";
|
dialog.Filter = "root file (*.xml)|*.xml";
|
||||||
dialog.Title = "Choose Root Xml File";
|
dialog.Title = "Select Root Xml File";
|
||||||
dialog.CheckFileExists = true;
|
dialog.CheckFileExists = true;
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
|
@ -53,6 +53,30 @@ namespace LubanAssistant
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool TryChooseInputDataDir(out string inputDataDir)
|
||||||
|
{
|
||||||
|
var dialog = new FolderBrowserDialog();
|
||||||
|
dialog.Description = "Select Data Dir";
|
||||||
|
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK && Directory.Exists(dialog.SelectedPath))
|
||||||
|
{
|
||||||
|
inputDataDir = dialog.SelectedPath;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
inputDataDir = null;
|
||||||
|
//var dialog = new OpenFileDialog();
|
||||||
|
//dialog.Title = "Select Data Dir";
|
||||||
|
//dialog.CheckFileExists = false;
|
||||||
|
//dialog.CheckPathExists = true;
|
||||||
|
//if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
//{
|
||||||
|
// inputDataDir = dialog.FileName;
|
||||||
|
// return true;
|
||||||
|
//}
|
||||||
|
//inputDataDir = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void BtnChooseRootFileClick(object sender, RibbonControlEventArgs e)
|
private void BtnChooseRootFileClick(object sender, RibbonControlEventArgs e)
|
||||||
{
|
{
|
||||||
if (TryChooseRootDefineFile(out var rootDefineFile))
|
if (TryChooseRootDefineFile(out var rootDefineFile))
|
||||||
|
|
@ -63,9 +87,84 @@ namespace LubanAssistant
|
||||||
|
|
||||||
private void BtnLoadClick(object sender, RibbonControlEventArgs e)
|
private void BtnLoadClick(object sender, RibbonControlEventArgs e)
|
||||||
{
|
{
|
||||||
if (CheckChooseRootDefineFile())
|
if (!HasSetRootDefineFile())
|
||||||
{
|
{
|
||||||
MessageBox.Show("load");
|
MessageBox.Show("请先设置Root定义文件");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TryChooseInputDataDir(out var dataDir))
|
||||||
|
{
|
||||||
|
DataDir = dataDir;
|
||||||
|
if (PromptIgnoreNotSaveData())
|
||||||
|
{
|
||||||
|
LoadDataToCurrentDoc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryGetTableName(out string tableName)
|
||||||
|
{
|
||||||
|
tableName = "test.TbExcelFromJson";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadDataToCurrentDoc()
|
||||||
|
{
|
||||||
|
MessageBox.Show($"从目录:{DataDir} 加载数据");
|
||||||
|
if (!TryGetTableName(out var tableName))
|
||||||
|
{
|
||||||
|
MessageBox.Show($"meta行未指定table名");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string inputDataDir = DataDir;
|
||||||
|
|
||||||
|
IAgent agent = new LocalAgent();
|
||||||
|
var loader = new CfgDefLoader(agent);
|
||||||
|
await loader.LoadAsync(RootDefineFile);
|
||||||
|
|
||||||
|
var rawDefines = loader.BuildDefines();
|
||||||
|
|
||||||
|
TimeZoneInfo timeZoneInfo = null;
|
||||||
|
|
||||||
|
var excludeTags = new List<string>();
|
||||||
|
var ass = new DefAssembly("", timeZoneInfo, excludeTags, agent);
|
||||||
|
|
||||||
|
ass.Load(rawDefines);
|
||||||
|
|
||||||
|
DefAssemblyBase.LocalAssebmly = ass;
|
||||||
|
|
||||||
|
var table = ass.GetCfgTable(tableName);
|
||||||
|
await DataLoaderUtil.LoadTableAsync(agent, table, inputDataDir, "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool PromptIgnoreNotSaveData()
|
||||||
|
{
|
||||||
|
if (HasNotsaveDataInCurrentWorksapce())
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("有未保存的数据,确定要覆盖吗?", "警告", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool HasNotsaveDataInCurrentWorksapce()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnReloadClick(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(DataDir))
|
||||||
|
{
|
||||||
|
MessageBox.Show("未设置加载目录");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (PromptIgnoreNotSaveData())
|
||||||
|
{
|
||||||
|
LoadDataToCurrentDoc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// 此代码由工具生成。
|
||||||
// Runtime Version:4.0.30319.42000
|
// 运行时版本:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||||
// the code is regenerated.
|
// 重新生成代码,这些更改将会丢失。
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace LubanAssistant {
|
||||||
///
|
///
|
||||||
[Microsoft.VisualStudio.Tools.Applications.Runtime.StartupObjectAttribute(0)]
|
[Microsoft.VisualStudio.Tools.Applications.Runtime.StartupObjectAttribute(0)]
|
||||||
[global::System.Security.Permissions.PermissionSetAttribute(global::System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
|
[global::System.Security.Permissions.PermissionSetAttribute(global::System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
|
||||||
public sealed partial class ThisAddIn : Microsoft.Office.Tools.AddInBase {
|
public sealed partial class LubanAssistant : Microsoft.Office.Tools.AddInBase {
|
||||||
|
|
||||||
internal Microsoft.Office.Tools.CustomTaskPaneCollection CustomTaskPanes;
|
internal Microsoft.Office.Tools.CustomTaskPaneCollection CustomTaskPanes;
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace LubanAssistant {
|
||||||
///
|
///
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||||
public ThisAddIn(global::Microsoft.Office.Tools.Excel.ApplicationFactory factory, global::System.IServiceProvider serviceProvider) :
|
public LubanAssistant(global::Microsoft.Office.Tools.Excel.ApplicationFactory factory, global::System.IServiceProvider serviceProvider) :
|
||||||
base(factory, serviceProvider, "AddIn", "ThisAddIn") {
|
base(factory, serviceProvider, "AddIn", "ThisAddIn") {
|
||||||
Globals.Factory = factory;
|
Globals.Factory = factory;
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ namespace LubanAssistant {
|
||||||
protected override void Initialize() {
|
protected override void Initialize() {
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
this.Application = this.GetHostItem<Microsoft.Office.Interop.Excel.Application>(typeof(Microsoft.Office.Interop.Excel.Application), "Application");
|
this.Application = this.GetHostItem<Microsoft.Office.Interop.Excel.Application>(typeof(Microsoft.Office.Interop.Excel.Application), "Application");
|
||||||
Globals.ThisAddIn = this;
|
Globals.LubanAssistant = this;
|
||||||
global::System.Windows.Forms.Application.EnableVisualStyles();
|
global::System.Windows.Forms.Application.EnableVisualStyles();
|
||||||
this.InitializeCachedData();
|
this.InitializeCachedData();
|
||||||
this.InitializeControls();
|
this.InitializeControls();
|
||||||
|
|
@ -180,19 +180,19 @@ namespace LubanAssistant {
|
||||||
private Globals() {
|
private Globals() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ThisAddIn _ThisAddIn;
|
private static LubanAssistant _LubanAssistant;
|
||||||
|
|
||||||
private static global::Microsoft.Office.Tools.Excel.ApplicationFactory _factory;
|
private static global::Microsoft.Office.Tools.Excel.ApplicationFactory _factory;
|
||||||
|
|
||||||
private static ThisRibbonCollection _ThisRibbonCollection;
|
private static ThisRibbonCollection _ThisRibbonCollection;
|
||||||
|
|
||||||
internal static ThisAddIn ThisAddIn {
|
internal static LubanAssistant LubanAssistant {
|
||||||
get {
|
get {
|
||||||
return _ThisAddIn;
|
return _LubanAssistant;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if ((_ThisAddIn == null)) {
|
if ((_LubanAssistant == null)) {
|
||||||
_ThisAddIn = value;
|
_LubanAssistant = value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new System.NotSupportedException();
|
throw new System.NotSupportedException();
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<hostitem:hostItem hostitem:baseType="Microsoft.Office.Tools.AddInBase" hostitem:namespace="LubanAssistant" hostitem:className="ThisAddIn" hostitem:identifier="ThisAddIn" hostitem:primaryCookie="AddIn" hostitem:master="true" hostitem:factoryType="Microsoft.Office.Tools.Excel.ApplicationFactory" hostitem:startupIndex="0" xmlns:hostitem="http://schemas.microsoft.com/2004/VisualStudio/Tools/Applications/HostItem.xsd">
|
<hostitem:hostItem hostitem:baseType="Microsoft.Office.Tools.AddInBase" hostitem:namespace="LubanAssistant" hostitem:className="ThisAddIn" hostitem:identifier="LubanAssistant" hostitem:primaryCookie="AddIn" hostitem:master="true" hostitem:factoryType="Microsoft.Office.Tools.Excel.ApplicationFactory" hostitem:startupIndex="0" xmlns:hostitem="http://schemas.microsoft.com/2004/VisualStudio/Tools/Applications/HostItem.xsd">
|
||||||
<hostitem:hostObject hostitem:name="Application" hostitem:identifier="Application" hostitem:type="Microsoft.Office.Interop.Excel.Application" hostitem:cookie="Application" hostitem:modifier="Internal" />
|
<hostitem:hostObject hostitem:name="Application" hostitem:identifier="Application" hostitem:type="Microsoft.Office.Interop.Excel.Application" hostitem:cookie="Application" hostitem:modifier="Internal" />
|
||||||
<hostitem:hostControl hostitem:name="CustomTaskPanes" hostitem:identifier="CustomTaskPanes" hostitem:type="Microsoft.Office.Tools.CustomTaskPaneCollection" hostitem:primaryCookie="CustomTaskPanes" hostitem:modifier="Internal" />
|
<hostitem:hostControl hostitem:name="CustomTaskPanes" hostitem:identifier="CustomTaskPanes" hostitem:type="Microsoft.Office.Tools.CustomTaskPaneCollection" hostitem:primaryCookie="CustomTaskPanes" hostitem:modifier="Internal" />
|
||||||
<hostitem:hostControl hostitem:name="VstoSmartTags" hostitem:identifier="VstoSmartTags" hostitem:type="Microsoft.Office.Tools.SmartTagCollection" hostitem:primaryCookie="VstoSmartTags" hostitem:modifier="Internal" />
|
<hostitem:hostControl hostitem:name="VstoSmartTags" hostitem:identifier="VstoSmartTags" hostitem:type="Microsoft.Office.Tools.SmartTagCollection" hostitem:primaryCookie="VstoSmartTags" hostitem:modifier="Internal" />
|
||||||
|
|
@ -10,7 +10,7 @@ using Microsoft.Office.Tools.Ribbon;
|
||||||
|
|
||||||
namespace LubanAssistant
|
namespace LubanAssistant
|
||||||
{
|
{
|
||||||
public partial class ThisAddIn
|
public partial class LubanAssistant
|
||||||
{
|
{
|
||||||
private void ThisAddIn_Startup(object sender, System.EventArgs e)
|
private void ThisAddIn_Startup(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
@ -241,15 +241,33 @@
|
||||||
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\JsonDataCreator.cs">
|
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\JsonDataCreator.cs">
|
||||||
<Link>Source\DataCreators\JsonDataCreator.cs</Link>
|
<Link>Source\DataCreators\JsonDataCreator.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\LuaDataCreator.cs">
|
||||||
|
<Link>Source\DataCreators\LuaDataCreator.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\MultiRowExcelDataCreator.cs">
|
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\MultiRowExcelDataCreator.cs">
|
||||||
<Link>Source\DataCreators\MultiRowExcelDataCreator.cs</Link>
|
<Link>Source\DataCreators\MultiRowExcelDataCreator.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\StringDataCreator.cs">
|
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\StringDataCreator.cs">
|
||||||
<Link>Source\DataCreators\StringDataCreator.cs</Link>
|
<Link>Source\DataCreators\StringDataCreator.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\XmlDataCreator.cs">
|
||||||
|
<Link>Source\DataCreators\XmlDataCreator.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataCreators\YamlDataCreator.cs">
|
||||||
|
<Link>Source\DataCreators\YamlDataCreator.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\AbstractDataSource.cs">
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\AbstractDataSource.cs">
|
||||||
<Link>Source\DataSources\AbstractDataSource.cs</Link>
|
<Link>Source\DataSources\AbstractDataSource.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Binary\BinaryDataSource.cs">
|
||||||
|
<Link>Source\DataSources\Binary\BinaryDataSource.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\DataSourceFactory.cs">
|
||||||
|
<Link>Source\DataSources\DataSourceFactory.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Excel\Cell.cs">
|
||||||
|
<Link>Source\DataSources\Excel\Cell.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Excel\ExcelDataSource.cs">
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Excel\ExcelDataSource.cs">
|
||||||
<Link>Source\DataSources\Excel\ExcelDataSource.cs</Link>
|
<Link>Source\DataSources\Excel\ExcelDataSource.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
@ -262,6 +280,15 @@
|
||||||
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Json\JsonDataSource.cs">
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Json\JsonDataSource.cs">
|
||||||
<Link>Source\DataSources\Json\JsonDataSource.cs</Link>
|
<Link>Source\DataSources\Json\JsonDataSource.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Lua\LuaDataSource.cs">
|
||||||
|
<Link>Source\DataSources\Lua\LuaDataSource.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Xml\XmlDataSource.cs">
|
||||||
|
<Link>Source\DataSources\Xml\XmlDataSource.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Luban.Job.Cfg\Source\DataSources\Yaml\YamlDataSource.cs">
|
||||||
|
<Link>Source\DataSources\Yaml\YamlDataSource.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\Luban.Job.Cfg\Source\Datas\DArray.cs">
|
<Compile Include="..\Luban.Job.Cfg\Source\Datas\DArray.cs">
|
||||||
<Link>Source\Datas\DArray.cs</Link>
|
<Link>Source\Datas\DArray.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
@ -538,8 +565,8 @@
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Source\AtomicLong.cs" />
|
<Compile Include="Source\Utils\AtomicLong.cs" />
|
||||||
<Compile Include="Source\CacheFileUtil.cs" />
|
<Compile Include="Source\Utils\CacheFileUtil.cs" />
|
||||||
<Compile Include="Source\Collections\CollectionExtension.cs" />
|
<Compile Include="Source\Collections\CollectionExtension.cs" />
|
||||||
<Compile Include="Source\Collections\CollectionUtil.cs" />
|
<Compile Include="Source\Collections\CollectionUtil.cs" />
|
||||||
<Compile Include="Source\Common\HashUtil.cs" />
|
<Compile Include="Source\Common\HashUtil.cs" />
|
||||||
|
|
@ -548,17 +575,16 @@
|
||||||
<Compile Include="Source\Common\StringUtil.cs" />
|
<Compile Include="Source\Common\StringUtil.cs" />
|
||||||
<Compile Include="Source\Common\TimeUtil.cs" />
|
<Compile Include="Source\Common\TimeUtil.cs" />
|
||||||
<Compile Include="Source\Common\ValueUtil.cs" />
|
<Compile Include="Source\Common\ValueUtil.cs" />
|
||||||
<Compile Include="Source\DataSources\DataSourceFactory.cs" />
|
|
||||||
<Compile Include="Source\Datas\DText.cs" />
|
<Compile Include="Source\Datas\DText.cs" />
|
||||||
<Compile Include="Source\Datas\DType.cs" />
|
<Compile Include="Source\Datas\DType.cs" />
|
||||||
<Compile Include="Source\Defs\CfgDefLoader.cs" />
|
<Compile Include="Source\Defs\CfgDefLoader.cs" />
|
||||||
<Compile Include="Source\Defs\DefAssembly.cs" />
|
<Compile Include="Source\Defs\DefAssembly.cs" />
|
||||||
<Compile Include="Source\Defs\DefField.cs" />
|
<Compile Include="Source\Defs\DefField.cs" />
|
||||||
<Compile Include="Source\Defs\DefTypeBase.cs" />
|
<Compile Include="Source\Defs\DefTypeBase.cs" />
|
||||||
<Compile Include="Source\FileInfo.cs" />
|
<Compile Include="Source\Protos\FileInfo.cs" />
|
||||||
<Compile Include="Source\GetImportFileOrDirectory.cs" />
|
<Compile Include="Source\Protos\GetImportFileOrDirectory.cs" />
|
||||||
<Compile Include="Source\LocalAgent.cs" />
|
<Compile Include="Source\LocalAgent.cs" />
|
||||||
<Compile Include="Source\QueryFilesExists.cs" />
|
<Compile Include="Source\Protos\QueryFilesExists.cs" />
|
||||||
<Compile Include="Source\Serialization\BeanBase.cs" />
|
<Compile Include="Source\Serialization\BeanBase.cs" />
|
||||||
<Compile Include="Source\Serialization\ByteBuf.cs" />
|
<Compile Include="Source\Serialization\ByteBuf.cs" />
|
||||||
<Compile Include="Source\Serialization\EUnmarshalError.cs" />
|
<Compile Include="Source\Serialization\EUnmarshalError.cs" />
|
||||||
|
|
@ -567,20 +593,18 @@
|
||||||
<Compile Include="Source\Serialization\ITypeId.cs" />
|
<Compile Include="Source\Serialization\ITypeId.cs" />
|
||||||
<Compile Include="Source\Serialization\SerializationException.cs" />
|
<Compile Include="Source\Serialization\SerializationException.cs" />
|
||||||
<Compile Include="Source\Utils\DataLoaderUtil.cs" />
|
<Compile Include="Source\Utils\DataLoaderUtil.cs" />
|
||||||
<Compile Include="ThisAddIn.cs">
|
<Compile Include="LubanAssistant.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<None Include="ThisAddIn.Designer.xml">
|
<None Include="LubanAssistant.Designer.xml">
|
||||||
<DependentUpon>ThisAddIn.cs</DependentUpon>
|
<DependentUpon>LubanAssistant.cs</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
<Compile Include="ThisAddIn.Designer.cs">
|
<Compile Include="LubanAssistant.Designer.cs">
|
||||||
<DependentUpon>ThisAddIn.Designer.xml</DependentUpon>
|
<DependentUpon>LubanAssistant.Designer.xml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="TypeVisitors\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
|
@ -604,7 +628,7 @@
|
||||||
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
|
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
|
||||||
<ProjectProperties HostName="Excel" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Excel" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\16.0\Excel\InstallRoot\Path#excel.exe" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
|
<ProjectProperties HostName="Excel" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Excel" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\16.0\Excel\InstallRoot\Path#excel.exe" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
|
||||||
<Host Name="Excel" GeneratedCodeNamespace="LubanAssistant" IconIndex="0">
|
<Host Name="Excel" GeneratedCodeNamespace="LubanAssistant" IconIndex="0">
|
||||||
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
|
<HostItem Name="ThisAddIn" Code="LubanAssistant.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="LubanAssistant.Designer.xml" GeneratedCode="LubanAssistant.Designer.cs" />
|
||||||
</Host>
|
</Host>
|
||||||
</FlavorProperties>
|
</FlavorProperties>
|
||||||
</VisualStudio>
|
</VisualStudio>
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,17 @@ namespace LubanAssistant.Properties {
|
||||||
this["rootDefineFile"] = value;
|
this["rootDefineFile"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string dataDir {
|
||||||
|
get {
|
||||||
|
return ((string)(this["dataDir"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["dataDir"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,8 @@
|
||||||
<Setting Name="rootDefineFile" Type="System.String" Scope="User">
|
<Setting Name="rootDefineFile" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)" />
|
<Value Profile="(Default)" />
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="dataDir" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Luban.Job.Cfg.DataSources
|
|
||||||
{
|
|
||||||
static class DataSourceFactory
|
|
||||||
{
|
|
||||||
public static readonly string[] validDataSourceSuffixes = new string[]
|
|
||||||
{
|
|
||||||
".xlsx",
|
|
||||||
".xls",
|
|
||||||
".csv",
|
|
||||||
".xml",
|
|
||||||
".lua",
|
|
||||||
".json",
|
|
||||||
".yml",
|
|
||||||
".bin",
|
|
||||||
};
|
|
||||||
|
|
||||||
public static AbstractDataSource Create(string url, string sheetName, Stream stream)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string ext = url.Contains(".") ? Path.GetExtension(url)?.Substring(1) : url;
|
|
||||||
AbstractDataSource source;
|
|
||||||
switch (ext)
|
|
||||||
{
|
|
||||||
case "csv":
|
|
||||||
case "xls":
|
|
||||||
case "xlsx": source = new Excel.ExcelDataSource(); break;
|
|
||||||
case "json": source = new Json.JsonDataSource(); break;
|
|
||||||
default: throw new Exception($"不支持的文件类型:{url}");
|
|
||||||
}
|
|
||||||
source.Load(url, sheetName, stream);
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new Exception($"文件{url} 加载失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -156,30 +156,12 @@ namespace Luban.Job.Cfg.Defs
|
||||||
return refTypes.Values.ToList();
|
return refTypes.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load(string outputService, Defines defines)
|
public void Load(Defines defines)
|
||||||
{
|
{
|
||||||
SupportDatetimeType = true;
|
SupportDatetimeType = true;
|
||||||
|
|
||||||
TopModule = defines.TopModule;
|
TopModule = defines.TopModule;
|
||||||
|
|
||||||
CfgTargetService = defines.Services.Find(s => s.Name == outputService);
|
|
||||||
|
|
||||||
if (CfgTargetService == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"service:{outputService} not exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(_patchName))
|
|
||||||
{
|
|
||||||
TargetPatch = defines.Patches.Find(b => b.Name == _patchName);
|
|
||||||
if (TargetPatch == null)
|
|
||||||
{
|
|
||||||
throw new Exception($"patch '{_patchName}' not in valid patch set");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._patches.AddRange(defines.Patches);
|
|
||||||
|
|
||||||
foreach (var e in defines.Enums)
|
foreach (var e in defines.Enums)
|
||||||
{
|
{
|
||||||
AddType(new DefEnum(e));
|
AddType(new DefEnum(e));
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@
|
||||||
<setting name="rootDefineFile" serializeAs="String">
|
<setting name="rootDefineFile" serializeAs="String">
|
||||||
<value />
|
<value />
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="dataDir" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
</LubanAssistant.Properties.Settings>
|
</LubanAssistant.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
<runtime>
|
<runtime>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue