From 94ede223f39eac79c2a22ed6ead1d5576f6c0e8a Mon Sep 17 00:00:00 2001 From: AlanMoonbase Date: Fri, 14 Mar 2025 16:58:46 -0700 Subject: [PATCH] add basic evnet logging and remove ambiguous ping controller --- src/Controllers/Common/AnalyticsController.cs | 10 +++++-- src/Controllers/Common/PingController.cs | 15 ---------- src/Schema/LogEvent.cs | 28 +++++++++++++++++++ 3 files changed, 36 insertions(+), 17 deletions(-) delete mode 100644 src/Controllers/Common/PingController.cs create mode 100644 src/Schema/LogEvent.cs diff --git a/src/Controllers/Common/AnalyticsController.cs b/src/Controllers/Common/AnalyticsController.cs index ae11475..fe540bb 100644 --- a/src/Controllers/Common/AnalyticsController.cs +++ b/src/Controllers/Common/AnalyticsController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using sodoff.Model; +using sodoff.Util; namespace sodoff.Controllers.Common { @@ -29,9 +30,14 @@ namespace sodoff.Controllers.Common [HttpPost] [Produces("application/xml")] [Route("AnalyticsWebService.asmx/LogEvent")] - public IActionResult LogEvent() + public IActionResult LogEvent([FromForm] string eventXml) { - // placeholder to prevent a ton of 404's + DateTime now = DateTime.UtcNow; + Schema.LogEvent? eventClass = XmlUtil.DeserializeXml(eventXml); + string eventToLog = $"Event Logged At {now.ToLocalTime()}\nUserID - {eventClass.UserID}\nEvent Category ID - {eventClass.EventCategoryID}\nEvent Type ID - {eventClass.EventTypeID}\nEvent Data - {eventClass.Data}"; + + Console.WriteLine(eventToLog); + return Ok(true); } diff --git a/src/Controllers/Common/PingController.cs b/src/Controllers/Common/PingController.cs deleted file mode 100644 index 39302f4..0000000 --- a/src/Controllers/Common/PingController.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace sodoff.Controllers.Common -{ - public class PingController : Controller - { - [HttpPost] - [Route("PingWebService.asmx/GetPingPayload")] - public IActionResult GetPingPayload() - { - return Ok("Pong!"); - } - } -} diff --git a/src/Schema/LogEvent.cs b/src/Schema/LogEvent.cs new file mode 100644 index 0000000..5fd988c --- /dev/null +++ b/src/Schema/LogEvent.cs @@ -0,0 +1,28 @@ +using System; +using System.Xml.Serialization; + +namespace sodoff.Schema; + +[XmlRoot(ElementName = "LogEvent", Namespace = "")] +[Serializable] +public class LogEvent +{ + [XmlElement(ElementName = "ApiKey")] + public string ApiKey; + + [XmlElement(ElementName = "ApiToken")] + public string ApiToken; + + [XmlElement(ElementName = "UserID")] + public string UserID; + + [XmlElement(ElementName = "EventTypeID")] + public int EventTypeID; + + [XmlElement(ElementName = "EventCategoryID")] + public int EventCategoryID; + + // Token: 0x040003CB RID: 971 + [XmlElement(ElementName = "Data")] + public string Data; +}