123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using ProjectBase.Data.BaseDAL.BaseDatabase;
- using ProjectBase.Data.Pager;
- using ProjectBase.Util;
- using SIMDP.DAL.IDALSQL;
- using SIMDP.Model;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SIMDP.DAL.DALSQL
- {
- /// <summary>
- /// PLC 配置摘要说明
- /// </summary>
- public class DalPlcInfo: BaseDALSQL<MoPlcInfo>, IDalPlcInfo
- {
- #region 对象实例及构造函数
- public static DalPlcInfo Instance
- {
- get
- {
- return new DalPlcInfo();
- }
- }
- public DalPlcInfo() : base("plc_info", "plc_id")
- {
- this.sortField = "plc_id";
- this.isDescending = false;
- }
- #endregion
- /// <summary>
- /// 将DataReader的属性值转化为实体类的属性值,返回实体类
- /// </summary>
- /// <param name="dr">有效的DataReader对象</param>
- /// <returns>实体类对象</returns>
- protected override MoPlcInfo DataReaderToEntity(IDataReader dataReader)
- {
- MoPlcInfo info = new MoPlcInfo();
- SmartDataReader reader = new SmartDataReader(dataReader);
- info.PlcId = reader.GetInt64("plc_id");
- info.PlcName = reader.GetString("plc_name");
- info.LinkType = reader.GetInt64("link_type");
- info.LinkConfig = reader.GetString("link_config");
- return info;
- }
- /// <summary>
- /// 将实体对象的属性值转化为Hashtable对应的键值
- /// </summary>
- /// <param name="obj">有效的实体对象</param>
- /// <returns>包含键值映射的Hashtable</returns>
- protected override Hashtable GetHashByEntity(MoPlcInfo obj)
- {
- MoPlcInfo info = obj as MoPlcInfo;
- Hashtable hash = new Hashtable();
- //hash.Add("plc_id", info.PlcId);
- hash.Add("plc_name", info.PlcName);
- hash.Add("link_type", info.LinkType);
- hash.Add("link_config", info.LinkConfig);
- return hash;
- }
- /// <summary>
- /// 获取字段中文别名(用于界面显示)的字典集合
- /// </summary>
- /// <returns></returns>
- public override Dictionary<string, string> GetColumnNameAlias()
- {
- Dictionary<string, string> dict = new Dictionary<string, string>();
- #region 添加别名解析
- dict.Add("plc_id", "PLC编号");
- dict.Add("plc_name", "PLC名称");
- dict.Add("link_type", "连接类型");
- dict.Add("link_config", "连接信息");
- #endregion
- return dict;
- }
- /// <summary>
- /// 获取PLC配置信息
- /// </summary>
- /// <param name="id">plc id</param>
- /// <param name="name">plc名称</param>
- /// <returns></returns>
- public List<MoPlcInfo> GetAllPlcInfo()
- {
- string sql = string.Format("SELECT * FROM plc_info ");
- return this.GetList(sql, null);
- }
- /// <summary>
- /// 以分页的方式获取PLC配置信息
- /// </summary>
- /// <param name="id"></param>
- /// <param name="name"></param>
- /// <param name="info">分页信息</param>
- /// <returns></returns>
- public List<MoPlcInfo> GetPlcInfoWithPager(long id, string name, PagerInfo info)
- {
- string sql = string.Format(" plc_id = {0} and plc_name = '{1}' ", id, name);
- return this.FindWithPager(sql, info);
- }
- /// <summary>
- /// 插入一条PLC配置信息
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public bool InsetPlcInfo(MoPlcInfo obj)
- {
- return this.Insert(GetHashByEntity(obj), null);
- }
- /// <summary>
- /// 删除记录
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DeleteWithId(long id, string userId)
- {
- return this.Delete(id, userId);
- }
- /// <summary>
- /// 更新信息
- /// </summary>
- /// <param name="id"></param>
- /// <param name="newoObj"></param>
- /// <returns></returns>
- public bool UpdateWithId(long id, MoPlcInfo newoObj)
- {
- return this.InsertUpdate(newoObj, id);
- }
- }
- }
|