6 changed files
Client/HomagGroup.DigitalFactory.ApiGateway.Client | ||
Interfaces | ||
IOptimizationServices.cs | ||
Services | ||
OptimizationServices.cs | ||
Documentation | ||
README.md | ||
Samples/csharp/HomagGroup.ApiGateway.Client.Samples | ||
IDImportViaTemplateAsyncTest.cs | ||
IDSendToPAAsyncTest.cs + | ||
TestBase.cs | ||
IOptimizationServices.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Interfaces/IOptimizationServices.cs+9/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Interfaces/IOptimizationServices.cs
Add comment 53 /// <returns></returns>
Add comment 54 Task<ImportDetails> IDImportViaTemplateAsync(ImportFileInfo importInfo, string machineId,
Add comment 55 string parameterId, string templateId, bool startOptimization = false, string jobName = null);
Add comment 56 Plus
Add comment 57 Plus /// <summary>
Add comment 58 Plus /// Send optimized saw to productionAssist, using intelliDivide
Add comment 59 Plus /// </summary>
Add comment 60 Plus /// <param name="importInfo"></param>
Add comment 61 Plus /// <param name="templateId"></param>
Add comment 62 Plus /// <param name="jobName"></param>
Add comment 63 Plus /// <returns></returns>
Add comment 64 Plus Task<ImportDetails> IDSendToPAAsync(ImportFileInfo importInfo, string templateId, string jobName = null);
Add comment 56 65 }
Add comment 57 66 }
Add comment 58 67
OptimizationServices.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Services/OptimizationServices.cs-16+71/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Services/OptimizationServices.cs
Add comment 111 public async Task<ImportDetails> IDImportViaTemplateAsync(ImportFileInfo importInfo, string machineId,
Add comment 112 string parameterId, string templateId, bool startOptimization = false, string jobName = null)
Add comment 113 {
Add comment 114 Minus if (string.IsNullOrEmpty(machineId))
Add comment 114 Plus ValidateImportViaTemplate(importInfo, machineId, parameterId, templateId);
Add comment 115 Plus
Add comment 116 Plus var request = new HttpRequestMessage { Method = HttpMethod.Post };
Add comment 117 Plus var query = string.IsNullOrEmpty(jobName) ? string.Empty : $"?jobName={Uri.EscapeDataString(jobName)}";
Add comment 118 Plus
Add comment 119 Plus if (startOptimization)
Add comment 115 120 {
Add comment 116 Minus throw new ArgumentNullException(nameof(machineId));
Add comment 121 Plus query = AppendStartOptimizationParam(query);
Add comment 117 122 }
Add comment 118 Minus if (string.IsNullOrEmpty(parameterId))
Add comment 123 Plus
Add comment 124 Plus var uri = $"{Prefix}optimizations/import/machine/{machineId}/parameter/{parameterId}/template/{templateId}{query}";
Add comment 125 Plus request.RequestUri = new Uri(uri, UriKind.Relative);
Add comment 126 Plus request.Headers.AcceptLanguage.Clear();
Add comment 127 Plus request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(CultureInfo.CurrentUICulture.Name));
Add comment 128 Plus
Add comment 129 Plus var multiContent = new MultipartFormDataContent();
Add comment 130 Plus byte[] data;
Add comment 131 Plus foreach (var file in importInfo.Files)
Add comment 119 132 {
Add comment 120 Minus throw new ArgumentNullException(nameof(parameterId));
Add comment 121 Minus }
Add comment 122 Minus if (string.IsNullOrEmpty(templateId))
Add comment 133 Plus using (var br = new BinaryReader(file.Stream))
Add comment 123 134 {
Add comment 124 Minus throw new ArgumentNullException(nameof(templateId));
Add comment 135 Plus data = br.ReadBytes((int)file.Stream.Length);
Add comment 125 136 }
Add comment 126 Minus if (importInfo == null)
Add comment 127 Minus {
Add comment 128 Minus throw new ArgumentNullException(nameof(importInfo));
Add comment 137 Plus var bytes = new ByteArrayContent(data);
Add comment 138 Plus multiContent.Add(bytes, "files", file.Name);
Add comment 129 139 }
Add comment 140 Plus request.Content = multiContent;
Add comment 130 141
Add comment 142 Plus var response = await Client.SendAsync(request).ConfigureAwait(false);
Add comment 143 Plus response.HandleDeprecatedMessages(request, ApiVersion, ThrowExceptionOnDeprecatedCalls, OnDeprecatedAction);
Add comment 144 Plus response.EnsureSuccessStatusCodeWithDetails(request);
Add comment 145 Plus var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
Add comment 146 Plus return JsonConvert.DeserializeObject<ImportDetails>(content, SerializerSettings.Default);
Add comment 147 Plus }
Add comment 148 Plus
Add comment 149 Plus /// <inheritdoc />
Add comment 150 Plus public async Task<ImportDetails> IDSendToPAAsync(ImportFileInfo importInfo, string templateId, string jobName = null)
Add comment 151 Plus {
Add comment 152 Plus ValidateSendtoPA(importInfo, templateId);
Add comment 153 Plus
Add comment 131 154 var request = new HttpRequestMessage { Method = HttpMethod.Post };
Add comment 132 155 var query = string.IsNullOrEmpty(jobName) ? string.Empty : $"?jobName={Uri.EscapeDataString(jobName)}";
Add comment 133 156
Add comment 134 Minus if (startOptimization)
Add comment 135 Minus {
Add comment 136 Minus query = AppendStartOptimizationParam(query);
Add comment 137 Minus }
Add comment 138 Minus
Add comment 139 Minus var uri = $"{Prefix}optimizations/import/machine/{machineId}/parameter/{parameterId}/template/{templateId}{query}";
Add comment 157 Plus var uri = $"{Prefix}optimizations/import/template/{templateId}/productionAssist{query}";
Add comment 140 158 request.RequestUri = new Uri(uri, UriKind.Relative);
Add comment 141 159 request.Headers.AcceptLanguage.Clear();
Add comment 142 160 request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(CultureInfo.CurrentUICulture.Name));
Add comment 161 179 return JsonConvert.DeserializeObject<ImportDetails>(content, SerializerSettings.Default);
Add comment 162 180 }
Add comment 163 181
Add comment 182 Plus private static void ValidateImportViaTemplate(ImportFileInfo importInfo, string machineId, string parameterId,
Add comment 183 Plus string templateId)
Add comment 184 Plus {
Add comment 185 Plus if (string.IsNullOrEmpty(machineId))
Add comment 186 Plus {
Add comment 187 Plus throw new ArgumentNullException(nameof(machineId));
Add comment 188 Plus }
Add comment 189 Plus
Add comment 190 Plus if (string.IsNullOrEmpty(parameterId))
Add comment 191 Plus {
Add comment 192 Plus throw new ArgumentNullException(nameof(parameterId));
Add comment 193 Plus }
Add comment 194 Plus
Add comment 195 Plus if (string.IsNullOrEmpty(templateId))
Add comment 196 Plus {
Add comment 197 Plus throw new ArgumentNullException(nameof(templateId));
Add comment 198 Plus }
Add comment 199 Plus
Add comment 200 Plus if (importInfo == null)
Add comment 201 Plus {
Add comment 202 Plus throw new ArgumentNullException(nameof(importInfo));
Add comment 203 Plus }
Add comment 204 Plus }
Add comment 205 Plus
Add comment 206 Plus private static void ValidateSendtoPA(ImportFileInfo importInfo, string templateId)
Add comment 207 Plus {
Add comment 208 Plus if (importInfo == null)
Add comment 209 Plus {
Add comment 210 Plus throw new ArgumentNullException(nameof(importInfo));
Add comment 211 Plus }
Add comment 212 Plus
Add comment 213 Plus if (string.IsNullOrEmpty(templateId))
Add comment 214 Plus {
Add comment 215 Plus throw new ArgumentNullException(nameof(templateId));
Add comment 216 Plus }
Add comment 217 Plus }
Add comment 218 Plus
Add comment 164 219 private string AppendStartOptimizationParam(string query)
Add comment 165 220 {
Add comment 166 221 const string startOptimizationParam = "startOptimization=true";
Add comment 21 1.11 |07.04.2022| Added new image sizes from MaterialManager
Add comment 22 1.12 |31.08.2022| Added IDGetTemplates / IDImportViaTemplate
Add comment 23 1.13 |02.09.2022| Updated IDImportViaTemplate
Add comment 24 Plus 1.14 |12.10.2022| Added IDSendToPA
Add comment 24 25
Add comment 25 26 ## Introduction
Add comment 26 27
Add comment 226 227 IDGetOptimizationSolutions | GET | `_PREFIX_/optimizations/`⤶<br/>`jobs/{jobId}/solutions` | Returns the optimization solutions | OptExecCut / NestingOptimization
Add comment 227 228 IDGetOptimizationSolutionData | GET | `_PREFIX_/optimizations/`⤶<br/>`jobs/{jobId}/solutions/`⤶<br/>`{solutionId}/data/{dataType}` | Returns the optimization solution data with the specified type<br/>Allowed values are:<br/>For cutting: saw / ptx<br/>For nesting: zip | OptExecCut / NestingOptimization
Add comment 228 229 IDImportViaTemplate | POST | `_PREFIX_/optimizations/`⤶<br/>`import/machine/{machineId}/`⤶<br/>`parameter/{parameterId}/`⤶<br/>`template/{templateId}{query}`| Creates a new optimization and imports information from csv or xls file with exiting template<br/>Allowed query parameters are:<br/>**jobName** for specifying a custom optimization job name<br/>**startOptimization** for also starting the job optimization | CuttingOptimizationImport
Add comment 230 Plus IDSendToPA | POST | `_PREFIX_/optimizations/`⤶<br/>`import/template/{templateId}/`⤶<br/>`productionAssist{query}` | Sends and aleady optimized SAW file to productionAssist<br/>Allowed query parameters are:<br/>**jobName** for specifying a custom optimization job name | CuttingOptimizationImport
Add comment 229 231
Add comment 230 232 ##### productionManager interface
Add comment 231 233
Add comment 919 921 ```
Add comment 920 922 For content and response see above (Example 1).
Add comment 921 923
Add comment 924 Plus ##### intelliDivide interface: IDSendToPA
Add comment 925 Plus
Add comment 926 Plus ###### Input
Add comment 927 Plus
Add comment 928 Plus Parameter | Description
Add comment 929 Plus ------------------|---------------------------------------------------------------------------------------------------------------------------------------------
Add comment 930 Plus templateId | The Id of the template used to process the file import
Add comment 931 Plus jobName | Optionally pass the name of the newly created customer optimization<br>If no jobName is passed, the file name will be used as customer optimization name
Add comment 932 Plus
Add comment 933 Plus ###### Example 1 (default)
Add comment 934 Plus
Add comment 935 Plus Request
Add comment 936 Plus
Add comment 937 Plus ```text
Add comment 938 Plus POST /api/gw/optimizations/import/template/be1a5f21-8151-4ef0-96fe-c73491551a34/productionAssist
Add comment 939 Plus api-version: 2021-08-10
Add comment 940 Plus Accept-Language: en-US
Add comment 941 Plus Content-Type: multipart/form-data; boundary=--some-boundary
Add comment 942 Plus Authorization: Basic NjU1MDFEMDktMkJCOS00M0MyLUI5RDMtMUZCMDAwNkE3NjlFOnNkMDlzaGR1Z985OGffc2ZkZ3pz32Y5ZGhzYWZkaHNmZN92ODlwYmZkOXZiaGFmZGd2
Add comment 943 Plus tracestate: someinternaltracedata
Add comment 944 Plus ```
Add comment 945 Plus
Add comment 946 Plus The content type must be `multipart/form-data`. The key name for each file part is `files`.
Add comment 947 Plus
Add comment 948 Plus Example body for a request with a SAW file:
Add comment 949 Plus
Add comment 950 Plus ```text
Add comment 951 Plus ----some-boundary
Add comment 952 Plus Content-Disposition: form-data; name="files"; filename="file.saw"
Add comment 953 Plus Content-Type: multipart/form-data; boundary=--some-boundary
Add comment 954 Plus
Add comment 955 Plus [Content of file.saw]
Add comment 956 Plus
Add comment 957 Plus ----some-boundary--
Add comment 958 Plus ```
Add comment 959 Plus
Add comment 960 Plus Response (200 Ok)
Add comment 961 Plus
Add comment 962 Plus We currently return the following import states:
Add comment 963 Plus
Add comment 964 Plus * Succeeded / Error
Add comment 965 Plus
Add comment 966 Plus Response (200 Ok)
Add comment 967 Plus
Add comment 968 Plus ```text
Add comment 969 Plus Content-Type: application/json
Add comment 970 Plus ```
Add comment 971 Plus
Add comment 972 Plus ```json
Add comment 973 Plus {
Add comment 974 Plus "state": "Succeeded",
Add comment 975 Plus "link": "https://intellidivide.homag.cloud/#/62b8fee0-1b35-41c1-b03a-b947304a0d58/jobs/9fde113d-cea7-4116-825a-0010d49870c9"
Add comment 976 Plus }
Add comment 977 Plus ```
Add comment 978 Plus
Add comment 979 Plus or
Add comment 980 Plus
Add comment 981 Plus ```text
Add comment 982 Plus Content-Type: application/json
Add comment 983 Plus ```
Add comment 984 Plus
Add comment 985 Plus ```json
Add comment 986 Plus {
Add comment 987 Plus "state": "Error",
Add comment 988 Plus "errorText": "The data of the import file is in an unexpected format.",
Add comment 989 Plus "errorDetails": "No header record was found.\r\nIReader state:\r\n ColumnCount: 0\r\n CurrentIndex: -1\r\n HeaderRecord:\r\n\r\nIParser state:\r\n ByteCount: 0\r\n CharCount: 26\r\n Row: 5\r\n RawRow: 5\r\n Count: 0\r\n RawRecord:\r\n\r\n"
Add comment 990 Plus }
Add comment 991 Plus ```
Add comment 992 Plus
Add comment 993 Plus or
Add comment 994 Plus
Add comment 995 Plus ```text
Add comment 996 Plus Content-Type: application/json
Add comment 997 Plus ```
Add comment 998 Plus
Add comment 999 Plus ```json
Add comment 1000 Plus {
Add comment 1001 Plus "state": "Error",
Add comment 1002 Plus "errorText": "No data could be identified for import. Please check the file and the import template"
Add comment 1003 Plus }
Add comment 1004 Plus ```
Add comment 1005 Plus
Add comment 1006 Plus ###### Examlpe 2 (with jobName)
Add comment 1007 Plus
Add comment 1008 Plus Request
Add comment 1009 Plus
Add comment 1010 Plus ```text
Add comment 1011 Plus POST /api/gw/optimizations/import/template/be1a5f21-8151-4ef0-96fe-c73491551a34/productionAssist?jobName=New%20job
Add comment 1012 Plus api-version: 2021-08-10
Add comment 1013 Plus Accept-Language: en-US
Add comment 1014 Plus Content-Type: multipart/form-data; boundary=--some-boundary
Add comment 1015 Plus Authorization: Basic NjU1MDFEMDktMkJCOS00M0MyLUI5RDMtMUZCMDAwNkE3NjlFOnNkMDlzaGR1Z985OGffc2ZkZ3pz32Y5ZGhzYWZkaHNmZN92ODlwYmZkOXZiaGFmZGd2
Add comment 1016 Plus tracestate: someinternaltracedata
Add comment 1017 Plus ```
Add comment 1018 Plus For content and response see above (Example 1).
Add comment 1019 Plus
Add comment 922 1020 ##### productionManager interface: PMImport (Example)
Add comment 923 1021
Add comment 924 1022 Request
IDImportViaTemplateAsyncTest.cs
/Samples/csharp/HomagGroup.ApiGateway.Client.Samples/IDImportViaTemplateAsyncTest.cs/Samples/csharp/HomagGroup.ApiGateway.Client.Samples/IDImportViaTemplateAsyncTest.cs
IDSendToPAAsyncTest.cs
/Samples/csharp/HomagGroup.ApiGateway.Client.Samples/IDSendToPAAsyncTest.cs/Samples/csharp/HomagGroup.ApiGateway.Client.Samples/IDSendToPAAsyncTest.cs
TestBase.cs
/Samples/csharp/HomagGroup.ApiGateway.Client.Samples/TestBase.cs/Samples/csharp/HomagGroup.ApiGateway.Client.Samples/TestBase.cs