public ActionResult Logging() { var logsData = new LoggingRepository().GetAll().ToList(); var logs = new List <LoggingViewModel>(); foreach (var item in logsData) { var log = new LoggingViewModel(); log.date = item.actionDate.ToString(); log.username = item.userName; log.ip = item.requestIP; log.controller = item.controllerName; log.action = item.actionName; log.httpRequestType = item.requestType; log.httpParameters = item.requestParams; logs.Add(log); } LogHelper logHelper = new LogHelper(); logHelper.getParams(this, 0); logHelper.logToDatabase(logHelper); return(View(logs)); }
public async Task <object> Post([FromBody] LoggingViewModel model) { MessageBase2 result = new MessageBase2(); LoggingDto dto = ConvertHelper.ChangeType <LoggingDto>(model); await _loggingService.AddAsync(dto); return(result); }
public Logging() { InitializeComponent(); BindingContext = viewModel = new LoggingViewModel() { Navigation = Navigation }; }
protected override void Act() { var cacheManager = LoggingViewModel.GetDescendentsOfType <TraceListenerData>().Single(); try { cacheManager.Property("TraceOutputOptions").BindableProperty.BindableValue = "abc"; } catch { } }
/// <summary> /// This method can be used to implement an independent logging through an endpoint /// </summary> /// <param name="loggingViewModel"></param> /// <param name="loggingBaseUrl"></param> public static void PostLogMessage(LoggingViewModel loggingViewModel, string loggingBaseUrl) { var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsync(loggingBaseUrl + "/logger", new StringContent(JsonConvert.SerializeObject(loggingViewModel), Encoding.UTF8, "application/json")).Result; response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { _ = response.Content.ReadAsStringAsync().Result; } }
protected override void Arrange() { base.Arrange(); elementViewModel = LoggingViewModel.GetDescendentsOfType <TraceListenerData>().Single(); HostAdapter.TasksChanged += (sender, args) => validationError = args.Tasks.First(); try { elementViewModel.Property("Filter").BindableProperty.BindableValue = "abc"; } catch { } }
private static LoggingViewModel GetVM(IEnumerable <WorkflowDescriptor> descriptors = null) { var vm = new LoggingViewModel(); var commService = new Mock <ICommunicationService>(); if (descriptors == null) { descriptors = new List <WorkflowDescriptor>(); } commService.Setup(s => s.GetResources(It.IsAny <string>())).Returns(descriptors); commService.Setup(s => s.GetDataListInputs(It.IsAny <string>(), It.IsAny <string>())).Returns(new List <DataListVariable>()); vm.CommunicationService = commService.Object; return(vm); }
private Log MapFromModel(LoggingViewModel model) { return(new Log { Id = model.Id, User = model.User, IPAddress = model.IPAddress, Controller = model.Controller, Action = model.Action, Method = model.Method, LogType = model.LogType, Date = model.Date }); }
/// <summary> /// Log Error /// </summary> /// <param name="methodName">Name of the method where the context belongs to</param> /// <param name="message">Message to be logged</param> /// <param name="ex">Exception object</param> protected void LogError(string methodName, string message, Exception ex) { var loggerModel = new LoggingViewModel(); loggerModel.CorrelationId = _corelationId; loggerModel.ApplicationName = this.GetType().Namespace; loggerModel.ClassName = this.GetType().Name; loggerModel.MethodName = methodName; loggerModel.LogType = LogTypeClassificationEnum.ERROR; loggerModel.ErrorMessage = message; loggerModel.Request = null; loggerModel.Response = null; loggerModel.Ex = ex; //BaseService.PostLogMessage(loggerModel, _configuration["LoggingSection:LoggingServiceURL"]); BaseService.PostLogMessage(loggerModel); }
public ActionResult Login(LoggingViewModel model) { if (ModelState.IsValid) { _loginService.Login(model.Login, model.Password); if (!_loginService.Login(model.Login, model.Password)) { this.ModelState.AddModelError("", "Login or password is incorrect"); return(View(model)); } return(RedirectToAction("Index", "Home")); } else { this.ModelState.AddModelError("", "Error"); } return(View(model)); }
public async Task <IActionResult> Index(int page = 1, DateTime?DateFrom = null, DateTime?DateTo = null, string RowId = "", LoggingAction?LoggingAction = null, LoggingCategory?LoggingCategory = null) { DateFrom = (DateFrom != null && DateFrom != DateTime.MinValue) ? ConvertDatetime.ConvertToGregorianDate((DateTime)DateFrom) : DateFrom; DateTo = (DateTo != null && DateTo != DateTime.MinValue) ? ConvertDatetime.ConvertToGregorianDate((DateTime)DateTo) : DateTo; var _model = new LoggingViewModel { DateFrom = DateFrom, DateTo = DateTo, RowID = RowId, LoggingAction = LoggingAction, LoggingCategory = LoggingCategory }; var _Data = await loggingService.SearchInLogging(DateFrom, DateTo, RowId, LoggingAction, LoggingCategory); _model.LoggingList = _Data.Select(a => new LoggingViewModelItems { ID = a.ID, ActionDate = a.ActionDate, LoggingAction = a.LoggingAction, LoggingCategory = a.LoggingCategory, RowID = a.RowID, UserName = a.UserData?.FirstName + " " + a.UserData?.SecondName + " " + a.UserData?.ThirdName, }).ToPagedList(page, Constants.PageSize); return(View(_model)); }
public ActionResult Logs() { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\burkarty\Documents\logging.mdf;Integrated Security=True;Connect Timeout=30"; SqlCommand cmd_credentials = new SqlCommand(); cmd_credentials.CommandText = "SELECT * FROM [dbo].[UserLog] ul JOIN [dbo].[User] u ON ul.UserId = u.Id ORDER BY ul.CreatedOn DESC"; cmd_credentials.Connection = con; con.Open(); SqlDataReader reader = cmd_credentials.ExecuteReader(); if (reader.HasRows) { List <LoggingViewModel> model = new List <LoggingViewModel>(); while (reader.Read()) { var log_entry = new LoggingViewModel(); log_entry.UserId = reader.GetValue(10).ToString(); log_entry.LogId = reader.GetValue(0).ToString(); log_entry.LogCreatedOn = reader.GetValue(7).ToString(); model.Add(log_entry); } return(View(model)); } else { ViewBag.Message = "No Results found"; return(View()); } }
/// <summary> /// File based logging /// </summary> /// <param name="loggingViewModel"></param> public static void PostLogMessage(LoggingViewModel loggingViewModel) { FileLogger(JsonConvert.SerializeObject(loggingViewModel)); }
public ActionResult Login() { var model = new LoggingViewModel(); return(View(model)); }
public LoggingView() { ViewModel = new LoggingViewModel(); this.InitializeComponent(); }