From 0d9a609bd75f82ff83e472dd0d19d253182cdefd Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Thu, 17 May 2018 17:18:12 +0000 Subject: [PATCH] --- CMS_CORE_Application/Form1.cs | 9 +++++-- .../Database/DatabaseController.cs | 24 +++++++++++++++++++ .../Server/Service/ILibraryService.cs | 3 +++ .../Server/Service/LibraryService.cs | 5 ++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 44969f9..7ab9813 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -216,8 +216,13 @@ namespace CMS_CORE_Application List b = null; cmsError = N.TOOLS_RAvailableTools(ref a, ref b); cmsError = N.TOOLS_RConfiguration(ref toolsConfig); - - cmsError = N.TOOLS_WUnloadToolInMagazine(1, 1); + cmsError = N.TOOLS_WUpdatePosition(new PositionModel() + { + Disabled = false, + MagazineId = 1, + PositionId = 1 + }); + // cmsError = N.TOOLS_WUnloadToolInMagazine(1, 1); // cmsError = N.TOOLS_WLoadToolInMagazine(1, new NewToolInMagazineModel() { PositionId = 2, ToolId = 19 }); //cmsError = N.PLC_WRefreshAllMessages(); //cmsError = N.PLC_RHeadsData(headsTest, 1); diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs index bc0a456..707ad5a 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs @@ -1031,6 +1031,30 @@ namespace Nc_Demo_Application.Database return null; } + public bool UpdateToolShank(int shankId, int toolId) + { + try + { + // Find the row to be update + DataRow row = ToolsDataTable.AsEnumerable().FirstOrDefault(x => Convert.ToInt32(x["id"]) == toolId); + + if (row == null) + return false; + + row["shankId"] = shankId; + + UpdateTool(ToolsDataTable); + } + catch (Exception ex) + { + Console.WriteLine("Update tool exception: " + ex.Message); + return false; + } + + return true; + } + + private void UpdateTool(DataTable tools) { UpdateDatabaseFromDataTable(tools, READ_TOOLS_QUERY); diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs index 75db250..baa4995 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs @@ -187,6 +187,9 @@ namespace Nc_Demo_Application.Server.Service [WebInvoke(Method = "PUT", UriTemplate = "tool_table/tool", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void PutTool(ref ToolsDataModel tool); + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/shank/{shankId}/tool/{toolId}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void UpdateToolShank(string shankId, string toolId); + [WebInvoke(Method = "DELETE", UriTemplate = "tool_table/tool/{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void DeleteTool(string id); diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs index 9516eba..a4a2ffa 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs @@ -513,6 +513,11 @@ namespace Nc_Demo_Application.Server.Service DatabaseController.getInstance().DeleteTool(Convert.ToInt32(id)); } + public void UpdateToolShank(string shankId, string toolId) + { + DatabaseController.getInstance().UpdateToolShank(Convert.ToInt32(shankId), Convert.ToInt32(toolId)); + } + #endregion Tools #region Edges