public MessageAuthorizationService(IServiceProvider provider, IHashAlgorithm algo, IRouterClient client, ILogger<MessageAuthorizationService> logger) { this.m_logger = logger; this.m_algo = algo; this.m_provider = provider; this.m_router = client; }
public RouterMetaProvider(ITaskSchedulerFactory taskSchedulerFactory, IRouterClient routerClient, IServerIdentityProvider serverIdentityProvider, IShamanLogger logger) { _serverIdentity = serverIdentityProvider.Get(); _taskScheduler = taskSchedulerFactory.GetTaskScheduler(); _routerClient = routerClient; _logger = logger; Load().Wait(); }
public MatchMakerServerInfoProvider(ITaskSchedulerFactory taskSchedulerFactory, IRouterServerInfoProviderConfig config, IShamanLogger logger, IRouterClient routerClient) { _logger = logger; _routerClient = routerClient; _taskScheduler = taskSchedulerFactory.GetTaskScheduler(); _config = config; _isRequestingNow = false; }
public ActionResult PostRefreshPopulations([FromServices] IRouterClient routerClient, [FromServices] IStonebranchClient stonebranchClient, string customerShortName, string projectShortName, Guid id) { var job = _jobProxy.GetJob(customerShortName, projectShortName, id); var requestId = Guid.NewGuid(); _workStatusProxy.Add(job, AnalyticsRunStatus.Running, Calculations.Percentage(0, 3, 14, _config.PreTAPercentageContribution), true, true); var populationIds = (job.populationIds == null || job.populationIds.Count < 1) ? string.Empty : String.Join(',', job.populationIds); var projectConfig = _iam.GetProjectConfig(customerShortName, projectShortName); var stopWatch = Stopwatch.StartNew(); var json = $@" {{ 'requestUUID': '{requestId}', 'customerShortName': '{customerShortName}', 'projectShortName': '{projectShortName}', 'requestType': 'ReprocessPopulation', 'requestData': {{ 'populationIds': [{populationIds}], 'forceRefresh': false, }} }} "; var response = routerClient.Client.PostAsync("postRequest", new StringContent(json, Encoding.UTF8, "application/json")).Result; _validation.ValidateResponse(response); if (job.lastRouterRequests.Keys.Contains("RefreshPopulations")) { job.lastRouterRequests["RefreshPopulations"] = requestId.ToString(); } else { job.lastRouterRequests.Add("RefreshPopulations", requestId.ToString()); } _jobProxy.UpdateJob(job); _taskLogging.LogOperation(customerShortName, projectShortName, "Refresh Populations message posted.", job, stopWatch.Elapsed); return(Ok(requestId)); }
public GatewayController(IMeasurementAuthorizationService measurementAuth, IMessageAuthorizationService messageAuth, IHttpContextAccessor ctx, ISensorRepository sensors, IApiKeyRepository keys, ISensorLinkRepository links, IBlobRepository blobs, IBlobService blobService, IRouterClient client, IAuthorizationService auth, ILogger <GatewayController> logger) : base(ctx, sensors, links, keys) { this.m_measurementAuthorizationService = measurementAuth; this.m_messageAuthorizationService = messageAuth; this.m_blobService = blobService; this.m_blobs = blobs; this.m_client = client; this.m_logger = logger; this.m_auth = auth; }
public IActionResult IsRefreshPopulationsFinished([FromServices] IRouterClient routerClient, string customerShortName, string projectShortName, Guid id) { var job = _jobProxy.GetJob(customerShortName, projectShortName, id); if (!job.lastRouterRequests.Keys.Contains("RefreshPopulations")) { throw new InvalidOperationException("Could not find any router requests for: RefreshPopulations"); } var stopWatch = Stopwatch.StartNew(); var response = routerClient.Client.GetAsync($"getRequestStatus?requestUuid={job.lastRouterRequests["RefreshPopulations"]}").Result; _validation.ValidateResponse(response); _taskLogging.LogOperation(customerShortName, projectShortName, "PollRefreshPopulations", job, stopWatch.Elapsed); var content = response.Content.ReadAsStringAsync(); return(Ok(content.Result)); }
public TriggerActionExecutionService( IHttpClientFactory factory, IRouterClient router, IControlMessageRepository controlMessages, ITextSendService text, IEmailSender mail, ITriggerRepository triggers, IOptions <TextServiceSettings> textOptions ) { this.m_triggerRepo = triggers; this.m_text = text; this.m_mail = mail; this.m_textSettings = textOptions.Value; this.m_httpFactory = factory; this.m_controlMessges = controlMessages; this.m_router = router; this.m_actuatorCounter = Metrics.CreateCounter("triggerservice_actuator_total", "Total number of actuator messages sent."); this.m_smsCounter = Metrics.CreateCounter("triggerservice_sms_total", "Total number of SMS messages sent."); this.m_emailCounter = Metrics.CreateCounter("triggerservice_email_total", "Total number of email messages sent."); this.m_httpCounter = Metrics.CreateCounter("triggerservice_http_total", "Total number of HTTP requests sent."); }
public ClientServerInfoProvider(IShamanLogger logger, IRouterClient routerClient) { _logger = logger; _routerClient = routerClient; }
public IActionResult IsUpdateSampleStatusFinished([FromServices] IRouterClient routerClient, string customerShortName, string projectShortName, Guid id, Guid flowchartRunId) { var key = $"UpdateSampleStatus_{flowchartRunId.ToString()}"; try { var job = _jobProxy.GetJob(customerShortName, projectShortName, id); List <Guid> pendingRequests = new List <Guid>(); List <Exception> failures = new List <Exception>(); if (!job.lastRouterRequests.Keys.Contains(key)) { throw new InvalidOperationException($"Could not find any router requests for: UpdateSampleStatus_{ flowchartRunId.ToString() }"); } var requestIds = JsonConvert.DeserializeObject <List <Guid> >(job.lastRouterRequests[key]); if (requestIds.Count > 0) { pendingRequests = new List <Guid>(requestIds); while (pendingRequests.Count > 0) { // Retry only pending requests requestIds.Intersect(pendingRequests).ToList().ForEach((request) => { var response = routerClient.Client.GetAsync($"getRequestStatus?requestUuid={request}").Result; _validation.ValidateResponse(response); var content = response.Content.ReadAsStringAsync(); var json = JObject.Parse(content.Result); var status = json["status"].Value <int>(); switch (status) { case 5: pendingRequests.Remove(request); break; case 7: pendingRequests.Remove(request); failures.Add(new Exception($"Update sample status request('{request}') failed: {json["exception_message"].Value<string>()} \n")); break; default: break; } }); } } if (failures.Count > 0) { throw new AggregateException(failures); } } catch (JsonReaderException) { throw new JsonReaderException($"Invalid json string for key {key} "); } catch (Exception) { throw; } return(Ok()); }
public ActionResult PostUpdateSampleStatus([FromServices] IRouterClient routerClient, string customerShortName, string projectShortName, Guid id, Guid flowchartRunId) { var job = _jobProxy.GetJob(customerShortName, projectShortName, id); var flowchartRun = job.flowchartRunRequest.FirstOrDefault(x => x.flowchartRunUUID == flowchartRunId); if (flowchartRun == null) { throw new NullReferenceException("The flowchart run was not present in the job."); } List <Guid> requestIds = new List <Guid>(); var updateSampleKey = $"UpdateSampleStatus_{flowchartRunId.ToString()}"; var stopWatch = Stopwatch.StartNew(); foreach (var sample in flowchartRun.hrSampleMeasureMetadata) { var requestId = Guid.NewGuid(); var json = $@" {{ 'requestUUID': '{requestId}', 'customerShortName': '{customerShortName}', 'projectShortName': '{projectShortName}', 'requestType': 'Sampling', 'requestData': {{ 'samplingData': {{ 'samplingRequestType': 'UpdateSampleStatus', 'samplingRequest': {{ 'measureKey': '', 'runGenerateHybridIdssReport':'false', 'flowchartRunGUID': '{flowchartRun.flowchartRunUUID}', 'hrSampleMeasureId': '{sample.Key}', 'samplingOptions': {{ 'activateOverSample': '{sample.Value.activateOverSample}', 'leaveNumeratorHitOpen': '{sample.Value.leaveNumeratorHitOpen}', 'removeContrasBeforeSample': '{sample.Value.removeContrasBeforeSample}', 'excludeContrasNextRun': '{sample.Value.excludeContrasNextRun}', 'excludePlanEmployees': '{sample.Value.excludePlanEmployees}', 'excludePopulationFallout': '{sample.Value.excludePopulationFallout}', 'metadataReportingYear': '{sample.Value.metadataReportingYear}' }} }} }} }} }}"; var response = routerClient.Client.PostAsync("postRequest", new StringContent(json, Encoding.UTF8, "application/json")).Result; _validation.ValidateResponse(response); requestIds.Add(requestId); } // Go ahead and add the empty list to the so that we can skip the next task if (job.lastRouterRequests.Keys.Contains(updateSampleKey)) { job.lastRouterRequests[updateSampleKey] = JsonConvert.SerializeObject(requestIds); } else { job.lastRouterRequests.Add(updateSampleKey, JsonConvert.SerializeObject(requestIds)); } _jobProxy.UpdateJob(job); if (requestIds.Count > 0) { _taskLogging.LogOperation(customerShortName, projectShortName, "UpdateSampleStatus message posted.", flowchartRun.flowchartRunUUID, stopWatch.Elapsed, _config.CacheDBPercentageContribution); } else { _taskLogging.LogOperation(customerShortName, projectShortName, "Skipping Update Sample Status as there is not sample data.", flowchartRun.flowchartRunUUID, stopWatch.Elapsed, _config.CacheDBPercentageContribution); } return(Ok()); }