Adds PasswordHasher + DbSetup
This commit is contained in:
parent
4ec4beef21
commit
db09261768
7 changed files with 269 additions and 45 deletions
|
|
@ -1,51 +1,43 @@
|
|||
using Npgsql;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// Tilpas connection string til dine behov
|
||||
var connectionString = "Host=192.168.1.57;Database=ptdb01;Username=postgres;Password=3911";
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
var connectionString = "Host=192.168.1.57;Database=ptdb01;Username=postgres;Password=3911";
|
||||
|
||||
try
|
||||
{
|
||||
await using NpgsqlConnection conn = new NpgsqlConnection(connectionString);
|
||||
await conn.OpenAsync();
|
||||
try
|
||||
{
|
||||
await using NpgsqlConnection conn = new NpgsqlConnection(connectionString);
|
||||
await conn.OpenAsync();
|
||||
|
||||
Console.WriteLine("Forbundet til databasen. Lytter efter notifikationer...");
|
||||
Console.WriteLine("Forbundet til databasen. Lytter efter notifikationer...");
|
||||
|
||||
// Opsæt notification handling
|
||||
conn.Notification += (o, e) =>
|
||||
{
|
||||
Console.WriteLine($"Notifikation modtaget:");
|
||||
Console.WriteLine($" PID: {e.PID}");
|
||||
Console.WriteLine($" Kanal: {e.Channel}");
|
||||
Console.WriteLine($" Payload: {e.Payload}");
|
||||
Console.WriteLine("------------------------");
|
||||
};
|
||||
conn.Notification += (o, e) =>
|
||||
{
|
||||
Console.WriteLine($"Notifikation modtaget:");
|
||||
Console.WriteLine($" PID: {e.PID}");
|
||||
Console.WriteLine($" Kanal: {e.Channel}");
|
||||
Console.WriteLine($" Payload: {e.Payload}");
|
||||
Console.WriteLine("------------------------");
|
||||
};
|
||||
|
||||
// Start lytning
|
||||
await using (var cmd = new NpgsqlCommand("LISTEN config_changes;", conn))
|
||||
{
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
await using (var cmd = new NpgsqlCommand("LISTEN config_changes;", conn))
|
||||
{
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
// Hold programmet kørende og lyt efter notifikationer
|
||||
Console.WriteLine("Tryk på en tast for at stoppe...");
|
||||
Console.WriteLine("Tryk på en tast for at stoppe...");
|
||||
|
||||
// Mens vi venter på input, skal vi huske at wait for notifikationer
|
||||
while (!Console.KeyAvailable)
|
||||
{
|
||||
// Wait for notification for 1 second, then continue loop
|
||||
await conn.WaitAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Der opstod en fejl: {ex.Message}");
|
||||
Console.WriteLine($"Stack trace: {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
while (!Console.KeyAvailable)
|
||||
{
|
||||
await conn.WaitAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Der opstod en fejl: {ex.Message}");
|
||||
Console.WriteLine($"Stack trace: {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue