1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using Cksoft.Data;
- using Cksoft.Data.Repository;
- using DllEapEntity;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DllEapDal.OFILM
- {
- public class MachineInfoChangeLogDal
- {
- private IDatabase CurrDb = null;
- public MachineInfoChangeLogDal()
- {
- }
- public MachineInfoChangeLogDal(IDatabase db)
- {
- CurrDb = db;
- }
- /// <summary>
- /// 获取最后一次修改机台信息的记录
- /// </summary>
- /// <param name="macCode"></param>
- /// <returns></returns>
- public async Task<MachineInfoChangeLog> GetLastModifyRecord(string macCode)
- {
- string errorinfo = string.Empty;
- var log = await CurrDb.FindListForConditionAsync<MachineInfoChangeLog>($" and a.maccode='{macCode}' " +
- $"order by id desc limit 0,1",
- ref errorinfo);
- return log.FirstOrDefault();
- }
- /// <summary>
- /// 新增修改记录
- /// </summary>
- /// <param name="macCode"></param>
- /// <param name="userCode"></param>
- /// <param name="operation"></param>
- /// <param name="content"></param>
- /// <returns></returns>
- public async Task<bool> InsertLog(string macCode, string userCode, string operation,
- string content)
- {
- string errorinfo = string.Empty;
- var log = new MachineInfoChangeLog
- {
- MacCode = macCode,
- Operation = operation,
- OperatonContent = content,
- RecCode = userCode,
- RecTime = DateTime.Now
- };
- using (IDatabase db = DbFactory.Base("eap"))
- {
- db.InsertFor(log, userCode);
- }
- return await Task.FromResult(true);
- }
- /// <summary>
- /// 批量新增机台信息修改日志
- /// </summary>
- /// <param name="macCodes"></param>
- /// <param name="userCode"></param>
- /// <param name="operation"></param>
- /// <param name="content"></param>
- /// <returns></returns>
- public async Task<bool> InsertLog(IEnumerable<string> macCodes, string userCode, string operation,
- string content)
- {
- var list = new List<MachineInfoChangeLog>();
- foreach (var item in macCodes)
- {
- list.Add(new MachineInfoChangeLog
- {
- MacCode = item,
- Operation = operation,
- OperatonContent = content,
- RecCode = userCode,
- RecTime = DateTime.Now
- });
- }
- using(IDatabase db = DbFactory.Base("eap"))
- {
- db.Insert<MachineInfoChangeLog>(list);
- }
- return await Task.FromResult(true);
- }
- }
- }
|