/// <summary> /// 操作日志 /// </summary> public OperationLogHandler(HttpRequest httpRequest) : base("OperateLogToDatabase") { var request = HttpContexts.Current.Request; log = new OperateLog() { Id = CombUtil.NewComb(), CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ServerHost = $"{IpBrowserUtil.GetServerHost()}【{IpBrowserUtil.GetServerHostIp()}】", ClientHost = $"{IpBrowserUtil.GetClientIp()}", RequestContentLength = httpRequest.ContentLength == null ? 0 : (int)httpRequest.ContentLength, RequestType = request.Method, UserAgent = request.Headers[HeaderNames.UserAgent] }; if (request.Method.ToLower() == "post") { var Result = httpRequest.Form; log.RequestData = httpRequest.Form.ToJson(); } else { log.RequestData = HttpUtility.UrlDecode(new StreamReader(httpRequest.Body).ReadToEnd()); } log.Url = new StringBuilder() .Append(request.Scheme) .Append("://") .Append(request.Host) .Append(request.PathBase) .Append(request.Path) .Append(request.QueryString) .ToString(); log.UrlReferrer = httpRequest.Headers[HeaderNames.Referer]; }
public async Task <JsonResult> GetDataBaseColumnsTree(SystemDataBaseTableDoubleWay doubleWay) { var columns = await _dataBaseLogic.GetDataBaseColumns(doubleWay); IList <TreeEntity> treeEntities = new List <TreeEntity>(); var parentId = CombUtil.NewComb(); TreeEntity treeEntity = new TreeEntity { id = parentId, name = doubleWay.TableName, nocheck = true }; treeEntities.Add(treeEntity); foreach (var co in columns) { treeEntity = new TreeEntity { pId = parentId, name = co.ColumnDescription + "(" + co.ColumnName + ")", code = co.ColumnDescription, id = co.ColumnName }; treeEntities.Add(treeEntity); } return(Json(treeEntities)); }
/// <summary> /// 保存人员信息 /// </summary> /// <param name="user">人员信息</param> /// <returns></returns> public async Task <OperateStatus> SaveUser(SystemUserSaveInput user) { OperateStatus operateStatus = new OperateStatus(); if (string.IsNullOrWhiteSpace(user.Id.ToString())) { user.CreateTime = DateTime.Now; user.Password = _3DESEncrypt.Encrypt("123456"); var resultUser = await _systemUserRepository.InsertAsync( new SystemUser(CombUtil.NewComb(), user.Code, user.Name, user.Password, user.Mobile, user.Email, user.FirstVisitTime, user.LastVisitTime, user.Remark, user.IsAdmin, user.CreateTime, user.IsFreeze, user.ImgUrl)); if (resultUser != null) { //添加用户到组织机构 operateStatus = await _permissionUserLogic.SavePermissionUser(EnumPrivilegeMaster.角色, user.RoleId, new List <string> { user.Id.ToString() }); if (operateStatus.ResultSign == ResultSign.Successful) { return(operateStatus); } } else { return(operateStatus); } } else { //删除对应组织机构 operateStatus = await _permissionUserLogic.DeletePrivilegeMasterUser(user.Id.ToString(), EnumPrivilegeMaster.角色); if (operateStatus.ResultSign == ResultSign.Successful) { //添加用户到组织机构 operateStatus = await _permissionUserLogic.SavePermissionUser(EnumPrivilegeMaster.角色, user.RoleId, new List <string> { user.Id.ToString() }); if (operateStatus.ResultSign == ResultSign.Successful) { var userInfo = await _systemUserRepository.GetAsync(user.Id); user.Password = userInfo.Password; var result = await _systemUserRepository.UpdateAsync(user); if (result != null) { operateStatus.Message = "Success"; operateStatus.ResultSign = ResultSign.Successful; } } } } return(operateStatus); }
/// <summary> /// 保存字典信息 /// </summary> /// <param name="dictionary">字典信息</param> /// <returns></returns> public async Task <OperateStatus> SaveDictionary(SystemDictionary dictionary) { OperateStatus operateStatus; if (dictionary.DictionaryId.IsEmptyGuid()) { dictionary.CreateTime = DateTime.Now; dictionary.CanbeDelete = true; dictionary.DictionaryId = CombUtil.NewComb(); operateStatus = await InsertAsync(dictionary); } else { dictionary.UpdateTime = DateTime.Now; dictionary.UpdateUserId = dictionary.CreateUserId; dictionary.UpdateUserName = dictionary.CreateUserName; var dic = await GetByIdAsync(dictionary.DictionaryId); dictionary.CanbeDelete = dic.CanbeDelete; dictionary.CreateTime = dic.CreateTime; dictionary.CreateUserId = dic.CreateUserId; dictionary.CreateUserName = dic.CreateUserName; operateStatus = await UpdateAsync(dictionary); } GeneratingParentIds(); return(operateStatus); }
/// <summary> /// 保存数据库配置 /// </summary> /// <param name="app">数据库配置</param> /// <returns></returns> public async Task <OperateStatus> SaveDataBase(SystemDataBase app) { if (!app.DataBaseId.IsEmptyGuid()) { return(await UpdateAsync(app)); } app.DataBaseId = CombUtil.NewComb(); return(await InsertAsync(app)); }
/// <summary> /// 保存按钮信息 /// </summary> /// <param name="button">按钮信息</param> /// <returns></returns> public async Task <OperateStatus> SaveButton(WorkflowButton button) { if (!button.ButtonId.IsEmptyGuid()) { return(await UpdateAsync(button)); } button.ButtonId = CombUtil.NewComb(); return(await InsertAsync(button)); }
/// <summary> /// 保存 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public async Task <OperateStatus> Save(SystemDownload entity) { if (!entity.DownloadId.IsEmptyGuid()) { return(await UpdateAsync(entity)); } entity.DownloadId = CombUtil.NewComb(); return(await InsertAsync(entity)); }
/// <summary> /// 保存 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public async Task <OperateStatus> Save(GanttTask entity) { if (!entity.Id.IsEmptyGuid()) { return(await UpdateAsync(entity)); } entity.Id = CombUtil.NewComb(); return(await InsertAsync(entity)); }
/// <summary> /// 保存数据库配置 /// </summary> /// <param name="emailAccount">数据库配置</param> /// <returns></returns> public async Task <OperateStatus> SaveEmailAccount(SystemEmailAccount emailAccount) { if (!emailAccount.EmailAccountId.IsEmptyGuid()) { return(await UpdateAsync(emailAccount)); } emailAccount.EmailAccountId = CombUtil.NewComb(); return(await InsertAsync(emailAccount)); }
/// <summary> /// 保存功能项信息 /// </summary> /// <param name="function">功能项信息</param> /// <returns></returns> public async Task <OperateStatus> SaveMenuButton(SystemMenuButton function) { if (function.MenuButtonId.IsEmptyGuid()) { function.MenuButtonId = CombUtil.NewComb(); return(await InsertAsync(function)); } return(await UpdateAsync(function)); }
/// <summary> /// 保存数据库配置 /// </summary> /// <param name="app">数据库配置</param> /// <returns></returns> public async Task <OperateStatus> SaveApp(SystemApp app) { if (!app.AppId.IsEmptyGuid()) { return(await UpdateAsync(app)); } app.AppId = CombUtil.NewComb(); return(await InsertAsync(app)); }
/// <summary> /// 保存字段信息 /// </summary> /// <param name="field">字段信息</param> /// <returns></returns> public async Task <OperateStatus> SaveField(SystemField field) { if (field.FieldId.IsEmptyGuid()) { field.FieldId = CombUtil.NewComb(); return(await InsertAsync(field)); } return(await UpdateAsync(field)); }
/// <summary> /// 保存配置信息 /// </summary> /// <param name="systemConfig"></param> /// <returns></returns> public Task <OperateStatus> SaveConfig(SystemConfig systemConfig) { if (systemConfig.Id.IsEmptyGuid()) { systemConfig.Id = CombUtil.NewComb(); systemConfig.CreateTime = DateTime.Now; return(InsertAsync(systemConfig)); } return(UpdateAsync(systemConfig)); }
/// <summary> /// 保存字典信息 /// </summary> /// <param name="dictionary">字典信息</param> /// <returns></returns> public async Task <OperateStatus> SaveDictionary(SystemDictionary dictionary) { if (dictionary.DictionaryId.IsEmptyGuid()) { dictionary.CanbeDelete = true; dictionary.DictionaryId = CombUtil.NewComb(); return(await InsertAsync(dictionary)); } return(await UpdateAsync(dictionary)); }
/// <summary> /// 保存数据权限规则 /// </summary> /// <param name="data">数据权限规则</param> /// <returns></returns> public async Task <OperateStatus> SaveData(SystemDataOutput data) { SystemData systemData = data.MapTo <SystemData>(); if (data.DataId.IsEmptyGuid()) { systemData.DataId = CombUtil.NewComb(); return(await InsertAsync(systemData)); } return(await UpdateAsync(systemData)); }
/// <summary> /// 保存功能项信息 /// </summary> /// <param name="input">功能项信息</param> /// <returns></returns> public async Task <OperateStatus> SaveMenuButton(SystemMenuButtonSaveInput input) { SystemMenuButton button = input.MapTo <SystemMenuButton>(); if (button.MenuButtonId.IsEmptyGuid()) { button.MenuButtonId = CombUtil.NewComb(); return(await InsertAsync(button)); } return(await UpdateAsync(button)); }
/// <summary> /// 保存文章 /// </summary> /// <param name="article"></param> /// <returns></returns> public Task <OperateStatus> SaveArticle(SystemArticle article) { if (article.ArticleId.IsEmptyGuid()) { article.ArticleId = CombUtil.NewComb(); return(InsertAsync(article)); } else { return(UpdateAsync(article)); } }
/// <summary> /// 保存菜单 /// </summary> /// <param name="systemMenu"></param> /// <returns></returns> public Task <OperateStatus> SaveMenu(SystemMenu systemMenu) { if (systemMenu.MenuId.IsEmptyGuid()) { systemMenu.MenuId = CombUtil.NewComb(); return(InsertAsync(systemMenu)); } else { return(UpdateAsync(systemMenu)); } }
/// <summary> /// 保存人员信息 /// </summary> /// <param name="user">人员信息</param> /// <param name="RoleId">业务表Id:如组织机构、角色Id</param> /// <returns></returns> public async Task <OperateStatus> SaveUser(SystemUserSaveInput user) { OperateStatus operateStatus; if (string.IsNullOrWhiteSpace(user.UserId)) { user.CreateTime = DateTime.Now; user.UserId = CombUtil.NewComb().ToString(); user.Password = _3DESEncrypt.Encrypt("123456"); operateStatus = await InsertAsync(user as SystemUser); if (operateStatus.ResultSign == ResultSign.Successful) { //添加用户到组织机构 operateStatus = await _permissionUserLogic.SavePermissionUser(EnumPrivilegeMaster.角色, user.RoleId, new List <string> { user.UserId }); if (operateStatus.ResultSign == ResultSign.Successful) { return(operateStatus); } } else { return(operateStatus); } } else { //删除对应组织机构 operateStatus = await _permissionUserLogic.DeletePrivilegeMasterUser(user.UserId, EnumPrivilegeMaster.角色); if (operateStatus.ResultSign == ResultSign.Successful) { //添加用户到组织机构 operateStatus = await _permissionUserLogic.SavePermissionUser(EnumPrivilegeMaster.角色, user.RoleId, new List <string> { user.UserId }); if (operateStatus.ResultSign == ResultSign.Successful) { var userInfo = await GetById(user.UserId); user.Password = userInfo.Password; return(await UpdateAsync(user)); } } } return(operateStatus); }
/// <summary> /// 构造函数 /// </summary> /// <param name="exception"></param> public ExceptionLogHandler(Exception exception) : base("ExceptionLogToDatabase") { PrincipalUser principalUser = new PrincipalUser(); var current = HttpContexts.Current; if (current != null) { principalUser = AuthenticationExtension.Current(); } if (principalUser == null) { principalUser = new PrincipalUser() { Name = "匿名用户", UserId = Guid.Empty }; } log = new ExceptionLog() { ExceptionLogId = CombUtil.NewComb().ToString(), CreateUserCode = principalUser.Code, CreateUserId = principalUser.UserId.ToString(), CreateUserName = principalUser.Name, ServerHost = String.Format("{0}【{1}】", IpBrowserUtil.GetServerHost(), IpBrowserUtil.GetServerHostIp()), ClientHost = String.Format("{0}", IpBrowserUtil.GetClientIp()), Runtime = "Web", CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Message = exception.Message, StackTrace = exception.StackTrace, ExceptionType = exception.GetType().FullName, ClientAddress = IpBrowserUtil.GetAddressByApi() }; //获取服务器信息 var request = HttpContexts.Current.Request; log.RequestUrl = string.Format("{0} ", request.Path); log.HttpMethod = request.Method; log.UserAgent = request.Headers["user-agent"]; log.InnerException = exception.InnerException != null?GetExceptionFullMessage(exception.InnerException) : ""; if (request?.HasFormContentType ?? request.HasFormContentType) { log.RequestData = request?.Form?.ToJson(); } else { if (request.Body.CanSeek) { log.RequestData = HttpUtility.UrlDecode(new StreamReader(request?.Body).ReadToEnd()); } } }
/// <summary> /// 保存功能项信息 /// </summary> /// <returns>功能项信息</returns> public async Task <OperateStatus> SaveMenuButton(SystemMenuButton menuButton) { if (menuButton.MenuButtonId.IsEmptyGuid()) { menuButton.CreateTime = DateTime.Now; menuButton.MenuButtonId = CombUtil.NewComb(); return(await InsertAsync(menuButton)); } else { var sysbutton = await _systemMenuButtonRepository.GetById(menuButton.MenuButtonId); menuButton.CreateTime = sysbutton.CreateTime; return(await UpdateAsync(menuButton)); } }
public async Task <OperateStatus> SavePays(SystemPays systemPays) { if (systemPays.PayId.IsEmptyGuid()) { systemPays.PayId = CombUtil.NewComb(); systemPays.CreateTime = DateTime.Now; return(await InsertAsync(systemPays)); } else { var pay = await _systemPaysRepository.GetById(systemPays.PayId); systemPays.CreateTime = pay.CreateTime; return(await UpdateAsync(systemPays)); } }
/// <summary> /// 保存文章类型 /// </summary> /// <param name="articleType"></param> /// <returns></returns> public async Task <OperateStatus> SaveArticleType(SystemArticleType articleType) { if (articleType.ArticleTypeId.IsEmptyGuid()) { articleType.CreateTime = DateTime.Now; articleType.ArticleTypeId = CombUtil.NewComb(); return(await InsertAsync(articleType)); } else { var artType = await _systemArticleTypeRepository.GetById(articleType.ArticleTypeId); articleType.CreateTime = artType.CreateTime; return(await UpdateAsync(articleType)); } }
/// <summary> /// 构造函数 /// </summary> public SqlLogHandler(string operateSql, DateTime endDateTime, double elapsedTime, string parameter ) : base("SqlLog") { Log = new SqlLog { SqlLogId = CombUtil.NewComb(), CreateTime = DateTime.Now, OperateSql = operateSql, ElapsedTime = elapsedTime, EndDateTime = endDateTime, Parameter = parameter }; }
/// <summary> /// 操作日志 /// </summary> public OperationLogHandler(HttpRequest httpRequest) : base("OperateLogToDatabase") { var request = HttpContexts.Current.Request; log = new OperateLog() { Id = CombUtil.NewComb(), CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ServerHost = String.Format("{0}【{1}】", IpBrowserUtil.GetServerHost(), IpBrowserUtil.GetServerHostIp()), ClientHost = String.Format("{0}", IpBrowserUtil.GetClientIp()), RequestContentLength = httpRequest.ContentLength == null ? 0 : (int)httpRequest.ContentLength, RequestType = request.Method, UserAgent = request.Headers[HeaderNames.UserAgent] }; if (request?.HasFormContentType ?? request.HasFormContentType) { log.RequestData = request?.Form?.ToJson(); } else { if (request.Body.CanSeek) { log.RequestData = HttpUtility.UrlDecode(new StreamReader(request?.Body).ReadToEnd()); } //if (request?.Body != null) //{ // log.RequestData = HttpUtility.UrlDecode(new StreamReader(request?.Body).ReadToEnd()); //} //else if (request?.Form != null) //{ // log.RequestData = request?.Form?.ToJson(); //} } log.Url = new StringBuilder() .Append(request.Scheme) .Append("://") .Append(request.Host) .Append(request.PathBase) .Append(request.Path) .Append(request.QueryString) .ToString(); log.UrlReferrer = httpRequest.Headers[HeaderNames.Referer]; }
/// <summary> /// 保存岗位信息 /// </summary> /// <param name="post">岗位信息</param> /// <returns></returns> public async Task <OperateStatus> SavePost(SystemPost post) { if (post.PostId.IsEmptyGuid()) { post.CreateTime = DateTime.Now; post.PostId = CombUtil.NewComb(); return(await InsertAsync(post)); } SystemPost systemPost = await GetByIdAsync(post.PostId); post.CreateTime = systemPost.CreateTime; post.CreateUserId = systemPost.CreateUserId; post.CreateUserName = systemPost.CreateUserName; post.UpdateTime = DateTime.Now; post.UpdateUserId = post.CreateUserId; post.UpdateUserName = post.CreateUserName; return(await UpdateAsync(post)); }
/// <summary> /// 保存菜单 /// </summary> /// <param name="menu">菜单信息</param> /// <returns></returns> public async Task <OperateStatus> SaveMenu(SystemMenu menu) { OperateStatus result; menu.CanbeDelete = true; if (menu.MenuId.IsEmptyGuid()) { menu.MenuId = CombUtil.NewComb(); result = await InsertAsync(menu); } else { result = await UpdateAsync(menu); } await GeneratingParentIds(); return(result); }
public LoginLogHandler(string UserId, string Code, string UserName, int LoginStatus) : base("LoginLogToDatabase") { log = new LoginLog { LoginLogId = CombUtil.NewComb().ToString(), CreateUserId = UserId, CreateUserCode = Code ?? "", ServerHost = String.Format("{0}【{1}】", IpBrowserUtil.GetServerHost(), IpBrowserUtil.GetServerHostIp()), ClientHost = String.Format("{0}", IpBrowserUtil.GetClientIp()), UserAgent = IpBrowserUtil.GetBrowser(), OsVersion = IpBrowserUtil.GetOsVersion(), LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), IpAddressName = IpBrowserUtil.GetAddressByApi(), CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), CreateUserName = UserName, LoginStatus = LoginStatus }; }
/// <summary> /// 保存基本信息 /// </summary> /// <param name="form"></param> /// <returns></returns> public async Task <OperateStatus> Save(WorkflowForm form) { if (form.FormId.IsEmptyGuid()) { form.CreateTime = DateTime.Now; form.CreateUserId = form.UpdateUserId; form.CreateUserName = form.UpdateUserName; form.FormId = CombUtil.NewComb(); return(await InsertAsync(form)); } WorkflowForm workflowProcess = await GetByIdAsync(form.FormId); form.CreateTime = workflowProcess.CreateTime; form.CreateUserId = workflowProcess.CreateUserId; form.CreateUserName = workflowProcess.CreateUserName; form.Html = workflowProcess.Html; form.SubTableJson = workflowProcess.SubTableJson; return(await UpdateAsync(form)); }
public LoginLogHandler(string userId, string code, string userName, int loginStatus) : base("LoginLogToDatabase") { log = new LoginLog { Id = CombUtil.NewComb(), CreateUserId = userId, CreateUserCode = code ?? "", ServerHost = $"{IpBrowserUtil.GetServerHost()}【{IpBrowserUtil.GetServerHostIp()}】", ClientHost = $"{IpBrowserUtil.GetClientIp()}", UserAgent = IpBrowserUtil.GetBrowser(), OsVersion = IpBrowserUtil.GetOsVersion(), LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), IpAddressName = IpBrowserUtil.GetAddressByApi(), CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), CreateUserName = userName, LoginStatus = loginStatus }; }