TagBox ve GridBoxların Raporda gösterildi
This commit is contained in:
parent
bfaa5224d6
commit
5970221681
4 changed files with 103 additions and 9 deletions
|
|
@ -686,15 +686,16 @@ public class DynamicFormReport : XtraReport
|
||||||
{
|
{
|
||||||
var bindingName = DynamicReportImageHelper.GetReportFieldName(selectField);
|
var bindingName = DynamicReportImageHelper.GetReportFieldName(selectField);
|
||||||
var lookup = DynamicReportImageHelper.GetLookup(field);
|
var lookup = DynamicReportImageHelper.GetLookup(field);
|
||||||
|
var isMultiValue = IsMultiValueLookupEditor(editorType);
|
||||||
|
|
||||||
if (lookup == null || selectField?.JoinOptions != null)
|
if (lookup == null || selectField?.JoinOptions != null)
|
||||||
{
|
{
|
||||||
return new FormReportField(field, bindingName, editorType, columnSpan, null, null, DynamicReportImageHelper.IsImageEditor(editorType));
|
return new FormReportField(field, bindingName, editorType, columnSpan, null, null, isMultiValue, DynamicReportImageHelper.IsImageEditor(editorType));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DynamicReportSqlBuilder.IsReportQueryableLookup(lookup))
|
if (DynamicReportSqlBuilder.IsReportQueryableLookup(lookup))
|
||||||
{
|
{
|
||||||
return new FormReportField(field, DynamicReportSqlBuilder.GetLookupBindingName(field), editorType, columnSpan, lookup, null, false);
|
return new FormReportField(field, DynamicReportSqlBuilder.GetLookupBindingName(field), editorType, columnSpan, lookup, null, isMultiValue, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lookup.DataSourceType == UiLookupDataSourceTypeEnum.StaticData)
|
if (lookup.DataSourceType == UiLookupDataSourceTypeEnum.StaticData)
|
||||||
|
|
@ -707,10 +708,16 @@ public class DynamicFormReport : XtraReport
|
||||||
columnSpan,
|
columnSpan,
|
||||||
lookup,
|
lookup,
|
||||||
staticLookupValues,
|
staticLookupValues,
|
||||||
|
isMultiValue,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FormReportField(field, bindingName, editorType, columnSpan, null, null, DynamicReportImageHelper.IsImageEditor(editorType));
|
return new FormReportField(field, bindingName, editorType, columnSpan, null, null, isMultiValue, DynamicReportImageHelper.IsImageEditor(editorType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsMultiValueLookupEditor(string editorType)
|
||||||
|
{
|
||||||
|
return editorType is PlatformConsts.EditorTypes.dxTagBox or "dxGridBox";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string CreateKeyFilter(string keyFieldName, string id)
|
private static string CreateKeyFilter(string keyFieldName, string id)
|
||||||
|
|
@ -749,5 +756,6 @@ public class DynamicFormReport : XtraReport
|
||||||
int ColumnSpan,
|
int ColumnSpan,
|
||||||
LookupDto Lookup,
|
LookupDto Lookup,
|
||||||
Dictionary<string, string> StaticLookupValues,
|
Dictionary<string, string> StaticLookupValues,
|
||||||
|
bool IsMultiValue,
|
||||||
bool IsImage) : DynamicReportSqlBuilder.IReportLookupColumn;
|
bool IsImage) : DynamicReportSqlBuilder.IReportLookupColumn;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -567,15 +567,16 @@ public class DynamicGridReport : XtraReport
|
||||||
{
|
{
|
||||||
var bindingName = DynamicReportImageHelper.GetReportFieldName(selectField);
|
var bindingName = DynamicReportImageHelper.GetReportFieldName(selectField);
|
||||||
var lookup = DynamicReportImageHelper.GetLookup(field);
|
var lookup = DynamicReportImageHelper.GetLookup(field);
|
||||||
|
var isMultiValue = IsMultiValueLookupEditor(editorType);
|
||||||
|
|
||||||
if (lookup == null || selectField?.JoinOptions != null)
|
if (lookup == null || selectField?.JoinOptions != null)
|
||||||
{
|
{
|
||||||
return new ReportColumn(field, bindingName, null, null, isImage, isHtml, editorType);
|
return new ReportColumn(field, bindingName, null, null, isMultiValue, isImage, isHtml, editorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DynamicReportSqlBuilder.IsReportQueryableLookup(lookup))
|
if (DynamicReportSqlBuilder.IsReportQueryableLookup(lookup))
|
||||||
{
|
{
|
||||||
return new ReportColumn(field, DynamicReportSqlBuilder.GetLookupBindingName(field), lookup, null, isImage, isHtml, editorType);
|
return new ReportColumn(field, DynamicReportSqlBuilder.GetLookupBindingName(field), lookup, null, isMultiValue, isImage, isHtml, editorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lookup.DataSourceType == UiLookupDataSourceTypeEnum.StaticData)
|
if (lookup.DataSourceType == UiLookupDataSourceTypeEnum.StaticData)
|
||||||
|
|
@ -586,12 +587,18 @@ public class DynamicGridReport : XtraReport
|
||||||
staticLookupValues?.Count > 0 ? DynamicReportSqlBuilder.GetLookupBindingName(field) : bindingName,
|
staticLookupValues?.Count > 0 ? DynamicReportSqlBuilder.GetLookupBindingName(field) : bindingName,
|
||||||
lookup,
|
lookup,
|
||||||
staticLookupValues,
|
staticLookupValues,
|
||||||
|
isMultiValue,
|
||||||
isImage,
|
isImage,
|
||||||
isHtml,
|
isHtml,
|
||||||
editorType);
|
editorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReportColumn(field, bindingName, null, null, isImage, isHtml, editorType);
|
return new ReportColumn(field, bindingName, null, null, isMultiValue, isImage, isHtml, editorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsMultiValueLookupEditor(string editorType)
|
||||||
|
{
|
||||||
|
return editorType is PlatformConsts.EditorTypes.dxTagBox or "dxGridBox";
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed record ReportColumn(
|
private sealed record ReportColumn(
|
||||||
|
|
@ -599,6 +606,7 @@ public class DynamicGridReport : XtraReport
|
||||||
string BindingName,
|
string BindingName,
|
||||||
LookupDto Lookup,
|
LookupDto Lookup,
|
||||||
Dictionary<string, string> StaticLookupValues,
|
Dictionary<string, string> StaticLookupValues,
|
||||||
|
bool IsMultiValue,
|
||||||
bool IsImage,
|
bool IsImage,
|
||||||
bool IsHtml,
|
bool IsHtml,
|
||||||
string EditorType,
|
string EditorType,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ internal static class DynamicReportSqlBuilder
|
||||||
string BindingName { get; }
|
string BindingName { get; }
|
||||||
LookupDto Lookup { get; }
|
LookupDto Lookup { get; }
|
||||||
Dictionary<string, string> StaticLookupValues { get; }
|
Dictionary<string, string> StaticLookupValues { get; }
|
||||||
|
bool IsMultiValue { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetLookupBindingName(ListFormField field)
|
internal static string GetLookupBindingName(ListFormField field)
|
||||||
|
|
@ -92,6 +93,11 @@ internal static class DynamicReportSqlBuilder
|
||||||
IReportLookupColumn column,
|
IReportLookupColumn column,
|
||||||
DataSourceTypeEnum dataSourceType)
|
DataSourceTypeEnum dataSourceType)
|
||||||
{
|
{
|
||||||
|
if (column.IsMultiValue)
|
||||||
|
{
|
||||||
|
return CreateStaticMultiLookupSelectPart(column, dataSourceType);
|
||||||
|
}
|
||||||
|
|
||||||
var sourceField = GetSourceField(column.Field.FieldName);
|
var sourceField = GetSourceField(column.Field.FieldName);
|
||||||
var cases = column.StaticLookupValues
|
var cases = column.StaticLookupValues
|
||||||
.Select(item => $"WHEN {DynamicReportImageHelper.ToSqlLiteral(item.Key, dataSourceType)} THEN {DynamicReportImageHelper.ToSqlLiteral(item.Value, dataSourceType)}");
|
.Select(item => $"WHEN {DynamicReportImageHelper.ToSqlLiteral(item.Key, dataSourceType)} THEN {DynamicReportImageHelper.ToSqlLiteral(item.Value, dataSourceType)}");
|
||||||
|
|
@ -110,6 +116,11 @@ internal static class DynamicReportSqlBuilder
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (column.IsMultiValue)
|
||||||
|
{
|
||||||
|
return CreateQueryMultiLookupSelectPart(column, lookupQuery, dataSourceType);
|
||||||
|
}
|
||||||
|
|
||||||
var lookupAlias = QuoteSqlIdentifier(LookupAlias);
|
var lookupAlias = QuoteSqlIdentifier(LookupAlias);
|
||||||
var valueExpr = QuoteSqlIdentifier(column.Lookup.ValueExpr ?? "Key");
|
var valueExpr = QuoteSqlIdentifier(column.Lookup.ValueExpr ?? "Key");
|
||||||
var displayExpr = QuoteSqlIdentifier(column.Lookup.DisplayExpr ?? "Name");
|
var displayExpr = QuoteSqlIdentifier(column.Lookup.DisplayExpr ?? "Name");
|
||||||
|
|
@ -123,6 +134,65 @@ internal static class DynamicReportSqlBuilder
|
||||||
return $"({scalarQuery}) AS {resultAlias}";
|
return $"({scalarQuery}) AS {resultAlias}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string CreateStaticMultiLookupSelectPart(
|
||||||
|
IReportLookupColumn column,
|
||||||
|
DataSourceTypeEnum dataSourceType)
|
||||||
|
{
|
||||||
|
var sourceField = GetSourceField(column.Field.FieldName);
|
||||||
|
var resultAlias = QuoteSqlIdentifier(column.BindingName);
|
||||||
|
var values = string.Join(
|
||||||
|
", ",
|
||||||
|
column.StaticLookupValues.Select(item =>
|
||||||
|
$"({DynamicReportImageHelper.ToSqlLiteral(item.Key, dataSourceType)}, {DynamicReportImageHelper.ToSqlLiteral(item.Value, dataSourceType)})"));
|
||||||
|
|
||||||
|
if (dataSourceType == DataSourceTypeEnum.Mssql)
|
||||||
|
{
|
||||||
|
return $"""
|
||||||
|
(SELECT STRING_AGG(CAST({LookupAliasForValues()}.DisplayValue AS NVARCHAR(MAX)), N', ')
|
||||||
|
FROM (VALUES {values}) AS {LookupAliasForValues()}(ValueKey, DisplayValue)
|
||||||
|
INNER JOIN STRING_SPLIT(CAST({sourceField} AS NVARCHAR(MAX)), N'{PlatformConsts.MultiValueDelimiter}') AS SplitValues
|
||||||
|
ON CAST({LookupAliasForValues()}.ValueKey AS NVARCHAR(4000)) = LTRIM(RTRIM(SplitValues.value))) AS {resultAlias}
|
||||||
|
""".ReplaceLineEndings(" ").Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"""
|
||||||
|
(SELECT string_agg(CAST({LookupAliasForValues()}."DisplayValue" AS TEXT), ', ')
|
||||||
|
FROM (VALUES {values}) AS {LookupAliasForValues()}("ValueKey", "DisplayValue")
|
||||||
|
INNER JOIN unnest(string_to_array(CAST({sourceField} AS TEXT), '{PlatformConsts.MultiValueDelimiter}')) AS SplitValues(value)
|
||||||
|
ON CAST({LookupAliasForValues()}."ValueKey" AS TEXT) = btrim(SplitValues.value)) AS {resultAlias}
|
||||||
|
""".ReplaceLineEndings(" ").Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string CreateQueryMultiLookupSelectPart(
|
||||||
|
IReportLookupColumn column,
|
||||||
|
string lookupQuery,
|
||||||
|
DataSourceTypeEnum dataSourceType)
|
||||||
|
{
|
||||||
|
var lookupAlias = QuoteSqlIdentifier(LookupAlias);
|
||||||
|
var valueExpr = QuoteSqlIdentifier(column.Lookup.ValueExpr ?? "Key");
|
||||||
|
var displayExpr = QuoteSqlIdentifier(column.Lookup.DisplayExpr ?? "Name");
|
||||||
|
var sourceField = GetSourceField(column.Field.FieldName);
|
||||||
|
var resultAlias = QuoteSqlIdentifier(column.BindingName);
|
||||||
|
|
||||||
|
var scalarQuery = dataSourceType == DataSourceTypeEnum.Mssql
|
||||||
|
? $"""
|
||||||
|
SELECT STRING_AGG(CAST({lookupAlias}.{displayExpr} AS NVARCHAR(MAX)), N', ')
|
||||||
|
FROM ({lookupQuery}) AS {lookupAlias}
|
||||||
|
INNER JOIN STRING_SPLIT(CAST({sourceField} AS NVARCHAR(MAX)), N'{PlatformConsts.MultiValueDelimiter}') AS SplitValues
|
||||||
|
ON CAST({lookupAlias}.{valueExpr} AS NVARCHAR(4000)) = LTRIM(RTRIM(SplitValues.value))
|
||||||
|
""".ReplaceLineEndings(" ").Trim()
|
||||||
|
: $"""
|
||||||
|
SELECT string_agg(CAST({lookupAlias}.{displayExpr} AS TEXT), ', ')
|
||||||
|
FROM ({lookupQuery}) AS {lookupAlias}
|
||||||
|
INNER JOIN unnest(string_to_array(CAST({sourceField} AS TEXT), '{PlatformConsts.MultiValueDelimiter}')) AS SplitValues(value)
|
||||||
|
ON CAST({lookupAlias}.{valueExpr} AS TEXT) = btrim(SplitValues.value)
|
||||||
|
""".ReplaceLineEndings(" ").Trim();
|
||||||
|
|
||||||
|
return $"({scalarQuery}) AS {resultAlias}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string LookupAliasForValues() => "LookupValues";
|
||||||
|
|
||||||
private static string GetSourceField(string fieldName)
|
private static string GetSourceField(string fieldName)
|
||||||
{
|
{
|
||||||
return $"{QuoteSqlIdentifier(SourceAlias)}.{QuoteSqlIdentifier(fieldName)}";
|
return $"{QuoteSqlIdentifier(SourceAlias)}.{QuoteSqlIdentifier(fieldName)}";
|
||||||
|
|
|
||||||
|
|
@ -715,15 +715,16 @@ public class DynamicTreeReport : XtraReport
|
||||||
{
|
{
|
||||||
var bindingName = DynamicReportImageHelper.GetReportFieldName(selectField);
|
var bindingName = DynamicReportImageHelper.GetReportFieldName(selectField);
|
||||||
var lookup = DynamicReportImageHelper.GetLookup(field);
|
var lookup = DynamicReportImageHelper.GetLookup(field);
|
||||||
|
var isMultiValue = IsMultiValueLookupEditor(editorType);
|
||||||
|
|
||||||
if (lookup == null || selectField?.JoinOptions != null)
|
if (lookup == null || selectField?.JoinOptions != null)
|
||||||
{
|
{
|
||||||
return new ReportColumn(field, bindingName, null, null, isImage, isHtml, editorType);
|
return new ReportColumn(field, bindingName, null, null, isMultiValue, isImage, isHtml, editorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DynamicReportSqlBuilder.IsReportQueryableLookup(lookup))
|
if (DynamicReportSqlBuilder.IsReportQueryableLookup(lookup))
|
||||||
{
|
{
|
||||||
return new ReportColumn(field, DynamicReportSqlBuilder.GetLookupBindingName(field), lookup, null, isImage, isHtml, editorType);
|
return new ReportColumn(field, DynamicReportSqlBuilder.GetLookupBindingName(field), lookup, null, isMultiValue, isImage, isHtml, editorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lookup.DataSourceType == UiLookupDataSourceTypeEnum.StaticData)
|
if (lookup.DataSourceType == UiLookupDataSourceTypeEnum.StaticData)
|
||||||
|
|
@ -734,12 +735,18 @@ public class DynamicTreeReport : XtraReport
|
||||||
staticLookupValues?.Count > 0 ? DynamicReportSqlBuilder.GetLookupBindingName(field) : bindingName,
|
staticLookupValues?.Count > 0 ? DynamicReportSqlBuilder.GetLookupBindingName(field) : bindingName,
|
||||||
lookup,
|
lookup,
|
||||||
staticLookupValues,
|
staticLookupValues,
|
||||||
|
isMultiValue,
|
||||||
isImage,
|
isImage,
|
||||||
isHtml,
|
isHtml,
|
||||||
editorType);
|
editorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ReportColumn(field, bindingName, null, null, isImage, isHtml, editorType);
|
return new ReportColumn(field, bindingName, null, null, isMultiValue, isImage, isHtml, editorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsMultiValueLookupEditor(string editorType)
|
||||||
|
{
|
||||||
|
return editorType is PlatformConsts.EditorTypes.dxTagBox or "dxGridBox";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TreeOptionDto GetTreeOptions(ListForm listForm)
|
private static TreeOptionDto GetTreeOptions(ListForm listForm)
|
||||||
|
|
@ -767,6 +774,7 @@ public class DynamicTreeReport : XtraReport
|
||||||
string BindingName,
|
string BindingName,
|
||||||
LookupDto Lookup,
|
LookupDto Lookup,
|
||||||
Dictionary<string, string> StaticLookupValues,
|
Dictionary<string, string> StaticLookupValues,
|
||||||
|
bool IsMultiValue,
|
||||||
bool IsImage,
|
bool IsImage,
|
||||||
bool IsHtml,
|
bool IsHtml,
|
||||||
string EditorType,
|
string EditorType,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue