Fix osai options
This commit is contained in:
Binary file not shown.
@@ -9,7 +9,7 @@
|
||||
<gammaOpt>true</gammaOpt>
|
||||
<lifeOpt>true</lifeOpt>
|
||||
<tcpOpt>true</tcpOpt>
|
||||
<coolingOpt>false</coolingOpt>
|
||||
<coolingOpt>true</coolingOpt>
|
||||
<multidimensionalShankOpt>true</multidimensionalShankOpt>
|
||||
<selfAdaptivePathOpt>true</selfAdaptivePathOpt>
|
||||
<dynamicCompensationOpt>true</dynamicCompensationOpt>
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Step.Model.DTOModels.ToolModels
|
||||
[Required]
|
||||
public bool CounterClockwiseRotation { get; set; }
|
||||
|
||||
public int? ShankId { get; set; }
|
||||
public int? ShankId { get; set; } = null;
|
||||
|
||||
public static explicit operator DTONcTool(DbNcToolModel obj)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
Id = obj.ToolId,
|
||||
FamilyId = obj.FamilyId,
|
||||
ShankId = obj.ShankId == null ? 0 : obj.ShankId.Value,
|
||||
ShankId = obj.ShankId,
|
||||
OffsetLength = obj.OffsetLength,
|
||||
ResidualLife = obj.ResidualLife,
|
||||
ResidualRevive = obj.ResidualRevive,
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Step.Model.DatabaseModels
|
||||
|
||||
public DbNcMagazinePositionModel MagazinePosition { get; set; }
|
||||
|
||||
public List<DbNcToolModel> Tools { get; set; }
|
||||
public List<DbNcToolModel> Tools { get; set; }
|
||||
|
||||
public static explicit operator NcShankModel(DbNcShankModel obj)
|
||||
{
|
||||
|
||||
@@ -928,8 +928,13 @@ namespace Step.NC
|
||||
{
|
||||
config.FamilyOptionActive = false;
|
||||
categories.Add("family");
|
||||
config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !(x.Name == "familyId")).ToList();
|
||||
config.ToolsConfiguration = config.ToolsConfiguration.Concat(config.FamiliesConfiguration.FamilyConfiguration).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.ToolsConfiguration = config.ToolsConfiguration.Concat(config.FamiliesConfiguration.FamilyReadOnlyConfiguration).ToList();
|
||||
}
|
||||
|
||||
if (!ToolManagerConfig.OffsetOpt)
|
||||
categories.Add("offset");
|
||||
|
||||
@@ -28,32 +28,27 @@ namespace Step.Controllers.WebApi
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
// If option is active, add family data to tools
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// If option is active, add family data to tools
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
// Get families
|
||||
List<DTONcFamilyModel> families = toolsManager.GetFamilies();
|
||||
|
||||
List<DTONcToolWithFamilyModel> toolsWithFamilies = new List<DTONcToolWithFamilyModel>();
|
||||
// Create tool&family return objecs
|
||||
foreach (var tool in tools)
|
||||
{
|
||||
// Get families
|
||||
List<DTONcFamilyModel> families = toolsManager.GetFamilies();
|
||||
|
||||
List<DTONcToolWithFamilyModel> toolsWithFamilies = new List<DTONcToolWithFamilyModel>();
|
||||
// Create tool&family return objecs
|
||||
foreach (var tool in tools)
|
||||
{
|
||||
toolsWithFamilies.Add
|
||||
(
|
||||
CreateToolAndFamilyObj( // Create return model with family data & tool data
|
||||
tool,
|
||||
families.Where(x => x.Id == tool.FamilyId).FirstOrDefault() // Find matching family
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Ok(toolsWithFamilies);
|
||||
toolsWithFamilies.Add
|
||||
(
|
||||
CreateToolAndFamilyObj( // Create return model with family data & tool data
|
||||
tool,
|
||||
families.Where(x => x.Id == tool.FamilyId).FirstOrDefault() // Find matching family
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(tools);
|
||||
return Ok(toolsWithFamilies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,17 +63,29 @@ namespace Step.Controllers.WebApi
|
||||
// Check if option is active
|
||||
if (ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
// Check if family exists
|
||||
DbNcFamilyModel fam = toolsManager.FindFamily(dtoToolWithFamily.FamilyId);
|
||||
if (fam == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
if (dtoToolWithFamily.FamilyId == 0)
|
||||
{
|
||||
// If param equal to 0 create a new family
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel() { Name = "NewFamily" };
|
||||
// Add new family & update family id
|
||||
DbNcFamilyModel newFam = toolsManager.AddFamily(newFamily);
|
||||
dtoToolWithFamily.FamilyId = newFam.FamilyId;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if family exists
|
||||
DbNcFamilyModel fam = toolsManager.FindFamily(dtoToolWithFamily.FamilyId);
|
||||
if (fam == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy only family data
|
||||
// Copy only family data from tool&fam model
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily);
|
||||
|
||||
// Add new family
|
||||
DbNcFamilyModel dbFam = toolsManager.AddFamily(newFamily);
|
||||
if (dbFam == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
@@ -86,14 +93,7 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
|
||||
// Check if option is active
|
||||
if (ToolManagerConfig.ShankOpt)
|
||||
{
|
||||
// If option is active check if shank exists
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(dtoToolWithFamily.ShankId.Value);
|
||||
if (shank == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
else
|
||||
if (!ToolManagerConfig.ShankOpt)
|
||||
{
|
||||
// If option is not active create a shank
|
||||
DTONewNcShankModel newShank = new DTONewNcShankModel()
|
||||
@@ -107,6 +107,8 @@ namespace Step.Controllers.WebApi
|
||||
// Connect tool to new shank
|
||||
dtoToolWithFamily.ShankId = ncShank.ShankId;
|
||||
}
|
||||
else
|
||||
dtoToolWithFamily.ShankId = null;
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
@@ -119,8 +121,8 @@ namespace Step.Controllers.WebApi
|
||||
return Ok(CreateToolAndFamilyObj(newTool, dtoToolWithFamily));
|
||||
}
|
||||
}
|
||||
|
||||
[Route("tool/{toolId:int}"), HttpPut]
|
||||
|
||||
[Route("tool/{toolId:int}"), HttpPut]
|
||||
public IHttpActionResult PutTool(int toolId, [FromBody][Required]DTONewNcToolWithFamilyModel dtoToolWithFamily)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
@@ -145,7 +147,7 @@ namespace Step.Controllers.WebApi
|
||||
// If option is active
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
// Copy only family
|
||||
// Copy only family
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily);
|
||||
// Update only family data
|
||||
@@ -202,25 +204,27 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError;
|
||||
if (!ToolManagerConfig.ShankOpt && tool.ShankId != null)
|
||||
{
|
||||
// If option is active find & delete tool shank
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(tool.ShankId.Value);
|
||||
|
||||
CmsError cmsError = ncHandler.DeleteNcShank(shank.ShankId);
|
||||
cmsError = ncHandler.DeleteNcShank(shank.ShankId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
}
|
||||
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
DbNcFamilyModel fam = toolsManager.FindFamily(tool.FamilyId);
|
||||
CmsError cmsError = ncHandler.DeleteNcFamily(fam);
|
||||
cmsError = ncHandler.DeleteNcFamily(fam);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
}
|
||||
|
||||
ncHandler.DeleteNcTool(tool);
|
||||
cmsError = ncHandler.DeleteNcTool(tool);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
@@ -398,7 +402,7 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion Families
|
||||
|
||||
#region Magazine positions
|
||||
@@ -482,7 +486,7 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
shanks = toolsManager.GetAvailableShanksWithoutChilds();
|
||||
}
|
||||
|
||||
|
||||
return Ok(shanks);
|
||||
}
|
||||
}
|
||||
@@ -492,7 +496,7 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DTONcToolModel> tools = toolsManager.GetAvailableTools();
|
||||
List<DTONcToolModel> tools = toolsManager.GetAvailableTools();
|
||||
|
||||
return Ok(tools);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user