Esempio n. 1
0
        private static async Task AsyncFlow()
        {
            var batchExample = new BatchExamples(_api);
            await batchExample.SetExportedStateAsync(_issuedInvoiceId, _partner1Id, ExportedState.Exported);

            await batchExample.SetExportedStateAsync(_issuedInvoiceId, _partner1Id, ExportedState.NotExported);
        }
Esempio n. 2
0
        /// <summary>
        /// Generates the example from files.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <param name="output">The output.</param>
        public void GenerateExampleFromFiles(Stream map, Stream output)
        {
            var exampleMaps   = JsonHelper.DeserializeFromStream <List <ExampleMap> >(map);
            var batchExamples = new BatchExamples();

            foreach (var exampleMap in exampleMaps)
            {
                var batchExample = new BatchExample
                {
                    Intent           = exampleMap.Intent,
                    ExamplesByEntity = new List <Dictionary <string, string> >()
                };

                // load values
                foreach (var exampleEntity in exampleMap.EntitySources)
                {
                    if (!this.entityValues.ContainsKey(exampleEntity.EntityName))
                    {
                        var values = File.ReadAllLines(exampleEntity.FilePathToValue);
                        this.entityValues.Add(exampleEntity.EntityName, new List <string>(values));
                    }
                }

                var firstEntity = exampleMap.EntitySources.First();
                for (int exampleIndex = 0; exampleIndex < this.entityValues[firstEntity.EntityName].Count; exampleIndex++)
                {
                    var entityExampleValues = new Dictionary <string, string>();
                    foreach (var exampleEntity in exampleMap.EntitySources)
                    {
                        entityExampleValues.Add(exampleEntity.EntityName, this.entityValues[exampleEntity.EntityName][exampleIndex]);
                    }

                    batchExample.ExamplesByEntity.Add(entityExampleValues);
                }

                batchExamples.Examples.Add(batchExample);
            }

            JsonHelper.SerializeToStream(batchExamples, output);
        }