Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

Congree version 6.080 and higher support the import of XM files together with a quality check, i.e. the settings for gatekeeper settings apply when importing a file. The consequence is that only those sentences are being imported that meet the defined quality criteria.

The endpoint to be used is Congree/api/AuthoringMemory/v2/ImportXml?ruleSet=<ruleset>&documentId=<document>

<ruleset> is the name of the ruleset to be used to check the document to be imported.

<document> is an arbitrary string defining the identity of the document, i.e the file name or any other name.

Codeblock
languagec#
 public CongreeImportXmlResponse ImportXml(CongreeXmlImportRequest xml, string ruleSet, string documentId)
        {
                     
            var request = new RestRequest("/Congree/api/AuthoringMemory/v2/ImportXml?ruleSet=" + ruleSet + "&documentId=" + documentId, Method.Post);
            request.AddHeader("Authorization", "Bearer " + this.token);
            request.AddHeader("Content-Type", "application/json");

            var jsonmessage = JsonConvert.SerializeObject(xml);
           
            request.AddParameter("application/json", jsonmessage, ParameterType.RequestBody);
           
            var response = client.Execute(request);

            
            CongreeImportXmlResponse importResponse = JsonConvert.DeserializeObject<CongreeImportXmlResponse>(response.Content);
            return importResponse;
        }

est4

The return value used in the sample code above is defined like shown below:

Codeblock
languagec#
 public class CongreeImportXmlResponse
    {
        public string Id { get; set; }
    }

The Id value returned by the import method can be used to retrieve information about the status and the result.

As only one document can be imported at a time it is necessary to check the status, i.e the completeness of the import.

Codeblock
languagec#
 public CongreeTaskStatus GetTaskStatus(string id)
        {
            
            var request = new RestRequest("/Congree/api/Tasks/v1/Status/" + id, Method.Get);
            request.AddHeader("Authorization", "Bearer " + this.token);
            var response =  client.Execute(request);

            CongreeTaskStatus taskStatus = JsonConvert.DeserializeObject<CongreeTaskStatus>(response.Content);

            return taskStatus;
        }
        

The return value is defined like this:

Codeblock
languagec#
 public class ErrorInfo
    {
        public int Code { get; set; }
        public string Message { get; set; }
    }

    public class CongreeTaskStatus
    {
        public string State { get; set; }
        public ErrorInfo ErrorInfo { get; set; }
    }

After the value of State is other than InProgress it is possible to retrieve information on the success, i.e. the number of imported sentences, information on failed imports etc. by retrieving this information as shown in the code sample below.

Codeblock
languagec#
 public CongreeTaskResult GetTaskResult(string id)
        {

            var request = new RestRequest("/Congree/api/Tasks/v1/Result/" + id, Method.Get);
            request.AddHeader("Authorization", "Bearer " + this.token);
            var response = client.Execute(request);

            CongreeTaskResult taskResult = JsonConvert.DeserializeObject<CongreeTaskResult>(response.Content);

            return taskResult;
        }

The class CongreeTaskResult is defined as shown below:

Codeblock
 public class Result
    {
        public int SkippedCount { get; set; }
        public int ImportedSentences { get; set; }
        public List<SkippedSentence> SkippedSentences { get; set; }
        public string DocumentId { get; set; }
    }

    public class CongreeTaskResult
    {
        public Result Result { get; set; }
    }

    public class SkippedSentence
    {
        public string SentenceText { get; set; }
        public string SkippedReason { get; set; }
    }