168 lines
4.2 KiB
C#
168 lines
4.2 KiB
C#
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; }
|
|
|
|
/// <summary>
|
|
/// 条码
|
|
/// </summary>
|
|
public string barcode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 条码
|
|
/// </summary>
|
|
public double temperature { get; set; }
|
|
|
|
/// <summary>
|
|
/// 初始压力
|
|
/// </summary>
|
|
public double startpressure { get; set; }
|
|
|
|
/// <summary>
|
|
/// 保压时间
|
|
/// </summary>
|
|
public double dwelltime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 压差
|
|
/// </summary>
|
|
public double diffpressure { get; set; }
|
|
|
|
/// <summary>
|
|
/// 结束压力
|
|
/// </summary>
|
|
public double endpressure { get; set; }
|
|
|
|
public DateTime CreateTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 普通0高温1
|
|
/// </summary>
|
|
public int Type { get; set; }
|
|
}
|
|
|
|
public class ScanData
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 条码
|
|
/// </summary>
|
|
public string barcode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 压力
|
|
/// </summary>
|
|
public double diffpressure { get; set; }
|
|
|
|
/// <summary>
|
|
/// 出口温度
|
|
/// </summary>
|
|
public double exit_temperature { get; set; }
|
|
|
|
/// <summary>
|
|
/// 温度
|
|
/// </summary>
|
|
public double temperature { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 保压时间
|
|
/// </summary>
|
|
public double dwelltime { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public DateTime CreateTime { get; set; }
|
|
|
|
/// <summary>
|
|
///高温模式 1是0否
|
|
/// </summary>
|
|
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<ScanData> GetScanData()
|
|
{
|
|
using (var connection = new MySqlConnection(_connectionString))
|
|
{
|
|
connection.Open();
|
|
var sql = @"SELECT * FROM scandata
|
|
|
|
ORDER BY CreateTime DESC";
|
|
return connection.Query<ScanData>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public bool TestConnection()
|
|
{
|
|
try
|
|
{
|
|
using (var connection = new MySqlConnection(_connectionString))
|
|
{
|
|
connection.Open();
|
|
return connection.State == ConnectionState.Open;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|