public string LogEvent(EventLogModel eventModel) { string success; try { using (var db = new OggleBoobleMySqlContext()) { db.EventLogs.Add(new EventLog() { FolderId = eventModel.FolderId, EventCode = eventModel.EventCode, EventDetail = eventModel.EventDetail, CalledFrom = eventModel.CalledFrom, VisitorId = eventModel.VisitorId, Occured = DateTime.Now }); db.SaveChanges(); } success = "ok"; } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
public LineApiController() { func = new Functional(); richMenu = new LineMessageTemplate.RichMenuResponse(); ChannelAccessToken = "q281ubFyT1L3Z1gAyrcLdLY4mHv2hXJFqAb/MEUO2OncgbgXdSsR6BDCXsrTZh0I3haZwDDaz1lrKF694gC0fTnp/CnbLma8WkiHW3UXwSf6gHxU5lNJP/IYeb1+KQRFeun9E5jJT8qx9lpQpY1S9AdB04t89/1O/w1cDnyilFU="; AccessTokenForSupport = "4bw1smnE8oLXGQg09XJRhq9H4xHh9w1207hwUxq5q1l"; clsPushMultiCast = new PushLineResponseMultiCastModel(); clsdupBubbleMultiCast = new dupBubbleMulticast(); clsdupBubbleMultiCastNoFooter = new dupBubbleMulticastNoFooter(); dataEvent = new EventLogModel(); }
public async Task AddStudentEvent(int studentId, EventLogTypes eventType, string remoteIp) { EventLogModel log = new EventLogModel() { Date = DateTime.Now, StudentId = studentId, Type = (int)eventType, IPAddress = remoteIp }; await AddStudentEvent(log); }
public LineApiController(string ChannelName) { func = new Functional(); richMenu = new LineMessageTemplate.RichMenuResponse(); ChannelAccessToken = "q281ubFyT1L3Z1gAyrcLdLY4mHv2hXJFqAb/MEUO2OncgbgXdSsR6BDCXsrTZh0I3haZwDDaz1lrKF694gC0fTnp/CnbLma8WkiHW3UXwSf6gHxU5lNJP/IYeb1+KQRFeun9E5jJT8qx9lpQpY1S9AdB04t89/1O/w1cDnyilFU="; // ChannelAccessToken = "Pq+kySWPUtbt1YvcDtMHXkbUIrN7CDqzx18DAPS4Ij153mb+1id7NNKp7m3c74Fg5h54zPR1kFraEGm8JC31540oCiUPSwgK3SiKsYd9+nftcztMkFRg2u0PXGReejmHfKccPvNmTSwEIB63yyOvFAdB04t89/1O/w1cDnyilFU="; AccessTokenForSupport = "4bw1smnE8oLXGQg09XJRhq9H4xHh9w1207hwUxq5q1l"; clsPushMultiCast = new PushLineResponseMultiCastModel(); clsdupBubbleMultiCast = new dupBubbleMulticast(); clsdupBubbleMultiCastNoFooter = new dupBubbleMulticastNoFooter(); dataEvent = new EventLogModel(); }
public EventLogModel GetFeulByObject(int ObjectId) { var url = "api/EventLog?ObjectId=" + ObjectId; string result = SC.Getcaller(url); if (result != null) { EventLogModel _event = JsonConvert.DeserializeObject <EventLogModel>(result); return(_event); } else { return(null); } }
public async Task AddStudentEvent(EventLogModel log) { const string sql = @" INSERT INTO [dbo].[EventLog] ([Date], [ModifiedBy], [StudentId], [Type], [IPAddress]) VALUES (@Date, @ModifiedBy, @StudentId, @Type, @IpAddress)"; try { log.Date = log.Date.ToUniversalTime(); await UnitOfWork.Context().ExecuteAsync(sql, log); } catch (Exception e) { e.Data["SQL"] = sql; ErrorStore.LogException(e, HttpContext.Current); throw e; } }
public async Task UpsertAsync(EventLogModel eventLog) { ItemResponse <EventLogModel> recordAdded = await _db.EventLog.UpsertItemAsync(eventLog); _logger.LogInformation($"{nameof(UpsertAsync)} RequestCharge:{recordAdded.RequestCharge}"); }
public async Task <IActionResult> RunAsync( [HttpTrigger(AuthorizationLevel.Function, "put", Route = "v1/event_log")] HttpRequest req ) { _logger.LogInformation($"{nameof(RunAsync)}"); // Check Content-Length. if (!req.Headers.ContainsKey(HEADER_CONTENT_LENGTH)) { return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } string contentLengthHeader = req.Headers[HEADER_CONTENT_LENGTH].ToString(); bool isNumeric = long.TryParse(contentLengthHeader, out long contentLength); if (!isNumeric) { return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } else if (contentLength < 0) { return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } else if (contentLength > Constants.MAX_SIZE_EVENT_LOG_PAYLOAD_BYTES) { return(new StatusCodeResult((int)HttpStatusCode.RequestEntityTooLarge)); } var requestBody = await new StreamReader(req.Body).ReadToEndAsync(); // Check RequestBody size. if (Encoding.ASCII.GetBytes(requestBody).LongLength > Constants.MAX_SIZE_EVENT_LOG_PAYLOAD_BYTES) { return(new StatusCodeResult((int)HttpStatusCode.RequestEntityTooLarge)); } // Check Valid Route IValidationServerService.ValidateResult validateResult = _validationServerService.Validate(req); if (!validateResult.IsValid) { if (validateResult.ErrorActionResult is BadRequestResult) { return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } else { return(validateResult.ErrorActionResult); } } V1EventLogSubmissionParameter submissionParameter; try { submissionParameter = JsonConvert.DeserializeObject <V1EventLogSubmissionParameter>(requestBody); } catch (JsonSerializationException e) { _logger.LogError("JsonSerializationException occurred."); return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } var requestTime = DateTimeOffset.UtcNow; // validation device if (!await _deviceValidationService.Validation(submissionParameter.Platform, submissionParameter, requestTime)) { _logger.LogInformation($"Invalid Device"); return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } var timestamp = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); using (SHA256 sha256 = SHA256.Create()) { foreach (var eventLog in submissionParameter.EventLogs) { // For considering user-privacy safe. if (!eventLog.HasConsent) { _logger.LogError("No consent log detected."); continue; } string id = ByteArrayUtils.ToHexString(sha256.ComputeHash(Encoding.ASCII.GetBytes(eventLog.ClearText))); var eventLogModel = new EventLogModel( eventLog.HasConsent, eventLog.Epoch, eventLog.Type, eventLog.Subtype, eventLog.Content, eventLog.Timestamp ) { id = id, Created = timestamp, }; await _eventLogRepository.UpsertAsync(eventLogModel); } } return(new StatusCodeResult((int)HttpStatusCode.Created)); }
public static void Add(EventLogModel eventLog) { eventLog.ID = _logs.Count + 1; eventLog.Time = DateTime.Now; _logs.Add(eventLog); }
private async Task AddStudentEvent(EventLogModel log) { await EventLogRepository.AddStudentEvent(log); }