-
Notifications
You must be signed in to change notification settings - Fork 6
/
Sample22_ReadResponse.cs
122 lines (103 loc) · 4.71 KB
/
Sample22_ReadResponse.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// <copyright file="Sample22_ReadResponse.cs" company="Relativity ODA LLC">
// © Relativity All Rights Reserved.
// </copyright>
namespace Relativity.Import.Samples.DotNetFrameworkClient.SamplesCollection
{
using System;
using System.Threading.Tasks;
using Relativity.Import.Samples.DotNetFrameworkClient.ImportSampleHelpers;
using Relativity.Import.V1;
using Relativity.Import.V1.Models.Settings;
using Relativity.Import.V1.Models.Sources;
/// <summary>
/// Class containing examples of using import service SDK.
/// </summary>
public partial class ImportServiceSample
{
/// <summary>
/// Example of canceling started job.
/// </summary>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public async Task Sample22_ReadResponse()
{
Console.WriteLine($"Running {nameof(this.Sample22_ReadResponse)}");
// GUID identifiers for import job and data source.
Guid importId = Guid.NewGuid();
Guid sourceId = Guid.NewGuid();
// destination workspace artifact Id.
const int workspaceId = 1000000;
ImportDocumentSettings invalidConfiguration = new ImportDocumentSettings();
DataSourceSettings dataSourceSettings = new DataSourceSettings();
using (Relativity.Import.V1.Services.IDocumentConfigurationController documentConfiguration =
this.serviceFactory.CreateProxy<Relativity.Import.V1.Services.IDocumentConfigurationController>())
using (Relativity.Import.V1.Services.IImportJobController importJobController =
this.serviceFactory.CreateProxy<Relativity.Import.V1.Services.IImportJobController>())
using (Relativity.Import.V1.Services.IImportSourceController importSourceController =
this.serviceFactory.CreateProxy<Relativity.Import.V1.Services.IImportSourceController>())
{
// Create import job.
Response response = await importJobController.CreateAsync(
importJobID: importId,
workspaceID: workspaceId,
applicationName: "Import-service-sample-app",
correlationID: "Sample-job-00022");
Console.WriteLine($"IsSuccess:{response?.IsSuccess}");
Console.WriteLine($"ImportJobID:{response?.ImportJobID}");
Console.WriteLine($"ErrorCode:{response?.ErrorCode}");
Console.WriteLine($"ErrorMessage:{response?.ErrorMessage}");
ResponseHelper.EnsureSuccessResponse(response, "IImportJobController.CreateAsync");
// try to configure job - use invalid configuration.
Response configureResponse = await documentConfiguration.CreateAsync(workspaceId, importId, invalidConfiguration);
Console.WriteLine("Add document configuration response");
Console.WriteLine($"IsSuccess:{response?.IsSuccess}");
if (!configureResponse.IsSuccess)
{
Console.WriteLine($"ImportJobID:{configureResponse?.ImportJobID}");
Console.WriteLine($"ErrorCode:{configureResponse?.ErrorCode}");
Console.WriteLine($"ErrorMessage:{configureResponse?.ErrorMessage}");
}
// try to add source to non existing job - use for example invalid configuration or invalid workspaceID .
Response sourceResponse = await importSourceController.AddSourceAsync(workspaceId, importId, sourceId, dataSourceSettings);
Console.WriteLine("Add Data source response:");
Console.WriteLine($"IsSuccess:{response?.IsSuccess}");
if (!sourceResponse.IsSuccess)
{
Console.WriteLine($"ImportJobID:{sourceResponse?.ImportJobID}");
Console.WriteLine($"ErrorCode:{sourceResponse?.ErrorCode}");
Console.WriteLine($"ErrorMessage:{sourceResponse?.ErrorMessage}");
}
// try to start job
response = await importJobController.BeginAsync(workspaceId, importId);
Console.WriteLine("Begin Job response:");
if (!response.IsSuccess)
{
Console.WriteLine($"ImportJobID:{response?.ImportJobID}");
Console.WriteLine($"ErrorCode:{response?.ErrorCode}");
Console.WriteLine($"ErrorMessage:{response?.ErrorMessage}");
}
}
}
}
}
// Example of output
/*
IImportJobController.CreateAsync
IsSuccess:True
ImportJobID:bf272e8c-c26b-435f-a21b-14a3f46661e2
ErrorCode:
ErrorMessage:
Add document configuration response
IsSuccess:True
ImportJobID:d612bf6a-b044-4c6b-b417-07b135c163fe
ErrorCode:C.CR.VLD.2001
ErrorMessage:Cannot create Job Configuration. Invalid import job configuration: Nothing is imported.
Add Data source response:
IsSuccess:True
ImportJobID:d612bf6a-b044-4c6b-b417-07b135c163fe
ErrorCode:S.CR.VLD.3001
ErrorMessage:Cannot create Data Source. Invalid load file settings: Delimiters are non-unique.
Begin Job response:
ImportJobID:d612bf6a-b044-4c6b-b417-07b135c163fe
ErrorCode:J.BEG.VLD.1508
ErrorMessage:Cannot begin Import Job. Job is not configured. Current Job state: New
*/