예제 #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);
        }
예제 #2
0
        public Int32 Create(transactions obj)
        {
            EDM edm = new EDM();

            edm.transactions.Add(obj);
            try
            {
                edm.SaveChanges();
                return(obj.id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public bool Delete(transactions obj)
        {
            EDM edm = new EDM();

            edm.Entry(obj).State = System.Data.Entity.EntityState.Deleted;
            try
            {
                edm.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        private void LoadDevice(Int32 intDeviceID)
        {
            List <DisplayGrid> lst = new List <DisplayGrid>();

            DisplayGrid obj    = new DisplayGrid();
            devices     device = new devices();

            device      = device.Read(intDeviceID);
            obj.setting = "Device ID";
            obj.value   = device.id.ToString();
            lst.Add(obj);

            obj         = new DisplayGrid();
            obj.setting = "Device URL name";
            obj.value   = device.device_url_name.ToString();
            lst.Add(obj);

            obj         = new DisplayGrid();
            obj.setting = "Device friendly name";
            obj.value   = device.device_name.ToString();
            lst.Add(obj);

            obj         = new DisplayGrid();
            obj.setting = "Device is retired";
            obj.value   = device.device_retired.ToString();
            lst.Add(obj);

            transactions transactions = new DAL.transactions();

            transactions.transactions_stats stats = transactions.GetDisplayStats(intDeviceID);

            if (stats.SerialNumber != null)
            {
                obj         = new DisplayGrid();
                obj.setting = "Serial number";
                obj.value   = stats.SerialNumber;
                lst.Add(obj);
            }
            if (stats.AndroidID != null)
            {
                obj         = new DisplayGrid();
                obj.setting = "Android ID";
                obj.value   = stats.AndroidID;
                lst.Add(obj);
            }
            if (stats.FirstLog != null)
            {
                obj         = new DisplayGrid();
                obj.setting = "First log date (time)";
                obj.value   = string.Format("{0:dddd, d MMMM yyyy (H:mm:ss)}", stats.FirstLog);
                obj.value  += " (" + CalculateTimeAgo(stats.FirstLog) + ")";
                lst.Add(obj);
            }
            if (stats.LastLog != null)
            {
                obj         = new DisplayGrid();
                obj.setting = "Last log date (time)";
                obj.value   = string.Format("{0:dddd, d MMMM yyyy (H:mm:ss)}", stats.LastLog);
                obj.value  += " (" + CalculateTimeAgo(stats.LastLog) + ")";
                lst.Add(obj);
            }
            if (stats.TotalNumberOfLogs > 0)
            {
                obj         = new DisplayGrid();
                obj.setting = "Total number of logs (all devices)";
                obj.value   = (string.Format("{0:### ### ### ### ### ### ##0}", stats.TotalNumberOfLogs)).Trim();
                lst.Add(obj);
            }
            if (stats.NumberOfLogs > 0)
            {
                obj         = new DisplayGrid();
                obj.setting = "Device logs (this device only)";
                obj.value   = (string.Format("{0:### ### ### ### ### ### ##0}", stats.NumberOfLogs)).Trim();
                lst.Add(obj);
            }
            if (stats.LastLongitude > -1000)
            {
                obj         = new DisplayGrid();
                obj.setting = "Longitude";
                obj.value   = string.Format("{0:##0.0###########}", stats.LastLongitude).Trim();
                lst.Add(obj);
            }
            if (stats.LastLatitude > -1000)
            {
                obj         = new DisplayGrid();
                obj.setting = "LastLatitude";
                obj.value   = string.Format("{0:##0.0###########}", stats.LastLatitude).Trim();
                lst.Add(obj);
            }
            if (stats.Altitude > 0)
            {
                obj         = new DisplayGrid();
                obj.setting = "Altitude";
                obj.value   = string.Format("{0:### ##0}", stats.Altitude).Trim();
                lst.Add(obj);
            }
            if (stats.Speed > 0)
            {
                obj         = new DisplayGrid();
                obj.setting = "Speed";
                obj.value   = string.Format("{0:### ##0}", stats.Speed).Trim();
                lst.Add(obj);
            }
            if (stats.Accuracy > 0)
            {
                obj         = new DisplayGrid();
                obj.setting = "Accuracy";
                obj.value   = string.Format("{0:### ##0}", stats.Accuracy).Trim();
                lst.Add(obj);
            }
            if (stats.Direction > -1)
            {
                obj         = new DisplayGrid();
                obj.setting = "Direction";
                obj.value   = string.Format("{0:##0}", stats.Direction);
                lst.Add(obj);
            }
            if (stats.Provider != "")
            {
                obj         = new DisplayGrid();
                obj.setting = "Location provider";
                obj.value   = stats.Provider;
                lst.Add(obj);
            }
            if (stats.Time_UTC > DateTime.MinValue)
            {
                obj         = new DisplayGrid();
                obj.setting = "Device local date(time)";
                obj.value   = string.Format("{0:dddd, d MMMM yyyy (H:mm:ss)}", stats.Time_UTC);
                lst.Add(obj);
            }
            if (stats.Battery > -1)
            {
                obj         = new DisplayGrid();
                obj.setting = "Battery";
                obj.value   = string.Format("{0:##0}", stats.Battery) + "%";
                lst.Add(obj);
            }

            grdDetail.DataSource = lst;
            grdDetail.DataBind();
        }