Beispiel #1
0
 protected override SolarNetwork Extract(ICursor cursor) => new SolarNetwork()
 {
     ID         = cursor.GetInt(cursor.GetColumnIndex(ID)),
     Name       = cursor.GetString(cursor.GetColumnIndex(Name)),
     Latitude   = cursor.GetDouble(cursor.GetColumnIndex(Latitude)),
     Longtitude = cursor.GetDouble(cursor.GetColumnIndex(Longtitude))
 };
Beispiel #2
0
        //Retrive All Details
        public IList <InfoMedica> GetAllInfoMedica(string idPersonal)
        {
            SQLiteDatabase db = this.ReadableDatabase;
            ICursor        c  = db.Query("InfoMedica", new string[] { "id", "idPersona", "identificacion", "peso", "altura", "presionArterial", "frecuenciaCardiaca", "detalle" }, "idPersona =  " + idPersonal, null, null, null, null);

            var infoMedica = new List <InfoMedica>();

            while (c.MoveToNext())
            {
                infoMedica.Add(new InfoMedica {
                    id                 = c.GetInt(0),
                    idPersona          = Int32.Parse(c.GetString(1)),
                    identificacion     = c.GetString(2),
                    peso               = c.GetDouble(3),
                    altura             = c.GetDouble(4),
                    presionArterial    = c.GetString(5),
                    frecuenciaCardiaca = c.GetString(6),
                    detalle            = c.GetString(7)
                });
            }

            c.Close();
            db.Close();
            return(infoMedica);
        }
Beispiel #3
0
 protected override Consumer Extract(ICursor cursor) => new Consumer()
 {
     ID                = cursor.GetInt(cursor.GetColumnIndex(ID)),
     NetworkID         = cursor.GetInt(cursor.GetColumnIndex(NetworkID)),
     Name              = cursor.GetString(cursor.GetColumnIndex(Name)),
     Icon              = cursor.GetString(cursor.GetColumnIndex(Icon)),
     EnergyConsumation = cursor.GetDouble(cursor.GetColumnIndex(EnergyConsumation)),
     UsageHours        = cursor.GetDouble(cursor.GetColumnIndex(UsageHours)),
     Count             = cursor.GetInt(cursor.GetColumnIndex(Count))
 };
Beispiel #4
0
 protected override Panel Extract(ICursor cursor) => new Panel()
 {
     ID         = cursor.GetInt(cursor.GetColumnIndex(ID)),
     NetworkID  = cursor.GetInt(cursor.GetColumnIndex(NetworkID)),
     ModuleType = (PanelModuleType)cursor.GetInt(cursor.GetColumnIndex(ModuleType)),
     ArrayType  = (PanelArrayType)cursor.GetInt(cursor.GetColumnIndex(ArrayType)),
     TiltAngle  = cursor.IsNull(cursor.GetColumnIndex(TiltAngle))
                         ? null : new double?(cursor.GetDouble(cursor.GetColumnIndex(TiltAngle))),
     SystemLosses = cursor.GetDouble(cursor.GetColumnIndex(SystemLosses)),
     PowerRating  = cursor.GetDouble(cursor.GetColumnIndex(PowerRating)),
     Count        = cursor.GetInt(cursor.GetColumnIndex(Count))
 };
        internal override void LoadCursor(ICursor cursor, MediaAssetQueryHelper helper)
        {
            base.LoadCursor(cursor, helper);

            if (helper.DateTakenColumn > -1)
            {
                TakenDate = DateTimeOffset.FromUnixTimeMilliseconds(cursor.GetLong(helper.DateTakenColumn)).DateTime;
            }

            if (helper.WidthColumn > -1)
            {
                Width = cursor.GetInt(helper.WidthColumn);
            }

            if (helper.HeightColumn > -1)
            {
                Height = cursor.GetInt(helper.HeightColumn);
            }

            if (helper.LatitudeColumn > -1)
            {
                Latitude = cursor.GetDouble(helper.LatitudeColumn);
            }

            if (helper.LongitudeColumn > -1)
            {
                Longitude = cursor.GetDouble(helper.LongitudeColumn);
            }

            if (helper.OrientationColumn > -1)
            {
                switch (cursor.GetInt(helper.OrientationColumn))
                {
                case 90:
                    Orientation = MediaFileImageOrientation.Left;
                    break;

                case 180:
                    Orientation = MediaFileImageOrientation.Down;
                    break;

                case 270:
                    Orientation = MediaFileImageOrientation.Right;
                    break;

                default:
                    Orientation = MediaFileImageOrientation.Up;
                    break;
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// This is where we fill-in the views with the contents of the cursor.
        /// </summary>
        /// <param name="view">View.</param>
        /// <param name="context">Context.</param>
        /// <param name = "cursor"></param>
        public override void BindView(View view, Context context, ICursor cursor)
        {
            // our view is pretty simple here --- just a text view
            // we'll keep the UI functional with a simple (and slow!) binding.
            var viewHolder = (ViewHolder)view.Tag;

            int viewType = GetItemViewType(cursor.Position);

            switch (viewType)
            {
            case ViewTypeToday:
            {
                // Get weather icon
                viewHolder.IconView.SetImageResource(Utility.GetArtResourceForWeatherCondition(
                                                         cursor.GetInt(ForecastFragment.ColWeatherConditionId)));
                break;
            }

            case ViewTypeFutureDay:
            {
                // Get weather icon
                viewHolder.IconView.SetImageResource(Utility.GetIconResourceForWeatherCondition(
                                                         cursor.GetInt(ForecastFragment.ColWeatherConditionId)));
                break;
            }
            }

            // TODO Read date from cursor
            var date = cursor.GetLong(ForecastFragment.ColWeatherDate);

            viewHolder.DateView.Text = Utility.GetFriendlyDayString(context, date);

            // TODO Read weather forecast from cursor
            var description = cursor.GetString(ForecastFragment.ColWeatherDesc);

            viewHolder.DescriptionView.Text = description;

            // For accessibility, add a content description to the icon field
            viewHolder.IconView.ContentDescription = description;

            // Read high temperature from cursor
            double high = cursor.GetDouble(ForecastFragment.ColWeatherMaxTemp);

            viewHolder.HighTempView.Text = Utility.FormatTemperature(context, high);

            // TODO Read low temperature from cursor
            double low = cursor.GetDouble(ForecastFragment.ColWeatherMinTemp);

            viewHolder.LowTempView.Text = Utility.FormatTemperature(context, low);
        }
Beispiel #7
0
        public List <Prato> listar()
        {
            List <Prato> lista = new List <Prato>();

            String sql = "Select * from " + TABELA + " ORDER BY nome";

            ICursor cursor = ReadableDatabase.RawQuery(sql, null);

            try
            {
                while (cursor.MoveToNext())
                {
                    Prato prat = new Prato();

                    prat.ID    = cursor.GetLong(0);
                    prat.Nome  = cursor.GetString(1);
                    prat.Valor = cursor.GetDouble(2);
                    lista.Add(prat);
                }
            }
            catch (SQLException e)
            {
                Log.Error(TAG, e.Message);
            }
            finally
            {
                cursor.Close();
            }

            return(lista);
        }
        public List <LatLng> RetrieveMarkerList()
        {
            string[] columns =
            {
                MapMarkerContract.MarkerTable._ID,
                MapMarkerContract.MarkerTable.COLUMN_NAME_LAT,
                MapMarkerContract.MarkerTable.COLUMN_NAME_LONG
            };

            ICursor       cursor     = ReadableDatabase.Query(MapMarkerContract.MarkerTable.TABLE_NAME, columns, null, null, null, null, null);
            List <LatLng> markerList = new List <LatLng>();

            while (cursor.MoveToNext())
            {
                markerList.Add(new LatLng(cursor.GetDouble(cursor.GetColumnIndex(MapMarkerContract.MarkerTable.COLUMN_NAME_LAT)),
                                          cursor.GetDouble(cursor.GetColumnIndex(MapMarkerContract.MarkerTable.COLUMN_NAME_LONG))));
            }

            return(markerList);
        }
        public override void BindView(View view, Context context, ICursor cursor)
        {
            view.FindViewById <TextView>(Resource.Id.note).Text = cursor.GetString(1);
            view.FindViewById <TextView>(Resource.Id.date).Text = cursor.GetString(2);
            ImageView i = view.FindViewById <ImageView> (Resource.Id.photo);

            i.SetImageBitmap(Utils.GetPreview(cursor.GetString(3), PreviewWidth, PreviewHeigth));
            double n = cursor.GetDouble(4);

            view.FindViewById <TextView> (Resource.Id.location).Text = string.Format("{0}, {1}", cursor.GetDouble(4), cursor.GetDouble(5));
        }
Beispiel #10
0
        internal override void LoadCursor(ICursor cursor, MediaAssetQueryHelper helper)
        {
            base.LoadCursor(cursor, helper);

            if (helper.DateTakenColumn > -1)
            {
                TakenDate = DateTimeOffset.FromUnixTimeMilliseconds(cursor.GetLong(helper.DateTakenColumn)).DateTime;
            }

            if (helper.WidthColumn > -1)
            {
                Width = cursor.GetInt(helper.WidthColumn);
            }

            if (helper.HeightColumn > -1)
            {
                Height = cursor.GetInt(helper.HeightColumn);
            }

            if (helper.LatitudeColumn > -1)
            {
                Latitude = cursor.GetDouble(helper.LatitudeColumn);
            }

            if (helper.LongitudeColumn > -1)
            {
                Longitude = cursor.GetDouble(helper.LongitudeColumn);
            }

            if (helper.DurationColumn > -1)
            {
                Duration = TimeSpan.FromMilliseconds(cursor.GetLong(helper.DurationColumn));
            }

            if (helper.ArtistColumn > -1)
            {
                Artist = cursor.GetString(helper.ArtistColumn);
            }
        }
Beispiel #11
0
        public string LookForSms(DateTime ahora)
        {
            bool   receiveSms = false;
            string codigo     = "";

            Android.Net.Uri inboxURI = Android.Net.Uri.Parse("content://sms/inbox");
            // Esperar sms
            while (!receiveSms)
            {
                if (ahora.AddMinutes(2) < DateTime.UtcNow)
                {
                    receiveSms = true;
                    codigo     = "Ha habido un error";
                    break;
                }
                ContentResolver cr     = this.ContentResolver;
                ICursor         cursor = cr.Query(inboxURI, null, null, null, null);
                cursor.MoveToFirst();
                double date = cursor.GetDouble(cursor.GetColumnIndex("date"));
                var    time = (new DateTime(1970, 1, 1)).AddMilliseconds(date);

                if (cursor != null && cursor.Count > 0)
                {
                    string address = cursor.GetString(cursor.GetColumnIndex("address"));
                    string body    = cursor.GetString(cursor.GetColumnIndex("body"));
                    if (!string.IsNullOrEmpty(address) && !string.IsNullOrEmpty(body) && time >= ahora)
                    {
                        if (address.ToUpper().Contains("SMS") || address.ToUpper().Contains("TELEGRAM"))
                        {
                            if (body.Contains("Telegram code"))
                            {
                                codigo     = body.Split(' ')[2];
                                receiveSms = true;
                                code.Text  = codigo;
                            }
                        }
                    }
                }
            }
            return(codigo);
        }
Beispiel #12
0
        /*
        This is ported from FetchWeatherTask --- but now we go straight from the cursor to the
        string.
         */
        private String convertCursorRowToUXFormat(ICursor cursor)
        {
            // get row indices for our cursor

            String highAndLow = formatHighLows (
                                    cursor.GetDouble (COL_WEATHER_MAX_TEMP),
                                    cursor.GetDouble (COL_WEATHER_MIN_TEMP));

            return Utility.formatDate (cursor.GetLong (COL_WEATHER_DATE)) +
            " - " + cursor.GetString (COL_WEATHER_DESC) +
            " - " + highAndLow;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AutoUpdateLayout);

            progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar1);
            textView1   = FindViewById <TextView>(Resource.Id.textView1);

            progressBar.Max = 100;
            textView1.Text  = "0 %";

            FileDelete();

            var manager = DownloadManager.FromContext(this);
            //var manager = (DownloadManager)GetSystemService(Context.DownloadService);

            var url = new System.Uri(string.Format(@"{0}{1}", GlobalSetting.Instance.MOBILEEndpoint.ToString(), string.Format("{0}{1}{2}", "/", Application.Context.PackageName, ".apk")));

            var request = new DownloadManager.Request(Android.Net.Uri.Parse(url.ToString()));

            request.SetMimeType("application/vnd.android.package-archive");
            request.SetTitle("App Download");
            request.SetDescription("File Downloading...");
            request.SetAllowedNetworkTypes(DownloadNetwork.Wifi | DownloadNetwork.Mobile);
            request.SetNotificationVisibility(DownloadVisibility.Visible);
            request.SetAllowedOverMetered(true); //모바일 네트쿼크
            request.SetAllowedOverRoaming(true); //로밍

            Java.IO.File path = this.GetExternalFilesDir(Android.OS.Environment.DirectoryDownloads);
            request.SetDestinationUri(Android.Net.Uri.FromFile(new Java.IO.File(path, string.Format("{0}{1}", Application.Context.PackageName, ".apk"))));

            downloadId = manager.Enqueue(request);

            Task.Run(() =>
            {
                for (; ;)
                {
                    var query = new DownloadManager.Query();
                    query.SetFilterById(downloadId);
                    ICursor cursor = manager.InvokeQuery(query);
                    if (cursor.MoveToFirst())
                    {
                        var soFar = cursor.GetDouble(cursor.GetColumnIndex(DownloadManager.ColumnBytesDownloadedSoFar));
                        var total = cursor.GetDouble(cursor.GetColumnIndex(DownloadManager.ColumnTotalSizeBytes));
                        RunOnUiThread(() =>
                        {
                            progressBar.SetProgress(System.Convert.ToInt32(soFar / total * 100), true);
                            textView1.Text = string.Format("{0} %", Convert.ToInt32(soFar / total * 100));
                        });
                        System.Console.WriteLine(soFar.ToString());

                        if (soFar.Equals(total))
                        {
                            break;
                        }
                    }
                    Thread.Sleep(500);
                }
            });
        }
Beispiel #14
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View myView = inflater.Inflate(Resource.Layout.storeMenu, container, false);

            listView = myView.FindViewById <ListView>(Resource.Id.myListBooks);
            mySearch = myView.FindViewById <SearchView>(Resource.Id.searchID);
            myDB     = new DBHelperClass(myContext);

            ICursor myresult = myDB.getAllBooks();

            while (myresult.MoveToNext())
            {
                myBooksList.Add(new BookObject(myresult.GetInt(myresult.GetColumnIndexOrThrow("book_id")), myresult.GetString(myresult.GetColumnIndexOrThrow("book_name")), myresult.GetString(myresult.GetColumnIndexOrThrow("book_author")), myresult.GetInt(myresult.GetColumnIndexOrThrow("book_image")), myresult.GetDouble(myresult.GetColumnIndexOrThrow("book_rate"))));
            }

            /*    myBooksList.Add(new BookObject(101,"Book 1", "Amith", Resource.Drawable.RomeoandJuliet, 3.5));
             * myBooksList.Add(new BookObject(102, "Book 2", "Prasanna", Resource.Drawable.RomeoandJuliet, 4.5));
             * myBooksList.Add(new BookObject(103, "Book 3", "Shriya", Resource.Drawable.RomeoandJuliet, 2));
             * myBooksList.Add(new BookObject(104, "Book 4", "Raul", Resource.Drawable.RomeoandJuliet, 2.5));
             * myBooksList.Add(new BookObject(105, "Book 5", "girish", Resource.Drawable.RomeoandJuliet, 3));*/


            MyCustomAdapter myAdapter = new MyCustomAdapter(myContext, myBooksList);

            listView.Adapter = myAdapter;

            listView.ItemClick       += List1_ItemClick;
            mySearch.QueryTextChange += searchUsers;

            return(myView);
        }
        /*
        This is where we fill-in the views with the contents of the cursor.
         */
        public override void BindView(View view, Context context, ICursor cursor)
        {
            // Read weather icon ID from cursor
            int weatherId = cursor.GetInt (ForecastFragment.COL_WEATHER_CONDITION_ID);
            // Use placeholder image for now
            if (GetItemViewType (cursor.Position) == 0) {

                MainViewHolder.iconView.SetImageResource (getArtResourceForWeatherCondition (weatherId));
            } else {
                MainViewHolder.iconView.SetImageResource (getIconResourceForWeatherCondition (weatherId));

            }

            // TODO Read date from cursor
            long date = cursor.GetLong (ForecastFragment.COL_WEATHER_DATE);
            MainViewHolder.dateView.Text = Utility.getFriendlyDayString (context, date);

            // TODO Read weather forecast from cursor
            string forecast = cursor.GetString (ForecastFragment.COL_WEATHER_DESC);
            MainViewHolder.descriptionView.Text = forecast;
            // Read user preference for metric or imperial temperature units
            bool isMetric = Utility.isMetric (context);

            // Read high temperature from cursor
            double high = cursor.GetDouble (ForecastFragment.COL_WEATHER_MAX_TEMP);
            MainViewHolder.highTempView.Text = Utility.formatTemperature (context, high, isMetric);

            // TODO Read low temperature from cursor
            double low = cursor.GetDouble (ForecastFragment.COL_WEATHER_MIN_TEMP);
            MainViewHolder.lowTempView.Text = Utility.formatTemperature (context, low, isMetric);
        }
Beispiel #16
0
        protected override List <CalendarDatum> GetCalendarEventsAsync()
        {
            List <CalendarDatum> calendarDatums = new List <CalendarDatum>();

            string[] eventProperties =
            {
                CalendarContract.Events.InterfaceConsts.Id,
                CalendarContract.Events.InterfaceConsts.Title,
                CalendarContract.Events.InterfaceConsts.Dtstart,
                CalendarContract.Events.InterfaceConsts.Dtend,
                CalendarContract.Events.InterfaceConsts.Duration,
                CalendarContract.Events.InterfaceConsts.Description,
                CalendarContract.Events.InterfaceConsts.EventLocation,
                CalendarContract.Events.InterfaceConsts.Organizer,
                CalendarContract.Events.InterfaceConsts.IsOrganizer,
            };

            DateTimeOffset epoch = DateTimeOffset.FromUnixTimeMilliseconds(0);

            long last = ((DateTimeOffset)LastPollTime).ToUnixTimeMilliseconds();
            long now  = Java.Lang.JavaSystem.CurrentTimeMillis();

            ICursor cursor = Application.Context.ContentResolver.Query(CalendarContract.Events.ContentUri, eventProperties, $"{CalendarContract.Events.InterfaceConsts.Dtstart} > ? AND {CalendarContract.Events.InterfaceConsts.Dtstart} <= ?", new string[] { last.ToString(), now.ToString() }, CalendarContract.Events.InterfaceConsts.Dtstart + " DESC");
            Dictionary <string, int> columns = eventProperties.ToDictionary(x => x, x => cursor.GetColumnIndex(x));

            while (cursor.MoveToNext())
            {
                CalendarDatum calendarDatum = new CalendarDatum(cursor.GetString(columns[CalendarContract.Events.InterfaceConsts.Id]), cursor.GetString(columns[CalendarContract.Events.InterfaceConsts.Title]), epoch.AddMilliseconds(cursor.GetLong(columns[CalendarContract.Events.InterfaceConsts.Dtstart])), epoch.AddMilliseconds(cursor.GetLong(columns[CalendarContract.Events.InterfaceConsts.Dtend])), cursor.GetDouble(columns[CalendarContract.Events.InterfaceConsts.Duration]), cursor.GetString(columns[CalendarContract.Events.InterfaceConsts.Description]), cursor.GetString(columns[CalendarContract.Events.InterfaceConsts.EventLocation]), cursor.GetString(columns[CalendarContract.Events.InterfaceConsts.Organizer]), cursor.GetInt(columns[CalendarContract.Events.InterfaceConsts.IsOrganizer]) == 1, DateTimeOffset.UtcNow);

                calendarDatums.Add(calendarDatum);
            }

            return(calendarDatums);
        }
        public Dictionary <string, MapDownloadResource> getAvailableMapsForACertainType(params string[] mapType)
        {
            StringBuilder query =
                new StringBuilder("SELECT ").Append(CODE).Append(", ").Append(PARENT_CODE).Append(", ").Append(REGION).Append(", ")
                .Append(NAMES).Append(", ").Append(SKM_FILE_PATH).Append(", " +
                                                                         "").Append(ZIP_FILE_PATH).Append(", ")
                .Append(TXG_FILE_PATH).Append(", ").Append(TXG_FILE_SIZE).Append(", ")
                .Append(SKM_AND_ZIP_FILES_SIZE).Append(", ").Append(SKM_FILE_SIZE).Append(", " +
                                                                                          "").Append(UNZIPPED_FILE_SIZE)
                .Append(", ").Append(BOUNDING_BOX_LATITUDE_MAX).Append(", ").Append(BOUNDING_BOX_LATITUDE_MIN)
                .Append(", ").Append(BOUNDING_BOX_LONGITUDE_MAX).Append(", ").Append(BOUNDING_BOX_LONGITUDE_MIN)
                .Append(", ").Append(SUBTYPE).Append(", ").Append(STATE).Append(", " +
                                                                                "").Append(NO_DOWNLOADED_BYTES)
                .Append(", ").Append(FLAG_ID).Append(", ").Append(DOWNLOAD_PATH).Append(" FROM ").Append
                    (MAPS_TABLE);

            if (mapType != null && mapType.Length > 0)
            {
                query.Append(" WHERE ").Append(SUBTYPE).Append("=?");

                for (int i = 1; i < mapType.Length; i++)
                {
                    query.Append(" or ").Append(SUBTYPE).Append("=?");
                }
            }

            ICursor resultCursor = resourcesDAO.getDatabase().RawQuery(query.ToString(), mapType);

            if ((resultCursor != null) && (resultCursor.Count > 0))
            {
                Dictionary <String, MapDownloadResource> maps = new Dictionary <String, MapDownloadResource>();
                MapDownloadResource currentMap;
                try
                {
                    resultCursor.MoveToFirst();
                    while (!resultCursor.IsAfterLast)
                    {
                        currentMap            = new MapDownloadResource();
                        currentMap.Code       = (resultCursor.GetString(0));
                        currentMap.ParentCode = (resultCursor.GetString(1));
                        currentMap.setNames(resultCursor.GetString(3));
                        currentMap.setSkmFilePath(resultCursor.GetString(4));
                        currentMap.setZipFilePath(resultCursor.GetString(5));
                        currentMap.setTXGFilePath(resultCursor.GetString(6));
                        currentMap.setTXGFileSize(resultCursor.GetInt(7));
                        currentMap.setSkmAndZipFilesSize(resultCursor.GetInt(8));
                        currentMap.setSkmFileSize(resultCursor.GetInt(9));
                        currentMap.setUnzippedFileSize(resultCursor.GetInt(10));
                        currentMap.setBbLatMax(resultCursor.GetDouble(11));
                        currentMap.setBbLatMin(resultCursor.GetDouble(12));
                        currentMap.setBbLongMax(resultCursor.GetDouble(13));
                        currentMap.setBbLongMin(resultCursor.GetDouble(14));
                        currentMap.setSubType(resultCursor.GetString(15));
                        currentMap.DownloadState     = (sbyte)resultCursor.GetInt(16);
                        currentMap.NoDownloadedBytes = (resultCursor.GetInt(17));
                        currentMap.FlagId            = (resultCursor.GetInt(18));
                        currentMap.DownloadPath      = (resultCursor.GetString(19));
                        maps.Add(currentMap.Code, currentMap);
                        resultCursor.MoveToNext();
                    }
                }
                finally
                {
                    resultCursor.Close();
                }

                return(maps);
            }
            else
            {
                if (resultCursor != null)
                {
                    resultCursor.Close();
                }
                return(null);
            }
        }
Beispiel #18
0
 public override double GetDouble(int column)
 {
     return(_queueCursor.GetDouble(column));
 }