Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue201688 #1099

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dotnet/DotNetStandardClasses.sln
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,11 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F8959289-4ED7-430C-97B7-FAAA29829708}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GxSoapHandler", "src\extensions\ws\src\GxSoapHandler\GxSoapHandler.csproj", "{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Functions", "Functions", "{E59B3248-4C26-4DB0-96CB-67437319E22B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneXus.Deploy.AzureFunctionsLibraries", "src\extensions\Azure\Libraries\GeneXus.Deploy.AzureFunctionsLibraries.csproj", "{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -652,6 +655,10 @@ Global
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Release|Any CPU.Build.0 = Release|Any CPU
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -782,6 +789,7 @@ Global
{F8959289-4ED7-430C-97B7-FAAA29829708} = {B5C28D81-BCD9-4B29-9B68-EDD81D1018D5}
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32} = {F8959289-4ED7-430C-97B7-FAAA29829708}
{E59B3248-4C26-4DB0-96CB-67437319E22B} = {41E1D031-799F-484F-85DE-7A30AF1A6FBA}
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA} = {BD804A75-9F3F-416C-BF6B-D3DF6C4A8DC0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E18684C9-7D76-45CD-BF24-E3944B7F174C}
Expand Down
1 change: 1 addition & 0 deletions dotnet/src/dotnetcore/GxClasses/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[assembly: InternalsVisibleTo("GxSearch")]
[assembly: InternalsVisibleTo("GxNetCoreStartup")]
[assembly: InternalsVisibleTo("GeneXus.Deploy.AzureFunctions.Handlers")]
[assembly: InternalsVisibleTo("GeneXus.Deploy.AzureFunctionsLibraries")]
[assembly: InternalsVisibleTo("AzureFunctionsTest")]
[assembly: InternalsVisibleTo("GXQueue")]
[assembly: InternalsVisibleTo("GXMessageBroker")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@

<ItemGroup Condition="'$(HttpSupport)' == 'true'">
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
<Compile Include="HttpHandler\*" />
</ItemGroup>

<ItemGroup Condition="'$(EventGridSupport)' == 'true'">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>GeneXus.Deploy.AzureFunctionsLibraries</AssemblyName>
<IncludeSource>true</IncludeSource>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
</ItemGroup>

<ItemGroup Condition="$(GenStdVersion)==''">
<ProjectReference Include="..\..\..\dotnetcore\GxClasses.Web\GxClasses.Web.csproj" />
<ProjectReference Include="..\..\..\dotnetcore\GxClasses\GxClasses.csproj" />
<ProjectReference Include="..\..\..\dotnetcore\Providers\Cache\GxRedis\GxRedis.csproj" />
</ItemGroup>

<ItemGroup Condition="$(GenStdVersion)!=''">
<PackageReference Include="GeneXus.Classes.Web.Core" Version="$(GenStdVersion)" />
<PackageReference Include="GeneXus.Redis.Core" Version="$(GenStdVersion)" />
</ItemGroup>

<ItemGroup>
<None Include="**\*.cs" Pack="true" PackagePath="src\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using GeneXus;
using GeneXus.Application;
using GeneXus.Cache;
using GeneXus.Deploy.AzureFunctions.HttpHandler;
using GeneXus.Utils;
using Microsoft.AspNetCore.Http;

namespace GxClasses.Web.Middleware
{
public class GXAzureRestService : GxRestService
{
static readonly IGXLogger log = GXLoggerFactory.GetLogger<GXAzureRestService>();
private readonly ICacheService2 _cacheService;
public GXAzureRestService(ICacheService2 redis) : base()
{
if (GxContext.IsAzureContext)
{
if (redis != null && redis.GetType() == typeof(Redis))
{
_cacheService = redis;
}
else
_cacheService = new InProcessCache();
}
else
{
GXLogging.Debug(log, "Error: Not an Azure context.");
throw new Exception("Operation Cancelled. Not an Azure context.");
}
}
public void SetServiceSession(HttpRequest request, HttpResponse response, HttpContext httpContext)
{
if (GxContext.IsAzureContext)
{
if ((context != null && context.HttpContext != null) && (Request != null && Response != null))
{
GXHttpAzureContext httpAzureContext = new GXHttpAzureContext(Request, Response, _cacheService);
if (httpAzureContext != null && httpAzureContext.Session != null && context != null && context.HttpContext != null)
context.HttpContext.Session = httpAzureContext.Session;
else
GXLogging.Debug(log, $"Error : Azure Serverless session could not be created.");
}
else
{
if (context != null)
{
context.HttpContext = httpContext;
GXHttpAzureContext httpAzureContext = new GXHttpAzureContext(request, response, _cacheService);
if (httpAzureContext != null && httpAzureContext.Session != null && context != null && context.HttpContext != null)
context.HttpContext.Session = httpAzureContext.Session;
else
GXLogging.Debug(log, $"Error : Azure Serverless session could not be created.");
}
}
}
else
{
GXLogging.Debug(log, "Error: Not an Azure context.");
throw new Exception("Operation Cancelled. Not an Azure context.");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
using System.Threading;
Expand All @@ -23,15 +24,17 @@ public class GXHttpAzureContext
public GXHttpAzureContext( HttpRequest request, HttpResponse response, ICacheService2 redis)
{
bool isSecure = IsSecureConnection(request);
sessionId = request.Cookies[AzureSessionId];

if (request != null && request.Cookies != null && request.Cookies[AzureSessionId] != null)
sessionId = request.Cookies[AzureSessionId];

if (redis != null && redis.GetType() == typeof(Redis))
_redis = redis;

if (string.IsNullOrEmpty(sessionId))
if (string.IsNullOrEmpty(sessionId) && request != null)
CreateSessionId(isSecure, response, request);

if ((_redis != null) & (sessionId != null))
if ((_redis != null) && (sessionId != null))
session = new RedisHttpSession(_redis, sessionId);
else
session = new MockHttpSession();
Expand Down Expand Up @@ -93,7 +96,7 @@ private void CreateSessionId(bool isSecure, HttpResponse response, HttpRequest r
public class MockHttpSession : ISession
{
string _sessionId = Guid.NewGuid().ToString();
readonly Dictionary<string, object> _sessionStorage = new Dictionary<string, object>();
readonly ConcurrentDictionary<string, object> _sessionStorage = new ConcurrentDictionary<string, object>();
string ISession.Id => _sessionId;
bool ISession.IsAvailable => throw new NotImplementedException();
IEnumerable<string> ISession.Keys => _sessionStorage.Keys;
Expand All @@ -111,22 +114,32 @@ Task ISession.LoadAsync(CancellationToken cancellationToken)
}
void ISession.Remove(string key)
{
_sessionStorage.Remove(key);
_sessionStorage.TryRemove(key, out Object value);
}
void ISession.Set(string key, byte[] value)
{
_sessionStorage[key] = Encoding.UTF8.GetString(value);
}
bool ISession.TryGetValue(string key, out byte[] value)
{

if (_sessionStorage.ContainsKey(key) && _sessionStorage[key] != null)
{
value = Encoding.ASCII.GetBytes(_sessionStorage[key].ToString());
return true;
value = Array.Empty<byte>();
try
{
if (_sessionStorage != null && _sessionStorage.ContainsKey(key) && _sessionStorage[key] != null)
{
value = Encoding.ASCII.GetBytes(_sessionStorage[key].ToString());
return true;
}
else
{
value = Array.Empty<byte>();
return false;
}
}
value = null;
return false;
catch (Exception ex)
{
throw ex;
}
}
}
public class RedisHttpSession : ISession
Expand Down Expand Up @@ -211,7 +224,7 @@ public bool TryGetValue(string key, out byte[] value)
}
}
}
value = null;
value = Array.Empty<byte>();
return false;
}
public bool SessionKeyExists(string sessionId)
Expand Down
Loading
Loading