public bool CheckDeviceOnlineOffline(int deviceID, int Parent_SerialNum)
{
//Resetting
dataCheckList.Clear();
string databasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// string databaseFile = databasePath + @"\Database\Buildings\Default_Building\Default_Building.mdb";
//String connection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+ databaseFile+ @";Persist Security Info=True ";
//C:\Program Files (x86)\T3000\Database\Buildings\Default_Building
//String connection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files (x86)\T3000\Database\Buildings\Default_Building\Default_Building.mdb;Persist Security Info=True ";
string sql = "select * from ALL_NODE where Object_Instance = '" + deviceID + "' and Parent_SerialNum = '" + Parent_SerialNum + "'";
bool status = false;
if (BuildingSelected.Count > 0)
{
/*
This path is dynamic path we calculated based on this
<installed directory of T3000 (not psycho)>\... where ... = Database\..value returned by files
*/
string path = databasePath; //@"C:\Folder1\Folder2\Folder3\Folder4";
string newPath = Path.GetFullPath(Path.Combine(path, @"..\"));
string againDbPath = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + newPath + "" + BuildingSelected[0].Building_Path;
try
{
using (SQLiteConnection conn = new SQLiteConnection(againDbPath))
{
using (SQLiteCommand cmd = new SQLiteCommand(sql, conn))
{
conn.Open();
SQLiteDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
dataCheckList.Add((bool)reader["Online_Status"]);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
if (dataCheckList.Count > 0)
{
if (dataCheckList[0] == true)
{
status = true;
}
}
//MessageBox.Show( "datacheckcount= " + dataCheckList.Count + " Status = " + status);
}
return status;
}