StableVersion4.3/HL_FristAidPlatform_DataBase/Base/T_Base_VideoDeviceServerDB.cs

101 lines
3.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System;
using System.Collections.Generic;
namespace HL_FristAidPlatform_DataBase
{
/// <summary>
/// 视频监控服务器端
/// </summary>
public class T_Base_VideoDeviceServerDB : BaseDB, IT_Base_VideoDeviceServer
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 增加一条数据
/// </summary>
public bool Add(T_Base_VideoDeviceServer model)
{
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false;
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(T_Base_VideoDeviceServer model)
{
//更新时指定列不更新
return db.Updateable(model).IgnoreColumns(it => new { it.CreationDate, it.Creator, it.CreatorID }).ExecuteCommand();
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(long ID)
{
return db.Deleteable<T_Base_VideoDeviceServer>().Where(new T_Base_VideoDeviceServer() { ID = Convert.ToInt32(ID) }).ExecuteCommand() == 1 ? true : false;
}
/// <summary>
/// 获得数据列表
/// </summary>
public TableModel<T_Base_VideoDeviceServerModel> GetPageList(int pageIndex, int pageSize, string keyWord)
{
int TotalNumber = 0;
TableModel<T_Base_VideoDeviceServerModel> t = new TableModel<T_Base_VideoDeviceServerModel>();
var listMode = db.Queryable<T_Base_VideoDeviceServer>().WhereIF(!string.IsNullOrEmpty(keyWord), Server => Server.UserName.Contains(keyWord) || Server.ServerName.Contains(keyWord) || Server.ServerIP.Contains(keyWord)).Where(Server => Server.DeleteFlag == 0)
.Select(Server => new T_Base_VideoDeviceServerModel
{
ID = Server.ID,
GUID = Server.GUID,
UserName = Server.UserName,
Password = Server.Password,
ServerName = Server.ServerName,
ServerType = Server.ServerType,
ServerTypeName = Server.ServerType.ToString(),
ServerIP = Server.ServerIP,
CommunicationPort = Server.CommunicationPort,
QueryPort = Server.QueryPort,
DeleteFlag = Server.DeleteFlag,
CreatorID = Server.CreatorID,
Creator = Server.Creator,
CreationDate = Server.CreationDate,
DeleteFlagCase = Server.DeleteFlag.ToString(),
}).OrderBy((Server) => Server.ID).ToPageList(pageIndex, pageSize, ref TotalNumber);
t.Code = 0;
t.PageCount = listMode.Count;
t.TotalNumber = TotalNumber;
t.Data = listMode;
t.Msg = "成功";
return t;
}
/// <summary>
/// 获得前几行数据
/// </summary>
public T_Base_VideoDeviceServer Get(long id)
{
return db.Queryable<T_Base_VideoDeviceServer>().First(it => it.ID == id);
}
/// <summary>
/// 根据服务器类型获取服务器数据
/// </summary>
/// <param name="type">服务器类型1注册服务器2流媒体服务器3报警服务器4解码服务器</param>
/// <returns></returns>
public TableModel<T_Base_VideoDeviceServer> GetListByType(int type)
{
List<T_Base_VideoDeviceServer> data = db.Queryable<T_Base_VideoDeviceServer>().Where(it => it.DeleteFlag == 0 && it.ServerType == type).ToList();
TableModel<T_Base_VideoDeviceServer> t = new TableModel<T_Base_VideoDeviceServer>();
t.Code = 0;
t.TotalNumber = data.Count;
t.Data = data;
t.Msg = "成功";
return t;
}
}
}