Пример #1
0
        private devices SelectDevice(int id)
        {
            devices devices = new devices();

            devices.Read(id);
            return(devices);
        }
Пример #2
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();
        }