public JsonResult Login(Sys_User entity) { try { int a = 10; int b = 0; int c = a / b; } catch (Exception ex) { NLogUtil.Error(ex.ToString()); //throw; } Sys_User user = _sysUserService.LoadEntities(c => c.UserName.Equals(entity.UserName)).SingleOrDefault(); if (user == null) { return(Json(new { state = 201, message = "用户名或密码错误" }, JsonRequestBehavior.AllowGet)); } if (user.PassWord.Equals(EncryptUtil.Md5(entity.PassWord))) { Session["YD_USER"] = user; string ip = Request.UserHostAddress; Sys_Log log = _logService.AddEntity(new Sys_Log { OccurTime = DateTime.Now, UserId = user.Id, Type = 1, LoginIp = ip }); return(Json(new { state = 200, messgae = "登录成功" }, JsonRequestBehavior.AllowGet)); } return(Json(new { state = 201, message = "用户名或密码错误" }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 批量添加日志 /// </summary> /// <param name="moduleName">功能模块名称,如 系统管理 >> 系统提醒 </param> /// <param name="dataId">操作数据id</param> /// <param name="type">日志类型,如新增、删除、登录、修改,请传递汉字</param> /// <param name="remark">备注,如果是删除的时候,可以把该删除数据的记录保存在该字段中</param> /// <param name="userId">操作人ID</param> /// <param name="userDepCode">操作部门代码</param> public void AddBatchLog(string moduleName, List <string> dataId, string type, string remark, string userId, string userDepCode) { try { string msg = string.Empty; Sys_LogBLL bllSys_Log = new Sys_LogBLL(); List <Sys_Log> list_log = new List <Sys_Log>(); foreach (var item in dataId) { Sys_Log Log = new Sys_Log(); Log.SysLogID = Guid.NewGuid().ToString(); Log.SysLog_OperateUserID = userId; Log.SysLog_OperateDep = userDepCode; Log.SysLog_OperateDate = DateTime.Now; Log.SysLog_TableName = string.Empty; Log.SysLog_OperateFunName = moduleName; Log.SysLog_OperateDataID = item; Log.SysLog_OperateType = type; Log.SysLog_Remark = remark; Log.SysLog_Ip = GetIP(); list_log.Add(Log); } bllSys_Log.Add(list_log); } catch { } }
public static void WriteLog(int user_id, string info, string ip, string target, int type, string device, LythenContext db) { Sys_Log log = new Sys_Log { log_content = info, log_device = device, log_ip = ip, log_target = target, log_time = DateTime.Now, log_type = type, log_user_id = user_id }; db.Sys_Log.Add(log); try { db.SaveChanges(); } catch (DbEntityValidationException ex) { StringBuilder errors = new StringBuilder(); IEnumerable <DbEntityValidationResult> validationResult = ex.EntityValidationErrors; foreach (DbEntityValidationResult result in validationResult) { ICollection <DbValidationError> validationError = result.ValidationErrors; foreach (DbValidationError err in validationError) { errors.Append(err.PropertyName + ":" + err.ErrorMessage + "\r\n"); } } ErrorUnit.WriteErrorLog(errors.ToString(), "WriteLog"); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), "WriteLog"); } }
/// <summary> /// 向ISMP发送日志 /// </summary> /// <param name="module"></param> /// <param name="logMessage"></param> /// <param name="logDetail"></param> /// <param name="operationType"></param> /// <param name="currentUser"></param> /// <returns></returns> public static bool SendSystemLogToISMP(string module, string logMessage, string logDetail, string operationType, ISMPUser currentUser) { try { Sys_Log log = new Sys_Log { AccountId = currentUser.OperatorAccountId, LoginName = currentUser.OperatorLoginName, Platform = Util.SMSProductId, Module = module, LogMessage = logMessage, LogType = LogType.Operation, LogTime = DateTime.Now, Log = logDetail, OperationType = operationType, IPAddress = currentUser.IPAddress }; string Param = JsonSerialize.Instance.Serialize <Sys_Log>(log); string url = Util.ISMPHost + "/CallBack/LogOperation?"; url += "Param=" + System.Web.HttpUtility.UrlEncode(Param); string resultISMP = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(resultISMP, new { success = true, message = string.Empty }); return(o.success); } catch (Exception ex) { Log4Logger.Error(ex); return(false); } }
private static void DequeueToTable(DataTable queueTable) { Sys_Log log = loggerQueueData.Dequeue(); DataRow row = queueTable.NewRow(); if (log.BeginDate == null) { log.BeginDate = DateTime.Now; } // row["Id"] = log.Id; row["LogType"] = log.LogType; row["RequestParameter"] = log.RequestParameter; row["ResponseParameter"] = log.ResponseParameter; row["ExceptionInfo"] = log.ExceptionInfo; row["Success"] = log.Success ?? -1; row["BeginDate"] = log.BeginDate; row["EndDate"] = log.EndDate; row["ElapsedTime"] = ((DateTime)log.EndDate - (DateTime)log.BeginDate).TotalMilliseconds; row["UserIP"] = log.UserIP; row["ServiceIP"] = log.ServiceIP; row["BrowserType"] = log.BrowserType; row["Url"] = log.Url; row["User_Id"] = log.User_Id ?? -1; row["UserName"] = log.UserName; row["Role_Id"] = log.Role_Id ?? -1; queueTable.Rows.Add(row); }
public static void SetServicesInfo(Sys_Log log, HttpContext context) { string result = String.Empty; log.Url = context.Request.Scheme + "://" + context.Request.Host + context.Request.PathBase + context.Request.Path; log.UserIP = context.GetUserIp()?.Replace("::ffff:", ""); log.ServiceIP = context.Connection.LocalIpAddress.MapToIPv4().ToString() + ":" + context.Connection.LocalPort; log.BrowserType = context.Request.Headers["User-Agent"]; if (string.IsNullOrEmpty(log.RequestParameter)) { try { log.RequestParameter = context.GetRequestParameters(); if (log.RequestParameter != null) { log.RequestParameter = HttpUtility.UrlDecode(log.RequestParameter, Encoding.UTF8); } } catch (Exception ex) { log.ExceptionInfo += $"日志读取参数出错:{ex.Message}"; Console.WriteLine($"日志读取参数出错:{ex.Message}"); } } }
public ActionResult GetPageListByMy(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject <Pagination>(); int userid = WebSecurityHelper.Passport.Current.UserId; Sys_Log log = new Sys_Log(); log.pageIndex = paginationobj.page; log.pageSize = paginationobj.rows; GetQueryVal(log, queryJson); log.F_OperateUserId = userid.ToString(); List <Sys_Log> list = _log.GetLogPage(log); var jsonData = new { rows = list, total = list.Count > 0 ? list[0].total : 0, page = paginationobj.page, records = list.Count > 0 ? list[0].totalCount : 0 }; return(Success(jsonData)); }
public HttpResponseMessage CheckLogin2(string userAccount, string password, string code) { password = "******"; ResultModel result = new ResultModel(); HttpResponseMessage httpResponseMessage = new HttpResponseMessage(); try { Sys_Log logEntity = new Sys_Log(); if (string.IsNullOrWhiteSpace(userAccount)) { throw new Exception("用户名错误,请重新输入"); } if (string.IsNullOrWhiteSpace(password)) { throw new Exception("密码错误,请重新输入"); } if (HttpContext.Current.Session["ubif_session_verifycode"].IsEmpty() || Md5.md5(code.ToLower(), 16) != HttpContext.Current.Session["ubif_session_verifycode"].ToString()) { throw new Exception("验证码错误,请重新输入"); } Sys_User userEntity = new UserApp().CheckLogin(userAccount, password); if (userEntity != null) { OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = userEntity.F_Id; operatorModel.UserCode = userEntity.F_Account; operatorModel.UserName = userEntity.F_RealName; operatorModel.CompanyId = userEntity.F_OrganizeId; operatorModel.DepartmentId = userEntity.F_DepartmentId; operatorModel.RoleId = userEntity.F_RoleId; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress); operatorModel.LoginTime = DateTime.Now; operatorModel.LoginToken = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); if (userEntity.F_Account == "admin") { operatorModel.IsSystem = true; } else { operatorModel.IsSystem = false; } OperatorProvider.Provider.AddCurrent(operatorModel); logEntity.F_Account = userEntity.F_Account; logEntity.F_NickName = userEntity.F_RealName; logEntity.F_Result = true; logEntity.F_Description = "登录成功"; new LogApp().WriteDbLog(logEntity); } } catch (Exception e) { result.status = "0"; result.message = e.Message; } httpResponseMessage.Content = new StringContent(result.ToJson(), System.Text.Encoding.UTF8, "application/json");; return(httpResponseMessage); }
public void WriteDbLog(Sys_Log Sys_Log) { Sys_Log.F_Id = Common.GuId(); Sys_Log.F_Date = DateTime.Now; Sys_Log.F_IPAddress = "117.81.192.182"; Sys_Log.F_IPAddressName = Net.GetLocation(Sys_Log.F_IPAddress); service.Insert(Sys_Log); }
/// <summary> /// /// </summary> /// <param name="requestParameter">请求参数</param> /// <param name="responseParameter">响应参数</param> /// <param name="success">响应结果1、成功,2、异常,0、其他</param> /// <param name="userInfo">用户数据</param> private static void Add(LoggerType loggerType, string requestParameter, string responseParameter, string ex, LoggerStatus status) { Sys_Log log = null; try { HttpContext context = Utilities.HttpContext.Current; if (context.Request.Method == "OPTIONS") { return; } ActionObserver cctionObserver = (context.RequestServices.GetService(typeof(ActionObserver)) as ActionObserver); //如果当前请求已经写过日志就不再写日志 if (cctionObserver.IsWrite) { return; } cctionObserver.IsWrite = true; if (context == null) { WriteText($"未获取到httpcontext信息,type:{loggerType.ToString()},reqParam:{requestParameter},respParam:{responseParameter},ex:{ex},success:{status.ToString()}"); return; } UserInfo userInfo = UserContext.Current.UserInfo; log = new Sys_Log() { BeginDate = cctionObserver.RequestDate, EndDate = DateTime.Now, User_Id = userInfo.User_Id, UserName = userInfo.UserTrueName, Role_Id = userInfo.Role_Id, LogType = loggerType.ToString(), ExceptionInfo = ex, RequestParameter = requestParameter, ResponseParameter = responseParameter, Success = (int)status }; SetServicesInfo(log, context); } catch (Exception exception) { log = log ?? new Sys_Log(); log.ExceptionInfo = exception.Message; } if (log == null) { return; } lock (_logger) { loggerQueueData.Enqueue(log); } }
public ActionResult CheckLogin(string username, string password, string code) { Sys_Log logEntity = new Sys_Log(); logEntity.F_ModuleName = "系统登录"; logEntity.F_Type = DbLogType.Login.ToString(); try { if (Session["dm_session_verifycode"].IsEmpty() || Md5.md5(code.ToLower(), 16) != Session["dm_session_verifycode"].ToString()) { throw new Exception("验证码错误,请重新输入"); } Sys_User userEntity = m_userService.CheckLogin(username, password); if (userEntity != null) { OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = userEntity.F_Id; operatorModel.UserCode = userEntity.F_Account; operatorModel.UserName = userEntity.F_RealName; operatorModel.CompanyId = userEntity.F_OrganizeId; operatorModel.DepartmentId = userEntity.F_DepartmentId; operatorModel.RoleId = userEntity.F_RoleId; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress); operatorModel.LoginTime = DateTime.Now; operatorModel.LoginToken = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); if (userEntity.F_Account == "admin") { operatorModel.IsSystem = true; } else { operatorModel.IsSystem = false; } OperatorProvider.Provider.AddCurrent(operatorModel); logEntity.F_Account = userEntity.F_Account; logEntity.F_NickName = userEntity.F_RealName; logEntity.F_Result = true; logEntity.F_Description = "登录成功"; m_logService.WriteDbLog(logEntity); } return(Content(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功。" }.ToJson())); } catch (Exception ex) { logEntity.F_Account = username; logEntity.F_NickName = username; logEntity.F_Result = false; logEntity.F_Description = "登录失败," + ex.Message; m_logService.WriteDbLog(logEntity); return(Content(new AjaxResult { state = ResultType.error.ToString(), message = ex.Message }.ToJson())); } }
public Task LogAsync(string userId, string realName, string ip, LogType logType, string moduleName, bool?result, string description) { Sys_Log log = this.CreateLog(userId, realName, ip, logType, moduleName, result, description); return(this.DoAsync(dbContext => { dbContext.Insert(log); })); }
/// <summary> /// DEBUG (调试信息):记录系统用于调试的一切信息,内容或者是一些关键数据内容的输出。 下面演示根据每个日志等级生成对应的一个文件。 /// </summary> /// <param name="entity"></param> /// <param name="ex"></param> public void Debug(Sys_Log entity, Exception ex = null) { entity.Id = StringHelper.GetUUID().ToString(); entity.Create_Time = DateTime.Now; entity.TraceIdentifier = CatContext.HttpContext.TraceIdentifier; entity.Level = LogLevel.DEBUG.ToString().ToLower(); logService.Debug(entity, ex); }
public void WriteDbLog(Sys_Log logEntity) { logEntity.F_Id = Common.GuId(); logEntity.F_Date = DateTime.Now; logEntity.F_IPAddress = "117.81.192.182"; logEntity.F_IPAddressName = Net.GetLocation(logEntity.F_IPAddress); logEntity.Create(); m_iRepository.Insert(logEntity); }
/// <summary> /// 新增日志 /// </summary> /// <param name="log"></param> /// <returns></returns> public int AddLog(Sys_Log log) { using (IDbConnection conn = DapperAdapter.MySQLOpenConnection(ConfigurationHelper.MySQLConnectionStr)) { //var param = new DynamicParameters(); string sql = @"insert into sys_log (F_LogId,F_CategoryId,F_OperateUserId,F_OperateTime,F_OperateAccount,F_OperateTypeId,F_OperateType,F_Module,F_IPAddress,F_Host,F_Browser,F_ExecuteResult,F_ExecuteResultJson,F_DeleteMark) VALUES (@F_LogId,@F_CategoryId,@F_OperateUserId,@F_OperateTime,@F_OperateAccount,@F_OperateTypeId,@F_OperateType,@F_Module,@F_IPAddress,@F_Host,@F_Browser,@F_ExecuteResult,@F_ExecuteResultJson,@F_DeleteMark);"; int result = conn.Execute(sql, log); return(result); } }
public void WriteDbLog(bool result, string resultLog) { Sys_Log Sys_Log = new Sys_Log(); Sys_Log.F_Id = Common.GuId(); Sys_Log.F_Date = DateTime.Now; Sys_Log.F_IPAddress = Net.Ip; Sys_Log.F_IPAddressName = Net.GetLocation(Sys_Log.F_IPAddress); Sys_Log.F_Result = result; Sys_Log.F_Description = resultLog; service.Insert(Sys_Log); }
Sys_Log CreateLog(string userId, string realName, string ip, LogType logType, string description) { Sys_Log entity = new Sys_Log { UserId = userId, RealName = realName, Type = logType, IP = ip, Description = description, CreationTime = DateTime.Now }; return(entity); }
public void WriteDbLog(Sys_Log logEntity) { logEntity.F_Id = Common.GuId(); logEntity.F_Date = DateTime.Now; logEntity.F_IPAddress = Net.Ip; logEntity.F_IPAddressName = Net.GetLocation(logEntity.F_IPAddress); var LoginInfo = OperatorProvider.Provider.GetCurrent(); if (LoginInfo != null) { logEntity.F_CreatorUserId = LoginInfo.UserId; } logEntity.F_CreatorTime = DateTime.Now; service.Insert(logEntity); }
public void Log(string logName, int moduleId, string moduleName, string errorMsg, string errorStack, string extraData) { var log = new Sys_Log(); log.LogId = Guid.NewGuid().ToString(); log.LogName = logName; log.ModuleId = moduleId; log.ModuleName = moduleName; log.ErrorMsg = errorMsg; log.ErrorStack = errorStack; log.ExtraData = extraData; log.CreatedDate = DateTime.Now; _logService.AddLog(log); }
public async Task <object> Login(LoginModel login, string cip, string cname) { var pss = MD5Comm.Get32MD5One(DESEncrypt.Encrypt(login.password, "AdminUI")); var list = Repository.Query(t => t.F_Account == login.userName).Result; var retpass = Repository.Query(t => t.F_UserPassword.Equals(pss)).Result.Count > 0?true:false; var retname = list.Count > 0 ? true : false; var ret = retname == true && retpass == true ? true : false; var loglist = new Sys_Log { F_Account = list[0].F_Account, F_NickName = list[0].F_RealName, F_Type = "Login", F_IPAddress = cip, F_IPAddressName = cname, F_ModuleName = "系统登录", F_Result = ret, F_Description = ret == true? "验证成功!":"账号或密码错误!", F_CreatorTime = DateTime.Now, F_Id = Common.GuId(), F_Date = DateTime.Now }; var log = Userlog.Add(loglist); if (ret) { //创建用户身份标识 var claims = new List <Claim>() { new Claim(ClaimTypes.Name, login.userName), new Claim(ClaimTypes.Role, list[0].F_IsAdministrator == true?"管理员":"普通用户"), new Claim(ClaimTypes.Rsa, list[0].F_SecurityLevel.ToString()) }; var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { }; await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); return(ret.ToJson()); } else { return(ret.ToJson()); } }
Sys_Log CreateLog(string userId, string realName, string ip, LogType logType, string moduleName, bool?result, string description) { Sys_Log entity = new Sys_Log(); entity.UserId = userId; entity.RealName = realName; entity.Type = logType; entity.ModuleName = moduleName; entity.IP = ip; entity.Result = result; entity.Description = description; entity.CreationTime = DateTime.Now; return(entity); }
/// <summary> /// 解析参数 /// </summary> /// <param name="log"></param> /// <param name="queryJson"></param> private void GetQueryVal(Sys_Log log, string queryJson) { var queryParam = queryJson.ToJObject(); // 关键字 if (!queryParam["keyword"].IsEmpty()) { log.F_Module = queryParam["keyword"].ToString(); } // 日志分类 if (!queryParam["CategoryId"].IsEmpty()) { log.F_CategoryId = queryParam["CategoryId"].ToInt(); } // 操作时间 if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) { log.startDate = queryParam["StartTime"].ToString(); log.endDate = queryParam["EndTime"].ToString(); } // 操作用户Id if (!queryParam["OperateUserId"].IsEmpty()) { log.F_OperateUserId = queryParam["OperateUserId"].ToString(); } // 操作用户账户 if (!queryParam["OperateAccount"].IsEmpty()) { log.F_OperateAccount = queryParam["OperateAccount"].ToString(); } // 操作类型 if (!queryParam["OperateType"].IsEmpty()) { log.F_OperateType = queryParam["OperateType"].ToString(); } // 功能模块 if (!queryParam["Module"].IsEmpty()) { log.F_Module = queryParam["Module"].ToString(); } }
public ActionResult VisitModules(string moduleName, string moduleUrl) { Sys_Log logEntity = new Sys_Log(); logEntity.F_CategoryId = StructDictCode.分类.访问; logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString(); logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit); logEntity.F_OperateAccount = WebSecurityHelper.Passport.Current.UserName + "(" + WebSecurityHelper.Passport.Current.UserNickName + ")"; logEntity.F_OperateUserId = WebSecurityHelper.Passport.Current.UserId.ToString(); logEntity.F_Module = moduleName; logEntity.F_ExecuteResult = "1"; logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl; this._log.AddLog(logEntity); return(Success("")); }
public ActionResult OutLogin() { Sys_Log logEntity = new Sys_Log() { F_ModuleName = "系统登录", F_Type = DbLogType.Exit.ToString(), F_Account = OperatorProvider.Provider.GetCurrent().UserCode, F_NickName = OperatorProvider.Provider.GetCurrent().UserName, F_Result = true, F_Description = "安全退出系统", }; m_logService.WriteDbLog(logEntity); Session.Abandon(); Session.Clear(); OperatorProvider.Provider.RemoveCurrent(); return(RedirectToAction("Index", "Login")); }
/// <summary> /// 向ISMP发送日志 /// </summary> /// <param name="log"></param> /// <returns></returns> public static bool SendSystemLogToISMP(Sys_Log log) { try { string Param = JsonSerialize.Instance.Serialize <Sys_Log>(log); string url = Util.ISMPHost + "/CallBack/LogOperation?"; url += "Param=" + System.Web.HttpUtility.UrlEncode(Param); string resultISMP = BXM.Utils.HTTPRequest.PostWebRequest(url, "", System.Text.Encoding.UTF8); var o = JsonConvert.DeserializeAnonymousType(resultISMP, new { success = true, message = string.Empty }); return(o.success); } catch (Exception ex) { Log4Logger.Error(ex); return(false); } }
/// <summary> /// 行为执行后,记录登录记录 /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuted(ActionExecutedContext filterContext) { base.OnActionExecuted(filterContext); Action = filterContext.RouteData.Values["action"].ToString(); JsonResult result = filterContext.Result as JsonResult; //TODO 这边需要改成从请求头和Cookie获取 //string account = filterContext.HttpContext.Request["Account"] == null ? filterContext.HttpContext.Request.Cookies["Account"]?.Value : filterContext.HttpContext.Request["Account"]; ModelResult mr; string userHostAddress = filterContext.HttpContext.Request.UserHostAddress;//IP地址 if (result != null) { mr = result.Data as LoginResult; Log = new Sys_Log { F_Account = "admin" }; #region 开启一个线程,后台处理日志信息 ThreadPool.QueueUserWorkItem((o => { try { Log.F_Id = Guid.NewGuid().ToString(); Log.F_Date = DateTime.Now; Log.F_IPAddress = userHostAddress; Log.F_Type = Action; Log.F_ModuleName = "系统登录"; Log.F_IPAddressName = "广东省河源市 电信"; Log.F_Result = mr?.Status; Log.F_Description = mr?.Message; Sys_User user = SysUserService.GetEntity(u => u.F_Account == Log.F_Account).FirstOrDefault(); Log.F_NickName = user?.F_NickName; //更新日志信息 SysLogService.AddEntity(Log); } catch (Exception ex) { ExceptionHelper.AddException(ex); } })); #endregion } }
/// <summary> /// 添加日志 /// </summary> /// <param name="moduleName">功能模块名称,如 系统管理 >> 系统提醒 </param> /// <param name="dataId">操作数据id</param> /// <param name="type">日志类型,如新增、删除、登录、修改,请传递汉字</param> /// <param name="remark">备注,如果是删除的时候,可以把该删除数据的记录保存在该字段中</param> /// <param name="userId">操作人ID</param> /// <param name="userDepCode">操作部门代码</param> public void AddLog(string moduleName, string dataId, string type, string remark, string userId, string userDepCode) { try { Sys_Log Log = new Sys_Log(); Sys_LogBLL bllSys_Log = new Sys_LogBLL(); Log.SysLogID = Guid.NewGuid().ToString(); Log.SysLog_OperateUserID = userId; Log.SysLog_OperateDep = userDepCode; Log.SysLog_OperateDate = DateTime.Now; Log.SysLog_TableName = string.Empty; Log.SysLog_OperateFunName = moduleName; Log.SysLog_OperateDataID = dataId; Log.SysLog_OperateType = type; Log.SysLog_Remark = remark; Log.SysLog_Ip = GetIP(); bllSys_Log.Add(Log); } catch { } }
public void WriteDbLog(bool result, string resultLog) { Sys_Log logEntity = new Sys_Log(); logEntity.F_Id = Common.GuId(); logEntity.F_Date = DateTime.Now; logEntity.F_Account = OperatorProvider.Provider.GetCurrent().UserCode; logEntity.F_NickName = OperatorProvider.Provider.GetCurrent().UserName; logEntity.F_IPAddress = Net.Ip; logEntity.F_IPAddressName = Net.GetLocation(logEntity.F_IPAddress); logEntity.F_Result = result; logEntity.F_Description = resultLog; var LoginInfo = OperatorProvider.Provider.GetCurrent(); if (LoginInfo != null) { logEntity.F_CreatorUserId = LoginInfo.UserId; } logEntity.F_CreatorTime = DateTime.Now; service.Insert(logEntity); }
public async void WriteDbAsyncLog(bool result, string ModuleName, string resultLog) { Sys_Log Sys_Log = new Sys_Log(); Sys_Log.F_Id = Common.GuId(); Sys_Log.F_Date = DateTime.Now; Sys_Log.F_IPAddress = Net.Ip; Sys_Log.F_IPAddressName = Net.GetLocation(Sys_Log.F_IPAddress); Sys_Log.F_Result = result; Sys_Log.F_ModuleName = ModuleName; if (resultLog.Length > 490) { Sys_Log.F_Description = resultLog.Substring(0, 490); } else { Sys_Log.F_Description = resultLog; } service.Insert(Sys_Log); }
public static void WriteDatalog(string jsonstrstart, string jsongstrend, bool result, string description, string typestr) { using (var db = SqlSugarDao.GetInstance()) { Sys_Log log = new Sys_Log(); log.F_Id = System.Guid.NewGuid().ToString(); log.F_Account = OperatorProvider.Provider.GetCurrent().UserCode; log.F_CreatorTime = DateTime.Now; log.F_CreatorUserId = "system"; log.F_Date = DateTime.Now; log.F_NickName = OperatorProvider.Provider.GetCurrent().UserName; log.F_IPAddress = Net.Net.Ip; log.F_IPAddressName = Net.Net.GetLocation(log.F_IPAddress); log.F_Result = result; log.F_Description = "表名:" + description; log.F_Before = jsonstrstart; log.F_Later = jsongstrend; log.F_Type = typestr; db.Insert(log); } }