From a5272be193a01550ddaf5dc2526fe6ab03a80cb5 Mon Sep 17 00:00:00 2001
From: Silvia Tzeneva <3305245+stzva@users.noreply.github.com>
Date: Wed, 16 Sep 2020 17:25:21 +0300
Subject: [PATCH 1/4] Add an example of a query using joins
---
.../NoarkWsClientSample.csproj | 2 +-
.../NoarkWsClientSample/Program.cs | 1 +
.../NoarkWsClientSample/QuerySample.cs | 23 +++++++++++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/NoarkWsClientSample.csproj b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/NoarkWsClientSample.csproj
index e1e9944..169406b 100644
--- a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/NoarkWsClientSample.csproj
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/NoarkWsClientSample.csproj
@@ -13,7 +13,7 @@
all
-
+
all
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs
index c3d1fab..cf75042 100644
--- a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs
@@ -34,6 +34,7 @@ public static void Main(string[] args)
finalizationSample.FinalizeObjectsInArchive("42", "43", "44", "45");
QuerySample querySample = new QuerySample(documasterClients);
+ querySample.GetCaseFileByTwoSecondaryClassesUsingJoins("45-67771344-7", "457-66-22-1");
querySample.GetCodeLists();
querySample.GetCaseFilesByExternalId("14", "2344-11", "External system");
querySample.GetCaseFileBySecondaryClass("14", "45503", "John Doe");
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/QuerySample.cs b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/QuerySample.cs
index 3aca59b..35c3578 100644
--- a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/QuerySample.cs
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/QuerySample.cs
@@ -146,5 +146,28 @@ public void GetRegistryEntriesCreatedInDateRange(string seriesId, DateTime fromD
Console.WriteLine($"Registry entry: Id: {registryEntry.Id}. Title: {registryEntry.Tittel}");
}
}
+
+ public void GetCaseFileByTwoSecondaryClassesUsingJoins(string secondaryClassIdent1, string secondaryClassIdent2)
+ {
+ NoarkClient client = this.documasterClients.GetNoarkClient();
+
+ int pageSize = 1;
+
+ QueryResponse queryResponse =
+ client.Query("#klasse1.klasseIdent=@klasseIdent1 && #klasse2.klasseIdent=@klasseIdent2",
+ pageSize)
+ .AddJoin("#klasse1", "refSekundaerKlasse")
+ .AddJoin("#klasse2", "refSekundaerKlasse")
+ .AddQueryParam("@klasseIdent1", secondaryClassIdent1)
+ .AddQueryParam("@klasseIdent2", secondaryClassIdent2)
+ .Execute();
+
+ if (queryResponse.Results.Any())
+ {
+ Saksmappe saksmappe = queryResponse.Results.First();
+ Console.WriteLine($"Found a case file with title '{saksmappe.Tittel}' linked to two secondary classes with klasseIdent '{secondaryClassIdent1}' and klasseIdent '{secondaryClassIdent2}'");
+ }
+
+ }
}
}
From 98d576435a88cb35d90411e9fe47135bff9defc9 Mon Sep 17 00:00:00 2001
From: Silvia Tzeneva <3305245+stzva@users.noreply.github.com>
Date: Wed, 16 Sep 2020 17:26:18 +0300
Subject: [PATCH 2/4] Add an example of using Azure grant types parameters for
authentication
---
.../NoarkWsClientSample/DocumasterClients.cs | 14 ++++++++++++--
.../NoarkWsClientSample/Options.cs | 3 +++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/DocumasterClients.cs b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/DocumasterClients.cs
index f7f92ef..3135fa6 100644
--- a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/DocumasterClients.cs
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/DocumasterClients.cs
@@ -53,8 +53,7 @@ private void RefreshAccessToken()
if (this.refreshToken == null)
{
- PasswordGrantTypeParams passwordGrantTypeParams = new PasswordGrantTypeParams(this.opts.ClientId,
- this.opts.ClientSecret, this.opts.Username, this.opts.Password, OpenIDConnectScope.OPENID);
+ PasswordGrantTypeParams passwordGrantTypeParams = GetDocumasterIdpGrantTypeParams();
AccessTokenResponse accessTokenResponse =
this.idpClient.GetTokenWithPasswordGrantType(passwordGrantTypeParams);
this.accessTokenExpirationTime = DateTime.Now.AddSeconds(accessTokenResponse.ExpiresInMs);
@@ -73,6 +72,17 @@ private void RefreshAccessToken()
}
}
+ private PasswordGrantTypeParams GetDocumasterIdpGrantTypeParams()
+ {
+ return new PasswordGrantTypeParams(this.opts.ClientId,
+ this.opts.ClientSecret, this.opts.Username, this.opts.Password, OpenIDConnectScope.OPENID);
+ }
+
+ private PasswordGrantTypeParams GetAzureGrantTypeParams()
+ {
+ return new AzureGrantTypeParams(this.opts.ClientId, this.opts.ClientSecret, this.opts.Username, this.opts.Password, OpenIDConnectScope.OPENID, this.opts.Resource);
+ }
+
private void InitIdpClient(Options options)
{
//IdpServerAddress is in the format https://clientname.dev.documaster.tech/idp/oauth2
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Options.cs b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Options.cs
index dba9e52..c99c98a 100644
--- a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Options.cs
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Options.cs
@@ -24,6 +24,9 @@ public class Options
[Option("password", Required = true, HelpText = "Password")]
public string Password { get; set; }
+ [Option("resource", Required = false, HelpText = "Resource")]
+ public string Resource { get; set; }
+
[Option("addr", Required = true, HelpText = "Server address, such as https://clientname.dev.documaster.tech:8083")]
public string ServerAddress { get; set; }
From 60011415ed901f735a6a4d8c14caa03a0ee13a7e Mon Sep 17 00:00:00 2001
From: Silvia Tzeneva <3305245+stzva@users.noreply.github.com>
Date: Wed, 16 Sep 2020 17:27:06 +0300
Subject: [PATCH 3/4] Add sample code for managing business specific metadata
---
.../BusinessSpecificMetadataSample.cs | 160 ++++++++++++++++++
.../NoarkWsClientSample.csproj | 2 +-
.../NoarkWsClientSample/Program.cs | 6 +
3 files changed, 167 insertions(+), 1 deletion(-)
create mode 100644 C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs
new file mode 100644
index 0000000..5322755
--- /dev/null
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Documaster.WebApi.Client.Noark5.Client;
+using Documaster.WebApi.Client.Noark5.NoarkEntities;
+
+namespace NoarkWsClientSample
+{
+ public class BusinessSpecificMetadataSample
+ {
+ private readonly DocumasterClients documasterClients;
+
+ public BusinessSpecificMetadataSample(DocumasterClients documasterClients)
+ {
+ this.documasterClients = documasterClients;
+ }
+
+ public void GetBusinessSpecificMetadataRegistry()
+ {
+ Console.WriteLine($"Get business-specific metadata registry");
+
+ NoarkClient client = this.documasterClients.GetNoarkClient();
+
+ BusinessSpecificMetadataInfo info = client.BsmRegistry();
+
+ foreach (MetadataGroupInfo metadataGroupInfo in info.Groups)
+ {
+ Console.WriteLine($"Group: {metadataGroupInfo.GroupName}");
+ foreach (MetadataFieldInfo metadataFieldInfo in metadataGroupInfo.Fields)
+ {
+ Console.WriteLine($"Field: Name={metadataFieldInfo.FieldName}, Type={metadataFieldInfo.FieldType}");
+ if(metadataFieldInfo.FieldValues != null)
+ {
+ //the field has predefined values
+ Console.WriteLine($"Field values: [{String.Join(",", metadataFieldInfo.FieldValues.ToArray())}]");
+ }
+ }
+ }
+ }
+
+ public void CrudOperationsWithBusinessSpecificMetadata()
+ {
+ Console.WriteLine($"Create, update and delete business-specific metadata groups and fields");
+
+ NoarkClient client = this.documasterClients.GetNoarkClient();
+
+ //Create group
+ MetadataGroupInfo group = new MetadataGroupInfo("group-applications", "Applications", "Business-specific metadata for applications");
+ MetadataGroupInfo savedGroup = client.PutBsmGroup(group);
+ Console.WriteLine($"Created group with group identifier {savedGroup.GroupId}");
+
+ //Create fields:
+ MetadataFieldInfo fieldAppliactionName = new MetadataFieldInfo("app-name", "Application name", "Application name", FieldType.String);
+ MetadataFieldInfo fieldAppliactionParticipants = new MetadataFieldInfo("app-participants", "Application participants", "Application participants", FieldType.String);
+ MetadataFieldInfo fieldAppliactionType = new MetadataFieldInfo("app-type", "Application type", "Application type", FieldType.Double, new List
-
+
all
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs
index cf75042..d02fcf4 100644
--- a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/Program.cs
@@ -42,6 +42,12 @@ public static void Main(string[] args)
FullTextSearchSample fullTextSearchSample = new FullTextSearchSample(documasterClients);
fullTextSearchSample.Search();
+
+ BusinessSpecificMetadataSample businessSpecificMetadataSample =
+ new BusinessSpecificMetadataSample(documasterClients);
+ businessSpecificMetadataSample.GetBusinessSpecificMetadataRegistry();
+ businessSpecificMetadataSample.CrudOperationsWithBusinessSpecificMetadata();
+ businessSpecificMetadataSample.AddAndUpdateBusinessSpecificMetadataToCaseFile("case file title");
}
private static Options ParserCommandLineArguments(string[] args)
From a59fb5b2c02a68b7792d924348ef6517ffabd6ac Mon Sep 17 00:00:00 2001
From: stzva <3305245+stzva@users.noreply.github.com>
Date: Thu, 24 Sep 2020 16:31:57 +0300
Subject: [PATCH 4/4] Fix typo
Co-authored-by: Dimitar Kumanov
---
.../NoarkWsClientSample/BusinessSpecificMetadataSample.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs
index 5322755..0027de9 100644
--- a/C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs
+++ b/C#/v1/NoarkWsClientSample/NoarkWsClientSample/BusinessSpecificMetadataSample.cs
@@ -129,7 +129,7 @@ public void AddAndUpdateBusinessSpecificMetadataToCaseFile(string caseFileTitle)
}
}
- //Delete a field
+ //Delete all field values from the case file
savedCaseFile.VirksomhetsspesifikkeMetadata.DeleteBsmField("group-applications", "app-secret");
//Delete a field value only