12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.Data.Common;
- using System.Linq;
- using System.Management;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- using ProjectBase.Data.BaseDAL;
- using SIMDP.DAL.IDALSQL;
- using SIMDP.Model;
- using SIMDP.Util;
- namespace SIMDP.BLL
- {
- public class BlLogOperation : BaseBLL<MoLogOperation>
- {
- private IDalLogOperation dalLogOperation;
- /// <summary>
- /// 构造函数
- /// </summary>
- public BlLogOperation() : base()
- {
- base.Init(this.GetType().FullName, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
- dalLogOperation = baseDal as IDalLogOperation;
- }
- /// <summary>
- /// 获取组织ID与组织名称的集合
- /// </summary>
- /// <returns></returns>
- public Dictionary<string, string> GetGroupName()
- {
- Dictionary<string, string> dic = new Dictionary<string, string>();
- //BlAuthoryGroup bl = new BlAuthoryGroup();
- List<MoAuthoryGroup> group = BLLFactory<BlAuthoryGroup>.Instance.GetAll();
- if (group.Count == 0 || group == null)
- {
- return null;
- }
- foreach (MoAuthoryGroup item in group)
- {
- dic.Add(item.GroupId, item.GroupName);
- }
- return dic;
- }
- /// <summary>
- /// 根据相关信息,写入用户的操作日志记录
- /// </summary>
- /// <param name="userId">操作用户</param>
- /// <param name="tableName">操作表名称</param>
- /// <param name="operationType">操作类型</param>
- /// <param name="note">操作详细表述,目前数据表不包含这个字段,赋值为空</param>
- /// <param name="trans">事务对象</param>
- /// <returns></returns>
- public static bool OnOperationLog(string userId, string tableName, string operationType,string note = null, DbTransaction trans = null)
- {
- //虽然实现了这个事件,但是我们还需要判断该表是否在配置表里面,如果不在,则不记录操作日志。
- //BlLogOperationSetting blSetting = new BlLogOperationSetting();
- MoLogOperationSetting settingInfo = BLLFactory<BlLogOperationSetting>.Instance.FindByTableName(tableName, trans);
- if (settingInfo != null)
- {
- bool insert = operationType == "增加" && settingInfo.InsertLog;
- bool update = operationType == "修改" && settingInfo.UpdateLog;
- bool delete = operationType == "删除" && settingInfo.DeleteLog;
- if (insert || update || delete)
- {
- MoLogOperation info = new MoLogOperation();
- info.TableName = tableName;
- info.Type = operationType;
- info.Time = DateTime.Now;
- if (!string.IsNullOrEmpty(userId))
- {
- //BlAuthoryUser blUser = new BlAuthoryUser();
- MoAuthoryUser userInfo = BLLFactory<BlAuthoryUser>.Instance.FindByID(userId, trans);
- if (userInfo != null)
- {
- info.Account = userId;
- info.Name = userInfo.UserName;
- info.GroupId = userInfo.GroupId;
- }
- }
- info.Ip = SysEnvironment.Ip;
- info.Mac = SysEnvironment.Mac;
- //BlLogOperation bl = new BlLogOperation();
- return BLLFactory<BlLogOperation>.Instance.Insert(info, trans);
- //return true;
- }
- }
- return false;
- }
- }
- }
|