prepravljena data mart sema i generator jebemliga

This commit is contained in:
2026-05-19 15:46:11 +02:00
parent 571c749e25
commit 946e4020d9
2 changed files with 182 additions and 173 deletions

View File

@@ -1,6 +1,7 @@
#:package MySqlConnector@2.3.7
using System.Text;
using System.Globalization;
using MySqlConnector;
// ── Config ────────────────────────────────────────────────────────────────────
@@ -45,7 +46,7 @@ async Task BulkInsert(string table, string columns, List<string> valueTuples)
}
string S(string? s) => s == null ? "NULL" : $"'{s.Replace("'", "''")}'";
string N(object? n) => n == null ? "NULL" : n.ToString()!;
string N(object? n) => n == null ? "NULL" : (n is IFormattable f) ? f.ToString(null, CultureInfo.InvariantCulture) : n.ToString()!;
string D(DateTime d) => $"'{d:yyyy-MM-dd}'";
string DT(DateTime d) => $"'{d:yyyy-MM-dd HH:mm:ss}'";
@@ -160,7 +161,7 @@ var roomTypes = new (string Code, string Desc, decimal BaseRate, bool Smoking)[]
};
await BulkInsert("room_type", "code, description, standard_rate, smoking_yn",
roomTypes.Select(rt => $"({S(rt.Code)},{S(rt.Desc)},{rt.BaseRate},0)").ToList());
roomTypes.Select(rt => $"({S(rt.Code)},{S(rt.Desc)},{N(rt.BaseRate)},0)").ToList());
var roomTypeIds = new Dictionary<string, int>();
{
@@ -194,7 +195,7 @@ foreach (var rt in roomTypes)
foreach (var rp in ratePeriods)
{
var rate = Math.Round(rt.BaseRate * rp.Multiplier, 2);
prrRows.Add($"({roomTypeIds[rt.Code]},{ratePeriodIds[rp.Code]},{rate})");
prrRows.Add($"({roomTypeIds[rt.Code]},{ratePeriodIds[rp.Code]},{N(rate)})");
}
await BulkInsert("period_room_rate", "room_type_id, rate_period_id, rate", prrRows);
@@ -514,7 +515,7 @@ while (bookingsDone < BOOKING_COUNT)
int ratePeriodId = monthToRatePeriodId[dfrom.Month];
decimal nightly = rateMap[(roomTypeId, ratePeriodId)];
decimal total = Math.Round(nightly * nights, 2);
roomBookingRows.Add($"({bookingId},{roomId},{D(dfrom)},{D(dto)},{nightly},{total})");
roomBookingRows.Add($"({bookingId},{roomId},{D(dfrom)},{D(dto)},{N(nightly)},{N(total)})");
}
}
}