using System.Data; using System.Text.Json; using Sozsoft.Platform.Enums; using static Sozsoft.Platform.PlatformConsts; public static class WizardConsts { public static string WizardKey(string code) => $"{Prefix.App}.Wizard.{code}"; public static string WizardKeyTitle(string code) => $"{WizardKey(code)}.Title"; public static string WizardKeyDesc(string code) => $"{WizardKey(code)}.Desc"; public static string WizardKeyParent(string code) => $"{WizardKey(code)}.Parent"; public static string PermCreate(string code) => $"{WizardKey(code)}.Create"; public static string PermUpdate(string code) => $"{WizardKey(code)}.Update"; public static string PermDelete(string code) => $"{WizardKey(code)}.Delete"; public static string PermExport(string code) => $"{WizardKey(code)}.Export"; public static string PermImport(string code) => $"{WizardKey(code)}.Import"; public static string PermNote(string code) => $"{WizardKey(code)}.Note"; public static string LangKeyCreate => "Create"; public static string LangKeyUpdate => "Update"; public static string LangKeyDelete => "Delete"; public static string LangKeyExport => "Export"; public static string LangKeyImport => "Import"; public static string LangKeyNote => "Note"; public static string MenuUrl(string code) => $"/admin/list/{code}"; public static string MenuIcon => "FcList"; public static readonly string DefaultExportJson = JsonSerializer.Serialize(new { Enabled = true, AllowExportSelectedData = false, PrintingEnabled = true, BackgroundColor = "#FFFFFF", Margin = 10 }); public static string DefaultLayoutJson(string DefaultLayout = "grid") => JsonSerializer.Serialize(new { Grid = true, Pivot = true, Chart = true, Tree = true, Gantt = true, Scheduler = true, DefaultLayout = DefaultLayout, }); public static readonly string DefaultFilterJson = "\"IsDeleted\" = 'false'"; public static readonly string DefaultFilterRowJson = JsonSerializer.Serialize(new { 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 DefaultSelectionSingleJson = JsonSerializer.Serialize(new { Mode = GridOptions.SelectionModeNone, AllowSelectAll = false }); public static string DefaultColumnOptionJson(bool FocusedRowEnabled = true) => JsonSerializer.Serialize(new { ColumnFixingEnabled = true, ColumnAutoWidth = true, ColumnChooserEnabled = true, AllowColumnResizing = true, AllowColumnReordering = true, ColumnResizingMode = "widget", FocusedRowEnabled = FocusedRowEnabled, }); public static string DefaultPermissionJson(string permissionName) { return JsonSerializer.Serialize(new { C = permissionName + ".Create", R = permissionName, U = permissionName + ".Update", D = permissionName + ".Delete", E = permissionName + ".Export", I = permissionName + ".Import", N = permissionName + ".Note", }); } public static string DefaultDeleteCommand(string tableName) { return $"UPDATE \"{tableName}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id"; } public static string DefaultInsertFieldsDefaultValueJson(DbType dbType = DbType.Guid) { return JsonSerializer.Serialize(new[] { 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, Value = "@NEWID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }); } public static string DefaultDeleteFieldsDefaultValueJson(DbType dbType = DbType.Guid) { return JsonSerializer.Serialize(new[] { new { FieldName = "DeleterId", FieldDbType = DbType.Guid, Value = "@USERID", CustomValueType = FieldCustomValueTypeEnum.CustomKey }, new { FieldName = "Id", FieldDbType = dbType, Value = "@ID", CustomValueType = FieldCustomValueTypeEnum.CustomKey } }); } public static readonly string DefaultPagerOptionJson = JsonSerializer.Serialize(new { 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 string DefaultEditingOptionJson( string Title, int Width, int Height, bool AllowDeleting, bool AllowAdding, bool AllowEditing, bool ConfirmDelete, bool SendOnlyChangedFormValuesUpdate, bool AllowDetail = false) => JsonSerializer.Serialize(new { Popup = new { Title = Title, Width = Width, Height = Height }, AllowDeleting = AllowDeleting, AllowAdding = AllowAdding, AllowEditing = AllowEditing, ConfirmDelete = ConfirmDelete, SendOnlyChangedFormValuesUpdate = SendOnlyChangedFormValuesUpdate, AllowDetail = AllowDetail }); }