Esempio n. 1
0
        public async Task <bool> TriggerVacantBatch(TriggerVacantBatchModel payload)
        {
            var model = new
            {
                parameters = payload
            };

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config.VacantBatchToken);
            var responseMessage = await httpClient.PostAsync(Config.VacantBatchUrl, new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"));

            var hordeResponseContent = await responseMessage.Content.ReadAsStringAsync();

            var errorResponse   = JsonConvert.DeserializeAnonymousType(hordeResponseContent, new { statusCode = 0 });
            var successResponse = JsonConvert.DeserializeAnonymousType(hordeResponseContent, new { DispatchedJobID = "" });

            if (errorResponse.statusCode != 0)
            {
                Logger.Warning($"Error response content from horde {hordeResponseContent}");
            }

            if (successResponse.DispatchedJobID != null)
            {
                Logger.Info($"Successful response content from horde {hordeResponseContent}");

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public async Task GetVacantReports([FromBody] GenContentMultiReturn[] model)
        {
            try
            {
                var user         = _userRepo.GetUser();
                var destinations = model.Select(m => m.Destination);

                var parameters = new TriggerVacantBatchModel
                {
                    destinations  = string.Join(",", destinations),
                    userFirstName = user.FirstName,
                    userLastName  = user.LastName,
                    userEmail     = user.Email,
                    userRoles     = string.Join(",", user.Roles),
                };

                await _reportRepo.TriggerVacantBatch(parameters);
            }
            catch (Exception e)
            {
                Logger.Error(e, "Could not trigger vacant batch");

                throw;
            }
        }