コード例 #1
0
        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);
            }
        }