Skip to main content

easyqueryapihandler-class

This class contains the handlers for all kind of HTTP requests to EasyQuery API (like GetModel, GetQuery, etc).

public class Korzh.EasyQuery.AspNetCore.EasyQueryApiHandler

Assembly: Korzh.EasyQuery.AspNetCore.dll

Constructors

NameTypeDescription
EasyQueryApiHandler(EasyQueryManager manager, HttpContext httpContext)voidInitializes a new instance of the Korzh.EasyQuery.AspNetCore.EasyQueryApiHandler class.

Fields

NameTypeDescription
HttpContextHttpContextThe current HttpContext
ManagerEasyQueryManagerAn instance of EasyQueryManager that incapsulates all business logic of EasyQuery API

Methods

NameTypeDescription
GetFileExtentionByContentType(string contentType)stringGets the file extention by the content type.
GetJSVersion()VersionGets the version of EasyQuery.JS library that has sent the request.
GetQueryFileExt(string fileFormat)stringGets the extension of the query file for specified file format (json or xml).
GetValidFileName(string fileName)stringGets the valid file name based on the string value passed in the parameter.
HandleErrorResponseAsync(int statusCode, string message, Func<JsonWriter, CancellationToken, Task> writeContentAction = null, `CancellationToken` ct = null)TaskHandles exceptions that might occur inside any other EasyQuery API request handler. If the writing to the response content has not started it returns a response with 400 code and the error message.
HandleExceptionAsync(Exception ex, CancellationToken ct = null)TaskHandles exceptions that might occur inside any other EasyQuery API request handler. If the writing to the response content has not started it returns a response with 400 code and the error message.
HandleExportResultAsync(string modelId, string formatType, CancellationToken ct = null)TaskHandles the ExportResult requests.
HandleFetchDataAsync(string modelId, CancellationToken ct = null)TaskHandles the "FetchData" request. This handler receives a query JSON in the request's body, builds a query (SQL or LINQ), executes it and return the result set (again in JSON format).
HandleGetLicenseKey2Async(CancellationToken ct = null)TaskHandles the "GetLicenseKey" request as an asynchronous operation.
HandleGetLicenseKeyAsync(CancellationToken ct = null)TaskHandles the "GetLicenseKey" request as an asynchronous operation.
HandleGetModelAsync(string modelId, CancellationToken ct = null)TaskHandles the "GetModel" request as an asynchronous operation.
HandleGetQueryAsync(string modelId, string queryId, CancellationToken ct = null)TaskHandles the "GetQuery" request and writes the response
HandleGetQueryFileAsync(string modelId, string fileFormat, CancellationToken ct = null)TaskHandles GetQueryFile request.
HandleGetQueryListAsync(string modelId, CancellationToken ct = null)TaskHandles the "GetQueryList" request and returns the list of saved queries for a particular model.
HandleGetValueListAsync(string modelId, string editorId, CancellationToken ct = null)TaskHandles the "GetValueList" request. Returs the list of values for a particular value editor.
HandleNewQueryAsync(string modelId, CancellationToken ct = null)TaskHandles the "NewQuery" request and returns a JSON representation of a new new empty query for a particular data model.
HandlePutLicenseKeyAsync(CancellationToken ct = null)TaskHandles the "PutLicenseKey" request as an asynchronous operation.
HandleRemoveQueryAsync(string modelId, string queryId, CancellationToken ct = null)TaskHandles the "RemoveQuery" request and remove the query with the specified ID from the storage.
HandleSaveQueryAsync(string modelId, string queryId, CancellationToken ct = null)TaskHandles the "SaveQuery" request for specified model and query. The JSON representation of the query should be passed in the request's body.
HandleSyncQueryAsync(string modelId, string queryId, CancellationToken ct = null)TaskHandles the "SyncQuery" request. This action gets a JSON representation of the query in request's body and passes it SyncQuery method of EasyQueryManager. The manager can save the query and/or build it and return SQL statement (depending on options)
HandleUploadQueryFileAsync(string modelId, CancellationToken ct = null)TaskHandles UploadQueryFile request.
LoadQueryFromFormFileAsync(IFormFile file, CancellationToken ct)TaskLoads query from a form file.
WriteErrorJsonResponseAsync(HttpContext context, string errorMessage, Func<JsonWriter, CancellationToken, Task> writeContentAction = null, `CancellationToken` ct = null)TaskWrites an ERROR response in JSON format. This function actually calls Korzh.EasyQuery.AspNetCore.EasyQueryApiHandler.WriteJsonResponseAsync(Microsoft.AspNetCore.Http.HttpContext,System.String,System.Func{Newtonsoft.Json.JsonWriter,System.Threading.CancellationToken,System.Threading.Tasks.Task},System.Threading.CancellationToken) with "error" value for the "result" parameter. It also writes a "message" property to the response object with the value passed in "errorMessage" parameter.
WriteExportedDataAsync(Stream responseStream, string formatType, CancellationToken ct)TaskWrites exported data to the response.
WriteExtraContentAsync(JsonWriter writer, CancellationToken ct = null)TaskWrites any extra content to the response body. Does nothing but can be overridden in the descendants.
WriteFetchDataResponseAsync(JsonWriter jsonWriter, IEqResultSet resultSet, CancellationToken ct)TaskWrites the response for ExecuteQuery request to JsonWriter. Can be overrided in derived classes to add extra data to the response.
WriteGetModelResponseAsync(JsonWriter jsonWriter, DataModel model, CancellationToken ct)TaskWrites the model's content to the JsonWriter. Can be overriden in the derived classes to write some extra data to the response for GetModel request .
WriteGetQueryResponseAsync(JsonWriter jsonWriter, Query query, CancellationToken ct)TaskBeing overriden in the derived classes this method allows to write some extra data to the response for GetQuery request .
WriteJsonResponseAsync(HttpContext context, string result, Func<JsonWriter, CancellationToken, Task> writeContentAction, CancellationToken ct)TaskWrites a response in JSON format. This function creates a HttpResponseStreamWriter and invokes the callback function which actually does the job.
WriteOkJsonResponseAsync(HttpContext context, Func<JsonWriter, CancellationToken, Task> writeContentAction, CancellationToken ct)TaskWrites an OK response in JSON format. This function actually calls Korzh.EasyQuery.AspNetCore.EasyQueryApiHandler.WriteJsonResponseAsync(Microsoft.AspNetCore.Http.HttpContext,System.String,System.Func{Newtonsoft.Json.JsonWriter,System.Threading.CancellationToken,System.Threading.Tasks.Task},System.Threading.CancellationToken) with "ok" value for the "result" parameter.
WriteQueryStreamAsync(HttpResponseStreamWriter responseWriter, string fileFormat, CancellationToken ct)TaskWrite query into the response stream.
WriteSyncQueryResponseAsync(JsonWriter jsonWriter, bool isAuthorized, bool querySaved, CancellationToken ct)TaskWrites the response for SyncQuery request to JsonWriter. Can be overrided in derived classes to add extra data to the respons