/// <summary> /// 写入日志,报表类操作 /// </summary> /// <param name="type">操作类型</param> /// <param name="report">报表名称</param> /// <param name="dt">时间(yyyy-MM-dd)或时间范围(yyyy-MM-dd - yyyy-MM-dd)</param> /// <returns></returns> public byte WriteLog(String type, String report,String dt) { OT_Log pTemp = new OT_Log(); try { var pUser = SessionManage.GetLoginUser(); if (pUser != null) { pTemp.Id = Guid.NewGuid(); pTemp.LogDate = DateTime.Now; pTemp.Type = type; pTemp.UserName = pUser.UserName; if(type!=OperationType.Login&&type!=OperationType.LoginOut) { pTemp.RptName = report; pTemp.Describe = String.Format("{0}{1}{2}", type, dt, report); } if (pUser.RoleList.Count > 0 && pUser.RoleList[0] != null) { pTemp.RoleName = pUser.RoleList[0].RoleName; } return (Create(pTemp)); } } catch (Exception ex) { SystemLog.GetInstance().Error("插入操作日志失败!", ex); } return (byte)EResult.Fail; }
/// <summary> /// 写入日志,非报表类操作 /// </summary> /// <param name="type">操作类型</param> /// <param name="describe">操作描述</param> /// <returns></returns> public byte WriteLog(String type, string describe) { OT_Log pTemp = new OT_Log(); try { var pUser = SessionManage.GetLoginUser(); if (pUser != null) { pTemp.Id = Guid.NewGuid(); pTemp.LogDate = DateTime.Now; pTemp.Type = type; pTemp.UserName = pUser.UserName; pTemp.RptName = string.Empty; pTemp.Describe = describe; if (pUser.RoleList.Count > 0 && pUser.RoleList[0] != null) { pTemp.RoleName = pUser.RoleList[0].RoleName; } return (Create(pTemp)); } } catch (Exception ex) { SystemLog.GetInstance().Error("插入操作日志失败!", ex); } return (byte)EResult.Fail; }
/// <summary> /// 添加日志 /// </summary> /// <param name="model">日志实体</param> /// <returns>添加结果</returns> public byte Create(OT_Log model) { using (TransactionScope transaction = new TransactionScope()) { db.OT_Log.Add(model); return Result.SaveChangesResult(db, transaction).ResultKey; } }