OpenTraceability 1.2.10
See the version list below for details.
dotnet add package OpenTraceability --version 1.2.10
NuGet\Install-Package OpenTraceability -Version 1.2.10
<PackageReference Include="OpenTraceability" Version="1.2.10" />
paket add OpenTraceability --version 1.2.10
#r "nuget: OpenTraceability, 1.2.10"
// Install OpenTraceability as a Cake Addin #addin nuget:?package=OpenTraceability&version=1.2.10 // Install OpenTraceability as a Cake Tool #tool nuget:?package=OpenTraceability&version=1.2.10
Open Traceability (C#)
This is an open-source library for handling traceability data in .NET using C#.
Setup
Before you can use the library you need to make sure to call the Setup method.
If you are just using the core library, you should call:
OpenTraceability.Setup.Initialize();
However, if you are using an extension library such as:
- OpenTraceability.GDST
Then you just need to call the setup method for that library such as:
OpenTraceability.GDST.Setup.Initialize();
And that will initialize everything you need.
Models
We have C# models that represent the various data objects in EPCIS including events, documents, and master data. Feel free to explore them.
This library was designed so that it could easily be extended to support many new CTEs/KDEs. It was also designed so that even without an extension library, the core library can still receive CTEs/KDEs from unknown extensions and namespaces and serialize/deserialize the data without losing any information.
More information on extensions can be found in the documentation later on. (coming soon)
EPCIS Query Document / EPCIS Document
These two objects inherit from the same base class EPCISBaseDocument
and represent the two types of documents in EPCIS. They are
used to represent the XML and JSON-LD versions of the documents. The Events and Master Data are stored in the EPCISBaseDocument.Events
and EPCISBaseDocument.MasterData
properties respectively.
It's important to note that the EPCISBaseDocument.EPCISVersion
property is used to determine the version of the document. This is important
because when mapping from the models into the XML or JSON-LD formats, the version is used to determine which format to use. If you are
trying to map into EPCIS XML 2.0 and not EPCIS XML 1.2, then you need to make sure that the EPCISBaseDocument.Version
property is set to EPCISVersion.V2
.
EPCIS Document Header
The XML format for EPCIS 1.2 and 2.0 require a Standard Business Document Header (SBDH). This is represented by the StandardBusinessDocumentHeader
class.
When converting from EPCIS JSON-LD into XML, you need to make sure to set this if the check schema is enabled. Otherwise, you will fail the schema validation.
You can use
StandardBusinessDocumentHeader.DummyHeader
to get a dummy header that you can use to pass schema validation for the XML formats.
Mapping
We support mapping between EPCIS 1.2 XML, EPCIS 2.0 XML, and EPCIS 2.0 JSON-LD. Our mappers are thread-safe and are accessible from the OpenTraceability.Mappers.OpenTraceabilityMappers
static object.
Reading EPCIS 1.2 XML
In order to read an EPCIS Query Document from an XML string in the EPCIS 1.2 xml format you can do the following:
// You can read an XML string representing an EPCIS 1.2 Query Document in XML format.
EPCISQueryDocument doc = OpenTraceabilityMappers.EPCISQueryDocument.XML.Map(queryDocXmlStr);
In order to read an EPCIS Document from an XML string in the EPCIS 1.2 xml format you can do the following:
// You can read an XML string representing an EPCIS 1.2 Document in XML format.
EPCISDocument doc = OpenTraceabilityMappers.EPCISDocument.XML.Map(docXmlStr);
Reading EPCIS 2.0 XML
This is done the same way as the 1.2 XML above. It auto-detects the version and maps it to the correct object.
In order to read an EPCIS Query Document from an XML string in the EPCIS 2.0 xml format you can do the following:
// You can read an XML string representing an EPCIS 2.0 Query Document in XML format.
EPCISQueryDocument doc = OpenTraceabilityMappers.EPCISQueryDocument.XML.Map(queryDocXmlStr);
In order to read an EPCIS Document from an XML string in the EPCIS 2.0 xml format you can do the following:
// You can read an XML string representing an EPCIS 2.0 Document in XML format.
EPCISDocument doc = OpenTraceabilityMappers.EPCISDocument.XML.Map(docXmlStr);
Reading EPCIS 2.0 JSON-LD
In order to read an EPCIS Query Document from a JSON string in the EPCIS 2.0 JSON-LD format you can do the following:
// You can read an XML string representing an EPCIS 2.0 Query Document in JSON-LD format.
EPCISQueryDocument doc = OpenTraceabilityMappers.EPCISQueryDocument.JSON.Map(queryDocXmlStr);
In order to read an EPCIS Document from a JSON string in the EPCIS 2.0 JSON-LD format you can do the following:
// You can read an XML string representing an EPCIS 2.0 Document in JSON-LD format.
EPCISDocument doc = OpenTraceabilityMappers.EPCISDocument.JSON.Map(docXmlStr);
Convert EPCIS 1.2 XML to EPCIS 2.0 XML
This example is for reading an EPCIS Query Document, but it would work the same with EPCIS Document as well.
// read the EPCIS 1.2 XML string
EPCISQueryDocument doc = OpenTraceabilityMappers.EPCISQueryDocument.XML.Map(queryDocXmlStr_1_2);
// set the EPCIS version
doc.EPCISVersion = EPCISVersion.V2;
// write it back out now
string queryDocXmlStr_2_0 = OpenTraceabilityMappers.EPCISQueryDocument.XML.Map(doc);
Convert EPCIS 1.2 XML to EPCIS 2.0 JSON-LD
This example is for reading an EPCIS Query Document, but it would work the same with EPCIS Document as well.
// read the EPCIS 1.2 XML string
EPCISQueryDocument doc = OpenTraceabilityMappers.EPCISQueryDocument.XML.Map(queryDocXmlStr_1_2);
// set the EPCIS version
doc.EPCISVersion = EPCISVersion.V2;
// write it back out now
string queryDocJsonStr_2_0 = OpenTraceabilityMappers.EPCISQueryDocument.JSON.Map(doc);
Querying for Data
We support querying traceability and master data using a very specific flavor of communication protocols from GS1.
- We support querying for event data using the
GET - /events
endpoint on the EPCIS 2.0 Query Interface. - We support resolving master data from a GS1 Digital Link Resolver using the GS1 Web Vocab JSON-LD format.
EPCIS Query Interface
The first interface that can be queried is for events from an EPCIS 2.0 Query Interface at the GET - /events
endpoint.
This is done using the EPCISTraceabilityResolver
class.
In order to use this, you need:
EPCISQueryInterfaceOptions
- URL
- Version
- Format
EPCISQueryParameters
- Here you can define one or more parameters for filtering the desired results.
using HttpClient = new HttpClient();
EPCISQueryInterfaceOptions options = new EPCISQueryInterfaceOptions()
{
URL = new Uri(url),
Format = _format,
Version = _version,
EnableStackTrace = true
};
EPC epc = new EPC("urn:epc:id:sgtin:0614141.107346.2019");
EPCISQueryParameters parameters = new EPCISQueryParameters(epc);
return await EPCISTraceabilityResolver.QueryEvents(options, parameters, client);
You can also use the trace-back feature to automatically trace-back the EPC.
using HttpClient = new HttpClient();
EPCISQueryInterfaceOptions options = new EPCISQueryInterfaceOptions()
{
URL = new Uri(url),
Format = _format,
Version = _version,
EnableStackTrace = true
};
EPC epc = new EPC("urn:epc:id:sgtin:0614141.107346.2019");
return await EPCISTraceabilityResolver.Traceback(options, epc, client);
GS1 Digital Link Resolver
You can also resolve master data from a GS1 Digital Link resolver with the MasterDataResolver
class. This class
takes in a DigitalLinkQueryOptions
object that contains the URL of the resolver and also an EPCISBaseDocument
and will search the EPCISBaseDocument for any master data that is not in the document but referenced in the events,
and try and resolve it and add it to the document.
DigitalLinkQueryOptions options = new DigitalLinkQueryOptions()
{
URL = new Uri(url),
EnableStackTrace = true
};
await MasterDataResolver.ResolveMasterData(options, doc, client);
Finally
You can always look in our unit tests for more examples of how to use the library.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Crc32.NET (>= 1.2.0)
- JsonSchema.Net (>= 4.1.0)
- Newtonsoft.Json (>= 13.0.2)
- Nito.AsyncEx.Coordination (>= 5.1.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on OpenTraceability:
Package | Downloads |
---|---|
OpenTraceability.GDST
Open source libraries for working with EPCIS in C# with extensions for GDST. |
|
OpenTraceability.TestServerPackage
A packaged version of a test server that can be deployed and used prop up a dummy EPCIS/Digital Link resolver.. |
|
OpenTraceability.MSC
Open source libraries for working with EPCIS in C# with extensions for MSC based on the GDST extensions. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.4.66 | 1,239 | 10/5/2024 |
1.4.64 | 108 | 10/4/2024 |
1.4.63 | 113 | 10/4/2024 |
1.4.62 | 120 | 10/3/2024 |
1.4.61 | 926 | 7/30/2024 |
1.4.60 | 116 | 7/26/2024 |
1.4.59 | 1,621 | 6/25/2024 |
1.4.58 | 1,018 | 5/31/2024 |
1.4.57 | 341 | 5/22/2024 |
1.4.56 | 1,330 | 4/17/2024 |
1.3.55 | 278 | 4/15/2024 |
1.3.54 | 694 | 2/6/2024 |
1.3.53 | 331 | 2/4/2024 |
1.2.14 | 275 | 2/2/2024 |
1.2.13 | 266 | 2/2/2024 |
1.2.12 | 1,105 | 11/29/2023 |
1.2.11 | 695 | 7/14/2023 |
1.2.10 | 568 | 7/10/2023 |
1.2.9 | 529 | 7/10/2023 |
1.2.8 | 487 | 7/7/2023 |
1.2.7 | 635 | 7/6/2023 |
1.2.7-beta86 | 464 | 7/6/2023 |
1.2.6 | 461 | 7/5/2023 |
1.2.6-beta85 | 453 | 7/5/2023 |
1.2.5 | 535 | 6/29/2023 |
1.2.5-beta84 | 435 | 7/5/2023 |
1.2.5-beta83 | 534 | 6/29/2023 |
1.2.4 | 527 | 6/28/2023 |
1.2.4-beta82 | 435 | 6/29/2023 |
1.2.4-beta80 | 445 | 6/29/2023 |
1.2.4-beta79 | 472 | 6/28/2023 |
1.2.4-beta78 | 507 | 6/28/2023 |
1.2.4-beta77 | 456 | 6/28/2023 |
1.2.4-beta76 | 481 | 6/28/2023 |
1.2.4-beta75 | 498 | 6/28/2023 |
1.2.4-beta74 | 465 | 6/28/2023 |
1.2.4-beta73 | 454 | 6/28/2023 |
1.2.4-beta72 | 435 | 6/28/2023 |
1.2.4-beta71 | 448 | 6/28/2023 |
1.2.4-beta70 | 437 | 6/28/2023 |
1.2.4-beta69 | 469 | 6/28/2023 |
1.2.4-beta68 | 444 | 6/28/2023 |
1.2.4-beta67 | 511 | 6/28/2023 |
1.2.4-beta66 | 512 | 6/28/2023 |
1.2.4-beta65 | 422 | 6/28/2023 |
1.2.4-beta64 | 516 | 6/28/2023 |
1.2.4-beta63 | 509 | 6/28/2023 |
1.2.4-beta62 | 496 | 6/28/2023 |
1.2.4-beta61 | 505 | 6/28/2023 |
1.2.4-beta60 | 538 | 6/28/2023 |
1.2.4-beta59 | 457 | 6/28/2023 |
1.2.4-beta58 | 515 | 6/28/2023 |
1.2.4-beta57 | 443 | 6/28/2023 |
1.2.4-beta56 | 502 | 6/28/2023 |
1.2.4-beta55 | 504 | 6/28/2023 |
1.2.4-beta54 | 426 | 6/28/2023 |
1.2.3 | 611 | 6/15/2023 |
1.2.2 | 553 | 6/13/2023 |
1.2.2-beta53 | 447 | 6/28/2023 |
1.2.2-beta52 | 492 | 6/28/2023 |
1.2.2-beta51 | 450 | 6/28/2023 |
1.2.2-beta50 | 474 | 6/28/2023 |
1.2.2-beta49 | 454 | 6/28/2023 |
1.2.2-beta48 | 510 | 6/28/2023 |
1.2.2-beta47 | 478 | 6/28/2023 |
1.2.2-beta46 | 502 | 6/28/2023 |
1.2.2-beta45 | 507 | 6/28/2023 |
1.2.2-beta44 | 481 | 6/28/2023 |
1.2.2-beta43 | 474 | 6/23/2023 |
1.2.2-beta42 | 496 | 6/23/2023 |
1.2.2-beta41 | 487 | 6/23/2023 |
1.2.2-beta40 | 491 | 6/23/2023 |
1.2.2-beta39 | 509 | 6/23/2023 |
1.2.2-beta38 | 531 | 6/23/2023 |
1.2.2-beta37 | 511 | 6/13/2023 |
1.2.1 | 607 | 5/23/2023 |
1.2.1-beta36 | 493 | 6/13/2023 |
1.2.1-beta35 | 453 | 5/23/2023 |
1.2.0 | 510 | 5/23/2023 |
1.2.0-beta34 | 483 | 5/23/2023 |
1.2.0-beta33 | 417 | 5/23/2023 |
1.1.9 | 566 | 5/12/2023 |
1.1.9-beta32 | 504 | 5/12/2023 |
1.1.8 | 564 | 5/12/2023 |
1.1.8-beta31 | 508 | 5/12/2023 |
1.1.7 | 493 | 5/12/2023 |
1.1.7-beta30 | 455 | 5/12/2023 |
1.1.6 | 470 | 5/8/2023 |
1.1.6-beta29 | 446 | 5/8/2023 |
1.1.5 | 502 | 5/8/2023 |
1.1.5-beta28 | 470 | 5/8/2023 |
1.1.5-beta27 | 506 | 5/8/2023 |
1.1.4 | 576 | 5/8/2023 |
1.1.4-beta26 | 457 | 5/8/2023 |
1.1.3 | 506 | 5/7/2023 |
1.1.3-beta25 | 449 | 5/8/2023 |
1.1.3-beta24 | 454 | 5/7/2023 |
1.1.2 | 511 | 5/5/2023 |
1.1.2-beta23 | 456 | 5/7/2023 |
1.1.2-beta22 | 422 | 5/5/2023 |
1.1.1 | 488 | 5/4/2023 |
1.1.1-beta20 | 455 | 5/4/2023 |
1.1.0 | 511 | 5/4/2023 |
1.1.0-beta19 | 458 | 5/4/2023 |
1.0.8 | 567 | 5/4/2023 |
1.0.8-beta18 | 463 | 5/4/2023 |
1.0.8-beta17 | 396 | 5/4/2023 |
1.0.7 | 551 | 5/3/2023 |
1.0.7-beta14 | 454 | 5/3/2023 |
1.0.6 | 524 | 5/3/2023 |
1.0.6-beta13 | 405 | 5/3/2023 |
1.0.5 | 509 | 5/3/2023 |
1.0.5-beta12 | 466 | 5/3/2023 |
1.0.5-beta11 | 422 | 5/3/2023 |
1.0.4 | 505 | 5/3/2023 |
1.0.4-beta9 | 394 | 5/3/2023 |
1.0.4-beta10 | 416 | 5/3/2023 |
1.0.2 | 549 | 5/3/2023 |
1.0.2-beta8 | 483 | 5/3/2023 |
1.0.1 | 532 | 5/3/2023 |
1.0.0 | 544 | 4/20/2023 |
1.0.0-beta9 | 457 | 4/20/2023 |
1.0.0-beta5 | 437 | 4/30/2023 |
1.0.0-beta4 | 459 | 4/20/2023 |
1.0.0-beta1 | 404 | 4/20/2023 |
1.0.0-beta | 382 | 4/20/2023 |