コード例 #1
0
ファイル: Database.designer.cs プロジェクト: helios57/anrl
 partial void Deletet_Tracker(t_Tracker instance);
コード例 #2
0
ファイル: Database.designer.cs プロジェクト: helios57/anrl
 partial void Updatet_Tracker(t_Tracker instance);
コード例 #3
0
ファイル: Reciever.cs プロジェクト: helios57/anrl
        /// <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);
            }
        }
コード例 #4
0
ファイル: Database.designer.cs プロジェクト: helios57/anrl
 partial void Insertt_Tracker(t_Tracker instance);
コード例 #5
0
ファイル: ANRLDataService.svc.cs プロジェクト: helios57/anrl
 /// <summary>
 /// Return a list of all Trackers
 /// </summary>
 /// <returns>List of Trackers</returns>
 public List<t_Tracker> GetTrackers()
 {
     try
     {
         LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetTrackers", "");
         DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH);
         List<t_Tracker> lstTrackers = new List<t_Tracker>();
         foreach (t_Tracker t in dataContext.t_Trackers)
         {
             t_Tracker tle = new t_Tracker();
             tle.ID = t.ID;
             tle.IMEI = t.IMEI.Trim();
             lstTrackers.Add(tle);
         }
         return lstTrackers;
     }
     catch (Exception ex)
     {
         LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetTrackers", ex.ToString());
     }
     return null;
 }