Fix tooltable

Frontend - Removed useless delete buttons & bug fix
Backend - fix shanks delete
This commit is contained in:
Lucio Maranta
2019-02-15 13:34:23 +01:00
parent b8b8127eb0
commit 3253c48501
11 changed files with 125 additions and 57 deletions
@@ -12,6 +12,8 @@ using System.Linq;
using System.Web.Http;
using static Step.Config.ServerConfig;
using static Step.Model.Constants;
using static Step.Listeners.SignalRStaticObjects;
using Step.Model.DTOModels;
namespace Step.Controllers.WebApi
{
@@ -81,6 +83,12 @@ namespace Step.Controllers.WebApi
DbNcFamilyModel fam = toolsManager.FindFamily(dtoToolWithFamily.FamilyId);
if (fam == null)
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
// Update return data
if (ToolManagerConfig.FamilyOpt)
{
dtoToolWithFamily.Name = fam.Name;
}
}
}
else
@@ -145,6 +153,10 @@ namespace Step.Controllers.WebApi
if (tool == null)
return NotFound();
// Check if tool is mounted in spindle
if (ToolIsInSpindle(toolId))
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
if (tool.FamilyId != dtoToolWithFamily.FamilyId)
{
// Check if family exists
@@ -204,6 +216,10 @@ namespace Step.Controllers.WebApi
if (tool == null)
return NotFound();
// Check if tool is mounted in spindle
if (ToolIsInSpindle(toolId))
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
using (NcHandler ncHandler = new NcHandler())
{
ncHandler.Connect();
@@ -296,6 +312,13 @@ namespace Step.Controllers.WebApi
if (shank == null)
return NotFound();
// Check if tools are mounted in spindle
foreach (var tool in shank.Tools)
{
if (ToolIsInSpindle(tool.ToolId))
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
}
using (NcHandler ncHandler = new NcHandler())
{
CmsError cmsError = ncHandler.Connect();
@@ -322,6 +345,13 @@ namespace Step.Controllers.WebApi
if (shank == null)
return NotFound();
// Check if tools are mounted in spindle
foreach (var tool in shank.Tools)
{
if (ToolIsInSpindle(tool.ToolId))
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
}
using (NcHandler ncHandler = new NcHandler())
{
CmsError cmsError = ncHandler.Connect();
@@ -383,6 +413,13 @@ namespace Step.Controllers.WebApi
if (family == null)
return NotFound();
// Check if tools are mounted in spindle
foreach (var tool in family.Tools)
{
if (ToolIsInSpindle(tool.ToolId))
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
}
using (NcHandler ncHandler = new NcHandler())
{
CmsError cmsError = ncHandler.Connect();
@@ -409,6 +446,13 @@ namespace Step.Controllers.WebApi
if (family == null)
return NotFound();
// Check if tools are mounted in spindle
foreach (var tool in family.Tools)
{
if (ToolIsInSpindle(tool.ToolId))
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
}
using (NcHandler ncHandler = new NcHandler())
{
CmsError cmsError = ncHandler.Connect();
@@ -547,7 +591,7 @@ namespace Step.Controllers.WebApi
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
// Check if the mag pos is disabled
if (magPos.Disabled == true)
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
return BadRequest(API_ERROR_KEYS.MAG_POS_DISABLED);
using (NcHandler ncHandler = new NcHandler())
{
@@ -597,13 +641,20 @@ namespace Step.Controllers.WebApi
if (shank == null)
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
// Check if tools are mounted in spindle
foreach (var tool in shank.Tools)
{
if (ToolIsInSpindle(tool.ToolId))
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
}
// Check if magazine position exists
DbNcMagazinePositionModel magPos = toolsManager.FindMagazinePosition(magazineId, positionId);
if (magPos == null)
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
// Check if the mag pos is disabled
if (magPos.Disabled == true)
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
//// Check if the mag pos is disabled
//if (magPos.Disabled == true)
// return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
// Check if magazine position is not occupied
DbNcShankModel shankMounted = toolsManager.FindShanksByPositions(magazineId, positionId);
@@ -706,5 +757,21 @@ namespace Step.Controllers.WebApi
return Ok();
}
}
private bool ToolIsInSpindle(int toolId)
{
foreach(var head in LastHeadsData.ToList())
{
if(head is DTOSpindleModel)
{
var spindle = head as DTOSpindleModel;
if (spindle.MountedTool == toolId)
return true;
}
}
return false;
}
}
}