VenturaSQL 4 Web API

The VenturaSQL 4 middleware is exposed as a Web API using an ASP.NET Controller. The requestData byte array created by the Recordsets on the client and transmitted to the server in binary format. The VenturaServerEngine will perform the requested database operations and return the data to the client in binary format. The client then unpacks the data and fills the records in Recordsets.

The VenturaSQL 4 server library will only be available for .NET 5 or higher. The libraries for .NET Framework 4.7 and ASP.NET Core 3.x will be discontinued.

using BlazorDemo.Client;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using VenturaSQL;
using VenturaSQL.AspNetCore.Server.RequestHandling;

namespace BlazorDemo.Server.Controllers
{
    [Authorize]
    public class VenturaSqlController : ControllerBase
    {
        [Route("api/venturasql")]
        [HttpPost]
        public async Task<IActionResult> Index([FromBody] byte[] requestData) // HttpRequestMessage request
        {

            var processor = new VenturaServerEngine();

            processor.CallBacks.LookupAdoConnector = LookupAdoConnector;

            await processor.ExecAsync(requestData);

            Response.ContentType = "application/octet-stream";

            await Response.Body.WriteAsync(processor.ResponseBuffer, 0, processor.ResponseLength);

            return Ok();
        }

        private AdoConnector LookupAdoConnector(string requestedName)
        {
            if (requestedName == "BikeStores")
                return ServerConnector.BikeStores;
            else if (requestedName == "Pharmacy")
                return ServerConnector.Pharmacy;

            throw new Exception($"Requested connector name {requestedName} is unknown on server.");
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *