/// <summary> /// получить последние данные по прибору с заданным номером телефона /// </summary> /// <param name="phone">номер телефона - ключевое поле</param> /// <param name="kontur">номер контура</param> /// <returns></returns> public HeateInfo GetHeatInfoLast(string phone, int kontur) { HeateInfo last = null; using (IDbConnection conn = new SQLiteConnection(this.db_.GetDefaultConnectionString())) { last = conn.Query <HeateInfo>("select Id, recvDate, phone, heatValue, powerValue, waterLose, waterLoseAll, tempIn, tempOut, n_pp, statusInput, eventCode, heatCorect, presure1, presure2, errorList, totalWorkHours, tempCold from db_heat_parameter where phone=@phone_ and n_pp=@kontur_ and datetime(recvDate)=(select max(datetime(recvDate)) from db_heat_parameter where phone=@phone_ and n_pp=@kontur_);", new { phone_ = phone, kontur_ = kontur }).FirstOrDefault(); } return(last); }
/// <summary> /// получить информацию о значениях счётчика по id /// </summary> /// <returns>HeateInfo - характеристики ИТП</returns> public HeateInfo GetHeatInfo(int id) { HeateInfo last = null; using (IDbConnection conn = new SQLiteConnection(this.db_.GetDefaultConnectionString())) { last = conn.Query <HeateInfo>("select Id, recvDate, phone, heatValue, powerValue, waterLose, waterLoseAll, tempIn, tempOut, n_pp, statusInput, eventCode, heatCorect, presure1, presure2, errorList, totalWorkHours,tempCold from db_heat_parameter where id=@id_;", new { id_ = id }).FirstOrDefault(); } return(last); }
/// <summary> /// получить информацию о значениях счётчика на дату /// </summary> /// <returns>Перечисление объектов HeateInfo - характеристики ИТП</returns> public HeateInfo GetHeatInfo(DateTime dateValue, string phone, int kontur, bool include_time = true) { HeateInfo last = null; string sql = @"select Id, recvDate, phone, heatValue, powerValue, waterLose, waterLoseAll, tempIn, tempOut, n_pp, statusInput, eventCode, heatCorect, presure1, presure2,errorList, totalWorkHours, tempCold from db_heat_parameter where phone=@phone and n_pp=@kontur_ "; if (include_time) { sql += " and recvDate=@date_"; } else { sql += " and strftime('%d%m%Y',recvDate)=strftime('%d%m%Y',@date_)"; } using (IDbConnection conn = new SQLiteConnection(this.db_.GetDefaultConnectionString())) { last = conn.Query <HeateInfo>(sql, new { phone = phone, date_ = dateValue, kontur_ = kontur }).OrderByDescending(x => x.recvDate).FirstOrDefault(); } return(last); }