-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add working schedule mission from GUI
- Loading branch information
1 parent
7cc497b
commit ce87279
Showing
15 changed files
with
196 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Text.Json; | ||
using Api.Controllers.Models; | ||
using Api.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Api.Controllers; | ||
[ApiController] | ||
[Route("echo-plant")] | ||
public class EchoPlantController : ControllerBase | ||
{ | ||
private readonly ILogger<EchoPlantController> _logger; | ||
private readonly IEchoService _echoService; | ||
public EchoPlantController(ILogger<EchoPlantController> logger, IEchoService echoService) | ||
{ | ||
_logger = logger; | ||
_echoService = echoService; | ||
} | ||
|
||
[HttpGet] | ||
[Route("/all-plants-info")] | ||
[ProducesResponseType(typeof(List<EchoPlantInfo>), StatusCodes.Status200OK)] | ||
[ProducesResponseType(StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(StatusCodes.Status403Forbidden)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||
[ProducesResponseType(StatusCodes.Status502BadGateway)] | ||
public async Task<ActionResult<EchoMission>> GetEchoPlantInfos() | ||
{ | ||
try | ||
{ | ||
var echoPlantInfos = await _echoService.GetEchoPlantInfos(); | ||
return Ok(echoPlantInfos); | ||
} | ||
catch (HttpRequestException e) | ||
{ | ||
if (e.StatusCode.HasValue && (int)e.StatusCode.Value == 404) | ||
{ | ||
_logger.LogWarning("Could not get plant info from Echo"); | ||
return NotFound("Echo plant info not found"); | ||
} | ||
|
||
_logger.LogError(e, "Error getting plant info from Echo"); | ||
return new StatusCodeResult(StatusCodes.Status502BadGateway); | ||
} | ||
catch (JsonException e) | ||
{ | ||
_logger.LogError(e, "Error deserializing plant info response from Echo"); | ||
return new StatusCodeResult(StatusCodes.Status500InternalServerError); | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#nullable disable | ||
#nullable disable | ||
namespace Api.Controllers.Models | ||
{ | ||
public class EchoPlantInfo | ||
{ | ||
public string InstallationCode { get; set; } | ||
public string ProjectDescription { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ | |
"Database": { | ||
"ConnectionString": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.