|
|
|
|
|
using SlnMesnac.RfidUpload.Model;
|
|
|
using SlnMesnac.RfidUpload.NLog;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
/*--------------------------------------------------------------------
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
* 机器名称:T14-GEN3-7895
|
|
|
* 命名空间:slnmesnac.rfidupload.Repository
|
|
|
* 唯一标识:af6b459e-40d9-4e83-97e6-0b17f28044e5
|
|
|
*
|
|
|
* 创建者:WenJY
|
|
|
* 电子邮箱:
|
|
|
* 创建时间:2024-12-06 9:01:34
|
|
|
* 版本:V1.0.0
|
|
|
* 描述:
|
|
|
*
|
|
|
*--------------------------------------------------------------------
|
|
|
* 修改人:
|
|
|
* 时间:
|
|
|
* 修改说明:
|
|
|
*
|
|
|
* 版本:V1.0.0
|
|
|
*--------------------------------------------------------------------*/
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
namespace slnmesnac.rfidupload.Repository
|
|
|
{
|
|
|
public class SqlSugarHelper
|
|
|
{
|
|
|
private static SqlSugarHelper instance = null;
|
|
|
private static readonly object padlock = new object();
|
|
|
|
|
|
private SqlSugarHelper() { }
|
|
|
public static SqlSugarHelper Instance
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
lock (padlock)
|
|
|
{
|
|
|
if (instance == null)
|
|
|
instance = new SqlSugarHelper();
|
|
|
return instance;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string url = System.Environment.CurrentDirectory + "/db/";
|
|
|
static string ConnectionString1 = $"Data Source={url}/hw.db";
|
|
|
|
|
|
public static SqlSugarClient db
|
|
|
{
|
|
|
|
|
|
get => new SqlSugarClient(new ConnectionConfig()
|
|
|
{
|
|
|
ConnectionString = $"Data Source={url}/hw.db",
|
|
|
DbType = SqlSugar.DbType.Sqlite, //必填, 数据库类型
|
|
|
IsAutoCloseConnection = true, //默认false, 时候知道关闭数据库连接, 设置为true无需使用using或者Close操作
|
|
|
InitKeyType = InitKeyType.SystemTable //默认SystemTable, codefist需要使用Attribute
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 插入记录
|
|
|
/// </summary>
|
|
|
/// <param name="printRecord"></param>
|
|
|
/// <returns></returns>
|
|
|
public int InsertRecord(UploadRecord record)
|
|
|
{
|
|
|
int result = db.Insertable(record).ExecuteCommand();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询记录列表--不包含strList字段
|
|
|
/// </summary>
|
|
|
/// <param name="printRecord"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<UploadRecord> GetRecordList()
|
|
|
{
|
|
|
List<UploadRecord> list;
|
|
|
list = db.SqlQueryable<UploadRecord>("select id,UPLOAD_RECORD.ffjhNo,opBatch,ffjhscrq,stationOrgCode,stationOrgName,strList,isSuccess from UPLOAD_RECORD").ToList();
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据封发计划编号查询记录
|
|
|
/// </summary>
|
|
|
/// <param name="code"></param>
|
|
|
/// <returns></returns>
|
|
|
public UploadRecord GetRecordByFfjhNo(string ffjhNo)
|
|
|
{
|
|
|
UploadRecord record = db.SqlQueryable<UploadRecord>($"select * from UPLOAD_RECORD where ffjhNo='{ffjhNo}'").ToList().FirstOrDefault();
|
|
|
return record;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 插入记录
|
|
|
/// </summary>
|
|
|
/// <param name="printRecord"></param>
|
|
|
/// <returns></returns>
|
|
|
public int InsertPrintCode(UploadRecord record)
|
|
|
{
|
|
|
int result = db.Insertable<UploadRecord>(record).ExecuteCommand();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据封发计划编号改变上传记录上传结果
|
|
|
/// </summary>
|
|
|
/// <param name="printRecord"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateRecordByFfjhNo(string ffjhNo,bool uploadResult)
|
|
|
{
|
|
|
int flag = uploadResult ? 1 : 0;
|
|
|
string sql = $"UPDATE UPLOAD_RECORD SET isSuccess = {flag} WHERE ffjhNo = {ffjhNo}";
|
|
|
int result = db.Updateable<UploadRecord>(sql).ExecuteCommand();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |