public void ManageCameraIncident(string Topic, string PayLoad)
        {
            dynamic  json       = JValue.Parse(PayLoad);
            DateTime incidentTS = DateTime.Now;
            string   cameraID   = json.result.cameraid;

            if (cameraID == "" || cameraID == null)
            {
                cameraID = json.result.cameraID;
            }
            string errorMsg = "";
            long   newId    = 0;
            string message  = json.result.type + " " + json.result.description + " From:" + cameraID;
            string strLat   = "0.0";
            string strLon   = "0.0";

            IO.Swagger.DatabaseInterface.DBIncident dbI = new IO.Swagger.DatabaseInterface.DBIncident();
            if (!dbI.FindCameraCoords(cameraID, ref strLat, ref strLon))
            {
                Console.WriteLine("No matching Camera for:" + json.result.cameraID);
                return;
            }
            double latDiff = 0.0;
            double lonDiff = 0.0;
            double lat     = double.Parse(strLat, CultureInfo.InvariantCulture);
            double lon     = double.Parse(strLon, CultureInfo.InvariantCulture);

            CartesianToGeo(4, lat, lon, ref latDiff, ref lonDiff);
            int randLon = random.Next(-3, 3);
            int randLat = random.Next(-3, 3);

            lat += ((double)randLon) * latDiff;
            lon += ((double)randLat) * lonDiff;

            dbI = new IO.Swagger.DatabaseInterface.DBIncident();
            if (!dbI.AddIncident(message, IncidentType, "[[" + lat.ToString(CultureInfo.InvariantCulture) + "," + lon.ToString(CultureInfo.InvariantCulture) + "]]", 4, "ONGOING", 100, PayLoad, incidentTS, "", "", "", "", "", ref errorMsg, ref newId))
            {
                System.Console.WriteLine("Failed to create incident:" + errorMsg);
            }
            else
            {
                dynamic jmsg = new JObject();
                jmsg.type             = "newincident";
                jmsg.incidentid       = newId;
                jmsg.status           = "ONGOING";
                jmsg.interventionplan = PayLoad;
                jmsg.prio             = 4;
                jmsg.timestamp        = DateTime.Now;
                string strMessage = jmsg.ToString();
                signalRSend("Incidents", strMessage);
            }
        }
        public void ManageDSSIncident(string Topic, string PayLoad)
        {
            if (Topic == "/DSS/Overcrowding")
            {
                dynamic  json       = JValue.Parse(PayLoad);
                DateTime incidentTS = json.inputDataTimestamp;
                foreach (dynamic rec in json.recommendations)
                {
                    string errorMsg = "";
                    long   newId    = 0;
                    string strLat   = rec.latitude.ToString();
                    string strLon   = rec.longitude.ToString();
                    string recom    = rec.recommendation;

                    IO.Swagger.DatabaseInterface.DBIncident dbI = new IO.Swagger.DatabaseInterface.DBIncident();
                    if (!dbI.AddIncident("Over crowded area", "OVERCROWDED", "[[" + strLat + "," + strLon + "]]", 4, "ONGOING", 78.5, PayLoad, incidentTS, "", "", "", "", "", ref errorMsg, ref newId))
                    {
                        System.Console.WriteLine("Failed to create incident:" + errorMsg);
                    }
                    else
                    {
                        dynamic jmsg = new JObject();
                        jmsg.type       = "newincident";
                        jmsg.incidentid = newId;
                        jmsg.status     = "ONGOING";
                        jmsg.prio       = 4;
                        jmsg.timestamp  = DateTime.Now;
                        string strMessage = jmsg.ToString();
                        signalRSend("Incidents", strMessage);
                    }
                }
            }
            else if (Topic == "GOST/Datastreams(43)/Observations")
            {
                dynamic  json       = JValue.Parse(PayLoad);
                DateTime incidentTS = json.phenomenonTime;

                string errorMsg = "";
                long   newId    = 0;
                string strLat   = "0.0";
                string strLon   = "0.0";
                string confStr  = json.result.confidence;
                double conf     = double.Parse(confStr, CultureInfo.InvariantCulture);
                conf *= 100;
                string[] cameraIDs = json.result.camera_ids.ToObject <string[]>();


                IO.Swagger.DatabaseInterface.DBIncident dbI = new IO.Swagger.DatabaseInterface.DBIncident();
                if (!dbI.FindCameraCoords(cameraIDs[0], ref strLat, ref strLon))
                {
                    return;
                }
                if (!dbI.AddIncident("Fight Detected", "FIGHT", "[[" + strLat + "," + strLon + "]]", 4, "ONGOING", conf, PayLoad, incidentTS, "", "", "", "", "", ref errorMsg, ref newId))
                {
                    System.Console.WriteLine("Failed to create incident:" + errorMsg);
                }
                else
                {
                    dynamic jmsg = new JObject();
                    jmsg.type       = "newincident";
                    jmsg.incidentid = newId;
                    jmsg.status     = "ONGOING";
                    jmsg.prio       = 4;
                    jmsg.timestamp  = DateTime.Now;
                    string strMessage = jmsg.ToString();
                    signalRSend("Incidents", strMessage);
                }
            }
        }