using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System; using Sockeye.Util; using Sockeye.Api.ControllerHelpers; using Microsoft.AspNetCore.Authorization; using System.Linq; using Sockeye.Biz; namespace Sockeye.Api.Controllers { /// /// Meta controller class /// [ApiVersion("8.0")] [Route("api/v{version:apiVersion}/")] [Authorize] [ApiController] public class ApiMetaController : ControllerBase { private readonly ApiServerState serverState; private readonly ILogger _log; /// /// /// /// /// public ApiMetaController(ILogger logger, ApiServerState apiServerState) { _log = logger; serverState = apiServerState; } private static string SupportUrl() { /* contactSupportUrl() { let dbId = encodeURIComponent( window.$gz.store.state.globalSettings.serverDbId ); let company = encodeURIComponent( window.$gz.store.state.globalSettings.company ); return `https://contact.ayanova.com/contact?dbid=${dbId}&company=${company}`; } */ return $"https://contact.ayanova.com/contact"; } /// /// Server landing page /// /// [AllowAnonymous] [HttpGet] public ContentResult Index() { //https://superuser.com/questions/361297/what-colour-is-the-dark-green-on-old-fashioned-green-screen-computer-displays var errorBlock = string.Empty; if (serverState.IsSystemLocked) errorBlock = $@"

SERVER LOCKED

{serverState.Reason}

"; var resp = $@" Sockeye server {errorBlock}

{SockeyeVersion.FullNameAndVersion}

Sockeye App

User and technical guide

Contact technical support

API explorer for developers

"; System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"(?<=\s)\s+"); resp = reg.Replace(resp, string.Empty).Replace("\n", "").Replace("\t", ""); return new ContentResult { ContentType = "text/html", StatusCode = 200, Content = resp }; } /// /// Get API server info for ABOUT form Sockeye display /// /// API server info [HttpGet("server-info")] public ActionResult ServerInfo() { return Ok(new { data = new { ServerVersion = SockeyeVersion.FullNameAndVersion, DBSchemaVersion = AySchema.currentSchema, ServerLocalTime = DateUtil.ServerDateTimeString(System.DateTime.UtcNow), ServerTimeZone = TimeZoneInfo.Local.Id, } }); } /// /// Get list of types and roles required /// /// A list of SockType role rights [HttpGet("role-rights")] public ActionResult RoleRights() { return Ok(new { data = new { SockTypes = BizRoles.roles.OrderBy(z => z.Key.ToString()).Select(z => new { SockType = z.Key.ToString(), Change = z.Value.Change.ToString(), ReadFullRecord = z.Value.ReadFullRecord.ToString(), Select = z.Value.Select.ToString() }).ToList() } }); } #if (DEBUG) /// /// Get build mode of server, used for automated testing purposes /// /// "DEBUG" or "RELEASE" [HttpGet("build-mode")] public ActionResult BuildMode() { return Ok(new { data = new { BuildMode = "DEBUG" } }); } #else /// /// Get build mode of server, used for automated testing purposes /// /// "DEBUG" or "RELEASE" [HttpGet("build-mode")] public ActionResult BuildMode() { return Ok(new { data = new { BuildMode = "RELEASE" } }); } #endif } } #region sigtest script /*

SIGTEST - 1

This is the signature header

Your browser does not support signing
The following browsers are supported:
IE 9.0 +, FIREFOX 3.0 +, SAFARI 3.0 +, CHROME 3.0 +, OPERA 10.0 +, IPAD 1.0 +, IPHONE 1.0 +, ANDROID 1.0 +

{SigScript()} private string SigScript(){ return @""; } */ #endregion