public ExposureKeyModel( byte[] keyData, DateTimeOffset rollingStart, TimeSpan rollingDuration, RiskLevel transmissionRisk) : base(keyData, rollingStart, rollingDuration, transmissionRisk) { }
public async Task UploadDiagnosisKeysAsync( string clusterId, IList <ITemporaryExposureKey> temporaryExposureKeyList, ReportType defaultRportType = ReportType.ConfirmedClinicalDiagnosis, RiskLevel defaultTrasmissionRisk = RiskLevel.Medium ) { var request = new RequestDiagnosisKey(temporaryExposureKeyList, defaultRportType, defaultTrasmissionRisk); var requestJson = JsonConvert.SerializeObject(request); Debug.Print(requestJson); var httpContent = new StringContent(requestJson); Uri uri = new Uri($"{Constants.API_ENDPOINT}/{clusterId}/chino-diagnosis-keys.json"); HttpResponseMessage response = await client.PutAsync(uri, httpContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); Debug.Print(content); } else { Debug.Print($"UploadDiagnosisKeysAsync {response.StatusCode}"); } }
public Key(byte[] keyData, DateTimeOffset rollingStart, TimeSpan rollingDuration, RiskLevel transmissionRisk) { KeyData = keyData; RollingStart = rollingStart; RollingDuration = rollingDuration; TransmissionRiskLevel = transmissionRisk; }
public void Update(RiskLevel data) { var validationResult = new UpdateRiskLevelValidator(_repository) .Validate(data); if (!validationResult.IsValid) { throw new RegoValidationException(validationResult); } using (var scope = CustomTransactionScope.GetTransactionScope()) { var riskLevel = _repository.RiskLevels.Single(x => x.Id == data.Id); riskLevel.BrandId = data.BrandId; riskLevel.Level = data.Level; riskLevel.Name = data.Name; riskLevel.Status = data.Status; riskLevel.Description = data.Description; riskLevel.DateUpdated = DateTimeOffset.Now; riskLevel.UpdatedBy = _actorInfoProvider.Actor.UserName; _repository.SaveChanges(); _eventBus.Publish(new RiskLevelUpdated(data.Id, data.BrandId, data.Level, data.Name, data.Status, data.Description)); scope.Complete(); } }
internal Key(byte[] keyData, long rollingStart, TimeSpan rollingDuration, RiskLevel transmissionRisk) { KeyData = keyData; RollingStart = DateTimeOffset.FromUnixTimeSeconds(rollingStart * (60 * 10)); RollingDuration = rollingDuration; TransmissionRiskLevel = transmissionRisk; }
public Alert(string alert, string url, RiskLevel risk, ConfidenceLevel confidence, string parameter, string other) : this(alert, url, risk, confidence) { Other = other; Parameter = parameter; }
public async Task CreatingAValidPolicyMustBeStoredInTheRepository() { string name = "Test Policy"; string description = "This is a test policy"; Dictionary <InsuranceCoverage, float> coverages = new Dictionary <InsuranceCoverage, float> { { InsuranceCoverage.Theft, 50 }, { InsuranceCoverage.Loss, 25 } }; DateTime coverageStartDate = DateTime.Now; int coverageLengthInMonths = 10; float premiumPrice = 50; RiskLevel riskLevel = RiskLevel.Low; repoMock .Setup(mock => mock.StorePolicyAsync(It.Is <InsurancePolicy>(policy => policy.Name == name && policy.Description == description && policy.CoveragePercentages.Count == coverages.Count && !policy.CoveragePercentages.Except(coverages).Any() && policy.CoverageStartDate == coverageStartDate && policy.PremiumCostInDollars == premiumPrice && policy.InsuredRiskLevel == riskLevel ))) .Returns(Task.CompletedTask) .Verifiable(); await service.CreatePolicyAsync(name, description, coverages, coverageStartDate, coverageLengthInMonths, premiumPrice, riskLevel); repoMock.Verify(); }
public Alert(string alert, string url, RiskLevel risk, ConfidenceLevel confidence) : this(alert, url) { Risk = risk; Confidence = confidence; }
public void Create(RiskLevel data) { if (data.Id == Guid.Empty) { data.Id = Guid.NewGuid(); data.Status = RiskLevelStatus.Inactive; } var validationResult = new CreateRiskLevelValidator(_repository) .Validate(data); if (!validationResult.IsValid) { throw new RegoValidationException(validationResult); } using (var scope = CustomTransactionScope.GetTransactionScope()) { data.CreatedBy = _actorInfoProvider.Actor.UserName; data.DateCreated = DateTimeOffset.Now; _repository.RiskLevels.Add(data); _repository.SaveChanges(); _eventBus.Publish(new RiskLevelCreated(data.Id, data.BrandId, data.Level, data.Name, data.Status, data.Description)); scope.Complete(); } }
public IHttpActionResult PutRiskLevel(int id, RiskLevel riskLevel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != riskLevel.RiskLevelId) { return(BadRequest()); } db.Entry(riskLevel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RiskLevelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IEnumerable <InvestmentSurveyResultViewModel> Calculate( RiskLevel riskLevel, int lumpSumInvestmentAmount, int monthlyInvestmentAmount, int targetAmount) { // TODO: This needs refactoring. var month = 1; var growthRate = new GrowthRateProvider(riskLevel); var dateIncrement = DateTime.Today; decimal currentAmount = lumpSumInvestmentAmount; decimal currentAmountMin = lumpSumInvestmentAmount; decimal currentAmountMax = lumpSumInvestmentAmount; var results = new List <InvestmentSurveyResultViewModel>(); do { results.Add(CreateResult(InvestmentSurveyResultType.Min, dateIncrement, month, currentAmountMin)); results.Add(CreateResult(InvestmentSurveyResultType.Max, dateIncrement, month, currentAmountMax)); results.Add(CreateResult(InvestmentSurveyResultType.Invested, dateIncrement, month, currentAmount)); month++; currentAmount += monthlyInvestmentAmount; dateIncrement = dateIncrement.AddMonths(1); currentAmountMin = currentAmount * growthRate.MinPercent; currentAmountMax = currentAmount * growthRate.MaxPercent; } while (currentAmount < targetAmount); return(results); }
public void RiskExposureTest_AND2() { var configuration = new V1ExposureRiskCalculationConfiguration() { DailySummary_DaySummary_ScoreSum = new V1ExposureRiskCalculationConfiguration.Threshold() { Op = V1ExposureRiskCalculationConfiguration.Threshold.OPERATION_GREATER_EQUAL, Value = 1170.0 }, ExposureWindow_ScanInstance_SecondsSinceLastScanSum = new V1ExposureRiskCalculationConfiguration.Threshold() { Op = V1ExposureRiskCalculationConfiguration.Threshold.OPERATION_GREATER_EQUAL, Value = 900.0 }, }; var dailySummary = new DailySummary() { DateMillisSinceEpoch = 0, DaySummary = new ExposureSummaryData() { ScoreSum = 1170.0 }, ConfirmedClinicalDiagnosisSummary = new ExposureSummaryData(), ConfirmedTestSummary = new ExposureSummaryData(), RecursiveSummary = new ExposureSummaryData(), SelfReportedSummary = new ExposureSummaryData() }; var exposureWindows = new List <ExposureWindow>() { new ExposureWindow() { CalibrationConfidence = CalibrationConfidence.High, DateMillisSinceEpoch = 0, Infectiousness = Infectiousness.High, ReportType = ReportType.Unknown, ScanInstances = new List <ScanInstance>() { new ScanInstance() { SecondsSinceLastScan = 600, TypicalAttenuationDb = 1 }, new ScanInstance() { SecondsSinceLastScan = 240, TypicalAttenuationDb = 10 } } } }; IExposureRiskCalculationService service = CreateService(); RiskLevel result = service.CalcRiskLevel(dailySummary, exposureWindows, configuration); Assert.Equal(RiskLevel.Low, result); }
public ExposureInfo(DateTime timestamp, TimeSpan duration, int attenuationValue, int totalRiskScore, RiskLevel riskLevel) { Timestamp = timestamp; Duration = duration; AttenuationValue = attenuationValue; TotalRiskScore = totalRiskScore; TransmissionRiskLevel = riskLevel; }
public ExposureKeyModel( byte[] keyData, DateTimeOffset rollingStart, TimeSpan rollingDuration, RiskLevel transmissionRisk, int daysSinceOnsetOfSymptoms) : base(keyData, rollingStart, rollingDuration, transmissionRisk) { DaysSinceOnsetOfSymptoms = daysSinceOnsetOfSymptoms; }
public ForecastRequestDtoBuilder WithValidDefaults() { _years = 5; _riskLevel = RiskLevel.low; _lumpSum = 10000; _monthlyInvestment = 1000; return(this); }
public ActionResult DeleteConfirmed(int id) { RiskLevel riskLevel = db.RiskLevels.Find(id); db.RiskLevels.Remove(riskLevel); db.SaveChanges(); return(RedirectToAction("Index")); }
public JsonCompatibleExposureInfo(ExposureInfo exposureInfo) { Timestamp = exposureInfo.Timestamp; Duration = exposureInfo.Duration; AttenuationValue = exposureInfo.AttenuationValue; TotalRiskScore = exposureInfo.TotalRiskScore; TransmissionRiskLevel = exposureInfo.TransmissionRiskLevel; }
private PropertyBagBasedQueueInfo(PropertyStreamReader reader) : base(new QueueInfoPropertyBag()) { KeyValuePair <string, object> item; reader.Read(out item); if (!string.Equals("NumProperties", item.Key, StringComparison.OrdinalIgnoreCase)) { throw new SerializationException(string.Format("Cannot deserialize PropertyBagBasedQueueInfo. Expected property NumProperties, but found '{0}'", item.Key)); } int value = PropertyStreamReader.GetValue <int>(item); for (int i = 0; i < value; i++) { reader.Read(out item); if (string.Equals(ExtensibleQueueInfoSchema.Identity.Name, item.Key, StringComparison.OrdinalIgnoreCase)) { QueueIdentity value2 = QueueIdentity.Parse(PropertyStreamReader.GetValue <string>(item)); this[this.propertyBag.ObjectIdentityPropertyDefinition] = value2; } else if (string.Equals(ExtensibleQueueInfoSchema.DeliveryType.Name, item.Key, StringComparison.OrdinalIgnoreCase)) { DeliveryType deliveryType = (DeliveryType)PropertyStreamReader.GetValue <int>(item); this.propertyBag[ExtensibleQueueInfoSchema.DeliveryType] = deliveryType; } else if (string.Equals(ExtensibleQueueInfoSchema.Status.Name, item.Key, StringComparison.OrdinalIgnoreCase)) { QueueStatus value3 = (QueueStatus)PropertyStreamReader.GetValue <int>(item); this.propertyBag[ExtensibleQueueInfoSchema.Status] = value3; } else if (string.Equals(ExtensibleQueueInfoSchema.RiskLevel.Name, item.Key, StringComparison.OrdinalIgnoreCase)) { RiskLevel value4 = (RiskLevel)PropertyStreamReader.GetValue <int>(item); this.propertyBag[ExtensibleQueueInfoSchema.RiskLevel] = value4; } else if (string.Equals(ExtensibleQueueInfoSchema.NextHopCategory.Name, item.Key, StringComparison.OrdinalIgnoreCase)) { NextHopCategory value5 = (NextHopCategory)PropertyStreamReader.GetValue <int>(item); this.propertyBag[ExtensibleQueueInfoSchema.NextHopCategory] = value5; } else { PropertyDefinition fieldByName = PropertyBagBasedQueueInfo.schema.GetFieldByName(item.Key); if (fieldByName != null) { this.propertyBag.SetField((QueueViewerPropertyDefinition <ExtensibleQueueInfo>)fieldByName, item.Value); } else { ExTraceGlobals.SerializationTracer.TraceWarning <string>(0L, "Cannot convert key index '{0}' into a property in the ExtensibleQueueInfo schema", item.Key); } } } if (this.propertyBag[ExtensibleQueueInfoSchema.NextHopDomain] != null) { QueueIdentity queueIdentity = (QueueIdentity)this[this.propertyBag.ObjectIdentityPropertyDefinition]; queueIdentity.NextHopDomain = (string)this.propertyBag[ExtensibleQueueInfoSchema.NextHopDomain]; } }
private AnnualGrowthFigures GetAnnualGrowthFigures(RiskLevel riskLevel) { var annualGrowth = _growths.SingleOrDefault(x => x.RiskLevel == riskLevel); if (annualGrowth == null) { throw new InvalidOperationException($"No annual growth figures for risk level {riskLevel}"); } return(annualGrowth.AnnualGrowthFigures); }
public ActionResult Edit([Bind(Include = "RiskLevelId,Level")] RiskLevel riskLevel) { if (ModelState.IsValid) { db.Entry(riskLevel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(riskLevel)); }
public void CreatingAPolicyWithDefaultValuesMustFail() { string name = null; string description = null; Dictionary <InsuranceCoverage, float> coverages = null; DateTime coverageStartDate = DateTime.Now; int coverageLengthInMonths = 0; float premiumPrice = 0; RiskLevel riskLevel = RiskLevel.None; repoMock .Setup(mock => mock.StorePolicyAsync(It.IsAny <InsurancePolicy>())) .Returns(Task.CompletedTask); Check .ThatAsyncCode(CreatePolicyAsync) .Throws <ArgumentNullException>(); name = "Test policy"; Check .ThatAsyncCode(CreatePolicyAsync) .Throws <ArgumentNullException>(); description = "This is a test"; Check .ThatAsyncCode(CreatePolicyAsync) .Throws <ArgumentNullException>(); coverages = new Dictionary <InsuranceCoverage, float> { { InsuranceCoverage.Earthquake, 10 } }; Check .ThatAsyncCode(CreatePolicyAsync) .Throws <ArgumentOutOfRangeException>(); coverageLengthInMonths = 10; Check .ThatAsyncCode(CreatePolicyAsync) .Throws <ArgumentOutOfRangeException>(); premiumPrice = 50; Check .ThatAsyncCode(CreatePolicyAsync) .Throws <ArgumentNullException>(); riskLevel = RiskLevel.Low; Check .ThatAsyncCode(CreatePolicyAsync) .DoesNotThrow(); async Task <InsurancePolicy> CreatePolicyAsync() { return(await service.CreatePolicyAsync(name, description, coverages, coverageStartDate, coverageLengthInMonths, premiumPrice, riskLevel)); } }
public ActionResult Create([Bind(Include = "RiskLevelId,Level")] RiskLevel riskLevel) { if (ModelState.IsValid) { db.RiskLevels.Add(riskLevel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(riskLevel)); }
public ActionResult Create(RiskLevel r) { if (ModelState.IsValid) { db.RiskLevels.Add(r); //db.ObjectStateManager.ChangeObjectState(r, EntityState.Modified); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(r)); }
public IHttpActionResult GetRiskLevel(int id) { RiskLevel riskLevel = db.RiskLevels.Find(id); if (riskLevel == null) { return(NotFound()); } return(Ok(riskLevel)); }
public ActionResult Edit(RiskLevel r, int id) { if (ModelState.IsValid) { db.RiskLevels.Attach(r); db.Entry(r).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(r)); }
public CMarkerRisk(PointLatLng p, RiskLevel l, String nsOrgName, Int32 nOrgLevel) : base(p) { this.mLevel = l; this.msOrgName = nsOrgName; this.mnOrgLevel = nOrgLevel; if (this.mLevel != RiskLevel.RiskLevel_none) { LoadBitmap(); } }
public IHttpActionResult PostRiskLevel(RiskLevel riskLevel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RiskLevels.Add(riskLevel); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = riskLevel.RiskLevelId }, riskLevel)); }
public Task(string name, string description, Milestone milestone, RiskLevel risk, int effort, int priority, string owner) : this() { Name = name; Id = -1; ParentId = milestone.Id; Description = description; Risk = risk; Effort = effort; Priority = priority; Owner = owner; }
public void WhenHigh_ThenReturnCorrectType() { //Arrange RiskLevel riskLevel = RiskLevel.medium; Type expectedType = typeof(MediumRiskBounds); //Act var actual = _boundsFactory.GetBounds(riskLevel); //Assert Assert.IsInstanceOfType(actual, expectedType); }
public Alert(string alert, string url, RiskLevel risk, ConfidenceLevel confidence, string parameter, string other, string attack, string description, string reference, string solution, string evidence, int cweId, int wascId) : this(alert, url, risk, confidence, parameter, other) { this.Attack = attack; this.Description = description; this.Reference = reference; this.Solution = solution; this.Evidence = evidence; this.CWEId = cweId; this.WASCId = wascId; }
public override void ImportRow(ExcelRange cells, int row) { var r = new RiskLevel { MinValue = cells[row, 1].Text.ConvertData <double>(), FileId = FileId, MaxValue = cells[row, 2].Text.ConvertData <double>(), Color = cells[row, 3].Text, Description = cells[row, 4].Text }; Context.RiskLevels.Add(r); }
public CMarkerRisk(Int32 nID, PointLatLng p, Int32 nMinZoomLevel, Int32 nMaxZoomLevel, RiskLevel l, string nsOrgName, Int32 nOrgLevel) : base(nID, p, nMinZoomLevel, nMaxZoomLevel) { this.mLevel = l; this.msOrgName = nsOrgName; this.mnOrgLevel = nOrgLevel; CenterFormat.Alignment = StringAlignment.Center; CenterFormat.LineAlignment = StringAlignment.Center; if (this.mLevel != RiskLevel.RiskLevel_none) { LoadBitmap(); } }
public Alert(string alert, string url, RiskLevel risk, ConfidenceLevel confidence) : this(alert, url) { this.Risk = risk; this.Confidence = confidence; }
public LABStudyRiskLevelModel(RiskLevel _risk) { IsRisk = true; Risk = _risk; RiskVigilanceIdentifier = _risk.idRiskLevel; }
public Alert(string alert, string url, RiskLevel risk, ConfidenceLevel confidence, string parameter, string other) : this(alert, url, risk, confidence) { this.Other = other; this.Parameter = parameter; }