public WebHookController(Db db, IHttpClientFactory httpClientFactory) { _stackModel = new StackModel(db); _logModel = new LogModel(db); _systemLogModel = new SystemLogModel(db); _httpClientFactory = httpClientFactory; }
public ActionResult DeleteForWhere(string Where) { SystemLogModel.Delete(Where); LogDAL.AppendSQLLog(MTConfig.CurrentUserID, typeof(SystemLogModel)); return(JsonSuccess(DeleteSuccess)); }
public ActionResult SystemLogDetails(object id) { ViewData[EditFlag] = true; var item = SystemLogModel.SingleOrDefault(id); return(View(item)); }
public ActionResult Delete(string id) { SystemLogModel.Delete(" where ID in (" + id + ")"); LogDAL.AppendSQLLog(MTConfig.CurrentUserID, typeof(SystemLogModel)); return(JsonSuccess(DeleteSuccess)); }
public ActionResult SystemLogEdit(SystemLogModel model) { if (string.IsNullOrEmpty(model.ID)) { ViewData[EditFlag] = true; model.InsTime = System.DateTime.Now; if (model.Insert() != null) { LogDAL.AppendSQLLog(MTConfig.CurrentUserID, typeof(SystemLogModel)); return(JsonSuccess("")); } return(JsonError("")); } else { ViewData[EditFlag] = true; model.InsTime = System.DateTime.Now; if (model.Update() > 0) { LogDAL.AppendSQLLog(MTConfig.CurrentUserID, typeof(SystemLogModel)); return(JsonSuccess("")); } return(JsonError("")); } }
public void ExportSystemLog() { switch (_exportType) { case LogExportType.Text: { _w.WriteLine("- PEBakery System Log -"); _w.WriteLine($"Exported by PEBakery {Global.Const.ProgramVersionStrFull}"); _w.WriteLine($"Exported at {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt K", CultureInfo.InvariantCulture)}"); _w.WriteLine(); var logs = _db.Table <LogModel.SystemLog>().OrderBy(x => x.Time); foreach (LogModel.SystemLog log in logs) { if (log.State == LogState.None) { _w.WriteLine($"[{log.TimeStr}] {log.Message}"); } else { _w.WriteLine($"[{log.TimeStr}] [{log.State}] {log.Message}"); } } } break; case LogExportType.Html: { Assembly assembly = Assembly.GetExecutingAssembly(); SystemLogModel m = new SystemLogModel { // Information HeadTitle = "PEBakery System Log", ExportEngineVersion = Global.Const.ProgramVersionStrFull, ExportTimeStr = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt K", CultureInfo.InvariantCulture), // Embed EmbedBootstrapCss = ResourceHelper.GetEmbeddedResourceString("Html.bootstrap.min.css", assembly), EmbedJQuerySlimJs = ResourceHelper.GetEmbeddedResourceString("Html.jquery.slim.min.js", assembly), EmbedBootstrapJs = ResourceHelper.GetEmbeddedResourceString("Html.bootstrap.bundle.min.js", assembly), // Data }; foreach (LogModel.SystemLog log in _db.Table <LogModel.SystemLog>().OrderBy(x => x.Time)) { m.SysLogs.AddItem(new SystemLogItem { TimeStr = log.TimeStr, State = log.State, Message = log.Message }); } HtmlRenderer.RenderHtmlAsync("Html._SystemLogView.sbnhtml", assembly, m, _w).Wait(); } break; } }
public ActionResult List() { if (!_permissionService.Authorize("ManageLogs")) { return(AccessDeniedView()); } var model = new SystemLogModel(); return(View(model)); }
public ActionResult SystemLogIndex(Page <SystemLogModel> model, string orderby = "") { ViewBag.orderby = orderby; if (model.CurrentPage <= 0) { model.CurrentPage = 1; } StringBuilder where = new StringBuilder("where 1=1 "); if (model.Item != null) { if (model.Item.ID != null) { where.AppendFormat(" and ID = {0} ", model.Item.ID); } if (model.Item.UserID != null) { where.AppendFormat(" and UserID = {0} ", model.Item.UserID); } if (model.Item.Type != null) { where.AppendFormat(" and Type = {0} ", model.Item.Type); } if (!string.IsNullOrEmpty(model.Item.LogInfo)) { where.AppendFormat(" and LogInfo like '%{0}%' ", model.Item.LogInfo.Trim()); } if (model.Item.InsTime != null) { where.AppendFormat(" and CONVERT(varchar(100),InsTime,23) = '{0}' ", model.Item.InsTime.Value.ToString("yyyy-MM-dd")); } if (!string.IsNullOrEmpty(model.Item.IP)) { where.AppendFormat(" and IP like '%{0}%' ", model.Item.IP.Trim()); } if (!string.IsNullOrEmpty(model.Item.Parameters)) { where.AppendFormat(" and Parameters like '%{0}%' ", model.Item.Parameters.Trim()); } } if (string.IsNullOrEmpty(orderby)) { where.Append(" order by ID desc"); } else { where.Append(" order by " + orderby + ""); } var page = SystemLogModel.Page(model.CurrentPage, MTConfig.ItemsPerPage, where.ToString(), model.Item); page.Item = model.Item; LogDAL.AppendSQLLog(MTConfig.CurrentUserID, typeof(SystemLogModel)); return(View(page)); }
public override void Write(object o) { SystemLogModel log = o as SystemLogModel; if (this.baseSeverityString != null && this.baseSeverityString.Contains(log.Severity.ToString())) { new SystemLogRepo().Insert(log); } else { new SystemLogRepo().Insert(log); } }
public void Save(SystemLogModel model) { vmsServerLinqDataContext datacontext = new vmsServerLinqDataContext(); SystemLog log = new SystemLog(); log.LogID = GetLongID(); log.LogValue = model.LogValue; log.Type = model.LogType; log.Time = model.LogTime; log.Source = model.Source; log.StackTrace = model.StackTrace; datacontext.SystemLogs.InsertOnSubmit(log); datacontext.SubmitChanges(); }
public void Save(SystemLogModel model) { vmsServerLinqDataContext datacontext = new vmsServerLinqDataContext(); SystemLog log = new SystemLog(); log.LogID = GetLongID(); log.LogValue = model.LogValue; log.Type = model.LogType; log.Time = model.LogTime; log.Source = model.Source; log.StackTrace = model.StackTrace; datacontext.SystemLogs.InsertOnSubmit(log); datacontext.SubmitChanges(); }
/// <summary> /// 登录验证 /// </summary> /// <param name="info"></param> /// <returns></returns> public async Task <UserDto> CheckLoginAsync(LoginInputDto info) { var group = await GroupRepository.GetByGroupAsync(info.GroupCode); UserDto user = new UserDto(); //if (hotel == null) //{ // user.State = LoginState.InvalidHotelCode; // return user; //} //var verifyUser = await UserRepository.GetByUserNameAsync(hotel.HotelId2.ToString(), info.UserName); var verifyUser = await UserRepository.GetByUserCodeAndGroupIdAsync(info.UserCode, info.GroupCode.ToInt()); if (verifyUser == null) { user.State = LoginState.InvalidAccount; return(user); } //if (user.UserPwd != info.UserPwd) //{ // user.State = LoginState.InvalidPassword; // return user; //} user.State = LoginState.Successed; user.UserCode = verifyUser.UserCode; user.UserName = verifyUser.UserName; user.ConnectionString = null; //hotel.ConnectionString; user.RoleId = ""; //verifyUser.RoleId; user.GroupCode = null; //hotel.HotelId2.ToString();//指定数据库连接Token SystemLogModel model = new SystemLogModel(); model.TypeId = 10; //系统登录 model.OperateModuleType = 10; //登录 model.OperatedTime = DateTime.Now; model.Content = "于" + DateTime.Now.ToString() + "登陆,电脑名称-" + Net.Host + ",登陆IP地址-" + Net.Ip;; model.Title = "系统登录"; model.OperateId = verifyUser.Id; model.Operator = verifyUser.UserName; model.OrganizationId = 0; model.OrganizationType = 1; //var logResult = UserLogRepository.SaveLog(hotel.HotelId2.ToString(), logInfo);//写入操作日志记录 var logResult = SysLogRepository.SaveModel(model);//写入操作日志记录 return(user); }
public ActionResult SystemLogEdit(object id, int actiontype = 0) { ViewData[EditFlag] = true; if (actiontype == 1) { SystemLogModel model = new SystemLogModel(); return(View(model)); } else { SystemLogModel model = SystemLogModel.SingleOrDefault(id); return(View(model)); } }
public IActionResult SystemLogDetail(int id) { var log = _logService.GetSystemLogById(id); var model = new SystemLogModel { Id = log.Id, LogTypeStr = log.LogLevel.Description(), Description = log.Description, Content = log.Content, IpAddress = log.IpAddress, ReferenceUrl = log.ReferenceUrl, CreatedTimeStr = log.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss") }; return(View(model)); }
public void TEST_HTTP_POST_SEND_SYS_LOG_BY_LEGAL_URL() { var model = new SystemLogModel { Source = "zlead", Host = "192.168.1.2", App = AppEnum.ANDROID, Type = RequestTypeEnum.API, Url = "https://www.baidu.com", Mode = ModeEnum.GET, Level = LevelEnum.DEBUG, Date = DateTime.Now, Edition = "v1.1.1", Message = "这是测试数据2003" }; Assert.Equal(HttpStatusCode.OK, HttpSingleton.Instance.PostSendLog(TestStaticString._postLegalUrl, model).code); }
private void RegisterLog(string logValue, string logType, string source, string stacktrace) { log4net.Info("Save Log:" + logValue + " - " + logType + " - " + source + " - " + stacktrace); try { SystemLogModel model = new SystemLogModel(); model.LogValue = logValue; model.LogType = logType; model.Source = source; model.StackTrace = stacktrace; model.LogTime = DateTime.Now; logAccess.Save(model); } catch (Exception ex) { log4net.Error("Cannot save log. Reason:" + ex.Message); } }
/// <summary> /// excute before action run /// </summary> /// <param name="context"></param> public void OnActionExecuting(ActionExecutingContext context) { _stopWatch = new Stopwatch(); _stopWatch.Start(); _acitonContext = context; var request = context.HttpContext.Request; _log = new SystemLogModel() { ID = Guid.NewGuid().ToString(), CreateTime = DateTime.Now, UserIP = context.HttpContext.Connection.RemoteIpAddress?.ToString(), Url = request.Path, Method = request.Method, LogType = LogTypeEnum.Log }; SetLogProperty(); switch (request.Method) { case "GET": _log.Params = request.QueryString.ToString(); break; case "POST": var stream = context.HttpContext.Request.Body; stream.Position = 0; using (var reader = new StreamReader(stream)) { _log.Params = reader.ReadToEnd().Trim(); } break; case "PUT": break; case "DELETE": break; } }
public static SystemLog ToEntity(this SystemLogModel model) { return(model.MapTo <SystemLogModel, SystemLog>()); }
public LogController(Db db) { _systemLogModel = new SystemLogModel(db); }
public long Add(SystemLogModel log) { return(_repository.Add(log)); }
private void RegisterLog(string logValue, string logType, string source, string stacktrace) { log4net.Info("Save Log:" + logValue + " - " + logType + " - " + source + " - " + stacktrace); try { SystemLogModel model = new SystemLogModel(); model.LogValue = logValue; model.LogType = logType; model.Source = source; model.StackTrace = stacktrace; model.LogTime = DateTime.Now; logAccess.Save(model); } catch (Exception ex) { log4net.Error("Cannot save log. Reason:" + ex.Message); } }
public static SystemLog ToEntity(this SystemLogModel model, SystemLog destination) { return(model.MapTo(destination)); }
public HomeController(Db db, AppSetting appSetting) { _userModel = new UserModel(db, appSetting); _systemLogModel = new SystemLogModel(db); }