private void sampleTimer_Tick(object sender, EventArgs e) { avgTcpConns = (GetNumTcpConns() + avgTcpConns) / 2; numSamplesLbl.Text = (++numSamples).ToString() + " Samples"; ProcessHistoryList.RefreshProcesses(); }
private void startBtn_Click(object sender, EventArgs e) { DialogResult userResp = userResp = MessageBox.Show("This will erase all previously gathered training data!\n Proceed?", "Warning", MessageBoxButtons.YesNo); if (userResp.Equals(DialogResult.Yes)) { // Begin sampling information ProcessHistoryList.RefreshProcesses(); sampleTimer.Enabled = true; } }
public async Task <ActionResult <ProcessHistoryList> > GetProcessHistory( [FromRoute] int instanceOwnerPartyId, [FromRoute] Guid instanceGuid) { string[] eventTypes = Enum.GetNames(typeof(InstanceEventType)).Where(x => x.StartsWith("process")).ToArray(); string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; ProcessHistoryList processHistoryList = new ProcessHistoryList(); List <InstanceEvent> processEvents = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null); processHistoryList.ProcessHistory = ProcessHelper.MapInstanceEventsToProcessHistory(processEvents); return(Ok(processHistoryList)); }
public async Task <ProcessHistoryList> GetProcessHistory(string instanceGuid, string instanceOwnerPartyId) { string apiUrl = $"instances/{instanceOwnerPartyId}/{instanceGuid}/process/history"; string token = JwtTokenUtil.GetTokenFromContext(_httpContextAccessor.HttpContext, _appSettings.RuntimeCookieName); HttpResponseMessage response = await _client.GetAsync(token, apiUrl); if (response.IsSuccessStatusCode) { string eventData = await response.Content.ReadAsStringAsync(); ProcessHistoryList processHistoryList = JsonConvert.DeserializeObject <ProcessHistoryList>(eventData); return(processHistoryList); } throw await PlatformHttpException.CreateAsync(response); }
public async void GetProcessHistory_UserIsAuthorized_ReturnsEmptyProcessHistoryReturnStatusForbidden() { // Arrange string requestUri = $"storage/api/v1/instances/1337/17ad1851-f6cb-4573-bfcb-a17d145307b3/process/history"; HttpClient client = GetTestClient(); string token = PrincipalUtil.GetToken(3, 1337, 2); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); // Act HttpResponseMessage response = await client.GetAsync(requestUri); string responseString = await response.Content.ReadAsStringAsync(); ProcessHistoryList processHistory = JsonConvert.DeserializeObject <ProcessHistoryList>(responseString); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Empty(processHistory.ProcessHistory); }
public async Task <ActionResult <ProcessHistoryList> > GetProcessHistory( [FromRoute] int instanceOwnerPartyId, [FromRoute] Guid instanceGuid) { string[] eventTypes = Enum.GetNames(typeof(InstanceEventType)).Where(x => x.StartsWith("process")).ToArray(); string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; ProcessHistoryList processHistoryList = new ProcessHistoryList(); try { List <InstanceEvent> processEvents = await _instanceEventRepository.ListInstanceEvents(instanceId, eventTypes, null, null); processHistoryList.ProcessHistory = ProcessHelper.MapInstanceEventsToProcessHistory(processEvents); return(Ok(processHistoryList)); } catch (Exception e) { _logger.LogError($"Unable to retriece process history for instance object {instanceId}. Due to {e}"); return(StatusCode(500, $"Unable to retriece process history for instance object {instanceId}: {e.Message}")); } }
public async void GetProcessHistory_UserIsAuthorized_ReturnsEmptyProcessHistoryReturnStatusForbidden() { // Arrange string requestUri = $"{BasePath}{InstanceId}/process/history"; _repositoryMock.Setup(r => r.ListInstanceEvents(It.IsAny <string>(), It.IsAny <string[]>(), null, null)).ReturnsAsync(new List <InstanceEvent>()); HttpClient client = GetTestClient(_repositoryMock.Object); string token = PrincipalUtil.GetToken(1, 2); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); // Act HttpResponseMessage response = await client.GetAsync(requestUri); string responseString = await response.Content.ReadAsStringAsync(); ProcessHistoryList processHistory = JsonConvert.DeserializeObject <ProcessHistoryList>(responseString); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Empty(processHistory.ProcessHistory); }