diff --git a/src/Luban.Job.Cfg/Source/DataCreators/ExcelNamedRowDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/ExcelNamedRowDataCreator.cs index c28ad0c..e6e3183 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/ExcelNamedRowDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/ExcelNamedRowDataCreator.cs @@ -290,7 +290,7 @@ namespace Luban.Job.Cfg.DataCreators private bool TryCreateColumnStream(Sheet.NamedRow x, Sheet.Title title, out ExcelStream stream) { - var cells = new List(); + var cells = new List(); for (int i = title.FromIndex; i <= title.ToIndex; i++) { foreach (var row in x.Rows) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs index 3cd19f2..7cc0b7f 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs @@ -1,4 +1,5 @@ -using Luban.Common.Utils; +using Bright.Collections; +using Luban.Common.Utils; using Luban.Job.Cfg.Datas; using Luban.Job.Cfg.Defs; using Luban.Job.Cfg.Utils; diff --git a/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs b/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs index bbe881a..8dda364 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/DataSourceFactory.cs @@ -22,7 +22,11 @@ namespace Luban.Job.Cfg.DataSources { try { +#if !LUBAN_ASSISTANT string ext = url.Contains('.') ? Path.GetExtension(url)?[1..] : url; +#else + string ext = url.Contains(".") ? Path.GetExtension(url)?.Substring(1) : url; +#endif AbstractDataSource source; switch (ext) { diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/Cell.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/Cell.cs new file mode 100644 index 0000000..99de989 --- /dev/null +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/Cell.cs @@ -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}"; + } + } +} diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs index 94a51a8..bf22973 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs @@ -14,7 +14,7 @@ namespace Luban.Job.Cfg.DataSources.Excel class ExcelStream { - private readonly List _datas; + private readonly List _datas; private readonly int _toIndex; private int _curIndex; @@ -24,7 +24,7 @@ namespace Luban.Job.Cfg.DataSources.Excel /// public bool NamedMode { get; set; } - public ExcelStream(List datas, int fromIndex, int toIndex, string sep, bool namedMode) + public ExcelStream(List datas, int fromIndex, int toIndex, string sep, bool namedMode) { NamedMode = namedMode; if (string.IsNullOrWhiteSpace(sep)) @@ -35,14 +35,14 @@ namespace Luban.Job.Cfg.DataSources.Excel } else { - this._datas = new List(); + this._datas = new List(); for (int i = fromIndex; i <= toIndex; i++) { var cell = datas[i]; object d = cell.Value; 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 { @@ -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; if (string.IsNullOrWhiteSpace(sep)) { - this._datas = new List { cell }; + this._datas = new List { cell }; this._toIndex = 0; this._curIndex = 0; } else { - this._datas = new List(); + this._datas = new List(); object d = cell.Value; if (!IsSkip(d)) { 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 { @@ -144,7 +144,7 @@ namespace Luban.Job.Cfg.DataSources.Excel // return nullable ? Read() : ReadSkipNull(); //} - public Sheet.Cell ReadCell() + public Cell ReadCell() { while (_curIndex <= _toIndex) { diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs index 907e82e..f27ce22 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs @@ -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 static IEnumerable CreateMultiRowNamedRow(List> rows, Title title, TBean bean) diff --git a/src/Luban.Job.Cfg/Source/Defs/DefBean.cs b/src/Luban.Job.Cfg/Source/Defs/DefBean.cs index 0b11af2..dac9cac 100644 --- a/src/Luban.Job.Cfg/Source/Defs/DefBean.cs +++ b/src/Luban.Job.Cfg/Source/Defs/DefBean.cs @@ -144,7 +144,7 @@ namespace Luban.Job.Cfg.Defs 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(); } diff --git a/src/Luban.Job.Cfg/Source/JobController.cs b/src/Luban.Job.Cfg/Source/JobController.cs index c9ad06b..4260262 100644 --- a/src/Luban.Job.Cfg/Source/JobController.cs +++ b/src/Luban.Job.Cfg/Source/JobController.cs @@ -150,9 +150,6 @@ namespace Luban.Job.Cfg DefAssemblyBase.LocalAssebmly = ass; - var targetService = ass.CfgTargetService; - - List exportTables = ass.GetExportTables(); List exportTypes = ass.GetExportTypes(); diff --git a/src/Luban.Job.Common/Source/Defs/DefBeanBase.cs b/src/Luban.Job.Common/Source/Defs/DefBeanBase.cs index 95021f0..2ae8289 100644 --- a/src/Luban.Job.Common/Source/Defs/DefBeanBase.cs +++ b/src/Luban.Job.Common/Source/Defs/DefBeanBase.cs @@ -91,7 +91,7 @@ namespace Luban.Job.Common.Defs return null; } - internal DefFieldBase GetField(string index) + public DefFieldBase GetField(string index) { return HierarchyFields.Where(f => f.Name == index).FirstOrDefault(); } diff --git a/src/LubanAssistant/AssistantTab.Designer.cs b/src/LubanAssistant/AssistantTab.Designer.cs index 9f5542b..9cfc89e 100644 --- a/src/LubanAssistant/AssistantTab.Designer.cs +++ b/src/LubanAssistant/AssistantTab.Designer.cs @@ -37,13 +37,14 @@ namespace LubanAssistant { this.tab1 = this.Factory.CreateRibbonTab(); this.group3 = this.Factory.CreateRibbonGroup(); - this.SetRootFile = this.Factory.CreateRibbonButton(); this.group1 = this.Factory.CreateRibbonGroup(); - this.load = this.Factory.CreateRibbonButton(); 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.saveSelected = this.Factory.CreateRibbonButton(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.reloadData = this.Factory.CreateRibbonButton(); this.tab1.SuspendLayout(); this.group3.SuspendLayout(); this.group1.SuspendLayout(); @@ -64,6 +65,22 @@ namespace LubanAssistant this.group3.Items.Add(this.SetRootFile); 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 // this.SetRootFile.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge; @@ -72,11 +89,6 @@ namespace LubanAssistant this.SetRootFile.ShowImage = true; this.SetRootFile.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnChooseRootFileClick); // - // group1 - // - this.group1.Items.Add(this.load); - this.group1.Name = "group1"; - // // load // this.load.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge; @@ -85,12 +97,6 @@ namespace LubanAssistant this.load.ShowImage = true; 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 // this.saveAll.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge; @@ -107,9 +113,12 @@ namespace LubanAssistant this.saveSelected.ShowImage = true; 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 // @@ -140,6 +149,7 @@ namespace LubanAssistant internal Microsoft.Office.Tools.Ribbon.RibbonButton SetRootFile; internal Microsoft.Office.Tools.Ribbon.RibbonButton saveSelected; private System.Windows.Forms.OpenFileDialog openFileDialog1; + internal Microsoft.Office.Tools.Ribbon.RibbonButton reloadData; } partial class ThisRibbonCollection diff --git a/src/LubanAssistant/AssistantTab.cs b/src/LubanAssistant/AssistantTab.cs index 74b00f8..687cdf5 100644 --- a/src/LubanAssistant/AssistantTab.cs +++ b/src/LubanAssistant/AssistantTab.cs @@ -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.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Threading.Tasks; using System.Windows.Forms; namespace LubanAssistant @@ -20,21 +26,15 @@ namespace LubanAssistant } } + public string DataDir { get; set; } + private void AssistantTab_Load(object sender, RibbonUIEventArgs e) { } - private bool CheckChooseRootDefineFile() + private bool HasSetRootDefineFile() { - if (string.IsNullOrWhiteSpace(RootDefineFile) || !File.Exists(RootDefineFile)) - { - if (TryChooseRootDefineFile(out var rootDefineFile)) - { - RootDefineFile = rootDefineFile; - return true; - } - } - return false; + return !string.IsNullOrWhiteSpace(RootDefineFile) && File.Exists(RootDefineFile); } private bool TryChooseRootDefineFile(out string rootDefineFile) @@ -42,7 +42,7 @@ namespace LubanAssistant var dialog = new OpenFileDialog(); dialog.DefaultExt = "xml"; dialog.Filter = "root file (*.xml)|*.xml"; - dialog.Title = "Choose Root Xml File"; + dialog.Title = "Select Root Xml File"; dialog.CheckFileExists = true; if (dialog.ShowDialog() == DialogResult.OK) { @@ -53,6 +53,30 @@ namespace LubanAssistant 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) { if (TryChooseRootDefineFile(out var rootDefineFile)) @@ -63,9 +87,84 @@ namespace LubanAssistant 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(); + 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(); } } diff --git a/src/LubanAssistant/ThisAddIn.Designer.cs b/src/LubanAssistant/LubanAssistant.Designer.cs similarity index 93% rename from src/LubanAssistant/ThisAddIn.Designer.cs rename to src/LubanAssistant/LubanAssistant.Designer.cs index 72c502a..593bf5b 100644 --- a/src/LubanAssistant/ThisAddIn.Designer.cs +++ b/src/LubanAssistant/LubanAssistant.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// 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. +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ @@ -15,7 +15,7 @@ namespace LubanAssistant { /// [Microsoft.VisualStudio.Tools.Applications.Runtime.StartupObjectAttribute(0)] [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; @@ -30,7 +30,7 @@ namespace LubanAssistant { /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [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") { Globals.Factory = factory; } @@ -42,7 +42,7 @@ namespace LubanAssistant { protected override void Initialize() { base.Initialize(); this.Application = this.GetHostItem(typeof(Microsoft.Office.Interop.Excel.Application), "Application"); - Globals.ThisAddIn = this; + Globals.LubanAssistant = this; global::System.Windows.Forms.Application.EnableVisualStyles(); this.InitializeCachedData(); this.InitializeControls(); @@ -180,19 +180,19 @@ namespace LubanAssistant { private Globals() { } - private static ThisAddIn _ThisAddIn; + private static LubanAssistant _LubanAssistant; private static global::Microsoft.Office.Tools.Excel.ApplicationFactory _factory; private static ThisRibbonCollection _ThisRibbonCollection; - internal static ThisAddIn ThisAddIn { + internal static LubanAssistant LubanAssistant { get { - return _ThisAddIn; + return _LubanAssistant; } set { - if ((_ThisAddIn == null)) { - _ThisAddIn = value; + if ((_LubanAssistant == null)) { + _LubanAssistant = value; } else { throw new System.NotSupportedException(); diff --git a/src/LubanAssistant/ThisAddIn.Designer.xml b/src/LubanAssistant/LubanAssistant.Designer.xml similarity index 71% rename from src/LubanAssistant/ThisAddIn.Designer.xml rename to src/LubanAssistant/LubanAssistant.Designer.xml index c3327b0..e71f7e3 100644 --- a/src/LubanAssistant/ThisAddIn.Designer.xml +++ b/src/LubanAssistant/LubanAssistant.Designer.xml @@ -1,4 +1,4 @@ - + diff --git a/src/LubanAssistant/ThisAddIn.cs b/src/LubanAssistant/LubanAssistant.cs similarity index 96% rename from src/LubanAssistant/ThisAddIn.cs rename to src/LubanAssistant/LubanAssistant.cs index c688b8a..9d6a81d 100644 --- a/src/LubanAssistant/ThisAddIn.cs +++ b/src/LubanAssistant/LubanAssistant.cs @@ -10,7 +10,7 @@ using Microsoft.Office.Tools.Ribbon; namespace LubanAssistant { - public partial class ThisAddIn + public partial class LubanAssistant { private void ThisAddIn_Startup(object sender, System.EventArgs e) { diff --git a/src/LubanAssistant/LubanAssistant.csproj b/src/LubanAssistant/LubanAssistant.csproj index 0d37324..f1faa9e 100644 --- a/src/LubanAssistant/LubanAssistant.csproj +++ b/src/LubanAssistant/LubanAssistant.csproj @@ -241,15 +241,33 @@ Source\DataCreators\JsonDataCreator.cs + + Source\DataCreators\LuaDataCreator.cs + Source\DataCreators\MultiRowExcelDataCreator.cs Source\DataCreators\StringDataCreator.cs + + Source\DataCreators\XmlDataCreator.cs + + + Source\DataCreators\YamlDataCreator.cs + Source\DataSources\AbstractDataSource.cs + + Source\DataSources\Binary\BinaryDataSource.cs + + + Source\DataSources\DataSourceFactory.cs + + + Source\DataSources\Excel\Cell.cs + Source\DataSources\Excel\ExcelDataSource.cs @@ -262,6 +280,15 @@ Source\DataSources\Json\JsonDataSource.cs + + Source\DataSources\Lua\LuaDataSource.cs + + + Source\DataSources\Xml\XmlDataSource.cs + + + Source\DataSources\Yaml\YamlDataSource.cs + Source\Datas\DArray.cs @@ -538,8 +565,8 @@ Settings.settings True - - + + @@ -548,17 +575,16 @@ - - - + + - + @@ -567,20 +593,18 @@ - + Code - - ThisAddIn.cs + + LubanAssistant.cs - - ThisAddIn.Designer.xml + + LubanAssistant.Designer.xml - - - + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -604,7 +628,7 @@ - + diff --git a/src/LubanAssistant/Properties/Settings.Designer.cs b/src/LubanAssistant/Properties/Settings.Designer.cs index fb719cf..fb333d6 100644 --- a/src/LubanAssistant/Properties/Settings.Designer.cs +++ b/src/LubanAssistant/Properties/Settings.Designer.cs @@ -34,5 +34,17 @@ namespace LubanAssistant.Properties { 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; + } + } } } diff --git a/src/LubanAssistant/Properties/Settings.settings b/src/LubanAssistant/Properties/Settings.settings index c3d99c0..736b17c 100644 --- a/src/LubanAssistant/Properties/Settings.settings +++ b/src/LubanAssistant/Properties/Settings.settings @@ -5,5 +5,8 @@ + + + \ No newline at end of file diff --git a/src/LubanAssistant/Source/DataSources/DataSourceFactory.cs b/src/LubanAssistant/Source/DataSources/DataSourceFactory.cs deleted file mode 100644 index 65457da..0000000 --- a/src/LubanAssistant/Source/DataSources/DataSourceFactory.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/src/LubanAssistant/Source/Defs/DefAssembly.cs b/src/LubanAssistant/Source/Defs/DefAssembly.cs index 250a29f..3f39f68 100644 --- a/src/LubanAssistant/Source/Defs/DefAssembly.cs +++ b/src/LubanAssistant/Source/Defs/DefAssembly.cs @@ -156,30 +156,12 @@ namespace Luban.Job.Cfg.Defs return refTypes.Values.ToList(); } - public void Load(string outputService, Defines defines) + public void Load(Defines defines) { SupportDatetimeType = true; 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) { AddType(new DefEnum(e)); diff --git a/src/LubanAssistant/Source/FileInfo.cs b/src/LubanAssistant/Source/Protos/FileInfo.cs similarity index 100% rename from src/LubanAssistant/Source/FileInfo.cs rename to src/LubanAssistant/Source/Protos/FileInfo.cs diff --git a/src/LubanAssistant/Source/GetImportFileOrDirectory.cs b/src/LubanAssistant/Source/Protos/GetImportFileOrDirectory.cs similarity index 100% rename from src/LubanAssistant/Source/GetImportFileOrDirectory.cs rename to src/LubanAssistant/Source/Protos/GetImportFileOrDirectory.cs diff --git a/src/LubanAssistant/Source/QueryFilesExists.cs b/src/LubanAssistant/Source/Protos/QueryFilesExists.cs similarity index 100% rename from src/LubanAssistant/Source/QueryFilesExists.cs rename to src/LubanAssistant/Source/Protos/QueryFilesExists.cs diff --git a/src/LubanAssistant/Source/AtomicLong.cs b/src/LubanAssistant/Source/Utils/AtomicLong.cs similarity index 100% rename from src/LubanAssistant/Source/AtomicLong.cs rename to src/LubanAssistant/Source/Utils/AtomicLong.cs diff --git a/src/LubanAssistant/Source/CacheFileUtil.cs b/src/LubanAssistant/Source/Utils/CacheFileUtil.cs similarity index 100% rename from src/LubanAssistant/Source/CacheFileUtil.cs rename to src/LubanAssistant/Source/Utils/CacheFileUtil.cs diff --git a/src/LubanAssistant/app.config b/src/LubanAssistant/app.config index fc8bbbf..63b4bde 100644 --- a/src/LubanAssistant/app.config +++ b/src/LubanAssistant/app.config @@ -10,6 +10,9 @@ + + +