diff --git a/docs/sponsor/weixin.JPG b/docs/sponsor/weixin.JPG new file mode 100644 index 0000000..f57b48e Binary files /dev/null and b/docs/sponsor/weixin.JPG differ diff --git a/docs/sponsor/zhifubao.JPG b/docs/sponsor/zhifubao.JPG new file mode 100644 index 0000000..20f45f1 Binary files /dev/null and b/docs/sponsor/zhifubao.JPG differ diff --git a/src/Luban.ClientServer/Program.cs b/src/Luban.ClientServer/Program.cs index f70ea16..6441517 100644 --- a/src/Luban.ClientServer/Program.cs +++ b/src/Luban.ClientServer/Program.cs @@ -43,7 +43,7 @@ namespace Luban.ClientServer Console.WriteLine("ERRORS:"); Console.WriteLine("\t" + err); Console.WriteLine(@" -Luban.Client ... [-- [job options]] +Luban.ClientServer ... [-- [job options]] e.g. Luban.ClientServer -j cfg -- --name abc diff --git a/src/Luban.Job.Cfg/Source/Datas/DArray.cs b/src/Luban.Job.Cfg/Source/Datas/DArray.cs index e5c18db..ad93796 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DArray.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DArray.cs @@ -28,6 +28,11 @@ namespace Luban.Job.Cfg.Datas throw new System.NotSupportedException(); } + public override int CompareTo(DType other) + { + throw new System.NotSupportedException(); + } + public override void Apply(IDataActionVisitor visitor, T x) { visitor.Accept(this, x); diff --git a/src/Luban.Job.Cfg/Source/Datas/DBean.cs b/src/Luban.Job.Cfg/Source/Datas/DBean.cs index a7cbcf7..ed4ff81 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DBean.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DBean.cs @@ -32,6 +32,11 @@ namespace Luban.Job.Cfg.Datas throw new System.NotSupportedException(); } + public override int CompareTo(DType other) + { + throw new System.NotSupportedException(); + } + public DType GetField(string fieldName) { if (ImplType.TryGetField(fieldName, out var _, out var findex)) diff --git a/src/Luban.Job.Cfg/Source/Datas/DBool.cs b/src/Luban.Job.Cfg/Source/Datas/DBool.cs index eb25cce..802cb70 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DBool.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DBool.cs @@ -48,5 +48,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DBool d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DByte.cs b/src/Luban.Job.Cfg/Source/Datas/DByte.cs index 6cdeab0..d9422ec 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DByte.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DByte.cs @@ -53,5 +53,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DByte d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DDateTime.cs b/src/Luban.Job.Cfg/Source/Datas/DDateTime.cs index 02ae769..b6f8ba7 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DDateTime.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DDateTime.cs @@ -31,6 +31,15 @@ namespace Luban.Job.Cfg.Datas return _localTime.GetHashCode(); } + public override int CompareTo(DType other) + { + if (other is DDateTime d) + { + return this._localTime.CompareTo(d._localTime); + } + throw new System.NotSupportedException(); + } + public string ToFormatString() { return DataUtil.FormatDateTime(Time); diff --git a/src/Luban.Job.Cfg/Source/Datas/DDouble.cs b/src/Luban.Job.Cfg/Source/Datas/DDouble.cs index ec86027..c06cad5 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DDouble.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DDouble.cs @@ -46,5 +46,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DDouble d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DEnum.cs b/src/Luban.Job.Cfg/Source/Datas/DEnum.cs index e190f36..e5f6153 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DEnum.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DEnum.cs @@ -56,5 +56,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DEnum d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DFint.cs b/src/Luban.Job.Cfg/Source/Datas/DFint.cs index b2f5d85..898dbc4 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DFint.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DFint.cs @@ -52,5 +52,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DFint d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DFloat.cs b/src/Luban.Job.Cfg/Source/Datas/DFloat.cs index 7912eee..15a7787 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DFloat.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DFloat.cs @@ -50,5 +50,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DFloat d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DFlong.cs b/src/Luban.Job.Cfg/Source/Datas/DFlong.cs index 34f5b66..8f46e15 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DFlong.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DFlong.cs @@ -46,5 +46,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DFlong d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DFshort.cs b/src/Luban.Job.Cfg/Source/Datas/DFshort.cs index bd50ee7..2ce5e28 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DFshort.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DFshort.cs @@ -27,6 +27,15 @@ namespace Luban.Job.Cfg.Datas return Value.GetHashCode(); } + public override int CompareTo(DType other) + { + if (other is DFshort d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } + public override void Apply(IDataActionVisitor visitor, T x) { visitor.Accept(this, x); diff --git a/src/Luban.Job.Cfg/Source/Datas/DInt.cs b/src/Luban.Job.Cfg/Source/Datas/DInt.cs index 79c6814..98c198a 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DInt.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DInt.cs @@ -67,5 +67,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DInt d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DLong.cs b/src/Luban.Job.Cfg/Source/Datas/DLong.cs index 3b574fa..33752e0 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DLong.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DLong.cs @@ -60,5 +60,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DLong d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DShort.cs b/src/Luban.Job.Cfg/Source/Datas/DShort.cs index 4803b90..395ef0d 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DShort.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DShort.cs @@ -46,5 +46,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DShort d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DString.cs b/src/Luban.Job.Cfg/Source/Datas/DString.cs index 61f96ee..e183bb3 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DString.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DString.cs @@ -50,5 +50,14 @@ namespace Luban.Job.Cfg.Datas { return Value.GetHashCode(); } + + public override int CompareTo(DType other) + { + if (other is DString d) + { + return this.Value.CompareTo(d.Value); + } + throw new System.NotSupportedException(); + } } } diff --git a/src/Luban.Job.Cfg/Source/Datas/DType.cs b/src/Luban.Job.Cfg/Source/Datas/DType.cs index 028b22e..54acdd2 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DType.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DType.cs @@ -3,7 +3,7 @@ using Luban.Job.Cfg.DataVisitors; namespace Luban.Job.Cfg.Datas { - public abstract class DType + public abstract class DType : System.IComparable { public abstract void Apply(IDataActionVisitor visitor, T x); @@ -19,6 +19,11 @@ namespace Luban.Job.Cfg.Datas { return this.Apply(ToStringVisitor.Ins); } + + public virtual int CompareTo(DType other) + { + throw new System.NotSupportedException(); + } } public abstract class DType : DType diff --git a/src/Luban.Job.Cfg/Source/RenderExtension.cs b/src/Luban.Job.Cfg/Source/RenderExtension.cs index 2cb09fd..42a8192 100644 --- a/src/Luban.Job.Cfg/Source/RenderExtension.cs +++ b/src/Luban.Job.Cfg/Source/RenderExtension.cs @@ -29,6 +29,7 @@ namespace Luban.Job.Cfg public static string RenderData(this Template template, DefTable table, List exportDatas, Dictionary extraModels = null) { var ctx = new TemplateContext(); + var env = new DTypeTemplateExtends { ["table"] = table, diff --git a/src/Luban.Job.Cfg/Source/Utils/DTypeTemplateExtends.cs b/src/Luban.Job.Cfg/Source/Utils/DTypeTemplateExtends.cs index 160fc73..916a934 100644 --- a/src/Luban.Job.Cfg/Source/Utils/DTypeTemplateExtends.cs +++ b/src/Luban.Job.Cfg/Source/Utils/DTypeTemplateExtends.cs @@ -1,6 +1,7 @@ using Luban.Job.Cfg.Datas; using Luban.Job.Cfg.DataVisitors; using Luban.Job.Cfg.Defs; +using System.Collections.Generic; namespace Luban.Job.Cfg.Utils { @@ -66,5 +67,22 @@ namespace Luban.Job.Cfg.Utils { return type.Apply(ToErlangLiteralVisitor.Ins); } + + public static List SortDataList(List datas, string indexName, bool asce) + { + var sortedDatas = new List(datas); + if (sortedDatas.Count > 1) + { + if (asce) + { + sortedDatas.Sort((a, b) => a.GetField(indexName).CompareTo(b.GetField(indexName))); + } + else + { + sortedDatas.Sort((a, b) => -a.GetField(indexName).CompareTo(b.GetField(indexName))); + } + } + return sortedDatas; + } } }