-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
67 lines (62 loc) · 1.95 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// See https://aka.ms/new-console-template for more information
using FirebirdSql.Data.FirebirdClient;
using System;
using System.IO;
using System.Text;
using System.Linq;
namespace Probe
{
class Program
{
private const string prodDbPath = @"C:\Microsip datos\ERIC.FDB";
private const string workingDir = @"C:\apis";
private static string fbConnectionString = string.Format("database=localhost:{0};user=sysdba;password=masterkey", prodDbPath);
private static void createBackupAndShadowDBs()
{
try
{
Directory.CreateDirectory(workingDir);
File.Copy(prodDbPath, Path.Combine(workingDir, "BACKUP.FDB"), true);
File.Copy(prodDbPath, Path.Combine(workingDir, "SHADOW.FDB"), true);
}
catch (IOException iox)
{
Console.WriteLine(iox.Message);
}
}
static void Main(string[] args)
{
createBackupAndShadowDBs();
using (var connection = new FbConnection(fbConnectionString))
{
connection.Open();
using (var events = new FbRemoteEvent(fbConnectionString))
{
List<string> eventList = new List<string>();
eventList.Add("ARTICULOS_ADD");
events.RemoteEventCounts += (sender, e) => Console.WriteLine($"Event: {e.Name} | Counts: {e.Counts}");
events.RemoteEventError += (sender, e) => Console.WriteLine($"ERROR: {e.Error}");
events.Open();
events.QueueEvents(eventList);
Console.WriteLine("Listening...");
Console.ReadLine();
}
// using (var transaction = connection.BeginTransaction())
// {
// using (var command = new FbCommand("select * from articulos", connection, transaction))
// {
// using (var reader = command.ExecuteReader())
// {
// while (reader.Read())
// {
// var values = new object[reader.FieldCount];
// reader.GetValues(values);
// Console.WriteLine(string.Join("|", values));
// }
// }
// }
// }
}
}
}
}