Load unload tool in magazine
Added Siemens functions like: available tools, load/unload, max values in configuration
This commit is contained in:
@@ -180,7 +180,7 @@ namespace Step.Controllers.WebApi
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
CmsError libraryError = ncHandler.GetMagazinesPositionsData(out List<PositionsModel> magazines);
|
||||
CmsError libraryError = ncHandler.GetMagazinesPositionsData(out List<PositionModel> magazines);
|
||||
if (libraryError.IsError())
|
||||
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
||||
return BadRequest(libraryError.message);
|
||||
@@ -201,9 +201,9 @@ namespace Step.Controllers.WebApi
|
||||
ncHandler.Connect();
|
||||
|
||||
// Create Library model
|
||||
PositionsModel pos = new PositionsModel()
|
||||
PositionModel pos = new PositionModel()
|
||||
{
|
||||
Id = positionId,
|
||||
PositionId = positionId,
|
||||
MagazineId = magazineId,
|
||||
Type = Convert.ToInt32(magazinesPos.Type)
|
||||
};
|
||||
@@ -357,7 +357,7 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
ncHandler.Connect();
|
||||
// Call delete library function
|
||||
CmsError libraryError = ncHandler.GetMagazinePositionsAndTools(magazineId, out List<MagazineAndToolModel> magazinePos);
|
||||
CmsError libraryError = ncHandler.GetMagazinePositionsAndTools(magazineId, out List<PositionModel> magazinePos);
|
||||
if (libraryError.IsError())
|
||||
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
||||
return BadRequest(libraryError.message);
|
||||
@@ -386,8 +386,8 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
}
|
||||
|
||||
[Route("magazine/{magazineId:int}"), HttpPut]
|
||||
public IHttpActionResult GetAvailableTools(int magazineId, [FromBody][Required] List<DTOUpdateMagazineModel> newMag)
|
||||
[Route("magazine/{magazineId:int}/load"), HttpPut]
|
||||
public IHttpActionResult LoadToolInToMagazine(int magazineId, [FromBody][Required] DTOUpdateMagazineModel newMag)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
@@ -396,9 +396,9 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
List<NewToolInMagazineModel> libraryMag = newMag.Select(x => new NewToolInMagazineModel { PositionId = x.PositionId, ToolId = x.ToolId }).ToList();
|
||||
NewToolInMagazineModel libraryMag = new NewToolInMagazineModel { PositionId = newMag.PositionId, ToolId = newMag.ToolId };
|
||||
// Call delete library function
|
||||
CmsError libraryError = ncHandler.UpdateMagazine(magazineId, libraryMag);
|
||||
CmsError libraryError = ncHandler.LoadToolInMagazine(magazineId, libraryMag);
|
||||
if (libraryError.IsError())
|
||||
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
||||
return BadRequest(libraryError.message);
|
||||
@@ -406,5 +406,25 @@ namespace Step.Controllers.WebApi
|
||||
return Ok(newMag);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("magazine/{magazineId:int}/unload/{positionId:int}"), HttpPut]
|
||||
public IHttpActionResult UnloadToolFromMagazine(int magazineId, int positionId)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
// Call delete library function
|
||||
CmsError libraryError = ncHandler.UnloadToolInMagazine(magazineId, positionId);
|
||||
if (libraryError.IsError())
|
||||
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
||||
return BadRequest(libraryError.message);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user