Fix start&stop & queue running index after swap
This commit is contained in:
+11
-5
@@ -354,9 +354,15 @@ namespace Step.NC
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public CmsError MoveQueueItems(int processId, int oldIndex, int newIndex, out List<DTOQueueModel> queue)
|
||||
public CmsError MoveQueueItems(int processId, int itemId, int newIndex, out List<DTOQueueModel> queue)
|
||||
{
|
||||
oldIndex = oldIndex - 1;
|
||||
itemId = itemId - 1;
|
||||
|
||||
// Update queue running index
|
||||
if (itemId < QueueRunningIndex && newIndex > QueueRunningIndex)
|
||||
QueueRunningIndex -= 1;
|
||||
if (newIndex < QueueRunningIndex && itemId > QueueRunningIndex)
|
||||
QueueRunningIndex += 1;
|
||||
|
||||
queue = new List<DTOQueueModel>();
|
||||
|
||||
@@ -364,12 +370,12 @@ namespace Step.NC
|
||||
if (!PartProgramQueue.ContainsKey(processId))
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
// Check if items exists
|
||||
if (PartProgramQueue[processId].ElementAtOrDefault(oldIndex) == null)
|
||||
if (PartProgramQueue[processId].ElementAtOrDefault(itemId) == null)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
|
||||
var item = PartProgramQueue[processId][oldIndex];
|
||||
var item = PartProgramQueue[processId][itemId];
|
||||
// Remove item in the old positions
|
||||
PartProgramQueue[processId].RemoveAt(oldIndex);
|
||||
PartProgramQueue[processId].RemoveAt(itemId);
|
||||
// Add in the new position
|
||||
PartProgramQueue[processId].Insert(newIndex, item);
|
||||
|
||||
|
||||
@@ -264,6 +264,8 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError = ncHandler.StartWorkingQueue(processId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
@@ -277,6 +279,8 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError = ncHandler.StopWorkingQueue(processId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
Reference in New Issue
Block a user