コード例 #1
0
ファイル: ApiController.cs プロジェクト: Tearth/Cosette
        public async Task <IActionResult> Generation([FromBody] GenerationDataRequest requestData)
        {
            var generationModel = _mapper.Map <GenerationModel>(requestData);
            await _generationService.Add(generationModel);

            return(new OkResult());
        }
コード例 #2
0
        public Task <SerializationSet> GetGenerationDataAsync(string databaseName, [FromBody] GenerationDataRequest request)
        {
            var runtimeService = this.cremaHost.GetService(typeof(IRuntimeService)) as IRuntimeService;

            if (runtimeService == null)
            {
                throw new NullReferenceException(nameof(runtimeService));
            }

            var result = runtimeService.GetDataGenerationData(databaseName, request.Tags, request.FilterExpression, request.IsDevMode, request.Revision);

            result.Validate();

            return(Task.FromResult(result.Value));
        }
コード例 #3
0
ファイル: WebService.cs プロジェクト: NicolaiSorensen/Cosette
        public async Task SendGenerationData(GenerationDataRequest requestData)
        {
            if (!_enabled)
            {
                return;
            }

            try
            {
                var httpContent = new StringContent(JsonConvert.SerializeObject(requestData), Encoding.UTF8, "application/json");
                var response    = await _httpClient.PostAsync("generation", httpContent);

                if (!response.IsSuccessStatusCode)
                {
                    throw new HttpRequestException();
                }
            }
            catch
            {
                Console.WriteLine($"[{DateTime.Now}] Request containing generation data failed!");
            }
        }