/// <summary> /// 数据显示的函数 /// </summary> public override void DisplayData() { InitDictItem();//数据字典加载(公用) if (!string.IsNullOrEmpty(ID)) { #region 显示信息 OperationLogInfo info = BLLFactory <OperationLog> .Instance.FindByID(ID); if (info != null) { tempInfo = info;//重新给临时对象赋值,使之指向存在的记录对象 txtUser_ID.Text = info.User_ID.ToString(); txtLoginName.Text = info.LoginName; txtFullName.Text = info.FullName; txtCompany_ID.Text = info.Company_ID; txtCompanyName.Text = info.CompanyName; txtTableName.Text = info.TableName; txtOperationType.Text = info.OperationType; txtNote.Text = info.Note; txtIPAddress.Text = info.IPAddress; txtMacAddress.Text = info.MacAddress; txtCreateTime.SetDateTime(info.CreateTime); } #endregion } }
private void GetOptContentLangID(OperationLogInfo optLogInfo) { try { string strRegex = string.Format("{0}<{0}\\w+{0}>{0}", ConstValue.SPLITER_CHAR_2); Regex regex = new Regex(strRegex); var collections = regex.Matches(optLogInfo.LogArgs); for (int i = 0; i < collections.Count; i++) { var item = collections[i]; int length = item.Length; if (length < 6) { continue; } string strLangID = item.Value.Substring(3, item.Value.Length - 6); if (string.IsNullOrEmpty(strLangID)) { continue; } mListOptContentLangIDs.Add(strLangID); } } catch { } }
/// <summary> /// 新增状态下的数据保存 /// </summary> /// <returns></returns> public override bool SaveAddNew() { OperationLogInfo info = tempInfo;//必须使用存在的局部变量,因为部分信息可能被附件使用 SetInfo(info); try { #region 新增数据 bool succeed = BLLFactory <OperationLog> .Instance.Insert(info); if (succeed) { //可添加其他关联操作 return(true); } #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditOperationLog)); MessageDxUtil.ShowError(ex.Message); } return(false); }
/// <summary> /// 编辑状态下的数据保存 /// </summary> /// <returns></returns> public override bool SaveUpdated() { OperationLogInfo info = BLLFactory <OperationLog> .Instance.FindByID(ID); if (info != null) { SetInfo(info); try { #region 更新数据 bool succeed = BLLFactory <OperationLog> .Instance.Update(info, info.ID); if (succeed) { //可添加其他关联操作 return(true); } #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditOperationLog)); MessageDxUtil.ShowError(ex.Message); } } return(false); }
private string GetOptContentDisplay(OperationLogInfo optLogInfo) { string strReturn = optLogInfo.LogArgs; try { var lang = mListOptContentLanguages.FirstOrDefault(l => l.Name == optLogInfo.LangID); if (lang != null) { strReturn = lang.Display; } string strRegex1 = string.Format("{{\\d+}}"); Regex regex1 = new Regex(strRegex1); var collection1 = regex1.Matches(strReturn); int count1 = collection1.Count; if (count1 > 0) { string[] arrArgs = optLogInfo.LogArgs.Split(new[] { string.Format("{0}{0}{0}", ConstValue.SPLITER_CHAR_2) }, StringSplitOptions.None); for (int i = 0; i < count1; i++) { if (arrArgs.Length > i) { strReturn = strReturn.Replace(collection1[i].Value, arrArgs[i]); } } } string strRegex2 = string.Format("{0}<{0}\\w+{0}>{0}", ConstValue.SPLITER_CHAR_2); Regex regex2 = new Regex(strRegex2); var collection2 = regex2.Matches(strReturn); int count2 = collection2.Count; if (count2 > 0) { for (int i = 0; i < count2; i++) { string str = collection2[i].Value; if (str.Length > 6) { string strID = str.Substring(3, str.Length - 6); lang = mListOptContentLanguages.FirstOrDefault(l => l.Name == strID); if (lang != null) { strReturn = strReturn.Replace( string.Format("{0}<{0}{1}{0}>{0}", ConstValue.SPLITER_CHAR_2, strID), lang.Display); } } } } } catch (Exception ex) { CurrentApp.WriteLog("GetOptContentDisplay", string.Format("Fail.\t{0}", ex.Message)); } return(strReturn); }
public void OperationLoggerInit(OperationLogInfo operationLogInfo, bool reInit = false) { if (!reInit) { _operationLogInfo = operationLogInfo; } PrintInfo(GlobalFlags.InfoMessages.LoggingTime); PrintInfo(GlobalFlags.InfoMessages.ServerName); PrintInfo(GlobalFlags.InfoMessages.ClientName); PrintInfo(GlobalFlags.InfoMessages.IsListAvailable); PrintInfo(GlobalFlags.InfoMessages.AvailableDeviceServers); }
/// <summary> /// 编辑或者保存状态下取值函数 /// </summary> /// <param name="info"></param> private void SetInfo(OperationLogInfo info) { info.LoginName = txtLoginName.Text; info.FullName = txtFullName.Text; info.CompanyName = txtCompanyName.Text; info.TableName = txtTableName.Text; info.OperationType = txtOperationType.Text; info.Note = txtNote.Text; info.MacAddress = this.txtMacAddress.Text; info.IPAddress = this.txtIPAddress.Text; info.CreateTime = txtCreateTime.DateTime; }
public JsonResult SaveUpdatePassword() { var oldPassword = WebHelper.Params["OldPassword"]; var newPassword = WebHelper.Params["NewPassword"]; var rePassword = WebHelper.Params["RePassword"]; if (string.IsNullOrEmpty(oldPassword)) { return(Json(Result.Error("原始密码不能为空"))); } if (string.IsNullOrEmpty(newPassword)) { return(Json(Result.Error("新密码不能为空"))); } if (newPassword.Length < 6) { return(Json(Result.Error("新密码长度不能小于6位"))); } if (newPassword != rePassword) { return(Json(Result.Error("两次输入的密码不一致"))); } var user = Business.User.Current.User; if (user.Password != EncryptHelper.MD5Encode(oldPassword).ToLower()) { return(Json(Result.Error("所输入原密码错误"))); } var newPasswordMd5 = EncryptHelper.MD5Encode(newPassword).ToLower(); provider.UpdateUser($"{UserCols.Id} = {user.Id}", $"{UserCols.Password} = {newPasswordMd5.ToSafeSql()}"); user.Password = newPasswordMd5; // 写入密码修改操作日志 var operationLog = new OperationLogInfo() { LoginName = user.LoginName, Type = OperationType.修改, BusinessName = "本人修改密码", Description = $"{oldPassword}->{newPassword}", Ip = WebHelper.GetClientIp(), CreateTime = DateTime.Now }; provider.CreateOperationLog(operationLog); return(Json(Result.Default)); }
public void CreateOperationLoggerInfo() { _operationLogInfo = new OperationLogInfo { DateTime = DateTime.Now, AirList = _airList, AvailableDeviceServers = GetAvailableDeviceServers(), IsListAvailable = IsListAvailable, ServerName = _serverName, ClientName = _name, AirListName = ListName }; }
/// <summary> /// 记录主数据操作日志 /// </summary> /// <param name="opData"></param> /// <param name="operationType"></param> /// <param name="tableName"></param> /// <param name="pageUrl"></param> /// <param name="browserInfo"></param> /// <param name="ipAddress"></param> /// <param name="createUser"></param> /// <returns></returns> public bool InsertLog(string opData, int operationType, string tableName , string pageUrl, string browserInfo, string ipAddress, string createUser) { OperationLogInfo info = new OperationLogInfo(); info.Fid = Guid.NewGuid(); info.OperationContext = opData; info.OperationType = operationType; info.TableName = tableName; info.IpAddress = ipAddress; info.PageUrl = pageUrl; info.BrowserInfo = browserInfo; info.CreateUser = createUser; info.CreateDate = DateTime.Now; info.ValidFlag = true; return(dal.Add(info) > 0 ? true : false); }
public JsonResult CheckLogin() { var ret = Result.Default; string loginName = WebHelper.Params["loginName"]; string password = WebHelper.Params["password"]; if (!string.IsNullOrEmpty(loginName) && !string.IsNullOrEmpty(password)) { if (!ValidateVerifyCode()) { Session[login_verify_code_image] = null; ret = Result.Error("验证码不正确"); } else { ret = Business.User.Login(loginName, password); if (ret.Success) { ret.Value = $"/Home/Index"; } // 插入登录日志 var operationLog = new OperationLogInfo() { LoginName = loginName, Type = OperationType.登录, BusinessName = ret.Success ? "登录成功" : "登录失败", Description = ret.Success ? $"UserType={Business.User.Current.User.Type}" : $"帐号:{loginName},密码:{password},{ret.Message}", Ip = WebHelper.GetClientIp(), CreateTime = DateTime.Now }; provider.CreateOperationLog(operationLog); } } else { ret = Result.Error("帐号密码不能为空"); } return(Json(ret)); }
public JsonResult SavePassword(UserInfo user) { if (user == null || string.IsNullOrEmpty(user.Password)) { return(Json(Result.Error("密码不能为空"))); } var password = user.Password; //新密码 user = provider.GetUser(user.Id); if (password.Length < 6) { return(Json(Result.Error("密码长度不能小于6位"))); } var rePassword = WebHelper.Params["RePassword"]; if (password != rePassword) { return(Json(Result.Error("两次输入的密码不一致"))); } var passwordMd5 = EncryptHelper.MD5Encode(password).ToLower(); provider.UpdateUser($"{UserCols.Id} = {user.Id}", $"{UserCols.Password} = {passwordMd5.ToSafeSql()}"); // 写入密码修改操作日志 var operationLog = new OperationLogInfo() { LoginName = Business.User.Current.User.LoginName, Type = OperationType.修改, BusinessName = "上级代改密码", Description = $"账号[{user.LoginName}]密码被修改为:{password}", Ip = WebHelper.GetClientIp(), CreateTime = DateTime.Now }; provider.CreateOperationLog(operationLog); return(Json(Result.Default)); }
// 为了使用Session(Business.User.Current) protected void Application_PreRequestHandlerExecute(object sender, EventArgs e) { // 写入请求参数操作日志(排除系统设置目录里面的查询相关操作) var absolutePath = Request.Url.AbsolutePath; if (WebHelper.IsAjax(Request.Headers) && !string.IsNullOrEmpty(absolutePath) && !absolutePath.StartsWith("/System/Get", StringComparison.OrdinalIgnoreCase)) { var _params = WebHelper.Params.AllKeys.Aggregate(string.Empty, (current, key) => current + (key + "=" + WebHelper.Params[key] + "&")); if (!string.IsNullOrEmpty(_params)) { var loginName = Business.User.IsLogin ? Business.User.Current.User.LoginName : "--未登录--"; var operationLog = new OperationLogInfo() { LoginName = loginName, Type = OperationType.请求参数, BusinessName = absolutePath, Description = $"{_params.Trim('&')}", Ip = WebHelper.GetClientIp(), CreateTime = DateTime.Now }; DataProvider.Instance.CreateOperationLog(operationLog); } } }
public long InsertInfo(OperationLogInfo info) { return(dal.Add(info)); }
public void OperationLoggerUpdateInfo(OperationLogInfo operationLogInfo) { Dispatcher.Invoke(new Action(() => OperationLoggerContent = "")); OperationLoggerInit(operationLogInfo); }
public override void ClearScreen() { this.tempInfo = new OperationLogInfo(); base.ClearScreen(); }
private void LoadOptLogInfos(int size, int skip) { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1200Codes.GetOptLogInfoList; if (mOnlyMyself) { webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); } else { webRequest.ListData.Add("0"); } webRequest.ListData.Add(size.ToString()); webRequest.ListData.Add(skip.ToString()); Service12001Client client = new Service12001Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service12001")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (webReturn.ListData == null) { return; } for (int i = 0; i < webReturn.ListData.Count; i++) { string strInfo = webReturn.ListData[i]; OperationReturn optReturn = XMLHelper.DeserializeObject <OperationLogInfo>(strInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } OperationLogInfo info = optReturn.Data as OperationLogInfo; if (info == null) { continue; } info.LogArgs = S1206App.DecryptString(info.LogArgs); mListOptContentLangIDs.Add(info.LangID); GetOptContentLangID(info); mListOptLogInfos.Add(info); mRecordCount++; } //去除重复 mListOptContentLangIDs = mListOptContentLangIDs.Where((l, i) => mListOptContentLangIDs.FindIndex(z => z == l) == i).ToList(); CurrentApp.WriteLog("LoadOptLogInfo", string.Format("Load end.\t{0}", mListOptLogInfos.Count)); } catch (Exception ex) { ShowException(ex.Message); } }