Sample code, showing how to use the CTMS API in C#
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
AdvancedSearch
AdvancedSearchSDK
FastPrintFolderStructure
FastPrintFolderStructureSDK
FolderOperations
OrchestrationProcessQuery
OrchestrationProcessQuerySDK
OrchestrationStartAndMonitorProcess
OrchestrationStartProcessSDK
PlatformTools
PrintFolderStructureWithAttributesSDK
QueryDatamodelAggregator
QueryServiceRegistry
QueryServiceRegistrySDK
SimpleSearch
SimpleSearchAsync
SimpleSearchSDK
lib
.gitignore
LICENSE
NOTICE
PlatformExamples.NET.sln
Readme.md

Readme.md

Please Read Me

  • Implementation:

    • The examples are implemented with C# 6/.NET 4.6.2 (target framework) and Visual Studio 2015.
    • There are two categories of examples: those using the PlatformSDK (projects to be identified with the suffix "SDK") and those using REST and HATEOAS directly.
    • The example SimpleSearchAsync shows, how asynchronous HTTP requests can be applied to use CTMS.
    • The non-PlatformSDK examples are configured to use a request timeout of 60s each.
    • There are some error checks but those are very general and might not cover all cases. Esp. timeouts or unreachable endpoints could happen at any time during the application of REST and HATEOAS.
    • No optimization and no parallelization (e.g. for requesting results from the platform) was implemented.
      • Esp. the examples use HATEOAS to get all links. Instead of HATEOAS all links could be used hard coded or being "bookmarked" without HATEOAS (resulting in faster execution time), but this is not the idea behind RESTful interfaces. Also mind, that those links could change in future so the only save way is to get the via HATEOAS. The examples do only use these URLs directly: https://$apidomain/auth and https://$apidomain/auth/tokens/current/extension other URLs are resolved using the CTMS Registry and HATEOAS!
    • For testing purposes, it was required to configure the WebRequestHandlers to accept arbitrary SSL certificates. Please notice, that this may not be acceptable for productive code.
    • When running the examples it is required to pass an OAuth2 token via the command line. The OAuth2 token can be optained from Avid.
    • The realm, which is passed to each example is checked by the CTMS Registry. If the services needed by the example cannot be found in the specified realm, the example requests the CTMS Registry for an alternative target.
  • Dependencies:

    • The projects using SDK examples make use of PlatformSDK.dll. This assembly, as well as a belonging to config file, reside in the folder lib.
    • Additionally, these 3rd-party libraries are used: Newtonsoft.Json 11.0.2, Tavis.UriTemplates 1.1.1 and WebApi.Hal 2.6.0
    • Each project in the solution brings its own packages.config file, in which the required NuGet packages are listed.
    • The Visual Studio solution is self contained, dependent libraries can be resolved via NuGet:
      • The installation of required NuGet packages runs automatically, when the solution is opened. If that didn't happen, the packages can be reinstalled manually:
        • For the following steps a "NuGet Package Manager Console Host" of version >= 2.8.60723.765 is required.
        • Windows PowerShell script execution must be enabled: issue "set-executionpolicy remotesigned" in an admin PowerShell console.
        • Open Tools>NuGet Package Manager>Package Manager Console:
          • Make sure, that the Package Manager Console is configured to have the "Package source" set to "All".
          • Issue the command "update-package -reinstall".
  • Running the examples:

    • => When running the executables on a terminal, make sure you have specified correct command line arguments: ExampleApplicationName apidomain [servicetype] [serviceversion] [realm] oauth2token username password ['searchexpression'] [advancedsearchdescriptionfilename]
    • The SimpleSearch/SimpleSearchAsync examples await the searchexpression in single quotes as last argument:
      • SimpleSearch.exe apidomain servicetype realm oAuth2Token username password 'searchexpression'
      • Example: SimpleSearch upstream avid.mam.assets.access BEEF UZ86FbYI76534 Administrator ABRAXAS '*'
      • SimpleSearchAsync.exe apidomain servicetype realm oAuth2Token username password 'searchexpression'
      • Example: SimpleSearchAsync upstream avid.mam.assets.access BEEF UZ86FbYI76534 Administrator ABRAXAS '*'
    • The AdvancedSearch example awaits the file name of a file containing the advanced search description as last argument:
      • AdvancedSearch.exe apidomain servicetype realm oauth2token username password advancedsearchdescriptionfilename
      • Example: AdvancedSearch upstream avid.mam.assets.access BEEF UZ86FbYI76534 Administrator ABRAXAS Resources\MAMAdvancedSearchDescription.txt
    • The SimpleSearchSDK and OrchestrationXXXSDK examples awaits the searchexpression in single quotes as last argument:
      • SimpleSearchSDK|OrchestrationXXXSDK apidomain servicetype realm oauth2token username password 'searchexpression'
      • Example: SimpleSearchSDK upstream BEEF UZ86FbYI76534 Administrator ABRAXAS '*'
    • The QueryServiceRegistry example needs no servicetype (always "avid.ctms.registry") and no realm (always "global"/"") argument.
      • QueryServiceRegistry.exe apidomain oAuth2Token username password
      • Example: QueryServiceRegistry upstream UZ86FbYI76534 Administrator Avid123
    • Optionally, e.g. for debugging purposes, the assembly can be started with the app.config being configured for a proxy server:
    <configuration>
       <!-- ... -->
    
       <system.net>
           <defaultProxy enabled = "true" useDefaultCredentials = "true">
               <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
           </defaultProxy>
       </system.net>
    </configuration>
    
    • Notice, that using a proxy can reduce the performance of HTTP requests.
    • Notice also, that having set proxy options as shown above while no proxy is configured can reduce the performance of HTTP requests by an order of magnitude!