public List <owners> List() { EDM edm = new EDM(); var prog = from tb in edm.owners.AsNoTracking() orderby tb.owner select tb; return(prog.ToList()); }
public List <devices> List() { EDM edm = new EDM(); var prog = from tb in edm.devices.AsNoTracking() orderby tb.device_name select tb; return(prog.ToList()); }
public List <logs> List() { EDM edm = new EDM(); var prog = from tb in edm.logs.AsNoTracking() orderby tb.time_utc select tb; return(prog.ToList()); }
public List <transactions> List() { EDM edm = new EDM(); var prog = from tb in edm.transactions.AsNoTracking() orderby tb.date_time select tb; return(prog.ToList()); }
public transactions_stats GetDisplayStats(Int32 intDeviceID) { transactions_stats result = new transactions_stats(); EDM edm = new EDM(); int intTotalTransactionCount = (from tb in edm.transactions.AsNoTracking() select tb).Count(); int intTransactionCount = (from tb in edm.transactions.AsNoTracking() where tb.devices_id == intDeviceID select tb).Count(); transactions transaction = (from tb in edm.transactions.AsNoTracking() where tb.devices_id == intDeviceID orderby tb.date_time descending select tb).FirstOrDefault(); DateTime dtFirstLog = (from tb in edm.transactions.AsNoTracking() where tb.devices_id == intDeviceID orderby tb.date_time ascending select tb.date_time).FirstOrDefault(); if (transaction == null) { return(null); } result.LastLog = transaction.date_time; result.FirstLog = dtFirstLog; result.NumberOfLogs = intTransactionCount; result.TotalNumberOfLogs = intTotalTransactionCount; logs logs = new logs(); logs log = (from tb in edm.logs.AsNoTracking() where tb.id == transaction.logs_id select tb).Single(); result.Accuracy = log.accuracy; result.Altitude = log.altitude; result.AndroidID = log.androidid; result.Battery = log.battery; result.Direction = log.direction; result.LastAltitude = log.altitude; result.LastLatitude = log.latitude; result.LastLongitude = log.longitude; result.Provider = log.provider; result.Satellites = log.satellites; result.SerialNumber = log.serial; result.Speed = log.speed; result.Time_UTC = log.time_utc; result.URL = log.url; return(result); }
public devices Read(Int32 id) { EDM edm = new EDM(); var prog = from tb in edm.devices.AsNoTracking() where tb.id == id select tb; if (prog.ToList().Count() > 0) { return(prog.ToList()[0]); } return(null); }
public bool Delete(devices obj) { EDM edm = new EDM(); edm.Entry(obj).State = System.Data.Entity.EntityState.Deleted; try { edm.SaveChanges(); return(true); } catch (Exception ex) { throw ex; } }
public Int32 Create(devices obj) { EDM edm = new EDM(); edm.devices.Add(obj); try { edm.SaveChanges(); return(obj.id); } catch (Exception ex) { throw ex; } }
public bool Update(logs obj) { EDM edm = new EDM(); edm.Entry(obj).State = System.Data.Entity.EntityState.Modified; try { edm.SaveChanges(); return(true); } catch (Exception ex) { throw ex; } }
public List <History> GetLastHit(Int32 intDeviceID) { EDM edm = new EDM(); var prog = (from tr in edm.transactions.AsNoTracking() join lg in edm.logs.AsNoTracking() on tr.logs_id equals lg.id where (tr.devices_id == intDeviceID) orderby tr.date_time descending select new History { latitude = lg.latitude, longitude = lg.longitude }).Take(1); if (prog.Count() != 1) { return(null); } return(prog.ToList()); }
public List <History> GetHistory(Int32 intDeviceID, DateTime dtStartDate, DateTime dtEndDate, bool booSmartFilter = true) { EDM edm = new EDM(); var prog = from tr in edm.transactions.AsNoTracking() join lg in edm.logs.AsNoTracking() on tr.logs_id equals lg.id where ((tr.devices_id == intDeviceID) && (tr.date_time <= dtEndDate) && (tr.date_time >= dtStartDate)) orderby tr.date_time select new History { latitude = lg.latitude, longitude = lg.longitude }; if (prog.Count() > 0) { if (booSmartFilter) { return(ApplyFilter(prog.ToList())); } else { return(prog.ToList()); } } return(null); }
private string MapWithMarkersOnly() { List <DisplayItems> lst = new List <DisplayItems>(); EDM edm = new EDM(); var prog = from tb in edm.GetLastOfEach() select new DisplayItems { device_id = (int)tb.device_id, log_date_time = tb.date_time.ToString(), location_provider = tb.provider, battery = (int)tb.battery, device = tb.device_name, latitude = (decimal)tb.latitude, longitude = (decimal)tb.longitude }; lst = prog.ToList(); StringBuilder builder = new StringBuilder(); builder.Append(MakeLine("<script src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>")); builder.Append(MakeLine("<script src=\"http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.1.min.js\"></script>")); builder.Append(MakeLine("<script type=\"text/javascript\">")); builder.Append(MakeLine("var locations = [")); builder.Append(MakeLine(AddAllMarkers(lst))); builder.Append(MakeLine("];")); builder.Append(MakeLine("var map = new google.maps.Map(document.getElementById('map'), {")); builder.Append(MakeLine("zoom: 5,")); builder.Append(MakeLine("center: new google.maps.LatLng(51.530616, -0.123125),")); builder.Append(MakeLine("mapTypeId: google.maps.MapTypeId.ROADMAP")); builder.Append(MakeLine("});")); builder.Append(MakeLine("var infowindow = new google.maps.InfoWindow();")); builder.Append(MakeLine("var marker, i;")); builder.Append(MakeLine("var markers = new Array();")); builder.Append(MakeLine("for (i = 0; i < locations.length; i++) { ")); builder.Append(MakeLine("marker = new google.maps.Marker({")); builder.Append(MakeLine("position: new google.maps.LatLng(locations[i][1], locations[i][2]),")); builder.Append(MakeLine("map: map")); builder.Append(MakeLine("});")); builder.Append(MakeLine("markers.push(marker);")); builder.Append(MakeLine("google.maps.event.addListener(marker, 'click', (function(marker, i) {")); builder.Append(MakeLine("return function() {")); builder.Append(MakeLine("infowindow.setContent(locations[i][0]);")); builder.Append(MakeLine("infowindow.open(map, marker);")); builder.Append(MakeLine("}")); builder.Append(MakeLine("})(marker, i));")); builder.Append(MakeLine("}")); builder.Append(MakeLine("function AutoCenter() {")); builder.Append(MakeLine("// Create a new viewpoint bound")); builder.Append(MakeLine("var bounds = new google.maps.LatLngBounds();")); builder.Append(MakeLine("// Go through each...")); builder.Append(MakeLine("$.each(markers, function (index, marker) {")); builder.Append(MakeLine("bounds.extend(marker.position);")); builder.Append(MakeLine("});")); builder.Append(MakeLine("// Fit these bounds to the map")); builder.Append(MakeLine("map.fitBounds(bounds);")); builder.Append(MakeLine("}")); builder.Append(MakeLine("AutoCenter();")); builder.Append(MakeLine("</script>")); return(builder.ToString()); }