add basic evnet logging and remove ambiguous ping controller

This commit is contained in:
Alan Moon 2025-03-14 16:58:46 -07:00
parent d3b7270dcd
commit 94ede223f3
3 changed files with 36 additions and 17 deletions

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using sodoff.Model; using sodoff.Model;
using sodoff.Util;
namespace sodoff.Controllers.Common namespace sodoff.Controllers.Common
{ {
@ -29,9 +30,14 @@ namespace sodoff.Controllers.Common
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("AnalyticsWebService.asmx/LogEvent")] [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<Schema.LogEvent>(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); return Ok(true);
} }

View File

@ -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!");
}
}
}

28
src/Schema/LogEvent.cs Normal file
View File

@ -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;
}