1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using Cksoft.Data;
- using Cksoft.Unity.Log4NetConfig;
- using DllEapEntity;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace DllEapDal.OFILM
- {
- public class CodelinkDal
- {
- public IDatabase CurrDb { get; set; }
- public CodelinkDal(IDatabase db)
- {
- CurrDb = db;
- }
- public int Insert(Postbondview mst, string macCode, ref string errorinfo)
- {
-
- string sqlInsert = $@"INSERT INTO `eap`.`postbondview`(`Time`, `TimeMS`, `Unit`, `Group`, `Zone`, `Pad`, `Target`, `Dir`, `OffsetX`, `OffsetY`, `OffsetT`, `PRSCode`, `Used`, `Foreigner`, `MacCode`) VALUES ('{mst.Time.ToString("yyyy-MM-dd HH:mm:ss")}', {mst.TimeMS}, {mst.Unit}, {mst.Group}, {mst.Zone}, {mst.Pad}, {mst.Target}, {mst.Dir}, {mst.OffsetX}, {mst.OffsetY}, {mst.OffsetT}, {mst.PRSCode}, {mst.Used}, {mst.Foreigner}, '{macCode}');";
- //LogHelper<CodelinkDal>.LogError("新增:" + sqlInsert, "LHA数据采集", string.Empty);
- var res = CurrDb.ExecuteBySql(sqlInsert);
- //var res = CurrDb.InsertFor(mst, string.Empty);
- if (res > 0)
- {
- var sql = "select @@identity;";
- return Convert.ToInt32(CurrDb.FindList<string>(sql).FirstOrDefault() ?? "-1");
- }
- return -1;
- }
- public int Inserts(List<Codelink> mst, ref string errorinfo)
- {
- var res = CurrDb.InsertFor(mst, string.Empty);
- if (res > 0)
- {
- var sql = "select @@identity;";
- return Convert.ToInt32(CurrDb.FindList<string>(sql).FirstOrDefault() ?? "-1");
- }
- return -1;
- }
- public string GetPostbondView(string macCode, ref string errorinfo)
- {
- string sql = $" select max(time) from postbondview where maccode='{macCode}'";
- return CurrDb.FindList<string>(sql).FirstOrDefault() ?? DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") ;
- }
- public IEnumerable<Codelink> Get(string filter, ref string errorinfo)
- {
- return CurrDb.FindListForCondition<Codelink>(filter, ref errorinfo);
- }
- public int Update(Codelink mst)
- {
- return CurrDb.UpdateFor(mst, string.Empty);
- }
- }
- }
|