【修复】修复读取多行记录的bug
parent
258f657ce8
commit
5181b1f305
|
|
@ -262,7 +262,7 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
|
||||
public DType Accept(TText type, ExcelStream x)
|
||||
{
|
||||
x = SepIfNeed(type, x);
|
||||
//x = SepIfNeed(type, x);
|
||||
string key = ParseString(x.Read());
|
||||
if (key == null)
|
||||
{
|
||||
|
|
@ -313,23 +313,26 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
return list;
|
||||
}
|
||||
|
||||
public static ExcelStream SepIfNeed(TType type, ExcelStream stream)
|
||||
{
|
||||
string sep = DataUtil.GetSep(type);
|
||||
if (!string.IsNullOrEmpty(sep))
|
||||
{
|
||||
return new ExcelStream(stream.ReadCell(), sep);
|
||||
}
|
||||
else
|
||||
{
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
//public static ExcelStream SepIfNeed(TType type, ExcelStream stream)
|
||||
//{
|
||||
// string sep = DataUtil.GetSep(type);
|
||||
// if (!string.IsNullOrEmpty(sep))
|
||||
// {
|
||||
// return new ExcelStream(stream.ReadCell(), sep);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return stream;
|
||||
// }
|
||||
//}
|
||||
|
||||
public DType Accept(TBean type, ExcelStream x)
|
||||
{
|
||||
var originBean = (DefBean)type.Bean;
|
||||
x = SepIfNeed(type, x);
|
||||
if (!string.IsNullOrEmpty(originBean.Sep))
|
||||
{
|
||||
x = new ExcelStream(x.ReadCell(), originBean.Sep);
|
||||
}
|
||||
|
||||
if (originBean.IsAbstractType)
|
||||
{
|
||||
|
|
@ -382,22 +385,22 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
|
||||
public DType Accept(TArray type, ExcelStream x)
|
||||
{
|
||||
return new DArray(type, ReadList(type.ElementType, SepIfNeed(type, x)));
|
||||
return new DArray(type, ReadList(type.ElementType, x));
|
||||
}
|
||||
|
||||
public DType Accept(TList type, ExcelStream x)
|
||||
{
|
||||
return new DList(type, ReadList(type.ElementType, SepIfNeed(type, x)));
|
||||
return new DList(type, ReadList(type.ElementType, x));
|
||||
}
|
||||
|
||||
public DType Accept(TSet type, ExcelStream x)
|
||||
{
|
||||
return new DSet(type, ReadList(type.ElementType, SepIfNeed(type, x)));
|
||||
return new DSet(type, ReadList(type.ElementType, x));
|
||||
}
|
||||
|
||||
public DType Accept(TMap type, ExcelStream x)
|
||||
{
|
||||
x = SepIfNeed(type, x);
|
||||
//x = SepIfNeed(type, x);
|
||||
|
||||
var datas = new Dictionary<DType, DType>();
|
||||
while (!x.TryReadEOF())
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
|
||||
public DType Accept(TBean type, Sheet sheet, TitleRow row)
|
||||
{
|
||||
string sep = DataUtil.GetSep(type);
|
||||
//string sep = DataUtil.GetSep(type);
|
||||
|
||||
if (row.Row != null)
|
||||
{
|
||||
|
|
@ -367,7 +367,7 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
}
|
||||
else if (row.Elements != null)
|
||||
{
|
||||
var s = row.AsMultiRowConcatElements(sep);
|
||||
var s = row.AsMultiRowConcatElements();
|
||||
return type.Apply(ExcelStreamDataCreator.Ins, s);
|
||||
}
|
||||
else
|
||||
|
|
@ -401,16 +401,16 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
|
||||
public DType Accept(TArray type, Sheet sheet, TitleRow row)
|
||||
{
|
||||
string sep = DataUtil.GetSep(type);
|
||||
//string sep = DataUtil.GetSep(type);
|
||||
|
||||
if (row.Row != null)
|
||||
{
|
||||
var s = row.AsStream(sep);
|
||||
var s = row.AsStream(DataUtil.GetTypeSep(type.ElementType));
|
||||
return new DArray(type, ReadList(type.ElementType, s));
|
||||
}
|
||||
else if (row.Rows != null)
|
||||
{
|
||||
var s = row.AsMultiRowStream(sep);
|
||||
var s = row.AsMultiRowStream(DataUtil.GetTypeSep(type.ElementType));
|
||||
return new DArray(type, ReadList(type.ElementType, s));
|
||||
}
|
||||
else if (row.Fields != null)
|
||||
|
|
@ -429,16 +429,14 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
|
||||
public DType Accept(TList type, Sheet sheet, TitleRow row)
|
||||
{
|
||||
string sep = DataUtil.GetSep(type);
|
||||
|
||||
if (row.Row != null)
|
||||
{
|
||||
var s = row.AsStream(sep);
|
||||
var s = row.AsStream(DataUtil.GetTypeSep(type.ElementType));
|
||||
return new DList(type, ReadList(type.ElementType, s));
|
||||
}
|
||||
else if (row.Rows != null)
|
||||
{
|
||||
var s = row.AsMultiRowStream(sep);
|
||||
var s = row.AsMultiRowStream(DataUtil.GetTypeSep(type.ElementType));
|
||||
return new DList(type, ReadList(type.ElementType, s));
|
||||
}
|
||||
else if (row.Fields != null)
|
||||
|
|
@ -457,16 +455,14 @@ namespace Luban.Job.Cfg.DataCreators
|
|||
|
||||
public DType Accept(TSet type, Sheet sheet, TitleRow row)
|
||||
{
|
||||
string sep = DataUtil.GetSep(type);
|
||||
|
||||
if (row.Row != null)
|
||||
{
|
||||
var s = row.AsStream(sep);
|
||||
var s = row.AsStream(DataUtil.GetTypeSep(type.ElementType));
|
||||
return new DSet(type, ReadList(type.ElementType, s));
|
||||
}
|
||||
else if (row.Rows != null)
|
||||
{
|
||||
var s = row.AsMultiRowStream(sep);
|
||||
var s = row.AsMultiRowStream(DataUtil.GetTypeSep(type.ElementType));
|
||||
return new DSet(type, ReadList(type.ElementType, s));
|
||||
}
|
||||
else if (row.Fields != null)
|
||||
|
|
|
|||
|
|
@ -151,10 +151,9 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
|||
return new ExcelStream(Rows, SelfTitle.FromIndex, SelfTitle.ToIndex, sep, SelfTitle.Default);
|
||||
}
|
||||
|
||||
public ExcelStream AsMultiRowConcatElements(string sep)
|
||||
public ExcelStream AsMultiRowConcatElements()
|
||||
{
|
||||
sep = string.IsNullOrEmpty(sep) ? SelfTitle.Sep : sep;
|
||||
return new ExcelStream(Elements.Select(e => e.Row).ToList(), SelfTitle.FromIndex, SelfTitle.ToIndex, sep, SelfTitle.Default);
|
||||
return new ExcelStream(Elements.Select(e => e.Row).ToList(), SelfTitle.FromIndex, SelfTitle.ToIndex, SelfTitle.Sep, SelfTitle.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ namespace Luban.Job.Cfg.Utils
|
|||
return tags.Count > 0 ? tags : null;
|
||||
}
|
||||
|
||||
const string SimpleContainerSep = ",;";
|
||||
public const string SimpleContainerSep = ",;";
|
||||
|
||||
public static string GetSep(TType type)
|
||||
{
|
||||
|
|
@ -158,6 +158,17 @@ namespace Luban.Job.Cfg.Utils
|
|||
}
|
||||
}
|
||||
|
||||
public static string GetTypeSep(TType type)
|
||||
{
|
||||
if (type.Tags != null && type.Tags.TryGetValue("sep", out var s) && !string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
return type.Apply(IsNotSepTypeVisitor.Ins) ? SimpleContainerSep : "";
|
||||
|
||||
}
|
||||
|
||||
public static bool IsCollectionEqual(List<DType> a, List<DType> b)
|
||||
{
|
||||
if (a.Count == b.Count)
|
||||
|
|
|
|||
Loading…
Reference in New Issue