Compare commits

..

4 Commits

Author SHA1 Message Date
Andrew Welker
b8f83b666b build: adjust allowed extensions for nuget packages 2024-02-05 11:15:00 -06:00
Andrew Welker
6e3804ce4c ci: add verbose output switch for msbuild 2024-02-05 10:57:48 -06:00
Andrew Welker
f139b01b29 build: fix condition parens 2024-02-05 10:57:33 -06:00
Andrew Welker
05bee43d85 build: actually get everything building correctly 2024-02-05 10:41:36 -06:00
27 changed files with 258 additions and 592 deletions

View File

@@ -65,7 +65,7 @@ jobs:
run: nuget restore .\$($Env:SOLUTION_FILE).sln
# Build the solutions in the docker image
- name: Build Solution
run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m
run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m -v:diag
- name: Create tag for non-rc builds
if: contains(steps.setVersion.outputs.version, 'alpha')
run: |
@@ -79,7 +79,7 @@ jobs:
# contains(steps.setVersion.outputs.version, '-beta-')
uses: ncipollo/release-action@v1
with:
artifacts: 'output\**\*.*(cpz|cplz)'
artifacts: 'output\**\*.*(cpz|cplz|nupkg)'
generateReleaseNotes: true
prerelease: ${{contains('debug', env.BUILD_TYPE)}}
tag: ${{ steps.setVersion.outputs.version }}

View File

@@ -42,7 +42,7 @@ jobs:
uses: ncipollo/release-action@v1
with:
updateRelease: true
artifacts: 'output\**\*.*(cpz|cplz)'
artifacts: 'output\**\*.*(cpz|cplz|nupkg)'
tag: ${{ steps.setVersion.outputs.version }}
- name: Setup Nuget
run: |

View File

@@ -1,7 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.0.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<Authors>PepperDash Technologies</Authors>
<Company>PepperDash Technologies</Company>
<Product>PepperDash Essentials</Product>
@@ -13,9 +12,11 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.cpz;.cplz</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\LICENSE.md" Pack="true" PackagePath=""/>
<None Include="..\..\README.md" Pack="true" PackagePath=""/>
<None Include="..\..\README.md" Pack="true" PackagePath=""/>
</ItemGroup>
</Project>

View File

@@ -1,26 +1,40 @@
<Project>
<ItemGroup>
<None Include="$(PackageOutputPath)\$(AssemblyName)\*.cpz" Condition="$(ProjectType) == 'Program'">
<Pack>true</Pack>
<PackagePath>build;</PackagePath>
</None>
<None Include="$(PackageOutputPath)\$(AssemblyName)\*.cplz" Condition="$(ProjectType) == 'ProgramLibrary'">
<Pack>true</Pack>
<PackagePath>build;</PackagePath>
</None>
</ItemGroup>
<Target Name="Create CPLZ" AfterTargets="Build; AfterRebuild" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''">
<Message Text="Creating CPLZ $(TargetDir)"></Message>
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))" />
<MakeDir Directories="$(PackageOutputPath)\$(AssemblyName)" Condition="!Exists('$(PackageOutputPath)\$(AssemblyName)')" />
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cplz" Overwrite="true"/>
<ItemGroup>
<FilesToDelete Include="$(TargetDir)*.cplz" />
</ItemGroup>
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))"/>
<Delete Files="@(FilesToDelete)" />
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(AssemblyName).$(Version).$(TargetFramework).cplz" Overwrite="true"/>
<Copy SourceFiles="$(PackageOutputPath)\$(AssemblyName).$(Version).$(TargetFramework).cplz" DestinationFiles="$(OutputPath)\$(AssemblyName).$(Version).$(TargetFramework).cplz" />
</Target>
<Target Name="Copy CPZ NET6" AfterTargets="SimplSharpPostProcess" Condition="($(ProjectType) == 'Program' And ( '$(TargetFramework)' == 'net6.0' ) Or ( '$(TargetFramework)' == 'net8.0' ))">
<Message Text="Copying CPZ"></Message>
<Move SourceFiles="$(TargetDir)$(TargetName).cpz" DestinationFiles="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz" />
<Target Name="Delete Old CPZ" BeforeTargets="BeforeBuild" Condition="$(ProjectType) == 'Program'">
<ItemGroup>
<FilesToDelete Include="$(TargetDir)*.cpz" />
</ItemGroup>
<Delete Files="@(FilesToDelete)" />
</Target>
<Target Name="Copy CPZ NET47" AfterTargets="SimplSharpPostProcess47" Condition="($(ProjectType) == 'Program' And ( '$(TargetFramework)' != 'net6.0' ) And ( '$(TargetFramework)' != 'net8.0' ))">
<Target Name="Move CPZ NET6" AfterTargets="SimplSharpPostProcess" Condition="(($(ProjectType) == 'Program') And ( '$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'net8.0' ))">
<Message Text="Copying CPZ"></Message>
<Move SourceFiles="$(TargetDir)$(TargetName).cpz" DestinationFiles="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz" />
<Move SourceFiles="$(TargetDir)$(TargetName).cpz" DestinationFiles="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz" />
<Copy SourceFiles="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz" DestinationFiles="$(PackageOutputPath)\$(TargetName).$(Version).$(TargetFramework).cpz" />
</Target>
<Target Name="Move CPZ NET47" AfterTargets="SimplSharpPostProcess47" Condition="($(ProjectType) == 'Program' And ( '$(TargetFramework)' != 'net6.0' And '$(TargetFramework)' != 'net8.0' ))">
<Message Text="Copying CPZ"></Message>
<Move SourceFiles="$(TargetDir)$(TargetName).cpz" DestinationFiles="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz" />
<Copy SourceFiles="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz" DestinationFiles="$(PackageOutputPath)\$(TargetName).$(Version).$(TargetFramework).cpz" />
</Target>
<Target Name="Include Crestron Zips" BeforeTargets="GenerateNuspec">
<ItemGroup>
<None Include="$(OutputPath)\**\*.cpz" Condition="$(ProjectType) == 'Program'">
<Pack>true</Pack>
<PackagePath>build;</PackagePath>
</None>
<None Include="$(OutputPath)\**\*.cplz" Condition="$(ProjectType) == 'ProgramLibrary'">
<Pack>true</Pack>
<PackagePath>build;</PackagePath>
</None>
</ItemGroup>
</Target>
</Project>

View File

@@ -375,7 +375,8 @@ namespace PepperDash.Essentials.Core.Bridges
{
try
{
Debug.Console(2, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
if (Debug.Level >= 1)
Debug.Console(1, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject;
if (uo == null) return;

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core
{
public interface ILoadConfig
{
void GoWithLoad();
}
}

View File

@@ -1,6 +1,4 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
@@ -19,39 +17,8 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
/// Describes a MobileSystemController that accepts IEssentialsRoom
/// </summary>
public interface IMobileControl3 : IMobileControl
{
void SendMessageObject(IMobileControlMessage o);
void AddAction(string key, Action<JToken> action);
void RemoveAction(string key);
void AddDeviceMessenger(IMobileControlMessenger messenger);
bool CheckForDeviceMessenger(string key);
}
/// <summary>
/// Describes a mobile control messenger
/// </summary>
public interface IMobileControlMessenger: IKeyed
{
IMobileControl3 AppServerController { get; }
string MessagePath { get; }
void RegisterWithAppServer(IMobileControl3 appServerController);
}
public interface IMobileControlMessage
{
[JsonProperty("type")]
string Type { get; }
[JsonProperty("clientId", NullValueHandling = NullValueHandling.Ignore)]
string ClientId { get; }
[JsonProperty("content", NullValueHandling = NullValueHandling.Ignore)]
JToken Content { get; }
void CreateMobileControlRoomBridge(IEssentialsRoom room, IMobileControl parent);
}
/// <summary>

View File

@@ -189,7 +189,7 @@ namespace PepperDash.Essentials.Core
CrestronConsole.ConsoleCommandResponse(
@"Type: '{0}'
CType: '{1}'
Description: {2}{3}", type.Key, cType, description, CrestronEnvironment.NewLine);
Description: {2}", type.Key, cType, description);
}
}

View File

@@ -21,9 +21,14 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Web\**" />
<EmbeddedResource Remove="Web\**" />
<None Remove="Web\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-385" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-383" />
</ItemGroup>
<ItemGroup>
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />

View File

@@ -75,6 +75,11 @@ namespace PepperDash.Essentials
version = Global.AssemblyVersion;
break;
}
case ("PepperDash_Essentials_DM.dll"):
{
version = Global.AssemblyVersion;
break;
}
case ("Essentials Devices Common.dll"):
{
version = Global.AssemblyVersion;

View File

@@ -154,7 +154,8 @@ namespace PepperDash.Essentials.Core.UI
private void Panel_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
{
Debug.Console(5, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
if (Debug.Level == 2)
Debug.Console(2, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject;
if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);

View File

@@ -9,7 +9,7 @@ using PepperDash.Essentials.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web
{
public class EssentialsWebApi : EssentialsDevice
public class EssemtialsWebApi : EssentialsDevice
{
private readonly WebApiServer _server;
@@ -43,7 +43,7 @@ namespace PepperDash.Essentials.Core.Web
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
public EssentialsWebApi(string key, string name)
public EssemtialsWebApi(string key, string name)
: this(key, name, null)
{
}
@@ -54,7 +54,7 @@ namespace PepperDash.Essentials.Core.Web
/// <param name="key"></param>
/// <param name="name"></param>
/// <param name="config"></param>
public EssentialsWebApi(string key, string name, EssentialsWebApiPropertiesConfig config)
public EssemtialsWebApi(string key, string name, EssentialsWebApiPropertiesConfig config)
: base(key, name)
{
Key = key;
@@ -65,115 +65,91 @@ namespace PepperDash.Essentials.Core.Web
BasePath = string.IsNullOrEmpty(config.BasePath) ? _defaultBasePath : config.BasePath;
_server = new WebApiServer(Key, Name, BasePath);
SetupRoutes();
Initialize();
}
private void SetupRoutes()
/// <summary>
/// Custom activate, add routes
/// </summary>
/// <returns></returns>
public override bool CustomActivate()
{
var routes = new List<HttpCwsRoute>
{
new HttpCwsRoute("versions")
{
Name = "ReportVersions",
RouteHandler = new ReportVersionsRequestHandler()
},
new HttpCwsRoute("appdebug")
{
Name = "AppDebug",
RouteHandler = new AppDebugRequestHandler()
},
new HttpCwsRoute("devices")
{
Name = "DevList",
RouteHandler = new DevListRequestHandler()
},
new HttpCwsRoute("deviceCommands")
{
Name = "DevJson",
RouteHandler = new DevJsonRequestHandler()
},
new HttpCwsRoute("deviceProperties/{deviceKey}")
{
Name = "DevProps",
RouteHandler = new DevPropsRequestHandler()
},
new HttpCwsRoute("deviceMethods/{deviceKey}")
{
Name = "DevMethods",
RouteHandler = new DevMethodsRequestHandler()
},
new HttpCwsRoute("deviceFeedbacks/{deviceKey}")
{
Name = "GetFeedbacksForDeviceKey",
RouteHandler = new GetFeedbacksForDeviceRequestHandler()
},
new HttpCwsRoute("deviceStreamDebug")
{
Name = "SetDeviceStreamDebug",
RouteHandler = new SetDeviceStreamDebugRequestHandler()
},
new HttpCwsRoute("disableAllStreamDebug")
{
Name = "DisableAllStreamDebug",
RouteHandler = new DisableAllStreamDebugRequestHandler()
},
new HttpCwsRoute("config")
{
Name = "ShowConfig",
RouteHandler = new ShowConfigRequestHandler()
},
new HttpCwsRoute("types")
{
Name = "GetTypes",
RouteHandler = new GetTypesRequestHandler()
},
new HttpCwsRoute("types/{filter}")
{
Name = "GetTypesByFilter",
RouteHandler = new GetTypesByFilterRequestHandler()
},
new HttpCwsRoute("joinMap/{bridgeKey}")
{
Name = "GetJoinMapsForBridgeKey",
RouteHandler = new GetJoinMapForBridgeKeyRequestHandler()
},
new HttpCwsRoute("joinMap/{bridgeKey}/{deviceKey}")
{
Name = "GetJoinMapsForDeviceKey",
RouteHandler = new GetJoinMapForDeviceKeyRequestHandler()
},
new HttpCwsRoute("debugSession")
var routes = new List<HttpCwsRoute>
{
new HttpCwsRoute("reportversions")
{
Name = "DebugSession",
RouteHandler = new DebugSessionRequestHandler()
Name = "ReportVersions",
RouteHandler = new ReportVersionsRequestHandler()
},
new HttpCwsRoute("doNotLoadConfigOnNextBoot")
new HttpCwsRoute("appdebug")
{
Name = "DoNotLoadConfigOnNextBoot",
RouteHandler = new DoNotLoadConfigOnNextBootRequestHandler()
Name = "AppDebug",
RouteHandler = new AppDebugRequestHandler()
},
new HttpCwsRoute("restartProgram")
{
Name = "Restart Program",
RouteHandler = new RestartProgramRequestHandler()
},
new HttpCwsRoute("loadConfig")
{
Name = "Load Config",
RouteHandler = new LoadConfigRequestHandler()
}
new HttpCwsRoute("devlist")
{
Name = "DevList",
RouteHandler = new DevListRequestHandler()
},
new HttpCwsRoute("devprops")
{
Name = "DevProps",
RouteHandler = new DevPropsRequestHandler()
},
new HttpCwsRoute("devjson")
{
Name = "DevJson",
RouteHandler = new DevJsonRequestHandler()
},
new HttpCwsRoute("setdevicestreamdebug")
{
Name = "SetDeviceStreamDebug",
RouteHandler = new SetDeviceStreamDebugRequestHandler()
},
new HttpCwsRoute("disableallstreamdebug")
{
Name = "DisableAllStreamDebug",
RouteHandler = new DisableAllStreamDebugRequestHandler()
},
new HttpCwsRoute("showconfig")
{
Name = "ShowConfig",
RouteHandler = new ShowConfigRequestHandler()
},
new HttpCwsRoute("gettypes")
{
Name = "GetTypes",
RouteHandler = new GetTypesRequestHandler()
},
new HttpCwsRoute("gettypes/{filter}")
{
Name = "GetTypesByFilter",
RouteHandler = new GetTypesByFilterRequestHandler()
},
new HttpCwsRoute("getjoinmap/{bridgeKey}")
{
Name = "GetJoinMapsForBridgeKey",
RouteHandler = new GetJoinMapForBridgeKeyRequestHandler()
},
new HttpCwsRoute("getjoinmap/{bridgeKey}/{deviceKey}")
{
Name = "GetJoinMapsForDeviceKey",
RouteHandler = new GetJoinMapForDeviceKeyRequestHandler()
},
new HttpCwsRoute("feedbacks/{deviceKey}")
{
Name = "GetFeedbacksForDeviceKey",
RouteHandler = new GetFeedbacksForDeviceRequestHandler()
}
};
};
foreach (var route in routes.Where(route => route != null))
{
var r = route;
_server.AddRoute(r);
}
foreach (var route in routes.Where(route => route != null))
{
var r = route;
_server.AddRoute(r);
}
}
return base.CustomActivate();
}
/// <summary>
/// Initializes the CWS class

View File

@@ -4,7 +4,7 @@ using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core.Web
{
public class EssentialsWebApiFactory : EssentialsDeviceFactory<EssentialsWebApi>
public class EssentialsWebApiFactory : EssentialsDeviceFactory<EssemtialsWebApi>
{
public EssentialsWebApiFactory()
{
@@ -16,7 +16,7 @@ namespace PepperDash.Essentials.Core.Web
Debug.Console(1, "Factory Attempting to create new Essentials Web API Server");
var props = dc.Properties.ToObject<EssentialsWebApiPropertiesConfig>();
if (props != null) return new EssentialsWebApi(dc.Key, dc.Name, props);
if (props != null) return new EssemtialsWebApi(dc.Key, dc.Name, props);
Debug.Console(1, "Factory failed to create new Essentials Web API Server");
return null;

View File

@@ -2,9 +2,6 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Web.RequestHandlers;
using System;
using Serilog.Events;
using Newtonsoft.Json.Converters;
namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
@@ -27,7 +24,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
/// <param name="context"></param>
protected override void HandleGet(HttpCwsContext context)
{
var appDebug = new AppDebug { MinimumLevel = Debug.WebsocketMinimumLogLevel };
var appDebug = new AppDebug { Level = Debug.Level };
var body = JsonConvert.SerializeObject(appDebug, Formatting.Indented);
@@ -63,11 +60,11 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
}
var appDebug = new AppDebug();
var requestBody = JsonConvert.DeserializeObject<AppDebug>(data);
var requestBody = JsonConvert.DeserializeAnonymousType(data, appDebug);
Debug.SetWebSocketMinimumDebugLevel(requestBody.MinimumLevel);
Debug.SetDebugLevel(requestBody.Level);
appDebug.MinimumLevel = Debug.WebsocketMinimumLogLevel;
appDebug.Level = Debug.Level;
var responseBody = JsonConvert.SerializeObject(appDebug, Formatting.Indented);
context.Response.StatusCode = 200;
@@ -79,8 +76,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
public class AppDebug
{
[JsonProperty("minimumLevel", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public LogEventLevel MinimumLevel { get; set; }
[JsonProperty("level", NullValueHandling = NullValueHandling.Ignore)]
public int Level { get; set; }
}
}

View File

@@ -1,96 +0,0 @@
using Crestron.SimplSharp;
using Crestron.SimplSharp.WebScripting;
using Crestron.SimplSharpPro.EthernetCommunication;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Web.RequestHandlers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
public class DebugSessionRequestHandler : WebApiBaseRequestHandler
{
public DebugSessionRequestHandler()
: base(true)
{
}
/// <summary>
/// Gets details for a debug session
/// </summary>
/// <param name="context"></param>
protected override void HandleGet(Crestron.SimplSharp.WebScripting.HttpCwsContext context)
{
var routeData = context.Request.RouteData;
if (routeData == null)
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
return;
}
try
{
var ip = CrestronEthernetHelper.GetEthernetParameter(
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
var port = 0;
if (!Debug.WebsocketSink.IsRunning)
{
Debug.Console(0, "Starting WS Server");
// Generate a random port within a specified range
port = new Random().Next(65435, 65535);
// Start the WS Server
Debug.WebsocketSink.StartServerAndSetPort(port);
Debug.SetWebSocketMinimumDebugLevel(Serilog.Events.LogEventLevel.Verbose);
}
var url = Debug.WebsocketSink.Url;
object data = new
{
url = Debug.WebsocketSink.Url
};
Debug.Console(0, "Debug Session URL: {0}", url);
// Return the port number with the full url of the WS Server
var res = JsonConvert.SerializeObject(data);
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.Write(res, false);
context.Response.End();
}
catch (Exception e)
{
Debug.Console(0, "Error: {0}", e);
}
}
/// <summary>
/// Stops a debug session
/// </summary>
/// <param name="context"></param>
protected override void HandlePost(HttpCwsContext context)
{
Debug.WebsocketSink.StopServer();
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.End();
Debug.Console(0, "Websocket Debug Session Stopped");
}
}
}

View File

@@ -1,76 +0,0 @@
using System.Text;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
public class DevMethodsRequestHandler : WebApiBaseRequestHandler
{
/// <summary>
/// Constructor
/// </summary>
/// <remarks>
/// base(true) enables CORS support by default
/// </remarks>
public DevMethodsRequestHandler()
: base(true)
{
}
/// <summary>
/// Handles GET method requests
/// </summary>
/// <param name="context"></param>
protected override void HandleGet(HttpCwsContext context)
{
var routeData = context.Request.RouteData;
if (routeData == null)
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
return;
}
object deviceObj;
if (!routeData.Values.TryGetValue("deviceKey", out deviceObj))
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
return;
}
var device = DeviceManager.GetDeviceForKey(deviceObj.ToString());
if (device == null)
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Device Not Found";
context.Response.End();
return;
}
var deviceMethods = DeviceJsonApi.GetMethods(device.Key);
if (deviceMethods == null || deviceMethods.ToLower().Contains("no device"))
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Not Found";
context.Response.End();
return;
}
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.Write(deviceMethods, false);
context.Response.End();
}
}
}

View File

@@ -18,59 +18,59 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
}
/// <summary>
/// Handles GET method requests
/// </summary>
/// <param name="context"></param>
protected override void HandleGet(HttpCwsContext context)
{
var routeData = context.Request.RouteData;
if (routeData == null)
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
/// <summary>
/// Handles POST method requests
/// </summary>
/// <param name="context"></param>
protected override void HandlePost(HttpCwsContext context)
{
if (context.Request.ContentLength < 0)
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
return;
}
return;
}
object deviceObj;
if (!routeData.Values.TryGetValue("deviceKey", out deviceObj))
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
var data = EssentialsWebApiHelpers.GetRequestBody(context.Request);
if (string.IsNullOrEmpty(data))
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
return;
}
return;
}
var device = DeviceManager.GetDeviceForKey(deviceObj.ToString());
var o = new DeviceActionWrapper();
var body = JsonConvert.DeserializeAnonymousType(data, o);
if (string.IsNullOrEmpty(body.DeviceKey))
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
if (device == null)
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Device Not Found";
context.Response.End();
return;
}
return;
}
var deviceProps = DeviceJsonApi.GetProperties(body.DeviceKey);
if (deviceProps == null || deviceProps.ToLower().Contains("no device"))
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Not Found";
context.Response.End();
var deviceProperties = DeviceJsonApi.GetProperties(device.Key);
if (deviceProperties == null || deviceProperties.ToLower().Contains("no device"))
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Not Found";
context.Response.End();
return;
}
return;
}
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.Write(deviceProperties, false);
context.Response.End();
}
}
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.Write(deviceProps, false);
context.Response.End();
}
}
}

View File

@@ -1,84 +0,0 @@
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
public class DoNotLoadConfigOnNextBootRequestHandler : WebApiBaseRequestHandler
{
/// <summary>
/// Constructor
/// </summary>
/// <remarks>
/// base(true) enables CORS support by default
/// </remarks>
public DoNotLoadConfigOnNextBootRequestHandler()
: base(true)
{
}
/// <summary>
/// Handles GET method requests
/// </summary>
/// <param name="context"></param>
protected override void HandleGet(HttpCwsContext context)
{
var data = new Data
{
DoNotLoadConfigOnNextBoot = Debug.DoNotLoadConfigOnNextBoot
};
var body = JsonConvert.SerializeObject(data, Formatting.Indented);
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.Write(body, false);
context.Response.End();
}
/// <summary>
/// Handles POST method requests
/// </summary>
/// <param name="context"></param>
protected override void HandlePost(HttpCwsContext context)
{
if (context.Request.ContentLength < 0)
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
return;
}
var data = EssentialsWebApiHelpers.GetRequestBody(context.Request);
if (string.IsNullOrEmpty(data))
{
context.Response.StatusCode = 400;
context.Response.StatusDescription = "Bad Request";
context.Response.End();
return;
}
var d = new Data();
var requestBody = JsonConvert.DeserializeAnonymousType(data, d);
Debug.SetDoNotLoadConfigOnNextBoot(requestBody.DoNotLoadConfigOnNextBoot);
var responseBody = JsonConvert.SerializeObject(d, Formatting.Indented);
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.Write(responseBody, false);
context.Response.End();
}
}
public class Data
{
[JsonProperty("doNotLoadConfigOnNextBoot", NullValueHandling = NullValueHandling.Ignore)]
public bool DoNotLoadConfigOnNextBoot { get; set; }
}
}

View File

@@ -1,6 +1,8 @@
using System.Linq;
extern alias Full
using System.Linq;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using Full.Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers

View File

@@ -1,6 +1,8 @@
using System.Linq;
extern alias Full
using System.Linq;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using Full.Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers

View File

@@ -1,39 +0,0 @@
using Crestron.SimplSharp;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
public class LoadConfigRequestHandler : WebApiBaseRequestHandler
{
/// <summary>
/// Constructor
/// </summary>
/// <remarks>
/// base(true) enables CORS support by default
/// </remarks>
public LoadConfigRequestHandler()
: base(true)
{
}
/// <summary>
/// Handles POST method requests
/// </summary>
/// <param name="context"></param>
protected override void HandlePost(HttpCwsContext context)
{
var message = "";
var cs = Global.ControlSystem as ILoadConfig;
if(cs != null)
cs.GoWithLoad();
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.Write(message, false);
context.Response.End();
}
}
}

View File

@@ -1,6 +1,8 @@
using System.Linq;
extern alias Full
using System.Linq;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using Full.Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers

View File

@@ -1,38 +0,0 @@
using Crestron.SimplSharp;
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
public class RestartProgramRequestHandler : WebApiBaseRequestHandler
{
/// <summary>
/// Constructor
/// </summary>
/// <remarks>
/// base(true) enables CORS support by default
/// </remarks>
public RestartProgramRequestHandler()
: base(true)
{
}
/// <summary>
/// Handles POST method requests
/// </summary>
/// <param name="context"></param>
protected override void HandlePost(HttpCwsContext context)
{
var message = "";
if(CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance)
CrestronConsole.SendControlSystemCommand($"progres -p:{InitialParametersClass.ApplicationNumber}", ref message);
context.Response.StatusCode = 200;
context.Response.StatusDescription = "OK";
context.Response.Write(message, false);
context.Response.End();
}
}
}

View File

@@ -1,5 +1,7 @@
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
extern alias Full
using Crestron.SimplSharp.WebScripting;
using Full.Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers;
using PepperDash.Essentials.Core.Config;

View File

@@ -27,6 +27,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-385" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-383" />
</ItemGroup>
</Project>

View File

@@ -10,13 +10,12 @@ using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Web;
using System;
using System.Linq;
namespace PepperDash.Essentials
{
public class ControlSystem : CrestronControlSystem, ILoadConfig
public class ControlSystem : CrestronControlSystem
{
HttpLogoServer LogoServer;
@@ -88,7 +87,7 @@ namespace PepperDash.Essentials
{
DeterminePlatform();
if (Debug.DoNotLoadConfigOnNextBoot)
if (Debug.DoNotLoadOnNextBoot)
{
CrestronConsole.AddNewConsoleCommand(s => CrestronInvoke.BeginInvoke((o) => GoWithLoad()), "go", "Loads configuration file",
ConsoleAccessLevelEnum.AccessOperator);
@@ -136,9 +135,7 @@ namespace PepperDash.Essentials
CrestronConsole.AddNewConsoleCommand(DeviceManager.GetRoutingPorts,
"getroutingports", "Reports all routing ports, if any. Requires a device key", ConsoleAccessLevelEnum.AccessOperator);
DeviceManager.AddDevice(new EssentialsWebApi("essentialsWebApi", "Essentials Web API"));
if (!Debug.DoNotLoadConfigOnNextBoot)
if (!Debug.DoNotLoadOnNextBoot)
{
GoWithLoad();
return;
@@ -173,8 +170,6 @@ namespace PepperDash.Essentials
Global.SetAssemblyVersion(fullVersion);
//Global.SetAssemblyVersion(fullVersionAtt.InformationalVersion);
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS
{
string userFolder;
@@ -222,7 +217,7 @@ namespace PepperDash.Essentials
}
else // Handles Linux OS (Virtual Control)
{
//Debug.SetDebugLevel(2);
Debug.SetDebugLevel(2);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", Global.AssemblyVersion);
@@ -245,7 +240,7 @@ namespace PepperDash.Essentials
{
try
{
Debug.SetDoNotLoadConfigOnNextBoot(false);
Debug.SetDoNotLoadOnNextBoot(false);
PluginLoader.AddProgramAssemblies();
@@ -310,8 +305,6 @@ namespace PepperDash.Essentials
{
Debug.Console(0, "Verifying and/or creating folder structure");
var configDir = Global.FilePathPrefix;
Debug.Console(0, "FilePathPrefix: {0}", configDir);
var configExists = Directory.Exists(configDir);
if (!configExists)
Directory.Create(configDir);
@@ -380,6 +373,7 @@ namespace PepperDash.Essentials
// Build the processor wrapper class
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
// DeviceManager.AddDevice(new EssemtialsWebApi("essentialsWebApi","Essentials Web API"));
// Add global System Monitor device
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance)
@@ -408,6 +402,51 @@ namespace PepperDash.Essentials
"WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available",
devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper());
//if (newDev == null)
// newDev = PepperDash.Essentials.Core.ProcessorExtensionDeviceFactory.GetExtensionDevice(devConf);
//if (newDev != null)
//{
// DeviceManager.AddDevice(newDev);
// continue;
//}
// Check if the processor is a DMPS model
//if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1)
//{
// Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt);
// var propertiesConfig = JsonConvert.DeserializeObject<DM.Config.DmpsRoutingPropertiesConfig>(devConf.Properties.ToString());
// if(propertiesConfig == null)
// propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig();
// DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig));
//}
//else
//if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1)
//{
// Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController.");
// var butToken = devConf.Properties["buttons"];
// if (butToken != null)
// {
// var buttons = butToken.ToObject<Dictionary<string, Essentials.Core.Touchpanels.KeypadButton>>();
// var tpController = new Essentials.Core.Touchpanels.Mpc3TouchpanelController(devConf.Key, devConf.Name, Global.ControlSystem, buttons);
// DeviceManager.AddDevice(tpController);
// }
// else
// {
// Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key);
// }
//}
//else
//{
// Debug.Console(2, "************Processor is not DMPS type***************");
//}
continue;
}

View File

@@ -11,7 +11,6 @@
<OutputPath>bin\$(Configuration)\</OutputPath>
<Title>PepperDash Essentials</Title>
<PackageId>PepperDashEssentials</PackageId>
<AssemblyInformationalVersion>$(Version)</AssemblyInformationalVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
@@ -47,7 +46,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-385" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-383" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />