/// <summary> /// 创建操作事务日志帮助类 /// </summary> /// <param name="type">类型</param> /// <returns></returns> public IOperationLogHelper <T> Create(OperationLogType type) { switch (type) { case OperationLogType.XML: return(new XMLOperationLogHelper <T>()); case OperationLogType.JSON: return(new JSONOperationLogHelper <T>()); default: return(null); } }
private void Seach() { OperationLogType type = (OperationLogType)Enum.Parse(typeof(OperationLogType), dplLogType.SelectedValue, false); DateTime begDate = new DateTime(); DateTime endDate = new DateTime(); begDate = DateTime.TryParse(txtBegDate.Text, out begDate) ? begDate : new DateTime(1900, 1, 1); endDate = DateTime.TryParse(txtEndDate.Text, out endDate) ? endDate.AddDays(1) : new DateTime(9999, 12, 31); begDate = new DateTime(begDate.Year, begDate.Month, begDate.Day, 0, 0, 0, DateTimeKind.Utc); endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 0, 0, 0, DateTimeKind.Utc); operationlogs = operationLogManager.GetByCondition(0, type, begDate, endDate); Session[OPERATIONLOGS] = operationlogs; gvwLog.DataSource = GetDisplay(0, operationlogs); gvwLog.DataBind(); }
/// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="logType">Type of the log.</param> /// <param name="operations">The operations to add (using <see cref="Log(Xtensive.Orm.IOperation)"/> method).</param> public OperationLog(OperationLogType logType, IEnumerable <IOperation> operations) : this(logType) { Log(operations); }
// Constructors /// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="logType">Type of the log.</param> public OperationLog(OperationLogType logType) { LogType = logType; }
public void OnActionExecuted(ActionExecutedContext context) { var httpResponse = context.HttpContext.Response; var returnResult = context.Result as JsonResult; var responseValue = (returnResult != null ? JsonConvert.SerializeObject(returnResult.Value) : null); _logger.LogInformation($"调用 {context.HttpContext.Request.Path}接口结束, 状态码是:{httpResponse.StatusCode}, 执行结果是:{responseValue}"); OperationType operation = OperationType.搜索; OperationLogType operationLogType = OperationLogType.操作日志; switch (context.HttpContext.Request.Method.ToUpper()) { case "GET": operation = OperationType.搜索; break; case "POST": operation = OperationType.新增; break; case "PUT": operation = OperationType.修改; break; case "DELETE": operation = OperationType.除; break; default: break; } var userProvider = new UserProvider(); var userInfo = userProvider.Get(); string content = string.Empty; if (context.HttpContext.Request.Path.Equals("/api/Login/Login")) { operation = OperationType.登录; operationLogType = OperationLogType.登录日志; if (returnResult != null) { string token = (returnResult.Value as ReturnResultModel)?.Data.ToString(); if (token.IsNullOrEmpty()) { return; } userInfo = userProvider.Get("Bearer " + token); content = $"用户[{userInfo?.Account}] {operation}系统, 输入的账号是 {userInfo?.Account},返回的数据是 {responseValue}"; } } else if (context.HttpContext.Request.Path.Equals("/api/Login/Logout")) { operation = OperationType.退出; operationLogType = OperationLogType.登录日志; content = $"用户[{userInfo?.Account}] {operation}系统, 退出的账号是 {userInfo?.Account},返回的数据是 {responseValue}"; } if (userInfo != null) { var entity = new T_Sys_Logs() { Operation = operation.EnumIntToString(), Operator = userInfo.Id, Content = content.IsNullOrEmpty() ? $"用户[{userInfo.Account}] {operation}数据, 输入的数据是 {_requestValue},返回的数据是 {responseValue}" : content, ResponseCode = httpResponse.StatusCode, Type = operationLogType.EnumIntToString() }; _logServer.AddLogsInfo(entity); } }
/// <summary> /// 保存类别 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { if (!CategoryNameValidate()) { ShowMessage("类别名称不能重复!"); return; } selectedCategory.Name = txtCategory.Text.Trim(); selectedCategory.Description = txtDescription.Text.Trim(); selectedCategory.ParentId = int.Parse(dplParent.SelectedValue); //update attribute for (int i = 0; i < gvwExtendedAttribute.Rows.Count; i++) { attributes[i].Order = i + 1; attributes[i] = GetExtendedAttributeFormRow(i, attributes[i]); } //TO Sort attributes IList <int> lstOrderChanged = new List <int>(); int order = 1; for (int i = 0; i < attributes.Count; i++) { ExtendedAttribute attr = attributes[i]; if (lstOrderChanged.Contains(attr.Id)) { continue; } attr.Order = order; order++; for (int j = i + 1; j < attributes.Count; j++) { if (attributes[j].Group.Equals(attr.Group)) { attributes[j].Order = order; order++; lstOrderChanged.Add(attributes[j].Id); } } } productCategoryManager.Save(selectedCategory, attributes, removedAttributes); //write operation log string message = selectedCategory.Id.Equals(0) ? "新增类别:" : "变更类别:"; message += txtCategory.Text; OperationLogType type = selectedCategory.Id.Equals(0) ? OperationLogType.Insert : OperationLogType.Update; WriteOperationLog(type, message); categories = productCategoryManager.GetByParentId(0); TreeNode root = new TreeNode("中材产品类别", "0"); tvwCategory.Nodes.Clear(); tvwCategory.Nodes.Add(root); AddChildNode(root, categories); tvwCategory.ExpandAll(); attributes = attributes.OrderBy <ExtendedAttribute, int>(p => p.Order).ToList <ExtendedAttribute>(); InitGridView(); ShowMessage("保存成功。"); //For Edit Status HasModify = false; hdfEditStatus.Value = string.Empty; } catch (Exception ex) { Log.Error(ex); RedirectToErrorPage(); } }