using OTSIncAReportApp.DataOperation.DataAccess; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OTSIncAReportApp._2_CommonFunction.CommonClass { internal class UserSTDDbData { private SqlHelper dbHelper; public UserSTDDbData(string STDDbName, string resultpath) { NLog.Logger log = NLog.LogManager.GetCurrentClassLogger(); if (!STDDbName.Contains(".db")) { STDDbName += ".db"; } if (STDDbName.ToLower() == "nostddb.db") { dbHelper = null; log.Error("Failed to load user-defined library" + "!"); } string fullPath = resultpath + STDDbName; string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + STDDbName; if (System.IO.File.Exists(fullPath)) { dbHelper = new SqlHelper("data source='" + fullPath + "'"); log.Warn("Loading the user standard library:" + fullPath + "!"); } else if (System.IO.File.Exists(fullPath2)) { dbHelper = new SqlHelper("data source='" + fullPath2 + "'"); log.Warn("Loading the user standard library:" + fullPath2 + "!"); } else { dbHelper = null; log.Error("Failed to load user-defined library" + "!"); } } public DataTable GetSubAttributeFromDatabase() { string sqliteString = "select STDId,Hardness,Density,Electrical_conductivity from ClassifySTD"; DataTable DT = new DataTable(); DT = dbHelper.ExecuteQuery(sqliteString); return DT; } public SqlHelper GetSqlHelper() { return dbHelper; } } }