using System;
|
using System.Text;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Runtime.Serialization;
|
using System.Linq;
|
using System.Reflection;
|
|
namespace IStation.DAL.LocalFile
|
{
|
/// <summary>
|
/// 泵站
|
/// </summary>
|
public class Station : IDAL.IStation<Entity.Station>
|
{
|
#region Path
|
|
/// <summary>
|
/// 获取文件路径
|
/// </summary>
|
private string GetFolderPath(long projectId)
|
{
|
return FileHelper.GetProjectPath(projectId);
|
}
|
|
#endregion
|
|
#region Query
|
|
/// <summary>
|
/// 查询全部
|
/// </summary>
|
public List<Entity.Station> QueryAll(long projectId)
|
{
|
if (projectId < 0)
|
return default;
|
var path = GetFolderPath(projectId);
|
var all = FileIdHelper<Entity.Station>.QueryAll(path);
|
var entities= all?.OrderBy(x => x.SortCode).ToList();
|
return entities;
|
}
|
|
/// <summary>
|
/// 根据Id查询
|
/// </summary>
|
public Entity.Station QueryById(long projectId, long id)
|
{
|
if (projectId < 0)
|
return default;
|
if (id < 0)
|
return default;
|
var all = QueryAll(projectId);
|
var entities = all?.ToList();
|
return entities?.Find(t => t.Id == id);
|
}
|
|
/// <summary>
|
/// 通过Id集合查询
|
/// </summary>
|
public List<Entity.Station> QueryByIds(long projectId, IEnumerable<long> ids)
|
{
|
if (projectId < 0)
|
return default;
|
if (ids == null || ids.Count() < 1)
|
return default;
|
var all = QueryAll(projectId);
|
var entities = all?.Where(x => ids.Contains(x.Id)).ToList();
|
return entities;
|
}
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入
|
/// </summary>
|
public long Insert(long projectId, Entity.Station rhs)
|
{
|
if (projectId < 0)
|
return default;
|
if (rhs == null)
|
return default;
|
var path = GetFolderPath(projectId);
|
return FileIdHelper<Entity.Station>.Insert(path, rhs);
|
}
|
|
/// <summary>
|
/// 批量插入
|
/// </summary>
|
public bool Inserts(long projectId, IEnumerable<Entity.Station> list)
|
{
|
if (projectId < 0)
|
return default;
|
if (list == null || list.Count() < 1)
|
return default;
|
var path = GetFolderPath(projectId);
|
return FileIdHelper<Entity.Station>.Inserts(path, list);
|
}
|
|
/// <summary>
|
/// 插入并返回
|
/// </summary>
|
public Entity.Station InsertR(long projectId, Entity.Station rhs)
|
{
|
if (projectId < 0)
|
return default;
|
if (rhs == null)
|
return default;
|
var path = GetFolderPath(projectId);
|
var entities = FileIdHelper<Entity.Station>.InsertR(path, rhs);
|
return entities;
|
}
|
|
/// <summary>
|
/// 批量插入并返回
|
/// </summary>
|
public List<long> InsertsR(long projectId, IEnumerable<Entity.Station> list)
|
{
|
if (projectId < 0)
|
return default;
|
if (list == null || list.Count() < 1)
|
return default;
|
var path = GetFolderPath(projectId);
|
var entities = FileIdHelper<Entity.Station>.InsertRs(path, list);
|
return entities?.Select(x=>x.Id).ToList();
|
}
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新
|
/// </summary>
|
public bool Update(long projectId, Entity.Station rhs)
|
{
|
if (projectId < 0)
|
return default;
|
if (rhs == null)
|
return default;
|
var path = GetFolderPath(projectId);
|
return FileIdHelper<Entity.Station>.Update(path, rhs);
|
}
|
|
/// <summary>
|
/// 批量更新
|
/// </summary>
|
public bool Updates(long projectId, IEnumerable<Entity.Station> list)
|
{
|
if (projectId < 0)
|
return default;
|
if (list == null || list.Count() < 1)
|
return default;
|
var path = GetFolderPath(projectId);
|
return FileIdHelper<Entity.Station>.Updates(path, list);
|
}
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 根据Id删除
|
/// </summary>
|
public bool DeleteById(long projectId, long id)
|
{
|
if (projectId < 0)
|
return default;
|
if (id < 0)
|
return default;
|
var path = GetFolderPath(projectId);
|
var bol = FileIdHelper<Entity.Station>.DeleteById(path, id);
|
return bol;
|
}
|
|
/// <summary>
|
/// 根据Id集合删除
|
/// </summary>
|
public bool DeleteByIds(long projectId, IEnumerable<long> ids)
|
{
|
if (projectId < 0)
|
return default;
|
if (ids == null || ids.Count() < 1)
|
return default;
|
var path = GetFolderPath(projectId);
|
var bol = FileIdHelper<Entity.Station>.DeleteByIds(path, ids);
|
return bol;
|
}
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
public bool Delete(long projectId, Entity.Station rhs)
|
{
|
if (projectId < 0)
|
return default;
|
if (rhs == null)
|
return default;
|
var path = GetFolderPath(projectId);
|
var bol = FileIdHelper<Entity.Station>.DeleteById(path, rhs.Id);
|
return bol;
|
}
|
|
/// <summary>
|
/// 批量删除
|
/// </summary>
|
public bool Deletes(long projectId, IEnumerable<Entity.Station> list)
|
{
|
if (projectId < 0)
|
return default;
|
if (list == null || list.Count() < 1)
|
return default;
|
var path = GetFolderPath(projectId);
|
var ids = list.Select(x => x.Id).ToList();
|
var bol = FileIdHelper<Entity.Station>.DeleteByIds(path, ids);
|
return bol;
|
}
|
|
/// <summary>
|
/// 删除全部
|
/// </summary>
|
public bool DeleteAll(long projectId)
|
{
|
if (projectId < 0)
|
return default;
|
var path = GetFolderPath(projectId);
|
var bol = FileIdHelper<Entity.Station>.DeleteAll(path);
|
return bol;
|
}
|
|
#endregion
|
|
}
|
}
|