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.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(sql).FirstOrDefault() ?? "-1"); } return -1; } public int Inserts(List mst, ref string errorinfo) { var res = CurrDb.InsertFor(mst, string.Empty); if (res > 0) { var sql = "select @@identity;"; return Convert.ToInt32(CurrDb.FindList(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(sql).FirstOrDefault() ?? DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") ; } public IEnumerable Get(string filter, ref string errorinfo) { return CurrDb.FindListForCondition(filter, ref errorinfo); } public int Update(Codelink mst) { return CurrDb.UpdateFor(mst, string.Empty); } } }