Via de Matrix.MxProject.WorkStation.Service is het mogelijk om barcodes/RFID's toe te voegen via een JSON post.
De barcodes/RFID's worden opgeslagen in het MatrixKozijn project. De waardes worden voor snel opzoeken ook toegevoegd aan de Matrix.Drive MongoDB database.
- URI voor Barcodes
http://localhost:8000/WorkStation/service/AddBarcodes - URI voor RFID's
http://localhost:8000/WorkStation/service/AddRFIDS - Header:
application/json
Vanaf build MatrixProject SP1 build 18432 is het ook mogelijk om de barcodes/RFID's toe te voegen via de Matrix.MxProject.WorkStation.Web service.
De data wordt automatisch door gestuurd naar de Matrix.MxProject.WorkStation.Service:
- URI voor Barcodes
http://localhost:1338/api/AddBarcodes - URI voor RFID's
http://localhost:1338/api/AddRFIDS
De data voor de barcodes dient doorgegeven te worden als JSON objecten:
- Value: waarde voor de barcode of RFID
- Brand_Id: Het id van het merk in MatrixKozijn
- SerieCode: De code van de serie/fase
- JobNr: Het opdrachtnummer in de projecteigenschappen in MatrixKozijn
- Mirrored: false = getekend merk, true = gespiegeld merk
Voorbeeld JSON
[ {"Value" : "B1112","Brand_Id" : 6,"SerieCode" : "001","JobNr" : "2020_1002.A0001","Mirrored" : false }, {"Value" : "B2222","Brand_Id" : 7,"SerieCode" : "001","JobNr" : "2020_1002.A0001","Mirrored" : false }, {"Value" : "B3332","Brand_Id" : 8,"SerieCode" : "001","JobNr" : "2020_1002.A0001","Mirrored" : false }, {"Value" : "B4442","Brand_Id" : 9,"SerieCode" : "001","JobNr" : "2020_1002.A0001","Mirrored" : true } ]
Voorbeeld C#
Een JSON post kan via vele programmeertalen gestuurd worden.
Hieronder een voorbeeld in C# (console app).
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; using Newtonsoft.Json.Linq; namespace Matrix.Drive.Examples { class Program { const string mes_service = "http://localhost:8000/WorkStation/service"; static void Main(string[] args) { Console.WriteLine("Example adding RFID/Barcodes"); Console.WriteLine("Adding RFID's via {0}", mes_service); _ = AddRfid_via_MES_Service(); Console.WriteLine("Adding Barcodes's via {0}", mes_service); _ = AddBarcode_via_MES_Service(); Console.WriteLine("Press any key to quit"); Console.ReadKey(); } static async Task AddRfid_via_MES_Service() { var j_rfids = new JArray { new JObject { ["Value"] = "1111", // the RFID value ["Brand_Id"] = 6, //The id of the brand in MatrixKozijn, Brand.Brand_ID ["SerieCode"] = "001", //The Code of the serie/phase, Series.Code ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties, ProjProp.JobNr ["Mirrored"] = false, //false = normal brand type, true = mirrored brand type }, new JObject { ["Value"] = "2222", // the RFID value ["Brand_Id"] = 7, ["SerieCode"] = "001", ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties ["Mirrored"] = false, }, new JObject { ["Value"] = "3333", // the RFID value ["Brand_Id"] = 8, ["SerieCode"] = "001", ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties ["Mirrored"] = false, }, new JObject { ["Value"] = "4444", // the RFID value ["Brand_Id"] = 9, ["SerieCode"] = "001", ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties ["Mirrored"] = true, }, }; var url = $"{mes_service}/AddRFIDS"; try { using (var wc = new WebClient()) { Console.WriteLine("Uri: {0}\nData: {1}", url, j_rfids.ToString()); wc.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/json"); await wc.UploadStringTaskAsync(url, j_rfids.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } static async Task AddBarcode_via_MES_Service() { var j_barcodes = new JArray { new JObject { ["Value"] = "B1111", // the barcode value ["Brand_Id"] = 6, //The id of the brand in MatrixKozijn, Brand.Brand_ID ["SerieCode"] = "001", //The Code of the serie/phase, Series.Code ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties, ProjProp.JobNr ["Mirrored"] = false, //false = normal brand type, true = mirrored brand type }, new JObject { ["Value"] = "B2222", // the barcode value ["Brand_Id"] = 7, ["SerieCode"] = "001", ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties ["Mirrored"] = false, }, new JObject { ["Value"] = "B3333", // the barcode value ["Brand_Id"] = 8, ["SerieCode"] = "001", ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties ["Mirrored"] = false, }, new JObject { ["Value"] = "B4444", // the barcode value ["Brand_Id"] = 9, ["SerieCode"] = "001", ["JobNr"] = "2020_1002", // the project JobNr from MxK project file properties ["Mirrored"] = true, }, }; var url = $"{mes_service}/AddBarcodes"; try { using (var wc = new WebClient()) { Console.WriteLine("Uri: {0}\nData: {1}", url, j_barcodes.ToString()); wc.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/json"); await wc.UploadStringTaskAsync(url, j_barcodes.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
Voorbeeld cURL
Een JSON post kan bijvoorbeeld ook gedaan worden via de cURL command line tool: https://curl.haxx.se/windows/.
curl -H "Content-Type: application/json" -X POST --data-binary @body.json http://localhost:8000/WorkStation/service/AddBarcodes
Hierbij is de JSON data opgeslagen in het bestand body.json.
Let op: de @ voor de bestandsnaam is belangrijk voor een correcte werking van cURL.