Beispiel #1
0
        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);
        }
Beispiel #2
0
        public bool Delete(logs obj)
        {
            EDM edm = new EDM();

            edm.Entry(obj).State = System.Data.Entity.EntityState.Deleted;
            try
            {
                edm.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public Int32 Create(logs obj)
        {
            EDM edm = new EDM();

            edm.logs.Add(obj);
            try
            {
                edm.SaveChanges();
                return(obj.id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }