Example #1
0
 partial void Deletet_GPS_IN(t_GPS_IN instance);
Example #2
0
 partial void Insertt_GPS_IN(t_GPS_IN instance);
Example #3
0
 partial void Updatet_GPS_IN(t_GPS_IN instance);
Example #4
0
        /// <summary>
        /// Handels the Data recieved and processed in the Message_Received_Processor
        /// Adds the Data to the Database
        /// For Threat-Security
        /// </summary>
        /// <param name="GPSData">THe Data</param>
        public void ProcessRecievedGPSData(string GPSData)
        {
            LogManager.AddLog(DB_PATH, 4, "Reciever.cs:ProcessRecievedGPSData:Start", GPSData);
            try
            {
                String trimedGPSData = GPSData.Trim(new char[] { '!', '$' });
                String[] GPScoords = trimedGPSData.Split(new char[] { ',', '*' });
                DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH);
                if (dataContext.t_Trackers.Count(p => p.IMEI == GPScoords[0]) == 0)
                {
                    t_Tracker t = new t_Tracker();
                    t.IMEI = GPScoords[0];
                    dataContext.t_Trackers.InsertOnSubmit(t);
                    dataContext.SubmitChanges();
                    OnTrackerAddded.Invoke(null, null);
                }
                string yy = GPScoords[3].Substring(4, 2);
                string mm = GPScoords[3].Substring(2, 2);
                string dd = GPScoords[3].Substring(0, 2);
                if (yy != "00" && mm != "00" && dd != "00") //Only save sensefull data
                {
                    DataService.t_GPS_IN new_position = new DataService.t_GPS_IN();
                    new_position.IMEI = GPScoords[0];
                    new_position.Status = Int32.Parse(GPScoords[1]);
                    new_position.GPS_fix = Int32.Parse(GPScoords[2]);
                    new_position.TimestampTracker = new DateTime(
                                            Int32.Parse("20" + yy),
                                            Int32.Parse(mm),
                                            Int32.Parse(dd),
                                            Int32.Parse(GPScoords[4].Substring(0, 2)),
                                            Int32.Parse(GPScoords[4].Substring(2, 2)),
                                            Int32.Parse(GPScoords[4].Substring(4, 2)));
                    new_position.longitude = GPScoords[5];
                    new_position.latitude = GPScoords[6];
                    new_position.altitude = GPScoords[7];
                    new_position.speed = GPScoords[8];
                    new_position.heading = GPScoords[9];
                    new_position.nr_used_sat = Int32.Parse(GPScoords[10]);
                    new_position.HDOP = GPScoords[11];
                    new_position.Timestamp = DateTime.Now;
                    new_position.Processed = false;

                    dataContext.t_GPS_INs.InsertOnSubmit(new_position);
                    dataContext.SubmitChanges();
                }
            }
            catch
            {
                LogManager.AddLog(DB_PATH, 0, "Reciever.cs:ProcessRecievedGPSData:Error", GPSData);
            }
        }