/// <summary> /// Return Log Entries /// </summary> /// <param name="DB_Path"></param> /// <param name="Count"></param> /// <returns></returns> public static List<t_Log> GetLogEntries(string DB_Path, int Count) { List<t_Log> Result = new List<t_Log>(); DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); Result = dataContext.t_Logs.Where(p => p.id > dataContext.t_Logs.Max(pp => pp.id) - Count).OrderBy(p => p.id).ToList(); return Result; }
/// <summary> /// Add a Log entry /// </summary> /// <param name="DB_Path">Path of the DB to add the Log</param> /// <param name="Level">Level of the Log 0 = Error, 4 = information</param> /// <param name="Project">Project which throw this log entry</param> /// <param name="Text">Description / Data of this Log</param> public static void AddLog(string DB_Path,int Level, string Project, string Text) { DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); t_Log LogEntry = new t_Log(); LogEntry.level = Level; LogEntry.project = Project; LogEntry.Text = Text; LogEntry.timestamp = DateTime.Now; dataContext.t_Logs.InsertOnSubmit(LogEntry); dataContext.SubmitChanges(); }
/// <summary> /// Imports a DxfFile that is in the specified Format. Any changes on the import schema may cause Errors! /// </summary> /// <param name="filepath"></param> public static void importFromDxf(string filepath, string DB_PATH) { StreamReader sr = new StreamReader(filepath); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); foreach (t_PolygonPoint tp in dataContext.t_PolygonPoints) { dataContext.t_PolygonPoints.DeleteOnSubmit(tp); } ///dataContext.t_PolygonPoints.DeleteAllOnSubmit(dataContext.t_PolygonPoints.ToList()); dataContext.SubmitChanges(); dataContext.t_Polygons.DeleteAllOnSubmit(dataContext.t_Polygons); dataContext.SubmitChanges(); int id = 1; List<string> lineList = new List<string>(); while (!sr.EndOfStream) { lineList.Add(sr.ReadLine()); } string[] lines = lineList.ToArray(); for (int i = 1; i < lines.Length; i++) //Looping through Array, starting with 1 (lines[0] is "0") { //Find Lines Containing a new Element Definition if (lines[i] == "LWPOLYLINE" && lines[i - 1] == " 0") // { //Reading out Layer ( "8" [\n] layerName) = Type of Element if (lines[i + 5] == " 8" && lines[i + 6].Contains("PROH")) // "Prohibited Zone" = ForbiddenZone { if (lines[i + 9] == " 90") { int numberOfVertexes = int.Parse(lines[i + 10]); t_Polygon p = new t_Polygon(); p.ID = id++; for (int j = 0; j < numberOfVertexes; j++) { t_PolygonPoint point = new t_PolygonPoint(); GpsPoint gp = new GpsPoint(double.Parse(lines[i + (j * 4) + 18], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + (j * 4) + 16], NumberFormatInfo.InvariantInfo) * 1000, GpsPointFormatImport.Swiss); point.longitude = (decimal)gp.Longitude; point.latitude = (decimal)gp.Latitude; point.ID_Polygon = p.ID; dataContext.t_PolygonPoints.InsertOnSubmit(point); } dataContext.t_Polygons.InsertOnSubmit(p); } } } } dataContext.SubmitChanges(); }
private void btnAddNewAirplaneToTracker_Click(object sender, EventArgs e) { if (lstTrackers.SelectedItems.Count == 1) { DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); t_Pilot f = new t_Pilot(); f.ID_Tracker = ((TrackerListEntry)lstTrackers.SelectedItems[0]).ID_Tracker; f.LastName = txtPilot.Text; f.SureName = txtAirplane.Text; dataContext.t_Pilots.InsertOnSubmit(f); dataContext.SubmitChanges(); RefreshTrackerList(); } }
private void btnAddAirplaneToTracker_Click(object sender, EventArgs e) { if (lstTrackers.SelectedItems.Count == 1 && drpAirplane.SelectedItem != null) { TrackerListEntry tle = (TrackerListEntry)lstTrackers.SelectedItems[0]; DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); foreach (t_Pilot f in dataContext.t_Pilots.Where(p => p.ID_Tracker == tle.ID_Tracker)) { f.ID_Tracker = 0; } t_Pilot fl = dataContext.t_Pilots.Single(p=>p.ID == ((AirplaneListEntry)drpAirplane.SelectedItem).ID); fl.ID_Tracker = tle.ID_Tracker; dataContext.SubmitChanges(); RefreshTrackerList(); } }
/// <summary> /// /// </summary> /// <param name="LastName"></param> /// <param name="SureName"></param> /// <param name="Color"></param> /// <returns></returns> public int AddNewPilot(String LastName, String SureName, String Color, byte[] Picture, int Id_Flag) { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:AddNewAirplane", LastName + SureName); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); t_Pilot f = new t_Pilot(); f.LastName = LastName; f.SureName = SureName; f.Color = Color; f.Picture = new System.Data.Linq.Binary(Picture); f.ID_Flag = Id_Flag; dataContext.t_Pilots.InsertOnSubmit(f); dataContext.SubmitChanges(); return f.ID; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:AddNewPilot", ex.ToString()); } return -1; }
/// <summary> /// Add Existim Pilot, may be modified /// </summary> /// <param name="PilotID"></param> /// <param name="TrackerID"></param> /// <param name="LastName"></param> /// <param name="SureName"></param> /// <param name="Color"></param> public void AddPilot(int PilotID, int TrackerID, String LastName, String SureName, String Color, byte[] Picture, int Id_Flag) { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:AddAirplane", PilotID.ToString() + " " + TrackerID.ToString()); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); foreach (t_Pilot f in dataContext.t_Pilots.Where(p => p.ID_Tracker == TrackerID)) { f.ID_Tracker = 0; } t_Pilot fl = dataContext.t_Pilots.Single(p => p.ID == PilotID); fl.LastName = LastName; fl.SureName = SureName; fl.Color = Color; fl.ID_Tracker = TrackerID; fl.Picture = new System.Data.Linq.Binary(Picture); fl.ID_Flag = Id_Flag; dataContext.SubmitChanges(); } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:AddPilot", ex.ToString()); } }
/// <summary> /// Remove the Race /// </summary> /// <param name="Race_ID">Remove Race</param> /// <returns></returns> public void RemoveRace(int Race_ID) { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:RemoveRace", Race_ID.ToString()); DatabaseDataContext context = new DatabaseDataContext(DB_PATH); context.t_Races.DeleteOnSubmit(context.t_Races.Single(p => p.ID == Race_ID)); context.SubmitChanges(); } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:RemoveRace", ex.ToString()); } }
/// <summary> /// Return a list of all Airplanes /// </summary> /// <returns>List of Airplanes</returns> public List<t_Pilot> GetPilots() { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetAirplanes", ""); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_Pilot> tmp = new List<t_Pilot>(); foreach (t_Pilot f in dataContext.t_Pilots) { t_Pilot pilo = new t_Pilot(); pilo.ID = f.ID; pilo.ID_Tracker = f.ID_Tracker; pilo.LastName = f.LastName; pilo.SureName = f.SureName; pilo.Color = f.Color; pilo.Picture = f.Picture; pilo.ID_Flag = f.ID_Flag; tmp.Add(pilo); } return tmp; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPilots", ex.ToString()); } return null; }
/// <summary> /// Get All Timestamps of recorsd in the DB for Delay /// </summary> /// <returns>List of Datetime Timestamps</returns> public List<DateTime> GetTimestamps() { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetTimestamps", ""); List<DateTime> timestamplist = new List<DateTime>(); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); foreach (t_Daten row in dataContext.t_Datens) { timestamplist.Add((DateTime)row.Timestamp); } return timestamplist; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetTimestamps", ex.ToString()); } return null; }
/// <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; }
/// <summary> /// Return a list of all Racecs /// </summary> /// <returns>List of Racecs</returns> public List<t_Race> GetRaces() { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetRaces", ""); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_Race> tmp = new List<t_Race>(); foreach (t_Race r in dataContext.t_Races) { t_Race race = new t_Race(); race.ID = r.ID; race.ID_Pilot_0 = r.ID_Pilot_0; race.ID_Pilot_1 = r.ID_Pilot_1; race.ID_Pilot_2 = r.ID_Pilot_2; race.ID_Pilot_3 = r.ID_Pilot_3; race.ID_PolygonGroup = r.ID_PolygonGroup; race.Name = r.Name; race.TimeEnd = r.TimeEnd; race.TimeStart = r.TimeStart; tmp.Add(race); } return tmp; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetRaces", ex.ToString()); } return null; }
private void RefreshTrackerList() { LogManager.AddLog(DB_Path, 4, "ControllCenter.cs:RefreshTrackerList", "Start"); DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); lstTrackers.Items.Clear(); foreach (t_Tracker t in dataContext.t_Trackers) { TrackerListEntry tle = new TrackerListEntry(t.ID, t.IMEI); #region Check airplanes attached ? //Remove GPS-Trackers if added to may Airplanes int Count = dataContext.t_Pilots.Count(p => p.ID_Tracker == t.ID); if (Count > 1) { foreach (t_Pilot f in dataContext.t_Pilots.Where(p => p.ID_Tracker == t.ID)) { f.ID_Tracker = 0; } dataContext.SubmitChanges(); } else if (Count == 1) { t_Pilot f = dataContext.t_Pilots.Single(p=>p.ID_Tracker==t.ID); tle.ID_Pilot = f.ID; tle.SureName = f.SureName; tle.LastName = f.LastName; } #endregion tle.Set(); lstTrackers.Items.Add(tle); } drpAirplane.Items.Clear(); foreach (t_Pilot f in dataContext.t_Pilots.Where(p=>p.ID_Tracker == 0)) { drpAirplane.Items.Add(new AirplaneListEntry(f)); } CheckButtons(); LogManager.AddLog(DB_Path, 4, "ControllCenter.cs:RefreshTrackerList", "Ende"); }
/// <summary> /// List of all PolygonPoints /// </summary> /// <returns>List of PolygonPoints</returns> public List<t_PolygonPoint> GetPolygons() { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetPolygons", ""); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_PolygonPoint> tmp = new List<t_PolygonPoint>(); t_PolygonPoint tmp_t_PolygonPoint; foreach (t_PolygonPoint t in dataContext.t_PolygonPoints) { tmp_t_PolygonPoint = new t_PolygonPoint(); tmp_t_PolygonPoint.ID = t.ID; tmp_t_PolygonPoint.latitude = t.latitude; tmp_t_PolygonPoint.altitude = t.altitude; tmp_t_PolygonPoint.longitude = t.longitude; tmp_t_PolygonPoint.ID_Polygon = t.ID_Polygon; tmp.Add(tmp_t_PolygonPoint); } return tmp; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPolygons", ex.ToString()); } return null; }
/// <summary> /// /// </summary> /// <param name="ID_PolygonGroup"></param> /// <returns></returns> public List<t_Polygon> GetPolygonsByGroup(int ID_PolygonGroup) { try { DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_Polygon> Result = new List<t_Polygon>(); foreach (t_Polygon p in dataContext.t_Polygons.Where(p => p.ID_PolygonGroup == ID_PolygonGroup)) { t_Polygon tmp = new t_Polygon(); tmp.ID = p.ID; tmp.ID_PolygonGroup = p.ID_PolygonGroup; tmp.Type = p.Type; Result.Add(tmp); } return Result; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPolygonsByGroup", ex.ToString()); } return null; }
private void btnRemvAirplaneFromTracker_Click(object sender, EventArgs e) { if (lstTrackers.SelectedItems.Count == 1) { TrackerListEntry tle = (TrackerListEntry)lstTrackers.SelectedItems[0]; DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); foreach (t_Pilot f in dataContext.t_Pilots.Where(p => p.ID_Tracker == tle.ID_Tracker)) { f.ID_Tracker = 0; } dataContext.SubmitChanges(); } RefreshTrackerList(); }
void of_FileOk(object sender, CancelEventArgs e) { OpenFileDialog of = sender as OpenFileDialog; if (of != null) { DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); dataContext.t_Pictures.DeleteAllOnSubmit(dataContext.t_Pictures.Where(p => p.isFlag)); dataContext.SubmitChanges(); foreach (String s in of.FileNames) { FileStream fs = File.OpenRead(s); List<Byte> lb = new List<Byte>(); lb.Clear(); int b; while ((b = fs.ReadByte()) >= 0) { lb.Add((Byte)b); } t_Picture p = new t_Picture(); p.isFlag = true; String[] Name = s.Split(new char[]{'\\'}); p.Name = Name[Name.Length - 1].Split(new char[] {'.'})[0]; if (p.Name.Contains("flag_")) { p.Name = p.Name.Substring(5); } p.Data = new Binary(lb.ToArray()); fs.Close(); dataContext.t_Pictures.InsertOnSubmit(p); dataContext.SubmitChanges(); } dataContext.SubmitChanges(); } }
/// <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); } }
/// <summary> /// /// </summary> /// <param name="IntervallStart"></param> /// <param name="IntervallEnd"></param> /// <returns></returns> public List<t_Daten> GetPathData(DateTime IntervallStart, DateTime IntervallEnd) { try { DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetPathData", IntervallStart.ToString() + " " + IntervallEnd.ToString()); //@todo ... add delay for anti-cheating-reasons if () { } List<t_Daten> tmp = new List<t_Daten>(); t_Daten tmp_t_Daten = new t_Daten(); foreach (t_Daten t in dataContext.t_Datens.Where(d => d.Timestamp >= IntervallStart && d.Timestamp < IntervallEnd)) { tmp_t_Daten = new t_Daten(); tmp_t_Daten.ID = t.ID; tmp_t_Daten.Timestamp = t.Timestamp; tmp_t_Daten.Latitude = t.Latitude; tmp_t_Daten.Longitude = t.Longitude; tmp_t_Daten.Altitude = t.Altitude; tmp_t_Daten.Speed = t.Speed; tmp_t_Daten.Penalty = t.Penalty; tmp_t_Daten.ID_Polygon = t.ID_Polygon; tmp_t_Daten.ID_Tracker = t.ID_Tracker; tmp.Add(tmp_t_Daten); } return tmp; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPathData", ex.ToString()); } return null; }
/// <summary> /// /// </summary> /// <param name="ID_Polygon"></param> /// <returns></returns> public List<t_Picture> GetAllFlags() { try { DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_Picture> Result = new List<t_Picture>(); foreach (t_Picture p in dataContext.t_Pictures.Where(p => p.isFlag)) { t_Picture tmp = new t_Picture(); tmp.id = p.id; tmp.isFlag = p.isFlag; tmp.Name = p.Name; tmp.Data = new System.Data.Linq.Binary(p.Data.ToArray()); Result.Add(tmp); } return Result; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetAllFlags", ex.ToString()); } return null; }
/// <summary> /// Remove this Tracker from any Airplane /// </summary> /// <param name="TrackerID"> ID of the Tracker</param> public void CleanTracker(int TrackerID) { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:CleanTracker", TrackerID.ToString()); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); foreach (t_Pilot f in dataContext.t_Pilots.Where(p => p.ID_Tracker == TrackerID)) { f.ID_Tracker = 0; } dataContext.SubmitChanges(); } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:CleanTracker", ex.ToString()); } }
/// <summary> /// /// </summary> /// <param name="Race"></param> public void AddRace(t_Race Race) { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:AddRace", ""); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); t_PolygonGroup PolygonGroup = new t_PolygonGroup(); #region Polygongroup & Polygons & PolygonPoints if (Race.t_PolygonGroup != null) { if (Race.ID_PolygonGroup == 0) { PolygonGroup.Name = Race.t_PolygonGroup.Name; dataContext.t_PolygonGroups.InsertOnSubmit(PolygonGroup); dataContext.SubmitChanges(); if (Race.t_PolygonGroup.t_Polygons.Count > 0) { foreach (t_Polygon poly in Race.t_PolygonGroup.t_Polygons) { t_Polygon tmp_poly = new t_Polygon(); tmp_poly.Type = poly.Type; tmp_poly.ID_PolygonGroup = PolygonGroup.ID; dataContext.t_Polygons.InsertOnSubmit(tmp_poly); dataContext.SubmitChanges(); foreach (t_PolygonPoint pp in poly.t_PolygonPoints) { t_PolygonPoint tmpPoint = new t_PolygonPoint(); tmpPoint.ID_Polygon = tmp_poly.ID; tmpPoint.longitude = pp.longitude; tmpPoint.latitude = pp.latitude; tmpPoint.altitude = pp.altitude; dataContext.t_PolygonPoints.InsertOnSubmit(tmpPoint); } } } } else { PolygonGroup.ID = (int)Race.ID_PolygonGroup; } dataContext.SubmitChanges(); } #endregion t_Race r = new t_Race(); if (Race.ID_Pilot_0 != 0) r.ID_Pilot_0 = Race.ID_Pilot_0; if (Race.ID_Pilot_1 != 0) r.ID_Pilot_1 = Race.ID_Pilot_1; if (Race.ID_Pilot_2 != 0) r.ID_Pilot_2 = Race.ID_Pilot_2; if (Race.ID_Pilot_3 != 0) r.ID_Pilot_3 = Race.ID_Pilot_3; if (Race.ID_PolygonGroup != 0) { r.ID_PolygonGroup = Race.ID_PolygonGroup; } else { r.ID_PolygonGroup = PolygonGroup.ID; } r.Name = Race.Name; r.TimeEnd = Race.TimeEnd; r.TimeStart = Race.TimeStart; dataContext.t_Races.InsertOnSubmit(r); dataContext.SubmitChanges(); LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:AddRace", "Sucessfull Added " + r.ID); } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:AddRace", ex.ToString()); } }
/// <summary> /// Calculate the Tables of t_Data and Insert all needed Entries /// Will be trigered form a 1 sec-Timer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CalculateTabels_Elapsed(object sender, ElapsedEventArgs e) { try { DataService.DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_GPS_IN> Positions = dataContext.t_GPS_INs.Where(a => !a.Processed).OrderBy(t => t.TimestampTracker).ToList(); List<t_Tracker> Trackers = dataContext.t_Trackers.ToList(); if (Positions.Count > 0)LogManager.AddLog(DB_PATH, 4, "RecieverService.cs:CalculateTabels_Elapsed:Lists","Positions.Count=" + Positions.Count + " Trackers.count=" + Trackers.Count); foreach (t_Tracker tr in Trackers) { List<t_GPS_IN> Positions_Tracker = Positions.Where(a => a.IMEI == tr.IMEI).OrderBy(a => a.TimestampTracker).ToList(); foreach (t_GPS_IN GPS_IN in Positions_Tracker) { t_Daten InsertData = new t_Daten(); InsertData.ID_Tracker = tr.ID; InsertData.Timestamp = GPS_IN.TimestampTracker; InsertData.Latitude = decimal.Round(ConvertCoordinates(GPS_IN.latitude), 16); InsertData.Longitude = decimal.Round(ConvertCoordinates(GPS_IN.longitude), 16); InsertData.Altitude = decimal.Parse(GPS_IN.altitude); dataContext.t_Datens.InsertOnSubmit(InsertData); GPS_IN.Processed = true; } } dataContext.SubmitChanges(); } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "RecieverService.cs:CalculateTabels_Elapsed:Error", ex.ToString()); } }
/// <summary> /// Return a list of all Racecs /// </summary> /// <returns>List of Racecs</returns> public List<t_PolygonGroup> GetPolygonGroup() { try { LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetParcours", ""); DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_PolygonGroup> tmp = new List<t_PolygonGroup>(); foreach (t_PolygonGroup pg in dataContext.t_PolygonGroups) { t_PolygonGroup tmppg = new t_PolygonGroup(); tmppg.ID = pg.ID; tmppg.Name = pg.Name; tmp.Add(tmppg); } return tmp; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPolygonGroup", ex.ToString()); } return null; }
/// <summary> /// /// </summary> /// <param name="ID_Polygon"></param> /// <returns></returns> public List<t_PolygonPoint> GetPolygonPoints(int ID_Polygon) { try { DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH); List<t_PolygonPoint> Result = new List<t_PolygonPoint>(); foreach (t_PolygonPoint p in dataContext.t_PolygonPoints.Where(p => p.ID_Polygon == ID_Polygon)) { t_PolygonPoint tmp = new t_PolygonPoint(); tmp.ID = p.ID; tmp.ID_Polygon = p.ID_Polygon; tmp.latitude = p.latitude; tmp.longitude = p.longitude; tmp.altitude = p.altitude; Result.Add(tmp); } return Result; } catch (Exception ex) { LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPolygonPoints", ex.ToString()); } return null; }
void fp_FileOk(object sender, CancelEventArgs e) { LogManager.AddLog(DB_Path, 4, "ControllCenter.cs:fp_FileOk", "Start"); OpenFileDialog f = (OpenFileDialog)sender; String DxfFilePath = f.FileName; StatusForm ef = new StatusForm(); ef.label1.Text = "Bitte warte, Penaltyzonen werden geladen."; ef.Show(); ef.Refresh(); try { ImportPenaltyZones.importFromDxf(DxfFilePath, DB_Path); DatabaseDataContext dataContext = new DatabaseDataContext(DB_Path); int count = dataContext.t_Polygons.Count(); lblPenaltyZonenLoaded.Text = count.ToString() + " Penalty Zonen geladen"; ef.Close(); LogManager.AddLog(DB_Path, 4, "ControllCenter.cs:fp_FileOk", "Ende"); } catch (Exception ex) { LogManager.AddLog(DB_Path,0, "ControllCenter.cs:fp_FileOk:Error", ex.ToString()); ef.Close(); MessageBox.Show("Fehler beim laden der Penalty-Zonen"); } }