diff --git a/Client/Browser_Tools/BrowserJSObject.cs b/Client/Browser_Tools/BrowserJSObject.cs index da31711b..ccbe27ac 100644 --- a/Client/Browser_Tools/BrowserJSObject.cs +++ b/Client/Browser_Tools/BrowserJSObject.cs @@ -1,5 +1,4 @@ using Chromium; -using Chromium.Remote; using Chromium.Remote.Event; using Chromium.WebBrowser; using Client.Config; @@ -13,15 +12,11 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; -using System.Drawing; -using System.Drawing.Imaging; using System.IO; using System.IO.Compression; using System.Linq; using System.Net.Http; -using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; using static Client.Utils.Constants; @@ -29,15 +24,17 @@ namespace CMS_Client.Browser_Tools { public class BrowserJSObject : JSObject { - //The first letter of All PUBLIC Variables and Methods must be Lower-Case (CEF Settings) + // The first letter of All PUBLIC Variables and Methods must be Lower-Case (CEF Settings) private MainForm mainForm; - private static readonly string[] _validExtensions = { "",".txt", ".cnc", ".ini", ".mpf", ".spf" }; + private static readonly string[] _validExtensions = { "", ".txt", ".cnc", ".ini", ".mpf", ".spf" }; private static readonly string[] _validImages = { ".jpg", ".jpeg", ".png" }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region CONSTRUCTOR_METHOD - //Constructor Method + + // Constructor Method public BrowserJSObject(MainForm f) { mainForm = f; @@ -54,7 +51,7 @@ namespace CMS_Client.Browser_Tools AddFunction("getChromiumVersion").Execute += getChromiumVersion; AddFunction("getClientID").Execute += getClientID; AddFunction("getConfiguredProcesses").Execute += getConfiguredProcesses; - AddFunction("getConfiguredProcessesInMainMenu").Execute += getConfiguredProcessesInMainMenu; + AddFunction("getConfiguredProcessesInMainMenu").Execute += getConfiguredProcessesInMainMenu; AddFunction("startNewProcess").Execute += startNewProcess; AddFunction("openOrStartProcess").Execute += openOrStartProcess; AddFunction("isVirtualKeybConfigured").Execute += isVirtualKeybConfigured; @@ -72,12 +69,13 @@ namespace CMS_Client.Browser_Tools AddFunction("delPPFromJob").Execute += delPPFromJob; } - #endregion + #endregion CONSTRUCTOR_METHOD /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region FORM_BEHAVIOUR_METHODS - //Minimize Main Window + // Minimize Main Window public void minimizeForm(object sender, CfrV8HandlerExecuteEventArgs e) { //Invoke method if is needed or call the method in STD mode @@ -86,16 +84,13 @@ namespace CMS_Client.Browser_Tools { mainForm.WindowState = FormWindowState.Minimized; }); - else { mainForm.WindowState = FormWindowState.Minimized; } } - - - //Maximize Main Window + // Maximize Main Window public void maximizeForm(object sender, CfrV8HandlerExecuteEventArgs e) { //Invoke method if is needed or call the method in STD mode @@ -104,16 +99,13 @@ namespace CMS_Client.Browser_Tools { mainForm.WindowState = FormWindowState.Maximized; }); - else { mainForm.WindowState = FormWindowState.Maximized; } } - - - //Close Main Window + // Close Main Window public void closeForm(object sender, CfrV8HandlerExecuteEventArgs e) { //If the mainform is disposed do nothing @@ -124,16 +116,17 @@ namespace CMS_Client.Browser_Tools mainForm.Close(); } - //Reload Broken Page + // Reload Broken Page private void reloadBrokenPage(object sender, CfrV8HandlerExecuteEventArgs e) { //Invoke method if is needed or call the method in STD mode mainForm.reloadBrokenPage(); } - #endregion + #endregion FORM_BEHAVIOUR_METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region NC_BEHAVIOUR_METHODS public void setNcWindowState(object sender, CfrV8HandlerExecuteEventArgs e) @@ -161,23 +154,25 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(NcWindow.NcCapture); } - #endregion + #endregion NC_BEHAVIOUR_METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region CHROMIUM_METHODS - //Get the Version of Chromium + // Get the Version of Chromium public void getChromiumVersion(object sender, CfrV8HandlerExecuteEventArgs e) { e.SetReturnValue(CfxRuntime.GetChromeVersion()); } - #endregion + #endregion CHROMIUM_METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region STEP_METHODS - //Get the ID of STEP Client + // Get the ID of STEP Client public void getClientID(object sender, CfrV8HandlerExecuteEventArgs e) { e.SetReturnValue((int)Config.ConnectionConfig.Id); @@ -188,31 +183,31 @@ namespace CMS_Client.Browser_Tools NcWindow.ForceStepFocus(); } - //Get the option of virtual Keyb configured + // Get the option of virtual Keyb configured private void isVirtualKeybConfigured(object sender, CfrV8HandlerExecuteEventArgs e) { e.SetReturnValue((Boolean)Config.ClientConfig.ShowVirtualKeyboard); } - #endregion + + #endregion STEP_METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESSES_METHODS - //Read all configured processes + // Read all configured processes public void getConfiguredProcesses(object sender, CfrV8HandlerExecuteEventArgs e) { - e.SetReturnValue(JsonConvert.SerializeObject(Config.ExtSoftwaresConfig.Where(X => X.inMainMenuBar==false))); - } + e.SetReturnValue(JsonConvert.SerializeObject(Config.ExtSoftwaresConfig.Where(X => X.inMainMenuBar == false))); + } - //Read all configured processes in main menu + // Read all configured processes in main menu public void getConfiguredProcessesInMainMenu(object sender, CfrV8HandlerExecuteEventArgs e) { e.SetReturnValue(JsonConvert.SerializeObject(Config.ExtSoftwaresConfig.Where(X => X.inMainMenuBar == true))); } - - - //Start a new process + // Start a new process public void startNewProcess(object sender, CfrV8HandlerExecuteEventArgs e) { if (e.Arguments.Count() == 0) @@ -222,9 +217,7 @@ namespace CMS_Client.Browser_Tools t.Start(e.Arguments[0].StringValue); } - - - //Open the last window or Start a new process + // Open the last window or Start a new process public void openOrStartProcess(object sender, CfrV8HandlerExecuteEventArgs e) { if (e.Arguments.Count() == 0) @@ -234,8 +227,7 @@ namespace CMS_Client.Browser_Tools t.Start(e.Arguments[0].StringValue); } - - //Function used in Thread + // Function used in Thread private void OpenStartNew(object id) { Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.id == (string)id); @@ -251,21 +243,21 @@ namespace CMS_Client.Browser_Tools } } - - //Function used in Thread + // Function used in Thread private void OpenNew(object id) { Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.id == (string)id); if (sft != null) Process.Start(sft.path, sft.arguments); } - #endregion + #endregion PROCESSES_METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region FILESYSTEM_METHODS - //Read all drives in Operating System + // Read all drives in Operating System public void getOSdriveList(object sender, CfrV8HandlerExecuteEventArgs e) { List drivelist = new List(); @@ -290,8 +282,7 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(JsonConvert.SerializeObject(drivelist)); } - - //Read all files in directory + // Read all files in directory public void getFileList(object sender, CfrV8HandlerExecuteEventArgs e) { List filelist = new List(); @@ -312,7 +303,6 @@ namespace CMS_Client.Browser_Tools { foreach (String item in Directory.GetDirectories(p)) { - filelist.Add(new Models.File { Name = Path.GetFileName(item), @@ -320,7 +310,6 @@ namespace CMS_Client.Browser_Tools Path = Path.GetFullPath(item), IsDirectory = true }); - } } catch (Exception ex) @@ -338,7 +327,6 @@ namespace CMS_Client.Browser_Tools Path = Path.GetFullPath(item), IsDirectory = false }); - } } catch (Exception ex) @@ -348,8 +336,7 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(JsonConvert.SerializeObject(filelist)); } - - //Upload and activate the program + // Upload and activate the program public async void uploadAndActivateProgram(object sender, CfrV8HandlerExecuteEventArgs e) { String fileToUpload = ""; @@ -362,7 +349,7 @@ namespace CMS_Client.Browser_Tools //Check the arguments numbers if (e.Arguments.Length < 1 || e.Arguments[0] == null) { - e.SetReturnValue(Constants.Uploadpage +"INVALID_ARGUMENTS"); + e.SetReturnValue(Constants.Uploadpage + "INVALID_ARGUMENTS"); return; } @@ -370,7 +357,7 @@ namespace CMS_Client.Browser_Tools fileToUpload = e.Arguments[0].StringValue; if (!System.IO.File.Exists(fileToUpload)) { - e.SetReturnValue(Constants.Uploadpage+";FILE_NOT_FOUND"); + e.SetReturnValue(Constants.Uploadpage + ";FILE_NOT_FOUND"); return; } @@ -399,7 +386,7 @@ namespace CMS_Client.Browser_Tools //Add the content to the form form.Add(new ByteArrayContent(filecontent), "file", fileName); - if(imagecontent != null) + if (imagecontent != null) form.Add(new ByteArrayContent(imagecontent), "image", imageName); //Send them @@ -407,17 +394,16 @@ namespace CMS_Client.Browser_Tools "http://" + Config.ConnectionConfig.ServerUrl + ":" + Config.ConnectionConfig.ServerPort + "/" + Constants.Uploadpage, form).Result; //Wait the answer - if(response.StatusCode == System.Net.HttpStatusCode.BadRequest) + if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) e.SetReturnValue(Constants.Uploadpage + ";" + await response.Content.ReadAsStringAsync()); - else if(response.StatusCode != System.Net.HttpStatusCode.OK) + else if (response.StatusCode != System.Net.HttpStatusCode.OK) e.SetReturnValue(Constants.Uploadpage + ";" + response.ReasonPhrase); else e.SetReturnValue(""); } - } - //Upload and add to queue + // Upload and add to queue public async void uploadAndAddToQueue(object sender, CfrV8HandlerExecuteEventArgs e) { string fileToUpload = ""; @@ -488,11 +474,9 @@ namespace CMS_Client.Browser_Tools else e.SetReturnValue(""); } - } - - //Read info of a file + // Read info of a file public void getProgramInfo(object sender, CfrV8HandlerExecuteEventArgs e) { InfoFile file = new InfoFile(); @@ -523,7 +507,6 @@ namespace CMS_Client.Browser_Tools file.Content = new List(); try { - StreamReader fileRead = new StreamReader(p); while ((line = fileRead.ReadLine()) != null && counter < 10) { @@ -540,7 +523,6 @@ namespace CMS_Client.Browser_Tools break; } } - } catch (Exception ex) { @@ -549,8 +531,7 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(JsonConvert.SerializeObject(file)); } - - //Private functions... + // Private functions private String ElaborateName(String name, DriveType type) { if (!String.IsNullOrWhiteSpace(name)) @@ -565,7 +546,6 @@ namespace CMS_Client.Browser_Tools } return "Undefined Drive"; } - } private String ElaborateType(DriveType type) @@ -577,15 +557,15 @@ namespace CMS_Client.Browser_Tools case DriveType.Network: return "NTW"; } return "SPFO"; - } - #endregion + #endregion FILESYSTEM_METHODS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region JOB_METHODS - - //Read all job + + // Read all job public void openJob(object sender, CfrV8HandlerExecuteEventArgs e) { JobToStep job = new JobToStep(); @@ -602,14 +582,13 @@ namespace CMS_Client.Browser_Tools using (ZipArchive archive = ZipFile.OpenRead(jobOpenFileDialog.FileName)) { - - //Setup main Fields + // Setup main Fields job.Name = Path.GetFileName(jobOpenFileDialog.FileName); job.LastEditTimestamp = new FileInfo(jobOpenFileDialog.FileName).LastAccessTime; foreach (ZipArchiveEntry entry in archive.Entries) { - //Main program + // Main program if (entry.Name.Equals(JOB_MAIN_FILENAME, StringComparison.OrdinalIgnoreCase)) { using (var reader = new StreamReader(entry.Open())) @@ -617,7 +596,7 @@ namespace CMS_Client.Browser_Tools job.IsoMainProgram = (reader.ReadToEnd()); } } - //Add all images + // Add all images else if (_validImages.Contains(Path.GetExtension(entry.Name).ToLower())) { var bytes = default(byte[]); @@ -627,21 +606,21 @@ namespace CMS_Client.Browser_Tools entry.Open().CopyTo(memstream); bytes = memstream.ToArray(); job.Metadata.Generics.Images.Add(new Image_param() - { - Name = Path.GetFileNameWithoutExtension(entry.Name), - Base64 = "data:image/" + Path.GetExtension(entry.Name).ToLower().TrimStart('.') + ";base64," + Convert.ToBase64String(bytes) - }); + { + Name = Path.GetFileNameWithoutExtension(entry.Name), + Base64 = "data:image/" + Path.GetExtension(entry.Name).ToLower().TrimStart('.') + ";base64," + Convert.ToBase64String(bytes) + }); } } - //Metadata - else if(entry.Name.Equals(JOB_METADATA_FILENAME, StringComparison.OrdinalIgnoreCase)) + // Metadata + else if (entry.Name.Equals(JOB_METADATA_FILENAME, StringComparison.OrdinalIgnoreCase)) { MetadataToFile metasFromFile = new MetadataToFile(); using (var reader = new StreamReader(entry.Open())) { metasFromFile = JsonConvert.DeserializeObject(reader.ReadToEnd()); - if(metasFromFile == null) + if (metasFromFile == null) { e.SetReturnValue(null); return; @@ -661,7 +640,6 @@ namespace CMS_Client.Browser_Tools entry.ExtractToFile(JOB_OPENING_PATH + entry.Name, true); } } - } e.SetReturnValue(JsonConvert.SerializeObject(job)); return; @@ -673,9 +651,7 @@ namespace CMS_Client.Browser_Tools } } - - - //Save all job + // Save all job public void saveJob(object sender, CfrV8HandlerExecuteEventArgs e) { MetadataToFile metafile = new MetadataToFile(); @@ -687,7 +663,7 @@ namespace CMS_Client.Browser_Tools //Call Save Dialog SaveFileDialog jobSaveFileDialog = new SaveFileDialog(); jobSaveFileDialog.Filter = "CMS Job Files(*.JOB)|*.job|Zip Files(*.ZIP)|*.zip"; - if(jobSaveFileDialog.ShowDialog() == DialogResult.OK) + if (jobSaveFileDialog.ShowDialog() == DialogResult.OK) { // Job deserialize JobToStep job = JsonConvert.DeserializeObject(e.Arguments[0].StringValue); @@ -696,7 +672,7 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("corrupted_model"))); return; } - + //Metadata metafile.Description = job.Metadata.Generics.Description; metafile.ExecutionTime = job.Metadata.Generics.ExecutionTime; @@ -715,18 +691,15 @@ namespace CMS_Client.Browser_Tools //delete Zip File if exists if (System.IO.File.Exists(jobSaveFileDialog.FileName)) System.IO.File.Delete(jobSaveFileDialog.FileName); - + //Create Zip File ZipFile.CreateFromDirectory(JOB_OPENING_PATH, jobSaveFileDialog.FileName); - } e.SetReturnValue(null); return; } - - - //Add an image + // Add an image public void addImageToJob(object sender, CfrV8HandlerExecuteEventArgs e) { OpenFileDialog imageOpenFileDialog = new OpenFileDialog(); @@ -742,25 +715,23 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("file_esists"))); return; } - + //Copy the file System.IO.File.Copy(imageOpenFileDialog.FileName, newImagePath); //Send to Step e.SetReturnValue(JsonConvert.SerializeObject(new Image_param() - { - Name = Path.GetFileNameWithoutExtension(imageOpenFileDialog.FileName), - Base64 = "data:image/" + Path.GetExtension(newImagePath).ToLower().TrimStart('.') + ";base64," + Convert.ToBase64String(System.IO.File.ReadAllBytes(newImagePath)) - })); + { + Name = Path.GetFileNameWithoutExtension(imageOpenFileDialog.FileName), + Base64 = "data:image/" + Path.GetExtension(newImagePath).ToLower().TrimStart('.') + ";base64," + Convert.ToBase64String(System.IO.File.ReadAllBytes(newImagePath)) + })); return; } e.SetReturnValue(null); return; } - - - //Delete an image + // Delete an image public void delImageFromJob(object sender, CfrV8HandlerExecuteEventArgs e) { //check the arguments @@ -781,12 +752,10 @@ namespace CMS_Client.Browser_Tools System.IO.File.Delete(imagePath); e.SetReturnValue(null); - return; + return; } - - - //Add a Part-Program + // Add a Part-Program public void addPPToJob(object sender, CfrV8HandlerExecuteEventArgs e) { OpenFileDialog PPOpenFileDialog = new OpenFileDialog(); @@ -815,15 +784,12 @@ namespace CMS_Client.Browser_Tools //Send to Step e.SetReturnValue(null); return; - } e.SetReturnValue(null); return; } - - - //Delete an image + // Delete an image public void delPPFromJob(object sender, CfrV8HandlerExecuteEventArgs e) { //check the arguments @@ -845,10 +811,9 @@ namespace CMS_Client.Browser_Tools e.SetReturnValue(null); return; - } + } - - //Clear the temp folder files + // Clear the temp folder files private void ClearTempPath() { DirectoryInfo di = new DirectoryInfo(JOB_OPENING_PATH); @@ -858,20 +823,19 @@ namespace CMS_Client.Browser_Tools dir.Delete(true); } - - //Clear the temp folder files + // Clear the temp folder files private string GetExtensionFromBase64(string base64img) { - base64img = base64img.Remove(0,"data:image/".Length); + base64img = base64img.Remove(0, "data:image/".Length); return base64img.Substring(0, base64img.IndexOf(";base64,")); } - //Clear the temp folder files private string GetContentFromBase64(string base64img) { return base64img.Substring(base64img.IndexOf(";base64,") + ";base64,".Length); } - #endregion + + #endregion JOB_METHODS } -} +} \ No newline at end of file diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index b903a8c0..87bda111 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Database/Controllers/NcToolManagerController.cs b/Step.Database/Controllers/NcToolManagerController.cs index db830409..c8a796c4 100644 --- a/Step.Database/Controllers/NcToolManagerController.cs +++ b/Step.Database/Controllers/NcToolManagerController.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; +using static Step.Utils.SupportFunctions; namespace Step.Database.Controllers { diff --git a/Step.Database/Controllers/QueueController.cs b/Step.Database/Controllers/QueueController.cs index 0f558586..98b49fae 100644 --- a/Step.Database/Controllers/QueueController.cs +++ b/Step.Database/Controllers/QueueController.cs @@ -51,11 +51,30 @@ namespace Step.Database.Controllers dbCtx.SaveChanges(); } - + + public void UpdateReps(int processId, int id, int reps) + { + QueueItemsModel item = dbCtx.Queue.Where(x => x.Id == id && x.Process == processId).FirstOrDefault(); + // Update reps + item.Reps = reps; + item.RemainingReps = reps; + + dbCtx.SaveChanges(); + } + + public void DeleteItem(int processId, int id) + { + QueueItemsModel item = dbCtx.Queue.Where(x => x.Id == id && x.Process == processId).FirstOrDefault(); + + dbCtx.Queue.Remove(item); + + dbCtx.SaveChanges(); + } + public void ReadAndPopulateQueue() { var dbQueue = dbCtx.Queue.ToList(); - + bool foundData = false; foreach(var entity in dbQueue) { // Check if process queue exists @@ -73,7 +92,13 @@ namespace Step.Database.Controllers Status = (QUEUE_ITEM_STATUS)entity.Status }); - if((QUEUE_ITEM_STATUS)entity.Status == QUEUE_ITEM_STATUS.RUNNING) + if ((QUEUE_ITEM_STATUS)entity.Status != QUEUE_ITEM_STATUS.FINISHED && !foundData) + { + QueueRunningIndexes[entity.Process] = entity.Id - 1; + foundData = true; + } + + if ((QUEUE_ITEM_STATUS)entity.Status == QUEUE_ITEM_STATUS.RUNNING) QueueRunningIndexes[entity.Process] = entity.Id - 1; } } diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index 882ce641..838d69aa 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -307,7 +307,7 @@ namespace Step.NC // Check if queue exists for the process if (PartProgramQueue.ContainsKey(item.ProcessId) && PartProgramQueue[item.ProcessId].ElementAtOrDefault(QueueRunningIndexes[item.ProcessId]) != null) { - // Set status + // Set status based on queue status if (item.Status == QUEUE_STATUS.RUNNING || item.Status == QUEUE_STATUS.CLOSING) PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].Status = QUEUE_ITEM_STATUS.RUNNING; @@ -318,6 +318,11 @@ namespace Step.NC PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].Status = QUEUE_ITEM_STATUS.WAITING_OPERATOR; } } + // Update data + using (QueueController queueController = new QueueController()) + { + queueController.UpdateQueue(); + } return NO_ERROR; } @@ -342,33 +347,33 @@ namespace Step.NC return NO_ERROR; } - public CmsError SwapQueueItems(int processId, int item1Index, int item2Index) - { - item1Index = item1Index - 1; - item2Index = item2Index - 1; + //public CmsError SwapQueueItems(int processId, int item1Index, int item2Index) + //{ + // item1Index = item1Index - 1; + // item2Index = item2Index - 1; - // Check if there is a queue - if (!PartProgramQueue.ContainsKey(processId)) - return INCORRECT_PARAMETERS_ERROR; - // Check if items exists - if (PartProgramQueue[processId].ElementAtOrDefault(item1Index) == null || PartProgramQueue[processId].ElementAtOrDefault(item2Index) == null) - return INCORRECT_PARAMETERS_ERROR; + // // Check if there is a queue + // if (!PartProgramQueue.ContainsKey(processId)) + // return INCORRECT_PARAMETERS_ERROR; + // // Check if items exists + // if (PartProgramQueue[processId].ElementAtOrDefault(item1Index) == null || PartProgramQueue[processId].ElementAtOrDefault(item2Index) == null) + // return INCORRECT_PARAMETERS_ERROR; - // Create a item - DTOQueueModel tmp = PartProgramQueue[processId][item1Index]; + // // Create a item + // DTOQueueModel tmp = PartProgramQueue[processId][item1Index]; - // Swap item 1 with 2 - PartProgramQueue[processId][item1Index] = PartProgramQueue[processId][item2Index]; - // Swap 2 with tmp - PartProgramQueue[processId][item2Index] = tmp; + // // Swap item 1 with 2 + // PartProgramQueue[processId][item1Index] = PartProgramQueue[processId][item2Index]; + // // Swap 2 with tmp + // PartProgramQueue[processId][item2Index] = tmp; - // Swap ids - PartProgramQueue[processId][item2Index].Id = item2Index + 1; - // Swap 2 with tmp - PartProgramQueue[processId][item1Index].Id = item1Index + 1; + // // Swap ids + // PartProgramQueue[processId][item2Index].Id = item2Index + 1; + // // Swap 2 with tmp + // PartProgramQueue[processId][item1Index].Id = item1Index + 1; - return NO_ERROR; - } + // return NO_ERROR; + //} public CmsError MoveQueueItems(int processId, int itemId, int newIndex, out List queue) { @@ -402,9 +407,7 @@ namespace Step.NC queue = PartProgramQueue[processId]; using (QueueController queueController = new QueueController()) - { queueController.UpdateQueue(); - } return NO_ERROR; } @@ -428,6 +431,10 @@ namespace Step.NC model = PartProgramQueue[processId][itemIndex]; + // Update database + using (QueueController queueController = new QueueController()) + queueController.UpdateReps(processId, itemIndex, reps); + return NO_ERROR; } @@ -444,6 +451,10 @@ namespace Step.NC if (tmpQueueItem != null) PartProgramQueue[processId].Remove(tmpQueueItem); } + + // Update db + using (QueueController queueController = new QueueController()) + queueController.DeleteItem(processId, id); return NO_ERROR; } @@ -452,9 +463,11 @@ namespace Step.NC { // Check if there is a queue if (PartProgramQueue.ContainsKey(processId)) - { PartProgramQueue[processId] = new List(); - } + + // Update db + using (QueueController queueController = new QueueController()) + queueController.UpdateQueue(); return NO_ERROR; } @@ -1259,6 +1272,7 @@ namespace Step.NC { config.MultitoolOptionActive = false; categories.Add("shankType"); + config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !(x.Name == "shankId")).ToList(); } if (!ToolManagerConfig.FamilyOpt) @@ -1736,7 +1750,7 @@ namespace Step.NC return cmsError; } - // Update tool + // R tool cmsError = UpdateNcTools(toolsManager); } }