Example #1
0
        public static void AddIncident(MiscData.Incident thisIncident)
        {
            try
            {
                MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == thisIncident.IncidentID); });
                if (thisFoundIncident == null)
                {
                    Incidents.Add(thisIncident);
                }
                else
                {
                    /*  this code was rewriting existing incidents from drivers, which we don't want to do.  Logic moved to update incident
                     * var _incident = Incidents.Find(i => i.IncidentID == thisIncident.IncidentID);
                     * _incident.Location = thisIncident.Location;
                     * _incident.FreewayID = thisIncident.FreewayID;
                     * _incident.LocationID = thisIncident.LocationID;
                     * _incident.BeatSegmentID = thisIncident.BeatSegmentID;
                     * _incident.TimeStamp = thisIncident.TimeStamp;
                     * _incident.CreatedBy = thisIncident.CreatedBy;
                     * _incident.Description = thisIncident.Description;
                     * _incident.IncidentNumber = thisIncident.IncidentNumber;
                     * _incident.CrossStreet1 = thisIncident.CrossStreet1;
                     * _incident.CrossStreet2 = thisIncident.CrossStreet2;
                     * _incident.Direction = thisIncident.Direction;
                     * */
                    //UpdateIncident(thisIncident);
                }
                //Log to database, proc will update or insert based on existing data
                SQL.SQLCode mySQL = new SQL.SQLCode();

                mySQL.RunProc("LogIncident", GetIncidentArray(thisIncident));
            }
            catch (Exception ex)
            {
                string msg = DateTime.Now.ToString() + Environment.NewLine;
                msg += "Error Logging Incident" + Environment.NewLine;
                msg += Environment.NewLine;
                msg += "Incident ID: " + thisIncident.IncidentID.ToString() + Environment.NewLine;
                msg += "FreeWay ID: " + thisIncident.FreewayID.ToString() + Environment.NewLine;
                msg += "Location: " + thisIncident.Location + Environment.NewLine;
                msg += "Location ID: " + thisIncident.LocationID.ToString() + Environment.NewLine;
                msg += "Beat Segment ID: " + thisIncident.BeatSegmentID.ToString() + Environment.NewLine;
                msg += "Time Stamp: " + thisIncident.TimeStamp.ToString() + Environment.NewLine;
                msg += "Created By: " + thisIncident.CreatedBy.ToString() + Environment.NewLine;
                msg += "Description: " + thisIncident.Description + Environment.NewLine;
                msg += "Incident Number: " + thisIncident.IncidentNumber + Environment.NewLine;
                msg += "Cross Street 1: " + thisIncident.CrossStreet1 + Environment.NewLine;
                msg += "Cross Street 2: " + thisIncident.CrossStreet2 + Environment.NewLine;
                msg += "Direction: " + thisIncident.Direction + Environment.NewLine;
                msg += "Beat Number: " + thisIncident.BeatNumber + Environment.NewLine;
                msg += "DispatchNumber: " + thisIncident.IncidentNumber;
                msg += Environment.NewLine;
                msg += ex.ToString();
                logger.LogEvent(msg, true);
            }
        }
Example #2
0
 public static MiscData.Incident FindIncidentByID(Guid _IncidentID)
 {
     MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == _IncidentID); });
     if (thisFoundIncident == null)
     {
         return(null);
     }
     else
     {
         return(thisFoundIncident);
     }
 }
Example #3
0
 public static string FindBeatNumberByID(Guid _IncidentID)
 {
     MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == _IncidentID); });
     if (thisFoundIncident != null)
     {
         return(thisFoundIncident.BeatNumber);
     }
     else
     {
         return("Unknown");
     }
 }
Example #4
0
 public static Guid FindIncidentCreatorFromAssist(Guid _IncidentID)
 {
     MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == _IncidentID); });
     if (thisFoundIncident == null)
     {
         Guid newGuid = new Guid("00000000-0000-0000-0000-000000000000");
         return(newGuid);
     }
     else
     {
         return(thisFoundIncident.CreatedBy);
     }
 }
Example #5
0
        /*
         * public static void AssignTruckToAssist(Guid AssistID, TowTruck.TowTruck thisTruck)
         * {
         *  MiscData.Assist thisFoundAssist = Assists.Find(delegate(MiscData.Assist a) { return a.AssistID == AssistID; });
         *  if (thisFoundAssist != null)
         *  {
         *      thisFoundAssist.FleetVehicleID = thisTruck.Extended.FleetVehicleID;
         *  }
         * }
         *
         * public static void RemoveTruckFromIncident(Guid AssistID)
         * {
         *  MiscData.Assist thisFoundAssist = Assists.Find(delegate(MiscData.Assist a) { return a.AssistID == AssistID; });
         *  if (thisFoundAssist != null)
         *  {
         *      thisFoundAssist.FleetVehicleID = new Guid("00000000-0000-0000-0000-000000000000");
         *  }
         * }
         */


        #endregion

        #region " Add, remove, return incidents "

        public static void UpdateIncidentBeat(Guid _IncidentiD, Guid _FleetVehicleID)
        {
            string BeatNumber = "";

            MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == _IncidentiD); });
            if (thisFoundIncident != null)
            {
                TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.Extended.FleetVehicleID == _FleetVehicleID); });
                if (thisFoundTruck != null)
                {
                    BeatNumber = thisFoundTruck.assignedBeat.BeatNumber;
                }
                thisFoundIncident.BeatNumber = BeatNumber;
            }
        }
Example #6
0
 public static void UpdateIncident(MiscData.Incident thisIncident)
 {
     try
     {
         MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == thisIncident.IncidentID); });
         if (thisFoundIncident != null)
         {
             var _incident = Incidents.Find(i => i.IncidentID == thisIncident.IncidentID);
             _incident.Location      = thisIncident.Location;
             _incident.FreewayID     = thisIncident.FreewayID;
             _incident.LocationID    = thisIncident.LocationID;
             _incident.BeatSegmentID = thisIncident.BeatSegmentID;
             //_incident.TimeStamp = thisIncident.TimeStamp;
             _incident.CreatedBy   = thisIncident.CreatedBy;
             _incident.Description = thisIncident.Description;
             //_incident.IncidentNumber = thisIncident.IncidentNumber;
             _incident.CrossStreet1 = thisIncident.CrossStreet1;
             _incident.CrossStreet2 = thisIncident.CrossStreet2;
             _incident.Direction    = thisIncident.Direction;
             _incident.BeatNumber   = thisIncident.BeatNumber;
         }
     }
     catch (Exception ex)
     {
         string msg = DateTime.Now.ToString() + Environment.NewLine;
         msg += "Error Logging Incident" + Environment.NewLine;
         msg += Environment.NewLine;
         msg += "Incident ID: " + thisIncident.IncidentID.ToString() + Environment.NewLine;
         msg += "FreeWay ID: " + thisIncident.FreewayID.ToString() + Environment.NewLine;
         msg += "Location: " + thisIncident.Location + Environment.NewLine;
         msg += "Location ID: " + thisIncident.LocationID.ToString() + Environment.NewLine;
         msg += "Beat Segment ID: " + thisIncident.BeatSegmentID.ToString() + Environment.NewLine;
         msg += "Time Stamp: " + thisIncident.TimeStamp.ToString() + Environment.NewLine;
         msg += "Created By: " + thisIncident.CreatedBy.ToString() + Environment.NewLine;
         msg += "Description: " + thisIncident.Description + Environment.NewLine;
         msg += "Incident Number: " + thisIncident.IncidentNumber + Environment.NewLine;
         msg += "Cross Street 1: " + thisIncident.CrossStreet1 + Environment.NewLine;
         msg += "Cross Street 2: " + thisIncident.CrossStreet2 + Environment.NewLine;
         msg += "Direction: " + thisIncident.Direction + Environment.NewLine;
         msg += Environment.NewLine;
         msg += ex.ToString();
         logger.LogEvent(msg, true);
     }
 }
Example #7
0
 public static void ClearIndicent(Guid _IncidentID)
 {
     MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == _IncidentID); });
     if (thisFoundIncident == null)
     {
         return;
     }
     else
     {
         Incidents.Remove(thisFoundIncident);
         for (int i = Assists.Count - 1; i >= 0; i--)
         {
             if (Assists[i].IncidentID == _IncidentID)
             {
                 Assists.Remove(Assists[i]);
             }
         }
     }
 }
Example #8
0
        private static ArrayList GetIncidentArray(MiscData.Incident thisIncident)
        {
            //to verify that we can translate everything into an arraylist correctly, we need to parse the elements in the object
            //into strings, filling default values if necessary
            ArrayList arrParams  = new ArrayList();
            string    IncidentID = thisIncident.IncidentID.ToString();
            string    Direction;

            if (string.IsNullOrEmpty(thisIncident.Direction))
            {
                Direction = "NA";
            }
            else
            {
                Direction = thisIncident.Direction;
            }
            string FreewayID = thisIncident.FreewayID.ToString();
            string Location  = "NA";

            if (!string.IsNullOrEmpty(thisIncident.Location))
            {
                Location = thisIncident.Location.ToString();
            }
            string LocationID    = thisIncident.LocationID.ToString();
            string BeatSegmentID = thisIncident.BeatSegmentID.ToString();
            string TimeStamp     = thisIncident.TimeStamp.ToString();
            string CrossStreet1  = "NA";

            if (!string.IsNullOrEmpty(thisIncident.CrossStreet1))
            {
                CrossStreet1 = thisIncident.CrossStreet1;
            }
            string CrossStreet2 = "NA";

            if (!string.IsNullOrEmpty(thisIncident.CrossStreet2))
            {
                CrossStreet2 = thisIncident.CrossStreet2;
            }
            string CreatedBy = thisIncident.CreatedBy.ToString();
            string Description;

            if (string.IsNullOrEmpty(thisIncident.Description))
            {
                Description = "NA";
            }
            else
            {
                Description = thisIncident.Description;
            }
            string IncidentNumber;

            if (string.IsNullOrEmpty(thisIncident.IncidentNumber))
            {
                IncidentNumber = "NA";
            }
            else
            {
                IncidentNumber = thisIncident.IncidentNumber;
            }
            string BeatNumber;

            if (string.IsNullOrEmpty(thisIncident.BeatNumber))
            {
                BeatNumber = "NA";
            }
            else
            {
                BeatNumber = thisIncident.BeatNumber;
            }

            arrParams.Add("@Direction~" + Direction);
            arrParams.Add("@IncidentID~" + IncidentID);
            arrParams.Add("@ApproximateLocation~" + Direction);
            arrParams.Add("@FreewayID~" + FreewayID);
            arrParams.Add("@Location~" + Location);
            arrParams.Add("@LocationID~" + LocationID);
            arrParams.Add("@BeatSegmentID~" + BeatSegmentID);
            arrParams.Add("@TimeStamp~" + TimeStamp);
            arrParams.Add("@CreatedBy~" + CreatedBy);
            arrParams.Add("@Description~" + Description);
            arrParams.Add("@IncidentNumber~" + IncidentNumber);
            arrParams.Add("@CrossStreet1~" + CrossStreet1);
            arrParams.Add("@CrossStreet2~" + CrossStreet2);
            arrParams.Add("@BeatNumber~" + BeatNumber);
            return(arrParams);
        }