using DataEntity.Device;
|
using DataEntity.Page;
|
using DataRWDAL.Base;
|
using HxEnum;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using XCommon.SqlSugar;
|
|
namespace DataRWDAL.Device
|
{
|
/// <summary>
|
/// 方法参数数据操作类
|
/// </summary>
|
public class DeviceConfigMethodParametersDB : BaseDB
|
{
|
/// <summary>
|
/// 获取方法参数分页数据
|
/// </summary>
|
/// <param name="pagination"></param>
|
/// <param name="condition"></param>
|
/// <returns></returns>
|
public static Tuple<List<DeviceConfigMethodParametersModel>, int> GetPageData(Pagination pagination, DeviceConfigMethodParametersModel condition)
|
{
|
using (var db = GetInstance())
|
{
|
var whereExpression = LinqExtensions.True<DeviceConfigMethodParametersModel>();
|
whereExpression = whereExpression.And(it => it.DeviceconfigMethodId.Equals(condition.DeviceconfigMethodId));
|
|
if (!string.IsNullOrEmpty(condition.ParameterName))
|
{
|
whereExpression = whereExpression.And(it => it.ParameterName.Contains(condition.ParameterName));
|
}
|
// u => u.Sort
|
return GetPage<DeviceConfigMethodParametersModel>(pagination, whereExpression, u => u.Sort, OrderByType.Asc);
|
}
|
}
|
|
/// <summary>
|
/// 根据方法参数Id,获取参数信息
|
/// </summary>
|
/// <param name="methodParameterId"></param>
|
/// <returns></returns>
|
public static DeviceConfigMethodParametersModel GetInfodById(string methodParameterId)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<DeviceConfigMethodParametersModel>().Single(it => it.Id.Equals(methodParameterId));
|
}
|
}
|
|
/// <summary>
|
/// 获取设备方法参数信息
|
/// </summary>
|
/// <param name="deviceconfigId"></param>
|
/// <param name="deviceconfigMethodId"></param>
|
/// <param name="type"></param>
|
/// <param name="parameterName"></param>
|
/// <returns></returns>
|
public static List<DeviceConfigMethodParametersModel> GetInfo(string deviceconfigId, string deviceconfigMethodId, int type, string parameterName)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<DeviceConfigMethodParametersModel>().Where(it => it.DeviceconfigId.Equals(deviceconfigId) &&
|
it.DeviceconfigMethodId.Equals(deviceconfigMethodId) && it.Type == type && it.ParameterName.Equals(parameterName)).
|
OrderBy(t => t.CreateTime, OrderByType.Asc).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 获取设备方法参数列表
|
/// </summary>
|
/// <param name="deviceconfigMethodId"></param>
|
/// <returns></returns>
|
public static List<DeviceConfigMethodParametersModel> GetInfoByDeviceconfigMethodId(string deviceconfigMethodId)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<DeviceConfigMethodParametersModel>().Where(it => it.DeviceconfigMethodId.Equals(deviceconfigMethodId)).
|
OrderBy(t => t.CreateTime, OrderByType.Asc).ToList();
|
}
|
}
|
|
public static List<DeviceConfigMethodParametersModel> GetInfoByDeviceconfigMethodId(string deviceconfigMethodId, ParameterTypeEnum parameterType)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<DeviceConfigMethodParametersModel>().Where(it => it.DeviceconfigMethodId.Equals(deviceconfigMethodId) &&
|
it.Type == EnumManagement.GetEnumValue(parameterType)).OrderBy(t => t.CreateTime, OrderByType.Asc).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 登录设备信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public static int Add(DeviceConfigMethodParametersModel model)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Insertable<DeviceConfigMethodParametersModel>(model).ExecuteCommand();
|
}
|
}
|
|
/// <summary>
|
/// 更新设备信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public static int Update(DeviceConfigMethodParametersModel model)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Updateable<DeviceConfigMethodParametersModel>(model).ExecuteCommand();
|
}
|
}
|
|
/// <summary>
|
/// 删除设备方法参数
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public static int DelById(DeviceConfigMethodParametersModel model)
|
{
|
using (var db = GetInstance())
|
{
|
return db.Deleteable<DeviceConfigMethodParametersModel>(model).ExecuteCommand();
|
}
|
}
|
|
/// <summary>
|
/// 获取设备方法参数列表
|
/// </summary>
|
/// <returns></returns>
|
public static List<DeviceConfigMethodParametersModel> GetDeviceConfigMethodParametersList()
|
{
|
using (var db = GetInstance())
|
{
|
return db.Queryable<DeviceConfigMethodParametersModel>().OrderBy(it => it.Id, OrderByType.Asc).ToList();
|
}
|
}
|
}
|
}
|