protected List <IncidentItem> GetIncidentObject() { DataBaseHelper myDB = new DataBaseHelper(); DataTable Location; Location = myDB.getAllLocation(); List <IncidentItem> IncidentObj = new List <IncidentItem>(); for (int i = 0; i < Location.Rows.Count; i++) { IncidentItem incident = new IncidentItem(Location.Rows[i]["reporterName"].ToString(), Location.Rows[i]["incidentType"].ToString(), Location.Rows[i]["Location"].ToString(), Location.Rows[i]["mainDispatch"].ToString(), Location.Rows[i]["reportContact"].ToString(), Location.Rows[i]["postalCode"].ToString(), Location.Rows[i]["incidentDesc"].ToString(), float.Parse(Location.Rows[i]["Latitude"].ToString()), float.Parse(Location.Rows[i]["Longitude"].ToString())); incident.NewIncidentID = Int32.Parse(Location.Rows[i]["IncidentID"].ToString()); incident.Status = Location.Rows[i]["Status"].ToString(); IncidentObj.Add(incident); } return(IncidentObj); }
protected void CreateIncidentButton(object sender, EventArgs e) { float Lat = float.Parse(LatInfo.Value); float Long = float.Parse(LngInfo.Value); //pass form variable into incidentManager IncidentItem incident = incidentController.createIncident(reportPersonTextBox.Text, typeOfIncidentDDL.Text, locationTextBox.Text, MainDispatchDDL.Text, contactNoTextBox.Text, postalCodeTextBox.Text, descriptionTextBox.Text, Lat, Long); //call newsfeed controller to do something foreach (ListItem assistTypeCBL in assistTypeCheckBoxList.Items) if (assistTypeCBL.Selected == true) incidentController.addSupportType(incident.NewIncidentID, Convert.ToInt32(assistTypeCBL.Value)); foreach (ListItem assistTypeCBL1 in CheckBoxList1.Items) if (assistTypeCBL1.Selected == true) incidentController.addSupportType(incident.NewIncidentID, Convert.ToInt32(assistTypeCBL1.Value)); foreach (ListItem assistTypeCBL2 in CheckBoxList2.Items) if (assistTypeCBL2.Selected == true) incidentController.addSupportType(incident.NewIncidentID, Convert.ToInt32(assistTypeCBL2.Value)); //update UI clearTextBox(); updateUIIncident(); //pass json string to javascript System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string sIncident = oSerializer.Serialize(incident); //converts object to json string ScriptManager.RegisterStartupScript(this, GetType(), "script", "replaceDefaultMarker(" + sIncident + ");", true); } // end of class
private static IncidentItem CreateExpectedItem2() { var expectedItem1 = new IncidentItem( "incident-id-2", info: "Info 2", location: new GeoPoint(49, 17), type: GeoIncidentType.Task, units: new List <UnitOfIncident> { CreateUnit1(IncidentTaskState.Zbo) }); return(expectedItem1); }
} // end of insertHobbies public int Create_Incident(IncidentItem i) { int IncidentID = 0; string sqlText = "INSERT INTO Database1.dbo.IncidentManager (incidentType, reporterName, reportContact, Location, postalCode, mainDispatch, incidentDesc, Latitude, Longitude) OUTPUT INSERTED.IncidentID VALUES(@incidentType, @reporterName, @reportContact, @Location, @postalCode, @mainDispatch, @incidentDesc, @latitude, @longitude)"; Command.Parameters.Clear(); Command.Parameters.Add("@incidentType", SqlDbType.VarChar, 100); //incidentType Command.Parameters["@incidentType"].Value = i.TypeOfIncident; Command.Parameters.Add("@reporterName", SqlDbType.VarChar, 100); //reporterName Command.Parameters["@reporterName"].Value = i.ReportPerson; Command.Parameters.Add("@reportContact", SqlDbType.VarChar, 100); //reportContact Command.Parameters["@reportContact"].Value = i.ContactNo; Command.Parameters.Add("@Location", SqlDbType.VarChar, 100); //Location Command.Parameters["@Location"].Value = i.Location; Command.Parameters.Add("@postalCode", SqlDbType.VarChar, 100); //postalCode Command.Parameters["@postalCode"].Value = i.PostalCode; Command.Parameters.Add("@mainDispatch", SqlDbType.VarChar, 100); //mainDispatch Command.Parameters["@mainDispatch"].Value = i.MainDispatch; Command.Parameters.Add("@incidentDesc", SqlDbType.VarChar, 100); //description Command.Parameters["@incidentDesc"].Value = i.Description; Command.Parameters.Add("@latitude", SqlDbType.Float, 100); //latitude Command.Parameters["@latitude"].Value = i.Latitude; Command.Parameters.Add("@longitude", SqlDbType.Float, 100); //longitude Command.Parameters["@longitude"].Value = i.Longitude; Command.CommandText = sqlText; settings = System.Configuration.ConfigurationManager.ConnectionStrings["Connection"]; string connectionString = settings.ConnectionString; SqlConnection Connection = new SqlConnection(connectionString); Command.Connection = Connection; Adapter.SelectCommand = Command; Connection.Open(); IncidentID = (int)Command.ExecuteScalar(); Connection.Close(); return(IncidentID); }
private static IncidentItem CreateExpectedItem1() { var expectedItem1 = new IncidentItem( "incident-id-1", GeoIncidentType.Task, "Info 1", location: new GeoPoint(48, 16), destination: new GeoPoint(19, 21), units: new List <UnitOfIncident> { CreateUnit1(IncidentTaskState.Abo), CreateUnit2() }); return(expectedItem1); }
public IncidentItem createIncident(string reportPerson, string typeOfIncident, string location, string mainDispatch , string contactNo, string postalCode, string description, float latitude, float longitude) { //using create item constructor IncidentItem i = new IncidentItem(reportPerson, typeOfIncident, location, mainDispatch, contactNo, postalCode, description, latitude, longitude); string message = "A " + typeOfIncident + " has occured at " + location + " at " + DateTime.Now.ToString(); new NewsFeedController().UpdateStatustoFB(message); new NewsFeedController().UpdateStatustoTwitter(message); //pass object to DAO, DAO deconstruct object and store to DB int newIncidentID = myDB.Create_Incident(i); return(getIncidentByID(newIncidentID)); }
public IncidentItem loadItem(DataSet ds) { string reportPerson = ds.Tables["reporterName"].ToString(); string typeOfIncident = ds.Tables["incidentType"].ToString(); string location = ds.Tables["Location"].ToString(); string mainDispatch = ds.Tables["mainDispatch"].ToString(); string contactNo = ds.Tables["reportContact"].ToString(); string postalCode = ds.Tables["postalCode"].ToString(); string description = ds.Tables["incidentDesc"].ToString(); string dt = ds.Tables["dateTime"].ToString(); int newIncidentID = int.Parse(ds.Tables["incidentID"].ToString()); float lat = float.Parse(ds.Tables["Latitude"].ToString()); float lng = float.Parse(ds.Tables["Longitutde"].ToString()); IncidentItem i = new IncidentItem(typeOfIncident, reportPerson, location, mainDispatch , contactNo, postalCode, description, lat, lng); return(i); }
} // end of updateIncidentStatus public IncidentItem getOneIncident(int IncidentID) { //IncidentItem i; settings = System.Configuration.ConfigurationManager.ConnectionStrings["Connection"]; string connectionString = settings.ConnectionString; Connection = new SqlConnection(connectionString); string sqlText = "SELECT * FROM Database1.dbo.IncidentManager WHERE IncidentID=@IncidentID"; Command.Parameters.Clear(); Command.Parameters.Add("@IncidentID", SqlDbType.Int); Command.Parameters["@IncidentID"].Value = IncidentID; Command.CommandText = sqlText; Command.Connection = Connection; Adapter.SelectCommand = Command; Connection.Open(); Adapter.Fill(DS, "getOneIncident"); Connection.Close(); DataTable oneIncident = DS.Tables["getOneIncident"]; DateTime dateTime = Convert.ToDateTime(oneIncident.Rows[0]["dateTime"].ToString()); string convertDateTime = dateTime.ToString(); string reportPerson = oneIncident.Rows[0]["reporterName"].ToString(); string typeOfIncident = oneIncident.Rows[0]["incidentType"].ToString(); string location = oneIncident.Rows[0]["Location"].ToString(); string mainDispatch = oneIncident.Rows[0]["mainDispatch"].ToString(); string contactNo = oneIncident.Rows[0]["reportContact"].ToString(); string postalCode = oneIncident.Rows[0]["postalCode"].ToString(); string description = oneIncident.Rows[0]["incidentDesc"].ToString(); string dt = oneIncident.Rows[0]["dateTime"].ToString(); int newIncidentID = int.Parse(oneIncident.Rows[0]["incidentID"].ToString()); IncidentItem i = new IncidentItem(reportPerson, typeOfIncident, location, mainDispatch, contactNo , postalCode, description, 0, 0); i.Latitude = float.Parse(oneIncident.Rows[0]["Latitude"].ToString()); i.Longitude = float.Parse(oneIncident.Rows[0]["Longitude"].ToString()); i.DateTime = convertDateTime; i.NewIncidentID = newIncidentID; return(i); }
public ItemDetailViewModel(IncidentItem incidentItem = null) { Title = incidentItem?.DescriptiveType; IncidentItem = incidentItem; }