public void Log(PerformanceLogTick t) { if (t.Stopwatch != null) { t.Stopwatch.Stop(); _loggingService.Information( Pattern, _applicationConfiguration.GetCurrentEnvironment().ToString(), _applicationConfiguration.GetApplicationId() ?? "", _applicationConfiguration.GetInstanceId() ?? "", t.Action ?? "", t.Url ?? "", t.HttpResponse ?? "", t.HttpResponseStatusCode ?? "", t.Browser ?? "", t.RequestJson, t.ResponseJson, t.Stopwatch.ElapsedMilliseconds, t.CorrelationId, t.Exception ); } else { _loggingService.Information( Pattern, _applicationConfiguration.GetCurrentEnvironment().ToString(), _applicationConfiguration.GetApplicationId() ?? "", _applicationConfiguration.GetInstanceId() ?? "", t.Action ?? "", t.Url ?? "", t.HttpResponse ?? "", t.HttpResponseStatusCode ?? "", t.Browser ?? "", t.RequestJson, t.ResponseJson, t.Miliseconds, t.CorrelationId, t.Exception ); } }
public X509Certificate2 GetValidCertificateFromEmbeddedResource() { const string testPwd = ""; const string demoPwd = ""; const string productionPwd = ""; if (_applicationConfiguration.GetCurrentEnvironment() == AppEnvironmentEnum.Test) { var testApplicationCertificate = new X509Certificate2("", testPwd); LogExtraInformation( "", testApplicationCertificate, testPwd, CertificateTypeEnum.TestApplication ); certificate = testApplicationCertificate; } else if (_applicationConfiguration.GetCurrentEnvironment() == AppEnvironmentEnum.Demo) { var demoApplicationCertificate = new X509Certificate2("", demoPwd); LogExtraInformation( "", demoApplicationCertificate, demoPwd, CertificateTypeEnum.DemoApplication ); certificate = demoApplicationCertificate; } else if (_applicationConfiguration.GetCurrentEnvironment() == AppEnvironmentEnum.Production) { _errorLog.LogInfo( this, string.Format("APP_CERT_PRE_FETCH_CHECK", certificate == null) ); X509Certificate2 productionApplicationCertificate = null; try { _errorLog.LogInfo(this, string.Format("APP_CERT_LENGTH_OF_EMBEDDED_RESOURCE", ""?.Length) ); productionApplicationCertificate = new X509Certificate2("", productionPwd); } catch (Exception certificateException) { _errorLog.LogFatal(this, certificateException.Message, certificateException); } _errorLog.LogInfo( this, string.Format("APP_CERT_GOT_CERT_FROM_EMBEDDED_RESOURCE", productionApplicationCertificate?.SubjectName.Name) ); certificate = productionApplicationCertificate; } // deal breaker.... if (certificate == null) { throw new NoNullAllowedException(nameof(certificate)); } if (_applicationConfiguration.ShouldVerifyCertificateExpirationDate()) { var validationResult = VerifyCertificateExpirationDate(certificate, CertificateTypeEnum.Application); } return(certificate); }