2026-03-04 13:47:25 +00:00
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
using Sozsoft.Platform.Enums;
|
|
|
|
|
|
using static Sozsoft.Platform.PlatformConsts;
|
2026-03-18 19:47:39 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
using System.Globalization;
|
2026-03-04 13:47:25 +00:00
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
|
2026-03-18 19:47:39 +00:00
|
|
|
|
public static class LabelHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string GetCamelCaseLabel<T>(string propertyName)
|
|
|
|
|
|
{
|
|
|
|
|
|
var prop = typeof(T).GetProperty(propertyName);
|
|
|
|
|
|
if (prop == null)
|
|
|
|
|
|
return propertyName;
|
|
|
|
|
|
|
|
|
|
|
|
// 1. Display varsa direkt onu kullan
|
|
|
|
|
|
var displayAttr = prop.GetCustomAttribute<DisplayAttribute>();
|
|
|
|
|
|
if (displayAttr != null && !string.IsNullOrWhiteSpace(displayAttr.Name))
|
|
|
|
|
|
return displayAttr.Name;
|
|
|
|
|
|
|
|
|
|
|
|
// 2. CamelCase → kelimelere ayır
|
|
|
|
|
|
var words = Regex
|
|
|
|
|
|
.Split(propertyName, "(?=[A-Z])")
|
|
|
|
|
|
.Where(x => !string.IsNullOrWhiteSpace(x))
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
// 3. Türkçe karakter dönüşümü + düzgün büyük harf
|
|
|
|
|
|
var culture = new CultureInfo("tr-TR");
|
|
|
|
|
|
|
|
|
|
|
|
words = words.Select(w =>
|
|
|
|
|
|
{
|
|
|
|
|
|
w = w.ToLower(culture);
|
|
|
|
|
|
|
|
|
|
|
|
// Türkçe karakter normalize (genel yaklaşım)
|
|
|
|
|
|
w = w
|
|
|
|
|
|
.Replace("i", "i") // bilinçli bırakıyoruz
|
|
|
|
|
|
.Replace("ı", "ı"); // zaten doğru
|
|
|
|
|
|
|
|
|
|
|
|
return culture.TextInfo.ToTitleCase(w);
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
return string.Join(" ", words);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-04 13:47:25 +00:00
|
|
|
|
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",
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-18 19:47:39 +00:00
|
|
|
|
public static string DefaultFieldPermissionJson(string permissionName)
|
|
|
|
|
|
{
|
|
|
|
|
|
return JsonSerializer.Serialize(new
|
|
|
|
|
|
{
|
|
|
|
|
|
C = permissionName + ".Create",
|
|
|
|
|
|
R = permissionName,
|
|
|
|
|
|
U = permissionName + ".Update",
|
|
|
|
|
|
E = true,
|
|
|
|
|
|
I = false,
|
|
|
|
|
|
Deny = false
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly string DefaultColumnCustomizationJson = JsonSerializer.Serialize(new
|
|
|
|
|
|
{
|
|
|
|
|
|
AllowReordering = true,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly string DefaultColumnFilteringJson = JsonSerializer.Serialize(new
|
|
|
|
|
|
{
|
|
|
|
|
|
AllowFiltering = true,
|
|
|
|
|
|
});
|
|
|
|
|
|
public static readonly string DefaultPivotSettingsJson = JsonSerializer.Serialize(new
|
|
|
|
|
|
{
|
|
|
|
|
|
IsPivot = true
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-04 13:47:25 +00:00
|
|
|
|
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
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|