/// <summary> /// Goes to the results page once the key has been received from the server. /// </summary> private void GoToResults(JsonResult <AccessResponse> result) { bool failed = result.HasError; AccessResponse response = null; // Fail if an empty response is received if (!failed) { response = result.Result; if (string.IsNullOrEmpty(response?.AccessToken) || string.IsNullOrEmpty( response?.RefreshToken)) { failed = true; } } // If the args have not been invalidated since the last time... if (m_creationArgs != null) { MultiPanel.SelectedPage = ResultPage; return; } if (failed) { Exception e = result.Exception; if (e != null) { ExceptionHandler.LogException(e, true); } // Error when fetching the key KeyPicture.Image = Resources.KeyWrong32; KeyLabel.Text = @"ESI token could not be obtained."; CharactersGroupBox.Text = @"Error report"; ResultsMultiPanel.SelectedPage = ESITokenFailedErrorPage; MultiPanel.SelectedPage = ResultPage; return; } // Are we updating existing API key? if (m_updateMode) { m_esiKey.TryUpdateAsync(response, OnUpdated); } else { ESIKey.TryAddOrUpdateAsync(DateTime.UtcNow.ToFileTime(), response, OnUpdated); } }
public async Task <AccessResponse> DeleteAsync(int code) { try { var exist = await _accessRepository.FindByIdAsync(code); AccessResponse response = exist == null ? new AccessResponse($"Access {code} not found") : new AccessResponse(exist); _accessRepository.Remove(exist); await _unitOfWork.CompleteAsync(); return(response); } catch (Exception e) { return(new AccessResponse($"An error occurred when deleting the access: { e.Message }")); } }
public async Task <AccessResponse> FindAsync(int code) { try { var exist = await _accessRepository.FindByIdAsync(code); if (exist != null) { exist.AccessLogs = await _accessLogRepository.ListByAccessCodeAsync(code); } AccessResponse response = exist == null ? new AccessResponse($"Access {code} not found") : new AccessResponse(exist); return(response); } catch (Exception e) { return(new AccessResponse($"An error occurred when finding the access: { e.Message }")); } }
///------------------------------------------------------------------------------------------------- /// <summary> /// Simple call to check DPSCAN Access. /// </summary> /// /// <remarks> /// Joey Brock <*****@*****.**>, 4/19/2013. /// </remarks> /// /// <param name="dpscans"> /// The dpscans. /// </param> /// /// <returns> /// true if it succeeds, false if it fails. /// </returns> ///------------------------------------------------------------------------------------------------- public static bool AccessDPScan(DPScanService dpscans) { if ((strUsername != null) && (strPassword != null)) { makeQueueDPScan("Checking for Username and Password"); aRequest.Username = strUsername; makeQueueDPScan("Found : Username [" + strUsername + " ]"); aRequest.Password = strPassword; makeQueueDPScan("Found : Password [" + strPassword + " ]"); try { makeQueueDPScan("Attempting to connect..."); aResponse = clientDPScan.CountAccess(aRequest); if (aResponse.Success) { makeQueueDPScan("Connection : [ SUCCESSFUL ] " + System.DateTime.Now.TimeOfDay.ToString()); //MessageBox.Show(aResponse.Success.ToString(), aResponse.ToString(), MessageBoxButtons.OK); return(true); } else { makeQueueDPScan("Connection : [ FAILED ] " + System.DateTime.Now.TimeOfDay.ToString()); } } catch (Exception ex) { if ((ex.ToString().Contains("Unhandled"))) { MessageBox.Show("Internet Connection : Disconnected", "DPScanService : NETWORK ERROR", MessageBoxButtons.OK); } else { MessageBox.Show("Exception : " + ex.Message, "DPScanService", MessageBoxButtons.OK); } makeQueueDPScan("Exception Error : " + ex.Message + " [ " + System.DateTime.Now.TimeOfDay.ToString() + " ]"); return(false); } return(true); } else { //DoIndependentWork(clientDPScan); return(false); } }
public async Task <AccessResponse> UpdateAsync(int code, Access access) { try { var exist = await _accessRepository.FindByIdAsync(code); AccessResponse response = exist == null ? new AccessResponse($"Access {code} not found") : new AccessResponse(exist); exist.CodeControl = access.CodeControl != 0 ? access.CodeControl : exist.CodeControl; exist.CodeDevice = access.CodeDevice != 0 ? access.CodeDevice : exist.CodeDevice; _accessRepository.Update(exist); await _unitOfWork.CompleteAsync(); return(response); } catch (Exception e) { return(new AccessResponse($"An error occurred when updating the access: { e.Message }")); } }
/// <summary> /// Updates the access token, or sets an error flag if the token could no longer be /// obtained. /// </summary> private void OnAccessToken(JsonResult <AccessResponse> result) { AccessResponse response = result.Result; m_queried = true; if (result.HasError) { // If it errors out, avoid checking again for another 5 minutes m_keyExpires = DateTime.UtcNow.AddMinutes(5.0); EveMonClient.Notifications.NotifySSOError(result); HasError = true; EveMonClient.OnESIKeyInfoUpdated(this); } else { AccessToken = response.AccessToken; m_keyExpires = response.ExpiryUTC; // Have to make a second request for the character information! SSOAuthenticationService.GetTokenInfo(AccessToken, OnTokenInfo); } }
/// <summary> /// Updates the access token, or sets an error flag if the token could no longer be /// obtained. /// </summary> /// <param name="response">The token response received from the server.</param> private void OnAccessToken(AccessResponse response) { m_queried = true; if (response == null) { // If it errors out, avoid checking again for another 5 minutes m_keyExpires = DateTime.UtcNow.AddMinutes(5.0); EveMonClient.Notifications.NotifySSOError(); HasError = true; m_queryPending = false; EveMonClient.OnESIKeyInfoUpdated(this); } else { AccessToken = response.AccessToken; // PKCE routinely updates refresh tokens RefreshToken = response.RefreshToken; m_keyExpires = response.ExpiryUTC; // Have to make a second request for the character information! SSOAuthenticationService.GetTokenInfo(AccessToken, OnTokenInfo); } }
private async Task <(AccessResponse, List <AccessResponse>)> GetByYear(DateTime dateTime) { var accessCount = new List <AccessResponse>(); var accessTotal = new AccessResponse(); for (int i = 1; i <= 12; i++) { var date = new DateTime(dateTime.Year, i, 1); var byMonth = await GetByMonth(date); accessTotal.AuthorizeCount += byMonth.Item1.AuthorizeCount; accessTotal.UnauthorizeCount += byMonth.Item1.UnauthorizeCount; accessTotal.Period = byMonth.Item1.Period; accessCount.Add(byMonth.Item1); } accessTotal.Total = accessTotal.UnauthorizeCount + accessTotal.UnauthorizeCount; accessTotal.Period = dateTime; return(accessTotal, accessCount); }
/// <summary> /// Asynchronously updates this ESI key through a <see cref="ESIKeyCreationEventArgs"/>. /// </summary> /// <param name="accessResponse">The access and refresh token.</param> /// <param name="callback">A callback invoked on the UI thread (whatever the result, success or failure)</param> /// <returns></returns> public void TryUpdateAsync(AccessResponse accessResponse, EventHandler <ESIKeyCreationEventArgs> callback) { TryAddOrUpdateAsync(ID, accessResponse, callback); }
private async Task <(AccessResponse, List <AccessResponse>)> GetByMonth(DateTime datetime) { var accessCount = await _context.Accesses .Where(x => x.Date.Date.Year == datetime.Date.Year && x.Date.Date.Month == datetime.Date.Month) .ToListAsync(); var accessResponse = new List <AccessResponse>(); var accessTotal = new AccessResponse(); if (datetime.Month == 2) { for (int i = 1; i <= 28; i++) { var access = new AccessResponse(); var date = new DateTime(datetime.Year, datetime.Month, i); access.Period = date; var item = accessCount.Where(x => x.Date.Day == i).FirstOrDefault(); if (item != null) { accessTotal.AuthorizeCount += item.AuthorizeCount; accessTotal.UnauthorizeCount += item.UnauthorizeCount; access.AuthorizeCount = item.AuthorizeCount; access.UnauthorizeCount = item.UnauthorizeCount; access.Total = access.AuthorizeCount + access.UnauthorizeCount; } accessResponse.Add(access); } var access2 = new AccessResponse(); var date2 = new DateTime(datetime.Year, 3, 29); access2.Period = date2; accessResponse.Add(access2); access2 = new AccessResponse(); date2 = new DateTime(datetime.Year, 3, 30); access2.Period = date2; accessResponse.Add(access2); } else { for (int i = 1; i <= 30; i++) { var access = new AccessResponse(); var date = new DateTime(datetime.Year, datetime.Month, i); access.Period = date; var item = accessCount.Where(x => x.Date.Day == i).FirstOrDefault(); if (item != null) { accessTotal.AuthorizeCount += item.AuthorizeCount; accessTotal.UnauthorizeCount += item.UnauthorizeCount; access.AuthorizeCount = item.AuthorizeCount; access.UnauthorizeCount = item.UnauthorizeCount; access.Total = access.AuthorizeCount + access.UnauthorizeCount; } accessResponse.Add(access); } } accessTotal.Total = accessTotal.AuthorizeCount + accessTotal.UnauthorizeCount; accessTotal.Period = datetime; return(accessTotal, accessResponse); }
public AccessResponse GetLog([FromBody] AccessLogRequest accessLogRequest) { AccessResponse accessResponse = new AccessResponse(); return(accessResponse); }
public AccessResponse Delete([FromBody] DeleteAccessRequest deleteAccessRequest) { AccessResponse accessResponse = new AccessResponse(); return(accessResponse); }
public AccessResponse CreateUpdate([FromBody] AccessRequest accessRequest) { AccessResponse accessResponse = new AccessResponse(); return(accessResponse); }
public AccessResponse UpdateAES([FromBody] AesKeyUpdateRequest aesKeyUpdateRequest) { AccessResponse accessResponse = new AccessResponse(); return(accessResponse); }