2025-11-11 19:49:52 +00:00
using System ;
2025-11-07 08:52:33 +00:00
using System.Data ;
2025-11-02 12:13:06 +00:00
using System.Text.Json ;
2025-11-11 19:49:52 +00:00
using Erp.Platform.Enums ;
using Erp.Platform.ListForms ;
using Erp.Platform.Queries ;
using static Erp . Platform . PlatformConsts ;
2025-11-02 12:13:06 +00:00
2025-11-11 19:49:52 +00:00
namespace Erp.Platform.PlatformSeeder ;
2025-11-02 12:13:06 +00:00
2025-11-02 13:29:37 +00:00
public static class SeederDefaults
2025-11-02 12:13:06 +00:00
{
2025-11-07 08:52:33 +00:00
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 } ,
2025-11-08 09:42:38 +00:00
new ( ) { FieldName = "IsDeleted" , FieldDbType = DbType . Boolean , Value = "false" , CustomValueType = FieldCustomValueTypeEnum . Value } ,
new ( ) { FieldName = "Id" , FieldDbType = DbType . Guid , Value = "@NEWID" , CustomValueType = FieldCustomValueTypeEnum . CustomKey }
2025-11-07 08:52:33 +00:00
} ) ;
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 }
} ) ;
2025-11-08 13:50:20 +00:00
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
} ) ;
2025-11-02 12:13:06 +00:00
public static readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'" ;
2025-11-14 19:32:36 +00:00
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 } ) ;
2025-11-02 12:13:06 +00:00
public static readonly string DefaultColumnOptionJson = JsonSerializer . Serialize ( new
{
ColumnFixingEnabled = true ,
ColumnAutoWidth = true ,
ColumnChooserEnabled = true ,
AllowColumnResizing = true ,
AllowColumnReordering = true ,
ColumnResizingMode = "widget" ,
} ) ;
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 DefaultSelectionSingleJson = JsonSerializer . Serialize ( new SelectionDto
{
Mode = GridOptions . SelectionModeSingle ,
AllowSelectAll = false
} ) ;
public static readonly string DefaultSelectionMultipleJson = JsonSerializer . Serialize ( new SelectionDto
{
AllowSelectAll = true ,
Mode = GridOptions . SelectionModeMultiple ,
SelectAllMode = GridOptions . SelectionAllModeAllPages
} ) ;
2025-11-08 20:22:50 +00:00
public static string DefaultTreeOptionJson ( string KeyExpr , string ParentIdExpr , bool AutoExpandAll = true ) = > JsonSerializer . Serialize ( new TreeOptionDto
2025-11-08 13:50:20 +00:00
{
2025-11-08 20:22:50 +00:00
KeyExpr = KeyExpr ,
2025-11-08 13:50:20 +00:00
ParentIdExpr = ParentIdExpr ,
RootValue = null ,
AutoExpandAll = AutoExpandAll
} ) ;
2025-11-02 12:13:06 +00:00
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 [ ]
{
2025-11-04 13:14:40 +00:00
new ( ) { Type = Enum . GetName ( UiColumnValidationRuleTypeEnum . required ) }
2025-11-02 12:13:06 +00:00
} ) ;
public static readonly string DefaultValidationRuleEmailJson = JsonSerializer . Serialize ( new ValidationRuleDto [ ]
{
2025-11-04 13:14:40 +00:00
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 ) } ,
2025-11-02 12:13:06 +00:00
} ) ;
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 ,
A = 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" ,
A = permissionName + ".Activity" ,
} ) ;
}
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
} ) ;
}
2025-11-11 19:49:52 +00:00
}