Aggiunto strato redis

This commit is contained in:
Samuele E. Locatelli
2018-05-23 15:40:25 +02:00
parent e682359c1d
commit cfe90d6fa5
9 changed files with 137 additions and 90 deletions
Vendored
+1 -1
View File
@@ -17,7 +17,7 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=60']) {
withEnv(['NEXT_BUILD_NUMBER=62']) {
// env.versionNumber = VersionNumber(versionNumberString : '0.8.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '0.8.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'SOSCONDOMINI'
+14 -46
View File
@@ -1,49 +1,17 @@
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PUB._Default" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PUB.Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<!DOCTYPE html>
<div class="jumbotron py-3">
<div class="container">
<h1>SOSCONDOMINI.NET</h1>
<p class="lead">Questo potrebbe diventare un carosello di presentazione, decidendo cosa scrivere.</p>
<p><a href="~/About" class="btn btn-primary btn-lg">Per maggiori informazioni &raquo;</a></p>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Test 1,2,3 microfono...
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-4">
<div style="min-height: 12em;">
<h2>CONDOMINI</h2>
<p>
Se il tuo amministratore ha aderito all'iniziativa da qui puoi verificare lo stato degli interventi in corso, di quelli programmati e di tutto il registro interventi passati che riguardano i fabbricati di tua competenza.
</p>
</div>
<p>
<a class="btn btn-outline-success" href="PCO/MyDashboard">Accesso CONDOMINO &raquo;</a>
</p>
</div>
<div class="col-md-4">
<div style="min-height: 12em;">
<h2>AMMINISTRATORI</h2>
<p>
Se sei un amministratore puoi avere maggiori informazioni per aderire al servizio o procedere direttametne alla tua area gestionale del link seguente
</p>
</div>
<p>
<a class="btn btn-outline-warning" href="PAM/MyDashboard">Portale AMMINISTRATORI &raquo;</a>
</p>
</div>
<div class="col-md-4">
<div style="min-height: 12em;">
<h2>AZIENDE</h2>
<p>
Se sei un piccolo artigiano o rappresenti un azienda di servizi e sei interessato a partecipare al nostro portale e alle nostre iniziative clicca qui per avere maggiori informazioni o accedere alla tua area riservata.
</p>
</div>
<p>
<a class="btn btn-outline-secondary" href="PAZ/MyDashboard">Portale AZIENDE &raquo;</a>
</p>
</div>
</div>
</div>
</asp:Content>
</form>
</body>
</html>
+6 -13
View File
@@ -1,22 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SteamWare;
using SteamWare;
using System;
namespace PUB
{
public partial class _Default : Page
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// verifico se ho in sessione il TIPO utente, altrimenti importo condomini.it
if(memLayer.ML.StringSessionObj("UserRole")=="")
{
memLayer.ML.setSessionVal("UserRole", "condomini.it");
}
// resetto i dati utente all'accesso alla pagina default...
devicesAuthProxy.stObj.clearAllUserData();
Response.Redirect("MainMenu");
}
}
}
+10 -1
View File
@@ -10,6 +10,15 @@
namespace PUB {
public partial class _Default {
public partial class Default {
/// <summary>
/// Controllo form1.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
}
}
+7 -7
View File
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SteamWare;
using System;
namespace PUB
{
@@ -11,7 +7,11 @@ namespace PUB
{
protected void Page_Load(object sender, EventArgs e)
{
// verifico se ho in sessione il TIPO utente, altrimenti importo condomini.it
if (memLayer.ML.StringSessionObj("UserRole") == "")
{
memLayer.ML.setSessionVal("UserRole", "condomini.it");
}
}
}
}
+10
View File
@@ -85,9 +85,18 @@
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Web.RedisSessionStateProvider, Version=2.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.RedisSessionStateProvider.2.2.6\lib\net40\Microsoft.Web.RedisSessionStateProvider.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="StackExchange.Redis, Version=1.2.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\StackExchange.Redis.1.2.6\lib\net46\StackExchange.Redis.dll</HintPath>
</Reference>
<Reference Include="StackExchange.Redis.StrongName, Version=1.2.6.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
<HintPath>..\packages\StackExchange.Redis.StrongName.1.2.6\lib\net46\StackExchange.Redis.StrongName.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
@@ -95,6 +104,7 @@
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.4.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
+38 -2
View File
@@ -5,6 +5,11 @@
-->
<configuration>
<appSettings>
<!--Impostazione gestione serializzazione variabili in sessione (es per Redis)-->
<add key="serializeSession" value="true" />
<add key="disable_singleton" value="true" />
<add key="errorPageRedirect" value="./Reset?Action=CDV" />
<add key="maxAgeAppConf_min" value="15" />
<!--parametri base-->
<add key="intUpdatePagina_ms" value="240000" />
<add key="baseLang" value="IT" />
@@ -17,7 +22,7 @@
<add key="_logLevel" value="7" />
<add key="_logMaxMb" value="30" />
<!--gestione auth dispositivi-->
<add key="AuthCookieName" value="AuthDeviceScheMe" />
<add key="AuthCookieName" value="AuthDeviceB2Bc" />
<add key="defaultDomain" value="B2BC" />
<add key="enablePlain" value="true" />
<add key="urlGestUtenti" value="UserAdmin" />
@@ -49,7 +54,34 @@
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<sessionState mode="Custom" customProvider="MySessionStateStore">
<providers>
<!-- For more details check https://github.com/Azure/aspnet-redis-providers/wiki -->
<!-- Either use 'connectionString' OR 'settingsClassName' and 'settingsMethodName' OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. -->
<!-- 'throwOnError','retryTimeoutInMilliseconds','databaseId' and 'applicationName' can be used with both options. -->
<!--
<add name="MySessionStateStore"
host = "127.0.0.1" [String]
port = "" [number]
accessKey = "" [String]
ssl = "false" [true|false]
throwOnError = "true" [true|false]
retryTimeoutInMilliseconds = "5000" [number]
databaseId = "0" [number]
applicationName = "" [String]
connectionTimeoutInMilliseconds = "5000" [number]
operationTimeoutInMilliseconds = "1000" [number]
connectionString = "<Valid StackExchange.Redis connection string>" [String]
settingsClassName = "<Assembly qualified class name that contains settings method specified below. Which basically return 'connectionString' value>" [String]
settingsMethodName = "<Settings method should be defined in settingsClass. It should be public, static, does not take any parameters and should have a return type of 'String', which is basically 'connectionString' value.>" [String]
loggingClassName = "<Assembly qualified class name that contains logging method specified below>" [String]
loggingMethodName = "<Logging method should be defined in loggingClass. It should be public, static, does not take any parameters and should have a return type of System.IO.TextWriter.>" [String]
redisSerializerType = "<Assembly qualified class name that implements Microsoft.Web.Redis.ISerializer>" [String]
/>
-->
<add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="localhost" accessKey="localhost" ssl="false" applicationName="B2BC" />
</providers>
</sessionState></system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
@@ -72,6 +104,10 @@
<assemblyIdentity name="Microsoft.AspNet.TelemetryCorrelation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.3.0" newVersion="1.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="StackExchange.Redis.StrongName" publicKeyToken="c219ff1ca8c2ce46" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.6.0" newVersion="1.2.6.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.webServer>
+48 -20
View File
@@ -12,17 +12,11 @@ namespace PUB.WebUserContols
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
doUpdate();
}
// altri controlli
if (!Page.IsPostBack)
{
Timer1.Interval = memLayer.ML.confReadInt("intUpdatePagina_ms");
Page.Title = Request.Url.ToString();
Page.Title = titolo;// Request.Url.ToString();
// se ho cambiato pagina registro...)
if (devicesAuthProxy.pagPrecedente != titolo)
{
@@ -36,21 +30,30 @@ namespace PUB.WebUserContols
{
bool userOk = checkUser();
bool pageOk = checkPageIsAuth();
bool areaOK = checkUserHasRight();
// controllo se c'è utente in sessione..
if ((userOk))
{
// ora controllo pagina...
if (!pageOk)
// controllo se sia OK la SEZIONE pagine
if (areaOK)
{
if (devicesAuthProxy.stObj.isPageEnabled(devicesAuthProxy.pagPrecedente))
// ora controllo pagina...
if (!pageOk)
{
Response.Redirect(devicesAuthProxy.pagPrecedente);
}
else
{
Response.Redirect("MainMenu");
if (devicesAuthProxy.stObj.isPageEnabled(devicesAuthProxy.pagPrecedente))
{
Response.Redirect(devicesAuthProxy.pagPrecedente);
}
else
{
Response.Redirect("MainMenu");
}
}
}
else
{
Response.Redirect("~/MainMenu");
}
}
else
{
@@ -58,8 +61,8 @@ namespace PUB.WebUserContols
Response.Redirect(memLayer.ML.CRS("urlGestUtenti"));
}
}
// aggiorno
doUpdate();
}
public void doUpdate()
@@ -171,6 +174,31 @@ namespace PUB.WebUserContols
memLayer.ML.setSessionVal("siteSearchVal", txtSearch.Text.Trim());
}
/// <summary>
/// verifica che l'utente ABBIA il diritto della sezione corrente (es PBO, PAM, ...)
/// </summary>
/// <returns></returns>
private bool checkUserHasRight()
{
bool allOk = false;
if (isPAM)
{
allOk = devicesAuthProxy.stObj.userHasRight("PAM");
}
else if (isPAZ)
{
allOk = devicesAuthProxy.stObj.userHasRight("PAZ");
}
else if (isPBO)
{
allOk = devicesAuthProxy.stObj.userHasRight("PBO");
}
else if (isPCO)
{
allOk = devicesAuthProxy.stObj.userHasRight("PCO");
}
return allOk;
}
/// <summary>
/// verifica che la pagina sia tra quelle autorizzate x l'utente
/// </summary>
@@ -192,7 +220,7 @@ namespace PUB.WebUserContols
if (!devicesAuthProxy.stObj.isAuth)
{
// controllo cookie device...
allOk = checkAuthCookieScheMe();
allOk = checkAuthCookie();
if (!allOk)
{
ResetUser();
@@ -251,7 +279,7 @@ namespace PUB.WebUserContols
/// <summary>
/// verifica la presenza di un cookie VALIDO per autorizzare il device ed avvia utente...
/// </summary>
private bool checkAuthCookieScheMe()
private bool checkAuthCookie()
{
bool answ = false;
try
@@ -271,7 +299,7 @@ namespace PUB.WebUserContols
device = devicesAuthProxy.stObj.taAnagDev.getByDeviceSecret(devSecret)[0];
email = device.USER_NAME;
}
catch
catch (Exception exc)
{ }
if (email != "")
{
+3
View File
@@ -25,10 +25,13 @@
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="2.7.0" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
<package id="Microsoft.Web.RedisSessionStateProvider" version="2.2.6" targetFramework="net462" />
<package id="Modernizr" version="2.8.3" targetFramework="net461" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
<package id="popper.js" version="1.14.3" targetFramework="net461" />
<package id="Respond" version="1.4.2" targetFramework="net461" />
<package id="StackExchange.Redis" version="1.2.6" targetFramework="net462" />
<package id="StackExchange.Redis.StrongName" version="1.2.6" targetFramework="net462" />
<package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net461" />
<package id="WebGrease" version="1.6.0" targetFramework="net461" />
</packages>