public static string testserialize(List <string> args) { DataSet <IncidentData> test = new DataSet <IncidentData>(); test.Data["Test"] = "Test"; IncidentData incident = new IncidentData(); incident.Id = "Moo"; incident.Time = DateTime.Now; ResponseData response = new ResponseData(); response.Id = "Moo"; response.Data.Add("Unit", "Also Moo"); response.Data.Add("UnitType", "Cow"); response.Data.Add("Shift", "Night Shift"); incident.Responses.Add(response); test.Add(incident); JsonSerializerSettings settings = new JsonSerializerSettings() { Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Auto, PreserveReferencesHandling = PreserveReferencesHandling.All }; string json = JsonConvert.SerializeObject(test, test.GetType(), settings); Console.WriteLine(json); return("Test passed."); }
public async Task <ActionResult <IncidentData> > PostIncidentData(IncidentData incidentData) { _context.IncidentData.Add(incidentData); await _context.SaveChangesAsync(); return(CreatedAtAction("GetIncidentData", new { id = incidentData.IncidentId }, incidentData)); }
public async Task <IActionResult> PutIncidentData(string id, IncidentData incidentData) { if (id != incidentData.IncidentId) { return(BadRequest()); } _context.Entry(incidentData).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!IncidentDataExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override void Save() { _incident.UpdatePersonFullName(); IncidentData id = new IncidentData(); id.Update(_incident); }
internal void CloseIncident(IncidentData incident) { if (!incident.IsClosed) { incident.IsClosed = true; incident.LastActivityTime = DateTime.Now; _publisher.Publish(new IncidentNotification()); } }
public void WebSrv_NI_Incident_GetByPrimaryKey_Test() { long _id = 1; IncidentAccess _sut = new IncidentAccess(_niEntities); IncidentData _row = _sut.GetByPrimaryKey(_id); Assert.IsNotNull(_row); Assert.AreEqual(_row.IncidentId, _id); System.Diagnostics.Debug.WriteLine(_row.ToString()); }
public IActionResult DeleteIncident(string id) { using (mypidbContext db = new mypidbContext()) { IncidentData deleteMe = db.IncidentData.Where(x => x.IncidentId == id).FirstOrDefault(); db.IncidentData.Remove(deleteMe); db.SaveChanges(); return(RedirectToAction("EmpTable")); } }
public IIncident GetNewDo(string value) { var newDto = new IncidentDto(); newDto.CodeId = value; newDto.IsNew = true; var domainObject = new IncidentData(newDto); return(domainObject); }
public void BuildDemoData() { IncidentData data = new IncidentData("1", new DateTime(2018, 12, 25, 7, 07, 07), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Public"; Incidents.Add(data); data = new IncidentData("2", new DateTime(2018, 12, 25, 21, 09, 21), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Residential"; Incidents.Add(data); data = new IncidentData("3", new DateTime(2018, 11, 28, 15, 15, 15), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Residential"; Incidents.Add(data); data = new IncidentData("4", new DateTime(2018, 11, 20, 20, 15, 15), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Residential"; Incidents.Add(data); data = new IncidentData("5", new DateTime(2018, 10, 12, 17, 15, 15), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Residential"; Incidents.Add(data); data = new IncidentData("6", new DateTime(2018, 9, 13, 18, 15, 15), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Residential"; Incidents.Add(data); data = new IncidentData("7", new DateTime(2018, 8, 4, 13, 15, 15), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Residential"; Incidents.Add(data); data = new IncidentData("8", new DateTime(2018, 8, 10, 08, 15, 15), "Corvallis", -123.2620, 44.5646); data.Data["Code"] = "311"; data.Data["Category"] = "EMS"; data.Data["Type"] = "Alpha"; data.Data["Area"] = "Residential"; Incidents.Add(data); }
//Gets saved crime data if user cannot get updated crime data online public IncidentData GetCrimeData() { var assembly = IntrospectionExtensions.GetTypeInfo(typeof(Database)).Assembly; Stream stream = assembly.GetManifestResourceStream("CrimeWatch.CrimeData.json"); IncidentData incidentData = null; var reader = new StreamReader(stream); var json = reader.ReadToEnd(); incidentData = JsonConvert.DeserializeObject <IncidentData>(json); return(incidentData); }
public static bool LooksEmpty(this IncidentData incident) { return (incident.Location == null && incident.TimeWindow == null && incident.Victims.Count == 0 && incident.Witnesses.Count == 0 && incident.Involved.Count == 0 && incident.Stolen.Count == 0 && incident.Damaged.Count == 0 && incident.Suspects.Count == 0 && incident.Vehicles.Count == 0); }
public IActionResult EditComment(string id, IncidentData updatedIncident) { using (mypidbContext db = new mypidbContext()) { IncidentData incident = db.IncidentData.Where(x => x.IncidentId == id).FirstOrDefault(); if (incident != null) { incident.AdminComments = updatedIncident.AdminComments; db.SaveChanges(); } } return(RedirectToAction("EmpTable")); }
public void LoadList() { ep.SetError(dgIncidents, ""); try { IncidentData id = new IncidentData(); _allIncidents = id.GetList(); _filteredIncidents = _allIncidents; } catch (Exception ex) { ep.SetError(dgIncidents, ex.Message); } }
public static string rmqsend(List <string> args) { if (args.Count == 0) { return("rmqsend requires 1 argument"); } producer.Connect(); IncidentData data = new IncidentData(); data.Data["Message"] = args[0]; producer.SendObject(data); return("Message sent"); }
public void ShouldRemoveEscalationForTouchedIncidents() { //Prepare IncidentData i = new IncidentData { LastActivityTime = DateTime.Now.AddSeconds(-30), IsEscalated = true }; var ctl = new FirstUnitTestDemo(); //Test ctl.EscalateIncidentIfRequired(i); //Assert Assert.IsFalse(i.IsEscalated, "Incident that was updated should not be escalated"); }
public void ShouldSendNotificationOnClosingOpenIncident() { var publisherMock = Substitute.For <IPublisher>(); //This is the mock var subj = new SecondStep_Stubs(publisherMock); var incident = new IncidentData { IsClosed = false }; //Test subj.CloseIncident(incident); //Assert Assert.IsTrue(incident.IsClosed, "Incident Should be closed"); publisherMock.Received(1).Publish(Arg.Any <INotificationData>()); }
public void ShouldEscalateAnUntouchedIncident() { //Prepare IncidentData i = new IncidentData { LastActivityTime = DateTime.Now.AddDays(-4), IsEscalated = false }; var ctl = new FirstUnitTestDemo(); //Test ctl.EscalateIncidentIfRequired(i); //Assert Assert.IsTrue(i.IsEscalated, "Old incidents should be escalated"); }
public void ShouldBeAbletoCloseIncident() { //Preparing IPublisher publisherStub = new PublisherStub(); var subj = new SecondStep_Stubs(publisherStub); var incident = new IncidentData { IsClosed = false }; //Test subj.CloseIncident(incident); //Assert Assert.IsTrue(incident.IsClosed, "Incident Should be closed"); }
protected async Task <IncidentData> GetCurrentIncidentAsync(ITurnContext context, bool throwIfNull = true) { return(await Accessors.CurrentIncident_Accessor.GetAsync( context, () => { if (throwIfNull) { throw new NullReferenceException("UserProfile cannot be null."); } else { var user = GetCurrentUserAsync(context, throwIfNull).Result; return IncidentData.NewUnspecified(user.Guid); } })); }
private RecommendationAndChoices RecommendFor(IncidentData incident) { if (incident.Location == null) { return(new RecommendationAndChoices() { Recommendation = ReviewBurglaryResources.Recommendation_AddLocation, Choices = new [] { ReviewBurglaryResources.Choice_AddLocation, ReviewBurglaryResources.Reject_AddLocation, ReviewBurglaryResources.Negative_AddLocation } }); } if (incident.Stolen.Count == 0) { return(new RecommendationAndChoices() { Recommendation = ReviewBurglaryResources.Recommendation_AddStolenProperty, Choices = new[] { ReviewBurglaryResources.Choice_AddStolenProperty, ReviewBurglaryResources.Reject_AddStolenProperty, ReviewBurglaryResources.Negative_AddStolenProperty } }); } // TODO: the other components of a report: // TimeWindow, DamagedProperty, Victims, Witnesses, Involved, Suspects, Vehicles (part of suspects?) return(new RecommendationAndChoices() { Recommendation = ReviewBurglaryResources.Recommendation_ReviewAllOptions, Choices = new[] { ReviewBurglaryResources.Choice_ReviewAllOptions, ReviewBurglaryResources.Choice_CloseReport } }); }
public void BuildDemoData() { var incident = new IncidentData("1", new DateTime(2018, 12, 25, 7, 07, 07), "Bethlehem", 35.200657, 31.705791); incident.Data["Code"] = "Z"; incident.Data["Category"] = "A"; incident.Data["Type"] = "JC"; Incidents.Add(incident); incident = new IncidentData("999", new DateTime(1980, 09, 07, 21, 09, 21), "Corvallis", -123.2620, 44.5646); incident.Data["Code"] = "K"; incident.Data["Category"] = "K"; incident.Data["Type"] = "M"; Incidents.Add(incident); incident = new IncidentData("456", new DateTime(1982, 03, 01, 15, 15, 15), "Corvallis", -123.2620, 44.5646); incident.Data["Code"] = "K"; incident.Data["Category"] = "B"; incident.Data["Type"] = "P"; Incidents.Add(incident); }
public void WebSrv_NI_Incident_ListByPagination01_Test() { IncidentAccess _sut = new IncidentAccess(_niEntities); string _pagination = "{\"first\":0,\"rows\":3,\"sortOrder\":1,\"filters\":{\"ServerId\":{\"value\":1,\"matchMode\":\"equals\"},\"Mailed\":{\"value\":false,\"matchMode\":\"equals\"},\"Closed\":{\"value\":false,\"matchMode\":\"equals\"},\"Special\":{\"value\":false,\"matchMode\":\"equals\"}},\"globalFilter\":null}"; IncidentPaginationData _data = _sut.ListByPagination(_pagination); System.Diagnostics.Debug.WriteLine(string.Format("Tot Rec:{0}, Msg:{1}", _data.totalRecords, _data.message)); List <IncidentData> _rows = _data.incidents; foreach (var _row in _rows) { System.Diagnostics.Debug.WriteLine(_row.ToString()); } Assert.IsTrue(_rows.Count == 3); IncidentData _row0 = _rows[0]; Assert.AreEqual(_row0.ServerId, 1); Assert.AreEqual(_row0.Mailed, false); }
public void ShouldSetDateTimeCorrectlyOnCloseIncident() { var publisherMock = Substitute.For <IPublisher>(); //This is the mock var subj = new SecondStep_Stubs(publisherMock); //Shimming var expectedTime = new DateTime(2017, 2, 26, 11, 30, 00); System.Prig.PDateTime.NowGet().Body = () => expectedTime; var test = DateTime.Now; var incident = new IncidentData { IsClosed = false }; subj.CloseIncident(incident); //Assert Assert.AreEqual(expectedTime, incident.LastActivityTime); }
// Asynchronous Method that returns a IncidentData object if the user is able to send a url request public async Task <IncidentData> GetCrimeDataAsync(string uri) { IncidentData incidentData = null; try { // get json data file HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); incidentData = JsonConvert.DeserializeObject <IncidentData>(content); } } catch (Exception ex) { Debug.WriteLine($"\tERROR {ex.Message}"); } return(incidentData); }
protected async override Task <DialogTurnResult> ParseChoiceAsync(FoundChoice choice, WaterfallStepContext stepContext, CancellationToken cancellationToken) { if (RecordNewBurglaryResources.Choice_NewReport == choice.Value) { var channelId = stepContext.Context.Activity.ChannelId; var userProfile = await Accessors.UserProfile_Accessor.GetAsync(stepContext.Context, () => Accessors.Storage.UserProfiles.ReadOrCreateAsync(channelId).Result, cancellationToken); var ownerGuid = userProfile.Guid; await Accessors.CurrentIncident_Accessor.SetAsync(stepContext.Context, IncidentData.NewBurglary(ownerGuid), cancellationToken); return(await stepContext.ReplaceDialogAsync(typeof(ReviewBurglaryDialog).CalcDialogId(), null, cancellationToken)); } else if (RecordNewBurglaryResources.Choice_Back == choice.Value) { return(await stepContext.EndDialogAsync(cancellationToken)); } else { await stepContext.Context.SendActivityAsync(MessageFactory.Text(RecordNewBurglaryResources.CannotConfirmIntent), cancellationToken); return(await stepContext.EndDialogAsync(cancellationToken)); } }
private static void onReceive(object sender, string message, IncidentData obj) { Console.WriteLine(string.Format("Received Message: {0} Object: {1}", message, obj)); }
public static string Summarise(this IncidentData incident) { if (incident.LooksEmpty()) { return(string.Format(IncidentSummaryResources.summary_empty_for_type, incident.Type.Summarise())); } var entries = new List <string>(); if (incident.Location != null) { if (incident.TimeWindow != null) { entries.Add(string.Format(IncidentSummaryResources.summary_location_and_timewindow_for_type, incident.Location.Summarise(), incident.TimeWindow.Summarise(), incident.Type.Summarise())); } else { entries.Add(string.Format(IncidentSummaryResources.summary_location_for_type, incident.Location.Summarise(), incident.Type.Summarise())); } } if (incident.ReportStarted != null) { if (incident.ReportCompleted != null) { entries.Add(string.Format(IncidentSummaryResources.summary_started_and_completed, incident.ReportStarted.Summarise(), incident.ReportCompleted.Summarise())); } else { entries.Add(string.Format(IncidentSummaryResources.summary_started_only, incident.ReportStarted.Summarise())); } } if (incident.Stolen.Count > 0) { entries.Add(string.Format(IncidentSummaryResources.summary_X_items_stolen_totalling, incident.Stolen.Count, incident.Stolen.TotalCost())); } if (incident.Damaged.Count > 0) { entries.Add(string.Format(IncidentSummaryResources.summary_X_items_damaged, incident.Damaged.Count)); } if (incident.Victims.Count > 0) { var descriptions = incident.Victims.Select(p => p.Summarise()); entries.Add(string.Format(IncidentSummaryResources.summary_X_victims, incident.Victims.Count, descriptions)); } if (incident.Witnesses.Count > 0) { var descriptions = incident.Witnesses.Select(p => p.Summarise()); entries.Add(string.Format(IncidentSummaryResources.summary_X_witnesses, incident.Witnesses.Count, descriptions)); } if (incident.Involved.Count > 0) { var descriptions = incident.Involved.Select(p => p.Summarise()); entries.Add(string.Format(IncidentSummaryResources.summary_X_involved, incident.Involved.Count, descriptions)); } if (incident.Suspects.Count > 0) { var descriptions = incident.Suspects.Select(p => p.Summarise()); entries.Add(string.Format(IncidentSummaryResources.summary_X_suspects, incident.Suspects.Count, descriptions)); } if (incident.Vehicles.Count > 0) { var descriptions = incident.Involved.Select(v => v.Summarise()); entries.Add(string.Format(IncidentSummaryResources.summary_X_vehicles, incident.Vehicles.Count, descriptions)); } entries.RemoveAll(e => string.IsNullOrWhiteSpace(e)); return(string.Join("\n", entries.Select(e => "* " + e))); }
public void EscalateIncidentIfRequired(IncidentData incident) { var escalationPoint = DateTime.Now.AddMinutes(-30); incident.IsEscalated = incident.LastActivityTime < escalationPoint; }