fix: add tieline type to output for console & CWS

This commit is contained in:
Andrew Welker
2024-06-24 14:57:07 -05:00
parent c50726f813
commit ba4ca20936
2 changed files with 82 additions and 90 deletions

View File

@@ -1,13 +1,6 @@
using System; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DM;
using PepperDash.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
@@ -89,8 +82,8 @@ namespace PepperDash.Essentials.Core
public override string ToString() public override string ToString()
{ {
return string.Format("Tie line: {0}:{1} --> {2}:{3}", SourcePort.ParentDevice.Key, SourcePort.Key, return string.Format("Tie line: {0}:{1} --> {2}:{3} {4}", SourcePort.ParentDevice.Key, SourcePort.Key,
DestinationPort.ParentDevice.Key, DestinationPort.Key); DestinationPort.ParentDevice.Key, DestinationPort.Key, Type.ToString());
} }
} }
@@ -109,6 +102,6 @@ namespace PepperDash.Essentials.Core
} }
[JsonIgnore] [JsonIgnore]
static TieLineCollection _Default; private static TieLineCollection _Default;
} }
} }

View File

@@ -1,25 +1,24 @@
using Crestron.SimplSharp.WebScripting; using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers; using PepperDash.Core.Web.RequestHandlers;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core.Web.RequestHandlers namespace PepperDash.Essentials.Core.Web.RequestHandlers
{ {
public class GetTieLinesRequestHandler:WebApiBaseRequestHandler public class GetTieLinesRequestHandler : WebApiBaseRequestHandler
{ {
public GetTieLinesRequestHandler() : base(true) { } public GetTieLinesRequestHandler() : base(true) { }
protected override void HandleGet(HttpCwsContext context) protected override void HandleGet(HttpCwsContext context)
{ {
var tieLineString = JsonConvert.SerializeObject(TieLineCollection.Default.Select((tl) => new { var tieLineString = JsonConvert.SerializeObject(TieLineCollection.Default.Select((tl) => new
{
sourceKey = tl.SourcePort.ParentDevice.Key, sourceKey = tl.SourcePort.ParentDevice.Key,
sourcePort = tl.SourcePort.Key, sourcePort = tl.SourcePort.Key,
destinationKey = tl.DestinationPort.ParentDevice.Key, destinationKey = tl.DestinationPort.ParentDevice.Key,
destinationPort = tl.DestinationPort.Key destinationPort = tl.DestinationPort.Key,
type = tl.Type.ToString(),
})); }));
context.Response.StatusCode = 200; context.Response.StatusCode = 200;