public void ReadDataForSavingConfiguration(string path,string chartTableName,string nodeTableName,string lineTableName,string tableNameDevice,string tableForComfortZoneSetting,string tableForCF_Detail,string mixnodeInfoTable)
{
//--Resetting values first
chartInfoPulledForSaving.Clear();
nodeInfoPulledForSaving.Clear();
lineInfoPulledForSaving.Clear();
deviceInfoPulledForSaving.Clear();
comfortZoneInforForEachChartForSaving.Clear();
ComfortZonesDetailForSaving.Clear();
mixNodeInfoListForSaveConfiguration.Clear();
////--This reads the value of data form db lets use list for storing the data
//string chartTableName = "tbl_" + selectedBuildingList[0].BuildingName + "_chart_detail";
//string nodeTableName = "tbl_" + selectedBuildingList[0].BuildingName + "_node_value";
//string lineTableName = "tbl_" + selectedBuildingList[0].BuildingName + "_line_value";
//string tableNameDevice = "tbl_" + selectedBuildingList[0].BuildingName + "_device_info_for_node";//currentNodeTableFromDB;
//string tableForComfortZoneSetting = "tbl_" + selectedBuildingList[0].BuildingName + "_chart_comfort_zone_setting";
//string tableForCF_Detail = "tbl_" + selectedBuildingList[0].BuildingName + "_comfort_zone_detail";
////lets get the id values...
//string databasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
//string databaseFile = databasePath + @"\db_psychrometric_project.s3db";
string connectionString = @"Data Source=" + path + ";Version=3;";
string sql_for_chart_detail = "SELECT * From " + chartTableName;
string sql_for_node = "SELECT * From " + nodeTableName;
string sql_for_line = "SELECT * From " + lineTableName;
string sql_forDevice = "SELECT * From " + tableNameDevice;
string sql_for_CF_Setting = "SELECT * From " + tableForComfortZoneSetting;
string sql_for_CF_Detail = "SELECT * From " + tableForCF_Detail;
string sql_for_mix_node_info = "SELECT * From " + mixnodeInfoTable;
;
// MessageBox.Show("sql1=" + sql1);
using (SQLiteConnection conx = new SQLiteConnection(connectionString))
{
conx.Close();
conx.Open();
SQLiteCommand cmd = new SQLiteCommand(sql_for_chart_detail, conx);
SQLiteDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (reader["chartID"].ToString() != "") {
//--Reading and inserting in a List
chartInfoPulledForSaving.Add(new chartDetailDT_X
{
// count = int.Parse(reader["count"].ToString()),
chartID = reader["chartID"].ToString(),
chartName = reader["chartName"].ToString(),
chart_respective_nodeID = reader["chart_respective_nodeID"].ToString(),
chart_respective_lineID = reader["chart_respective_lineID"].ToString() ,
enableChartStatus = reader["enableChartStatus"].ToString()
});
}
}
//----Reading the node information
SQLiteCommand cmd1 = new SQLiteCommand(sql_for_node, conx);
SQLiteDataReader reader1 = cmd1.ExecuteReader();
while (reader1.Read())
{
if (reader1["chart_respective_nodeID"].ToString() != "") {
//--Reading and inserting in a List
nodeInfoPulledForSaving.Add(new nodeDataTypeForSaving
{
//count = int.Parse(reader1["count"].ToString()),
chart_respective_nodeID = reader1["chart_respective_nodeID"].ToString(),
nodeID = reader1["nodeID"].ToString(),
xValue = double.Parse(reader1["xValue"].ToString()),
yValue = double.Parse(reader1["yValue"].ToString()),
temperature_source = reader1["temperature_source"].ToString(),
humidity_source = reader1["humidity_source"].ToString(),
name = reader1["name"].ToString(),
// label = reader1["label"].ToString(),
colorValue = reader1["colorValue"].ToString(),
// showTextItem = reader1["showTextItem"].ToString(),
nodeSize = int.Parse(reader1["nodeSize"].ToString()),
airFlow = int.Parse(reader1["airFlow"].ToString()),
lastUpdatedDate = reader1["lastUpdatedDate"].ToString()
});
}
}
//--Reading the line information
SQLiteCommand cmd2 = new SQLiteCommand(sql_for_line, conx);
SQLiteDataReader reader2 = cmd2.ExecuteReader();
while (reader2.Read())
{
if(reader2["chart_respective_lineID"].ToString() != "") {
//This is the reading part of the data...
lineInfoPulledForSaving.Add(new lineDataType_X
{
// count = int.Parse(reader2["count"].ToString()),
chart_respective_lineID = reader2["chart_respective_lineID"].ToString(),
lineID = reader2["lineID"].ToString(),
prevNodeID = reader2["prevNodeID"].ToString(),
nextNodeID = reader2["nextNodeID"].ToString(),
lineColorValue = reader2["lineColorValue"].ToString(),
lineSeriesID = reader2["lineSeriesID"].ToString(),
thickness = reader2["thickness"].ToString(),
name = reader2["name"].ToString(),
status = reader2["status"].ToString()
});
}
}
//--Pulling data for device info
SQLiteCommand cmd3 = new SQLiteCommand(sql_forDevice, conx);
SQLiteDataReader reader3 = cmd3.ExecuteReader();
while (reader3.Read())
{
if (reader3["nodeID"].ToString() != "")
{
deviceInfoPulledForSaving.Add(new dt_for_device_info
{
nodeID = reader3["nodeID"].ToString(),
device_instance_id_for_param1 = reader3["device_instanceID_for_param1"].ToString(),
ip_for_param1 = reader3["IP_for_param1"].ToString(),
device_instance_id_for_param2 = reader3["device_instanceID_for_param2"].ToString(),
ip_for_param2 = reader3["IP_for_param2"].ToString(),
param1id = reader3["param1ID"].ToString(),
param2id = reader3["param2ID"].ToString(),
param1info = reader3["param1_info"].ToString(),
param2info = reader3["param2_info"].ToString(),
param1_id_type = reader3["param1_identifier_type"].ToString(),
param2_id_type = reader3["param2_identifier_type"].ToString()
});
}
}
//--Now reading the chart info
SQLiteCommand cmd4 = new SQLiteCommand(sql_for_CF_Detail, conx);
SQLiteDataReader reader4 = cmd4.ExecuteReader();
while (reader4.Read())
{
if(reader4["id"].ToString() != "") {
ComfortZonesDetailForSaving.Add(new dataTypeForCF
{
id = reader4["id"].ToString(),
name = reader4["name"].ToString(),
min_temp = reader4["min_temp"].ToString(), //this is in string formate
max_temp = reader4["max_temp"].ToString(),
min_hum = reader4["min_hum"].ToString(),
max_hum = reader4["max_hum"].ToString(),
colorValue = ColorTranslator.FromHtml(reader4["colorValue"].ToString())
});
}
}
//--Now reading the last part associated comfortzone with each chart
SQLiteCommand cmd5 = new SQLiteCommand(sql_for_CF_Setting, conx);
SQLiteDataReader reader5 = cmd5.ExecuteReader();
while (reader5.Read())
{
if (reader5["chartID"].ToString() != "") {
//This is the reading part of the data...
comfortZoneInforForEachChartForSaving.Add(new datatype_for_comfortzone
{
chartid = reader5["chartID"].ToString(),//reader["chartID"].ToString(),
comfortzoneid = reader5["comfort_zone_ID"].ToString(),
status = reader5["status"].ToString()
});
}
}
//==For mix node loading up
SQLiteCommand cmd6 = new SQLiteCommand(sql_for_mix_node_info, conx);
SQLiteDataReader reader6 = cmd6.ExecuteReader();
while (reader6.Read())
{
if (reader6["chartID"].ToString() != "")
{
//This is the reading part of the data...
mixNodeInfoListForSaveConfiguration.Add(new dataTypeFor_mix_node_info
{
ChartID = reader6["chartID"].ToString(),//reader["chartID"].ToString(),
nodeID = reader6["nodeID"].ToString(),
previousNodeID = reader6["previousNodeID"].ToString(),
nextNodeID = reader6["nextNodeID"].ToString(),
});
}
}
} //close of using statement
//} //close of using statement
}