183 lines
7.4 KiB
C#
183 lines
7.4 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Text.Json;
|
|
using Erp.Platform.Enums;
|
|
using Erp.Platform.ListForms;
|
|
using Erp.Platform.Queries;
|
|
using static Erp.Platform.PlatformConsts;
|
|
|
|
namespace Erp.Platform.PlatformSeeder;
|
|
|
|
public static class SeederDefaults
|
|
{
|
|
public static string DefaultDeleteCommand(string tableName)
|
|
{
|
|
return $"UPDATE \"{TableNameResolver.GetFullTableName(tableName)}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id";
|
|
}
|
|
|
|
public static readonly string DefaultInsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[]
|
|
{
|
|
new() { FieldName = "CreationTime", FieldDbType = DbType.DateTime, Value = "@NOW", CustomValueType = FieldCustomValueTypeEnum.CustomKey },
|
|
new() { FieldName = "CreatorId", FieldDbType = DbType.Guid, Value = "@USERID", CustomValueType = FieldCustomValueTypeEnum.CustomKey },
|
|
new() { FieldName = "IsDeleted", FieldDbType = DbType.Boolean, Value = "false", CustomValueType = FieldCustomValueTypeEnum.Value },
|
|
new() { FieldName = "Id", FieldDbType = DbType.Guid, Value = "@NEWID", CustomValueType = FieldCustomValueTypeEnum.CustomKey }
|
|
});
|
|
|
|
public static readonly string DefaultDeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[]
|
|
{
|
|
new() { FieldName = "DeleterId", FieldDbType = DbType.Guid, Value = "@USERID", CustomValueType = FieldCustomValueTypeEnum.CustomKey },
|
|
new() { FieldName = "Id", FieldDbType = DbType.Guid, Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey }
|
|
});
|
|
|
|
public static string DefaultEditingOptionJson(
|
|
string Title,
|
|
int Width,
|
|
int Height,
|
|
bool AllowDeleting,
|
|
bool AllowAdding,
|
|
bool AllowUpdating,
|
|
bool ConfirmDelete,
|
|
bool SendOnlyChangedFormValuesUpdate) => JsonSerializer.Serialize(new GridEditingDto
|
|
{
|
|
Popup = new GridEditingPopupDto() { Title = Title, Width = Width, Height = Height },
|
|
AllowDeleting = AllowDeleting,
|
|
AllowAdding = AllowAdding,
|
|
AllowUpdating = AllowUpdating,
|
|
ConfirmDelete = ConfirmDelete,
|
|
SendOnlyChangedFormValuesUpdate = SendOnlyChangedFormValuesUpdate
|
|
});
|
|
|
|
public static readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'";
|
|
public static readonly string DefaultFilterRowJson = JsonSerializer.Serialize(new GridFilterRowDto { Visible = true });
|
|
public static readonly string DefaultHeaderFilterJson = JsonSerializer.Serialize(new { Visible = true });
|
|
public static readonly string DefaultSearchPanelJson = JsonSerializer.Serialize(new { Visible = true });
|
|
public static readonly string DefaultGroupPanelJson = JsonSerializer.Serialize(new { Visible = true });
|
|
public static readonly string DefaultColumnOptionJson = JsonSerializer.Serialize(new
|
|
{
|
|
ColumnFixingEnabled = false,
|
|
ColumnAutoWidth = true,
|
|
ColumnChooserEnabled = true,
|
|
AllowColumnResizing = true,
|
|
AllowColumnReordering = true,
|
|
ColumnResizingMode = "widget",
|
|
FocusRowEnabled = true,
|
|
});
|
|
public static readonly string DefaultLayoutJson = JsonSerializer.Serialize(new LayoutDto()
|
|
{
|
|
Grid = true,
|
|
Card = true,
|
|
Pivot = true,
|
|
Chart = true,
|
|
DefaultLayout = "grid",
|
|
CardLayoutColumn = 4
|
|
});
|
|
public static readonly string DefaultExportJson = JsonSerializer.Serialize(new ChartExportDto
|
|
{
|
|
Enabled = true,
|
|
AllowExportSelectedData = false,
|
|
PrintingEnabled = true,
|
|
BackgroundColor = "#FFFFFF",
|
|
Margin = 10
|
|
});
|
|
public static readonly string DefaultSelectionSingleJson = JsonSerializer.Serialize(new SelectionDto
|
|
{
|
|
Mode = GridOptions.SelectionModeNone,
|
|
AllowSelectAll = false
|
|
});
|
|
public static readonly string DefaultSelectionMultipleJson = JsonSerializer.Serialize(new SelectionDto
|
|
{
|
|
AllowSelectAll = true,
|
|
Mode = GridOptions.SelectionModeMultiple,
|
|
SelectAllMode = GridOptions.SelectionAllModeAllPages
|
|
});
|
|
public static string DefaultTreeOptionJson(string KeyExpr, string ParentIdExpr, bool AutoExpandAll = true) => JsonSerializer.Serialize(new TreeOptionDto
|
|
{
|
|
KeyExpr = KeyExpr,
|
|
ParentIdExpr = ParentIdExpr,
|
|
RootValue = null,
|
|
AutoExpandAll = AutoExpandAll
|
|
});
|
|
public static readonly string DefaultPagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto
|
|
{
|
|
Visible = true,
|
|
AllowedPageSizes = "10,20,50,100",
|
|
ShowPageSizeSelector = true,
|
|
ShowNavigationButtons = true,
|
|
ShowInfo = false,
|
|
InfoText = "Page {0} of {1} ({2} items)",
|
|
DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive,
|
|
ScrollingMode = GridColumnOptions.ScrollingModeStandard,
|
|
LoadPanelEnabled = "auto",
|
|
LoadPanelText = "Loading..."
|
|
});
|
|
public static readonly string DefaultColumnCustomizationJson = JsonSerializer.Serialize(new ColumnCustomizationDto
|
|
{
|
|
AllowReordering = true,
|
|
});
|
|
public static readonly string DefaultPivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto
|
|
{
|
|
IsPivot = true
|
|
});
|
|
public static readonly string DefaultValidationRuleRequiredJson = JsonSerializer.Serialize(new ValidationRuleDto[]
|
|
{
|
|
new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required) }
|
|
});
|
|
public static readonly string DefaultValidationRuleEmailJson = JsonSerializer.Serialize(new ValidationRuleDto[]
|
|
{
|
|
new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.email), Reevaluate = true, IgnoreEmptyValue = true }
|
|
});
|
|
public static readonly string DefaultValidationRuleEmailRequiredJson = JsonSerializer.Serialize(new ValidationRuleDto[]
|
|
{
|
|
new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.email) },
|
|
});
|
|
public static string DefaultPermissionJson(string c, string r, string u, string d, string e, string i, string a)
|
|
{
|
|
return JsonSerializer.Serialize(new PermissionCrudDto
|
|
{
|
|
C = c,
|
|
R = r,
|
|
U = u,
|
|
D = d,
|
|
E = e,
|
|
I = i,
|
|
N = a,
|
|
});
|
|
}
|
|
public static string DefaultPermissionJson(string permissionName)
|
|
{
|
|
return JsonSerializer.Serialize(new PermissionCrudDto
|
|
{
|
|
C = permissionName + ".Create",
|
|
R = permissionName,
|
|
U = permissionName + ".Update",
|
|
D = permissionName + ".Delete",
|
|
E = permissionName + ".Export",
|
|
I = permissionName + ".Import",
|
|
N = permissionName + ".Note",
|
|
});
|
|
}
|
|
public static string DefaultFieldPermissionJson(string permissionName)
|
|
{
|
|
return JsonSerializer.Serialize(new ListFormFieldPermissionDto
|
|
{
|
|
C = permissionName + ".Create",
|
|
R = permissionName,
|
|
U = permissionName + ".Update",
|
|
E = true,
|
|
I = false,
|
|
Deny = false
|
|
});
|
|
}
|
|
public static string DefaultFieldPermissionJson(string c, string r, string u, bool e, bool i, bool d)
|
|
{
|
|
return JsonSerializer.Serialize(new ListFormFieldPermissionDto
|
|
{
|
|
C = c,
|
|
R = r,
|
|
U = u,
|
|
E = e,
|
|
I = i,
|
|
Deny = d
|
|
});
|
|
}
|
|
}
|