diff --git a/Jenkinsfile b/Jenkinsfile index 9b3e3dc2..01b6c92a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,7 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=1294']) { + withEnv(['NEXT_BUILD_NUMBER=1295']) { // env.versionNumber = VersionNumber(versionNumberString : '6.9.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '6.9.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO' diff --git a/MP-IO/App_Readme/Elmah.txt b/MP-IO/App_Readme/Elmah.txt new file mode 100644 index 00000000..784b3094 --- /dev/null +++ b/MP-IO/App_Readme/Elmah.txt @@ -0,0 +1,15 @@ +A new HTTP handler has been configured in your application for consulting the +error log and its feeds. It is reachable at elmah.axd under your application +root. If, for example, your application is deployed at http://www.example.com, +the URL for ELMAH would be http://www.example.com/elmah.axd. You can, of +course, change this path in your application's configuration file. + +ELMAH is also set up to be secure such that it can only be accessed locally. +You can enable remote access but then it is paramount that you secure access +to authorized users or/and roles only. This can be done using standard +authorization rules and configuration already built into ASP.NET. For more +information, see http://code.google.com/p/elmah/wiki/SecuringErrorLogPages on +the project site. + +Please review the commented out authorization section under + and make the appropriate changes. diff --git a/MP-IO/App_Start/WebApiConfig.cs b/MP-IO/App_Start/WebApiConfig.cs new file mode 100644 index 00000000..82161890 --- /dev/null +++ b/MP-IO/App_Start/WebApiConfig.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; + +namespace MP_IO.App_Start +{ + public static class WebApiConfig + { + public static void Register(HttpConfiguration config) + { + // Servizi e configurazione dell'API Web + + // Route dell'API Web + config.MapHttpAttributeRoutes(); + + config.Routes.MapHttpRoute( + name: "DefaultApi", + routeTemplate: "api/{controller}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + } + } +} \ No newline at end of file diff --git a/MP-IO/Controllers/WebAPI/CacheFilter.cs b/MP-IO/Controllers/WebAPI/CacheFilter.cs new file mode 100644 index 00000000..d1176ce1 --- /dev/null +++ b/MP-IO/Controllers/WebAPI/CacheFilter.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Web; +using System.Web.Http.Filters; + +namespace MP_IO.Controllers.WebAPI +{ + public class CacheFilter : ActionFilterAttribute + { + public int TimeDuration { get; set; } + public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) + { + actionExecutedContext.Response.Headers.CacheControl = new CacheControlHeaderValue + { + MaxAge = TimeSpan.FromSeconds(TimeDuration), + MustRevalidate = true, + Public = true + }; + } + } +} \ No newline at end of file diff --git a/MP-IO/Controllers/WebAPI/IOBController.cs b/MP-IO/Controllers/WebAPI/IOBController.cs new file mode 100644 index 00000000..e9ddb9f9 --- /dev/null +++ b/MP-IO/Controllers/WebAPI/IOBController.cs @@ -0,0 +1,88 @@ +using MapoDb; +using SteamWare; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; + +namespace MP_IO.Controllers.WebAPI +{ + public class IOBController : ApiController + { + /// + /// GET api/IOB + /// è un check alive del server + /// + /// + [CacheFilter(TimeDuration = 10)] + [HttpGet] + public string Get() + { + if (memLayer.ML.CRB("IOB_RedEnab")) + { + // conto la richiesta nel contatore REDIS + long nCall = memLayer.ML.setRCntI(DataLayer.mHash("COUNT:pCall:IOB_INDEX")); + //... se == nCall2Log scrivo su log e resetto + long nCall2Log = memLayer.ML.cdvi("nCall2Log"); + if (nCall >= nCall2Log) + { + // loggo + logger.lg.scriviLog(string.Format("IOB_INDEX: effettuate {0} call", nCall), tipoLog.INFO); + // resetto! + memLayer.ML.resetRCnt(DataLayer.mHash("COUNT:pCall:IOB_INDEX")); + } + } + return "OK"; + } + + /// + /// GET api/IOB/SIMUL_03 + /// Verifica stato enabled di un determinato IOB + /// + /// + /// + [CacheFilter(TimeDuration = 5)] + [HttpGet] + public string Get(string id) + { + string answ = "ND"; + // se id nullo --> KO! + if (id == null) + { + answ = "KO"; + } + else + { + try + { + DataLayer DataLayerObj = new DataLayer(); + // salvo risposta! + answ = DataLayerObj.insEnab(id) ? "OK" : "NO"; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in enabled{0}{1}", Environment.NewLine, exc)); + answ = "NO"; + } + } + return answ; + } + + // POST api/ + public void Post([FromBody]string value) + { + } + + // PUT api//5 + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api//5 + public void Delete(int id) + { + } + } +} \ No newline at end of file diff --git a/MP-IO/Global.asax.cs b/MP-IO/Global.asax.cs index 605f4d0b..b60e2b04 100644 --- a/MP-IO/Global.asax.cs +++ b/MP-IO/Global.asax.cs @@ -1,18 +1,21 @@ -using System.Web.Mvc; +using MP_IO.App_Start; +using System.Web.Http; +using System.Web.Mvc; using System.Web.Routing; namespace MP_IO { - public class WebApiApplication : System.Web.HttpApplication - { - protected void Application_Start() + public class WebApiApplication : System.Web.HttpApplication { - // Codice eseguito all'avvio dell'applicazione - AreaRegistration.RegisterAllAreas(); - RouteConfig.RegisterRoutes(RouteTable.Routes); + protected void Application_Start() + { + // Codice eseguito all'avvio dell'applicazione + AreaRegistration.RegisterAllAreas(); + GlobalConfiguration.Configure(WebApiConfig.Register); + RouteConfig.RegisterRoutes(RouteTable.Routes); - // avvio il metodo init x applicazione... - MP_Startup.Init(); + // avvio il metodo init x applicazione... + MP_Startup.Init(); + } } - } } diff --git a/MP-IO/MP-IO.csproj b/MP-IO/MP-IO.csproj index 90e369f3..8a5fab7a 100644 --- a/MP-IO/MP-IO.csproj +++ b/MP-IO/MP-IO.csproj @@ -57,6 +57,9 @@ ..\packages\DnsClient.1.2.0\lib\net45\DnsClient.dll + + ..\packages\elmah.corelibrary.1.2.2\lib\Elmah.dll + ..\packages\SharpZipLib.1.2.0\lib\net45\ICSharpCode.SharpZipLib.dll @@ -127,6 +130,10 @@ ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll @@ -160,6 +167,12 @@ ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll + ..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll @@ -183,12 +196,15 @@ + - + + Always + @@ -256,8 +272,11 @@ + + + default.aspx ASPXCodeBehind diff --git a/MP-IO/Web.config b/MP-IO/Web.config index 555713c6..f3127a01 100644 --- a/MP-IO/Web.config +++ b/MP-IO/Web.config @@ -4,325 +4,379 @@ http://go.microsoft.com/fwlink/?LinkId=169433 --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MP-IO/favicon.ico b/MP-IO/favicon.ico index 4f0e0ad0..daacbc8c 100644 Binary files a/MP-IO/favicon.ico and b/MP-IO/favicon.ico differ diff --git a/MP-IO/packages.config b/MP-IO/packages.config index c356d0a0..c5f4623b 100644 --- a/MP-IO/packages.config +++ b/MP-IO/packages.config @@ -4,6 +4,8 @@ + + @@ -12,6 +14,13 @@ + + + + + + +