commit 21/11/2024
This commit is contained in:
62
Database.cs
62
Database.cs
@@ -1,6 +1,7 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data.SQLite;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -26,7 +27,7 @@ namespace FAtoPA
|
||||
private bool CreateFSMTable()
|
||||
{
|
||||
//Debug.WriteLine("About to execute CreateFSMTable");
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -47,7 +48,7 @@ namespace FAtoPA
|
||||
}
|
||||
|
||||
public bool ClearFSMTable() {
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
var deleteCmd = connection.CreateCommand();
|
||||
@@ -57,7 +58,7 @@ namespace FAtoPA
|
||||
int result = deleteCmd.ExecuteNonQuery();
|
||||
return (result > 0);
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error deleting FSMData: " + e.Message);
|
||||
}
|
||||
@@ -68,7 +69,7 @@ namespace FAtoPA
|
||||
public List<FSMData> GetFSMDatas()
|
||||
{
|
||||
List<FSMData> fsmDatas = new List<FSMData>();
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -88,7 +89,7 @@ namespace FAtoPA
|
||||
|
||||
public bool AddFSMData(params FSMData[] data)
|
||||
{
|
||||
using(var connection = new SqliteConnection(connectionString))
|
||||
using(var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
@@ -109,7 +110,7 @@ namespace FAtoPA
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error inserting FSMData: " + e.Message);
|
||||
transaction.Rollback();
|
||||
@@ -124,7 +125,7 @@ namespace FAtoPA
|
||||
|
||||
public bool RemoveFSMDatabySIID(String SIID)
|
||||
{
|
||||
using (var conn = new SqliteConnection(connectionString))
|
||||
using (var conn = new SQLiteConnection(connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
var deleteCmd = conn.CreateCommand();
|
||||
@@ -135,7 +136,7 @@ namespace FAtoPA
|
||||
int result = deleteCmd.ExecuteNonQuery();
|
||||
return (result > 0);
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error deleting FSMData: " + e.Message);
|
||||
return false;
|
||||
@@ -146,7 +147,7 @@ namespace FAtoPA
|
||||
private bool CreateModbusTable()
|
||||
{
|
||||
//Debug.WriteLine("About to execute CreateModbusTable");
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -167,7 +168,7 @@ namespace FAtoPA
|
||||
|
||||
public bool ClearModbusTable()
|
||||
{
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
var deleteCmd = connection.CreateCommand();
|
||||
@@ -177,7 +178,7 @@ namespace FAtoPA
|
||||
int result = deleteCmd.ExecuteNonQuery();
|
||||
return (result > 0);
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error deleting ModbusData: " + e.Message);
|
||||
}
|
||||
@@ -187,7 +188,7 @@ namespace FAtoPA
|
||||
|
||||
public Boolean AddModbusData(params ModbusData[] data)
|
||||
{
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
@@ -208,7 +209,7 @@ namespace FAtoPA
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error inserting ModbusData: " + e.Message);
|
||||
transaction.Rollback();
|
||||
@@ -224,7 +225,7 @@ namespace FAtoPA
|
||||
public List<ModbusData> GetModbusDatas()
|
||||
{
|
||||
List<ModbusData> modbusDatas = new List<ModbusData>();
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -244,7 +245,7 @@ namespace FAtoPA
|
||||
|
||||
public bool RemoveModbusDatabySIID(String SIID)
|
||||
{
|
||||
using (var conn = new SqliteConnection(connectionString))
|
||||
using (var conn = new SQLiteConnection(connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
var deleteCmd = conn.CreateCommand();
|
||||
@@ -255,7 +256,7 @@ namespace FAtoPA
|
||||
int result = deleteCmd.ExecuteNonQuery();
|
||||
return (result > 0);
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error deleting ModbusData: " + e.Message);
|
||||
return false;
|
||||
@@ -266,7 +267,7 @@ namespace FAtoPA
|
||||
private bool CreateVXTable()
|
||||
{
|
||||
//Debug.WriteLine("About to execute CreateVXTable");
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -287,7 +288,7 @@ namespace FAtoPA
|
||||
|
||||
public bool ClearVXTable()
|
||||
{
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
var deleteCmd = connection.CreateCommand();
|
||||
@@ -297,7 +298,7 @@ namespace FAtoPA
|
||||
int result = deleteCmd.ExecuteNonQuery();
|
||||
return (result > 0);
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error deleting VXData: " + e.Message);
|
||||
}
|
||||
@@ -308,7 +309,7 @@ namespace FAtoPA
|
||||
public List<VXData> GetVXDatas()
|
||||
{
|
||||
List<VXData> vxDatas = new List<VXData>();
|
||||
using (var connection = new SqliteConnection(connectionString))
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -328,7 +329,7 @@ namespace FAtoPA
|
||||
|
||||
public bool RemoveVXDatabySIID(String SIID)
|
||||
{
|
||||
using (var conn = new SqliteConnection(connectionString))
|
||||
using (var conn = new SQLiteConnection(connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
var deleteCmd = conn.CreateCommand();
|
||||
@@ -339,7 +340,7 @@ namespace FAtoPA
|
||||
int result = deleteCmd.ExecuteNonQuery();
|
||||
return (result > 0);
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error deleting VXData: " + e.Message);
|
||||
return false;
|
||||
@@ -348,7 +349,7 @@ namespace FAtoPA
|
||||
}
|
||||
|
||||
public bool AddVXData(params VXData[] data) {
|
||||
using(var connection = new SqliteConnection(connectionString))
|
||||
using(var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
@@ -370,7 +371,7 @@ namespace FAtoPA
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (SqliteException e)
|
||||
catch (SQLiteException e)
|
||||
{
|
||||
Debug.WriteLine("Error inserting VXData: " + e.Message);
|
||||
transaction.Rollback();
|
||||
@@ -385,7 +386,7 @@ namespace FAtoPA
|
||||
|
||||
}
|
||||
|
||||
class FSMData
|
||||
class FSMData : INotifyPropertyChanged
|
||||
{
|
||||
public String SIID { get; set; }
|
||||
public Boolean Enable { get; set; }
|
||||
@@ -417,6 +418,13 @@ namespace FAtoPA
|
||||
this.Value = "";
|
||||
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
|
||||
class ModbusData
|
||||
|
||||
Reference in New Issue
Block a user