Пример #1
0
        internal bool FetchTileFromCache(string url)
        {
            TileData result = null;

            StatusCode = HttpStatusCode.Ambiguous;
            Status     = "";
            ImageData  = null;

            if (string.IsNullOrWhiteSpace(_connString))
            {
                return(false);
            }

            using (var conn = _dbClient.GetConnection(_connString))
            {
                conn.Open();
                using (var cmd = _dbClient.GetCommand("sp_GetCachedMapTile", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    _dbClient.AddParameterWithValue("url", url, cmd);

                    using (var sqlResults = cmd.ExecuteReader())
                    {
                        while (sqlResults.Read())
                        {
                            Source     = DataUtility.ParseString(sqlResults, "SourceUrl");
                            StatusCode = string.IsNullOrWhiteSpace(Source) ? HttpStatusCode.NotFound : HttpStatusCode.OK;
                            Status     = "";
                            _x         = DataUtility.ParseInt(sqlResults, "CoordX");
                            _y         = DataUtility.ParseInt(sqlResults, "CoordY");
                            _zoom      = DataUtility.ParseInt(sqlResults, "Zoom");
                            SetImageData((byte[])sqlResults["ImageData"]);
                        }
                    }
                }
            }

            if (StatusCode == HttpStatusCode.Ambiguous)
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        public void SaveMapImageToCache(double lat, double lon, int zoom, int width, int height, byte[] imagedata)
        {
            if (string.IsNullOrWhiteSpace(_connString))
            {
                return;
            }

            using (var conn = _dbClient.GetConnection(_connString))
            {
                conn.Open();
                using (var cmd = _dbClient.GetCommand("sp_SaveMapImageToCache", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    _dbClient.AddParameterWithValue("lat", lat, cmd);
                    _dbClient.AddParameterWithValue("lon", lon, cmd);
                    _dbClient.AddParameterWithValue("zoom", zoom, cmd);
                    _dbClient.AddParameterWithValue("width", width, cmd);
                    _dbClient.AddParameterWithValue("height", height, cmd);
                    _dbClient.AddParameterWithValue("imagedata", imagedata, cmd);

                    cmd.ExecuteNonQuery();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Deletes the specified <paramref name="user" /> from the user store.
        /// </summary>
        /// <param name="user">The user to delete.</param>
        /// <param name="cancellationToken">The <see cref="T:System.Threading.CancellationToken" /> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>The <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation, containing the <see cref="T:Microsoft.AspNetCore.Identity.IdentityResult" /> of the update operation.</returns>
        public override Task <IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (user == null)
            {
                throw new ArgumentException($"Invalid argument. User cannot be null.", nameof(user), null);
            }

            // Check for valid data
            if (string.IsNullOrWhiteSpace(user.Id.ToString()))
            {
                throw new ArgumentException($"Invalid argument. Id cannot be null or empty.", nameof(user.Id), null);
            }

            using (var conn = _dbClient.GetConnection(_connString))
            {
                IDbCommand cmd = _dbClient.GetCommand("sp_AuthDeleteUser", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                _dbClient.AddParameterWithValue("@id", user.Id, cmd);

                conn.Open();
                cmd.ExecuteScalar();
                conn.Close();
            }

            return(Task.FromResult(IdentityResult.Success));
        }