chore: add Imagoverum fleet management package
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
using Imagoverum.FleetManagement.BizLogic;
|
||||
using Matrix42.Blob.Contracts;
|
||||
using Matrix42.WebApi.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Imagoverum.FleetManagement.Services
|
||||
{
|
||||
[RoutePrefix("api/car")]
|
||||
public class CarController(IBlobManager blobManager) : ApiController
|
||||
{
|
||||
[HttpGet, Route("geoposition")]
|
||||
public GeoLocation GetLocation(string region = "world")
|
||||
{
|
||||
return GeoLocation.GetRandom(region);
|
||||
}
|
||||
|
||||
[HttpPost, Route("test")]
|
||||
public string TestCar()
|
||||
{
|
||||
var blobState = blobManager.IsBlobConfigured()
|
||||
? "With Configured Cloud"
|
||||
: "Without Configured Cloud";
|
||||
|
||||
return CarTester.IsCarWorkingProperly()
|
||||
? $"Car test successful completed ({blobState}) on {RuntimeInformation.OSDescription} environment at " + DateTime.UtcNow.ToString("o")
|
||||
: $"Car test failed ({blobState}) on {RuntimeInformation.OSDescription} environment at " + DateTime.UtcNow.ToString("o");
|
||||
}
|
||||
|
||||
[Route("error")]
|
||||
[HttpGet]
|
||||
public IHttpActionResult Throw()
|
||||
{
|
||||
throw new Exception("Boom! Unhandled!");
|
||||
}
|
||||
|
||||
public class GeoLocation(double latitude, double longitude)
|
||||
{
|
||||
/// <summary>
|
||||
/// Latitude in decimal degrees. Valid range: -90 to 90.
|
||||
/// </summary>
|
||||
public double Latitude { get; set; } = latitude;
|
||||
|
||||
/// <summary>
|
||||
/// Longitude in decimal degrees. Valid range: -180 to 180.
|
||||
/// </summary>
|
||||
public double Longitude { get; set; } = longitude;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random geographic location.
|
||||
/// If a region is specified, limits the random coordinates within that region.
|
||||
/// </summary>
|
||||
/// <param name="region">Optional region: "europe", "asia", "north-america", "south-america", "africa", "australia", or "world" (default).</param>
|
||||
public static GeoLocation GetRandom(string region = "world")
|
||||
{
|
||||
var rnd = new Random();
|
||||
|
||||
// Define approximate bounding boxes for major regions
|
||||
(double latMin, double latMax, double lonMin, double lonMax) bounds = region.ToLower() switch
|
||||
{
|
||||
"europe" => (35, 71, -25, 45),
|
||||
"asia" => (-10, 81, 25, 180),
|
||||
"north-america" => (5, 83, -170, -30),
|
||||
"south-america" => (-56, 13, -82, -34),
|
||||
"africa" => (-35, 37, -18, 52),
|
||||
"australia" => (-47, -10, 110, 155),
|
||||
_ => (-90, 90, -180, 180) // whole world
|
||||
};
|
||||
|
||||
double latitude = rnd.NextDouble() * (bounds.latMax - bounds.latMin) + bounds.latMin;
|
||||
double longitude = rnd.NextDouble() * (bounds.lonMax - bounds.lonMin) + bounds.lonMin;
|
||||
|
||||
return new GeoLocation(latitude, longitude);
|
||||
}
|
||||
|
||||
public override string ToString() => $"Lat: {Latitude:F5}, Lon: {Longitude:F5}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
|
||||
<!-- Build can target either RID from CLI/YAML; locally we'll build both via the target below -->
|
||||
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
|
||||
<AppendRuntimeIdentifierToOutputPath>true</AppendRuntimeIdentifierToOutputPath>
|
||||
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latestmajor</LangVersion>
|
||||
|
||||
<!-- Where to mirror outputs (project-relative, stable in CI & local) -->
|
||||
<!-- Adjust ..\..\..\ if your folder depth differs -->
|
||||
<BasePackageAssembliesDir>$(MSBuildProjectDirectory)\..\..\..\BasePackage\Assemblies\</BasePackageAssembliesDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Imagoverum.FleetManagement.BizLogic\Imagoverum.FleetManagement.BizLogic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Matrix42.Blob.Contracts">
|
||||
<HintPath>..\..\..\..\Root\bin\Matrix42.Blob.Contracts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Matrix42.WebApi.Contracts">
|
||||
<HintPath>..\..\..\..\Root\bin\Matrix42.WebApi.Contracts.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Imagoverum.FleetManagement.Services.dll.host.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<M42ExtensionId>22be0879-4587-cf4b-333c-08de16408acb</M42ExtensionId>
|
||||
<M42AssemblyPattern>$(MSBuildProjectName)*.*</M42AssemblyPattern>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\..\Extension.Assemblies.targets" Condition="Exists('..\..\..\Extension.Assemblies.targets')" />
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<host xmlns="urn:m42/host.config">
|
||||
<modules>
|
||||
<module assembly="Matrix42.DataLayer.Persistence" />
|
||||
<module assembly="Matrix42.Blob.BizLogic" />
|
||||
</modules>
|
||||
<sections></sections>
|
||||
</host>
|
||||
@@ -0,0 +1,3 @@
|
||||
REM %robodir%robocopy %targetDir% %basedir%BasePackage\Assemblies\ Imagoverum.FleetManagement*.* /s %roboOptions%
|
||||
|
||||
exit /b 0
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Matrix42.Imagoverum.FleetManagement.Services": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:63088;http://localhost:63089"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user