Files
Omika/tools/Omika.TosrvProbe/Program.cs
T
2026-10-23 18:46:50 +02:00

52 lines
1.8 KiB
C#

// Probe pour vérifier les opérations dans TOSRV (base Service BATIK.01_BLS).
using System.Data.OleDb;
const string server = "127.0.0.1";
const int port = 4900;
const string user = "susana";
const string password = "123";
string BuildConnStr(string database) =>
$"Provider=PCSOFT.HFSQL;Data Source={server}:{port};Initial Catalog={database};User ID={user};Password={password}";
Console.WriteLine("=== Opérations TOSRV dans BATIK.01_BLS ===");
try
{
using var conn = new OleDbConnection(BuildConnStr("BATIK.01_BLS"));
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT IDTOSRV, TS_Date, TS_Mobile, TS_JSON, TS_CMD FROM TOSRV";
using var reader = cmd.ExecuteReader();
Console.WriteLine("\n Toutes les opérations TOSRV:");
while (reader.Read())
{
string id = reader["IDTOSRV"]?.ToString() ?? "";
string date = reader["TS_Date"]?.ToString() ?? "";
string mobile = reader["TS_Mobile"]?.ToString() ?? "";
string json = reader["TS_JSON"]?.ToString() ?? "";
string cmdVal = reader["TS_CMD"]?.ToString() ?? "";
// Extraire l'operationId du JSON si présent.
string opId = "";
int idx = json.IndexOf("operationId");
if (idx >= 0)
{
int start = json.IndexOf('"', idx + 12);
int end = json.IndexOf('"', start + 1);
if (start >= 0 && end > start)
opId = json.Substring(start + 1, end - start - 1);
}
Console.WriteLine($" IDTOSRV={id}, Date={date}, Mobile={mobile}, Cmd={cmdVal}, OpId={opId}");
}
}
}
catch (Exception ex)
{
Console.WriteLine($" ERREUR: {ex.Message}");
}
Console.WriteLine("\nProbe TOSRV terminé.");