using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 材料热传导系数
{
public class ConductivityTestData
{
public int Id { get; set; }
///
/// 条码
///
public string barcode { get; set; }
///
/// 条码
///
public double temperature { get; set; }
///
/// 初始压力
///
public double startpressure { get; set; }
///
/// 保压时间
///
public double dwelltime { get; set; }
///
/// 压差
///
public double diffpressure { get; set; }
///
/// 结束压力
///
public double endpressure { get; set; }
public DateTime CreateTime { get; set; }
///
/// 普通0高温1
///
public int Type { get; set; }
}
public class ScanData
{
public int Id { get; set; }
///
/// 条码
///
public string barcode { get; set; }
///
/// 压力
///
public double diffpressure { get; set; }
///
/// 出口温度
///
public double exit_temperature { get; set; }
///
/// 温度
///
public double temperature { get; set; }
///
/// 保压时间
///
public double dwelltime { get; set; }
public DateTime CreateTime { get; set; }
///
///高温模式 1是0否
///
public bool IsHighMode { get; set; }
}
public class ConductivityRepository
{
private readonly string _connectionString;
public ConductivityRepository()
{
_connectionString = "Server=localhost;Database=fullautowaterpressure;User=root;Password=123456;port=3306;charset=utf8;";
}
public void InsertReportItems(ConductivityTestData data)
{
using (var connection = new MySqlConnection(_connectionString))
{
connection.Open();
var sql = @"INSERT INTO normaltemperature
(barcode, temperature, startpressure, dwelltime,
diffpressure, endpressure, CreateTime, type)
VALUES
(@barcode, @temperature, @startpressure, @dwelltime, @diffpressure,@endpressure,CURRENT_TIMESTAMP,@type)";
connection.Execute(sql, data);
}
}
public void InsertScanItems(ScanData data)
{
using (var connection = new MySqlConnection(_connectionString))
{
connection.Open();
var sql = @"INSERT INTO scandata
(barcode,diffpressure,exit_temperature,temperature, dwelltime,CreateTime)
VALUES
(@barcode,@diffpressure,@exit_temperature,@temperature , @dwelltime ,CURRENT_TIMESTAMP)";
connection.Execute(sql, data);
}
}
public List GetScanData()
{
using (var connection = new MySqlConnection(_connectionString))
{
connection.Open();
var sql = @"SELECT * FROM scandata
ORDER BY CreateTime DESC";
return connection.Query(sql).ToList();
}
}
public bool TestConnection()
{
try
{
using (var connection = new MySqlConnection(_connectionString))
{
connection.Open();
return connection.State == ConnectionState.Open;
}
}
catch
{
return false;
}
}
}
}