diff --git a/src/lib/MBS.Web/Control.cs b/src/lib/MBS.Web/Control.cs index da34d3d..8286683 100644 --- a/src/lib/MBS.Web/Control.cs +++ b/src/lib/MBS.Web/Control.cs @@ -13,6 +13,7 @@ public abstract class Control : IWebHandler } public Dictionary PathVariables { get; } = new Dictionary(); + public Control(Dictionary? pathVariables = null) { if (pathVariables == null) @@ -91,7 +92,7 @@ public abstract class Control : IWebHandler { context.Response.ContentType = "application/xhtml+xml"; - OnInit(new RenderEventArgs(context.Request, context.Response)); + OnInit(new RenderEventArgs(context)); XmlWriter writer = XmlWriter.Create(context.Response.Stream); Render(writer); diff --git a/src/lib/MBS.Web/RenderEventArgs.cs b/src/lib/MBS.Web/RenderEventArgs.cs index 7a77606..3f6784c 100644 --- a/src/lib/MBS.Web/RenderEventArgs.cs +++ b/src/lib/MBS.Web/RenderEventArgs.cs @@ -2,14 +2,11 @@ namespace MBS.Web; public class RenderEventArgs : EventArgs { + public WebContext Context { get; } - public WebRequest Request { get; } - public WebResponse Response { get; } - - public RenderEventArgs(WebRequest request, WebResponse response) + public RenderEventArgs(WebContext context) { - Request = request; - Response = response; + Context = context; } } \ No newline at end of file diff --git a/src/lib/MBS.Web/UI/WebControls/AdditionalDetailWidget.cs b/src/lib/MBS.Web/UI/WebControls/AdditionalDetailWidget.cs new file mode 100644 index 0000000..3da8cb1 --- /dev/null +++ b/src/lib/MBS.Web/UI/WebControls/AdditionalDetailWidget.cs @@ -0,0 +1,23 @@ + + +namespace MBS.Web.UI.WebControls; + +public class AdditionalDetailWidget : Container +{ + protected override string TagName => "div"; + + protected override IEnumerable GetStyleClasses() + { + return new string[] { "uwt-actionpreviewbutton apb-show-text apb-style-ellipsis" }; + } + + protected override IList GetChildControls() + { + return base.GetChildControls(); + } + + //
+ //
Manufacturer
+ //
    type to search the list
    +} \ No newline at end of file diff --git a/src/lib/MBS.Web/WebContext.cs b/src/lib/MBS.Web/WebContext.cs index b88742e..d3ac49a 100644 --- a/src/lib/MBS.Web/WebContext.cs +++ b/src/lib/MBS.Web/WebContext.cs @@ -2,14 +2,17 @@ namespace MBS.Web; public class WebContext { - public WebContext(WebApplication application, WebRequest request, WebResponse response) + public WebContext(WebApplication application, WebRequest request, WebResponse response, Dictionary session) { Application = application; Request = request; Response = response; + Session = session; } public WebApplication Application { get; } public WebRequest Request { get; } public WebResponse Response { get; } + + public Dictionary Session { get; } } diff --git a/src/lib/MBS.Web/WebServer.cs b/src/lib/MBS.Web/WebServer.cs index 5bad89c..d4a4ca3 100644 --- a/src/lib/MBS.Web/WebServer.cs +++ b/src/lib/MBS.Web/WebServer.cs @@ -133,6 +133,8 @@ public class WebServer return sb.ToString(); } + private Dictionary> _sessions = new Dictionary>(); + private void HandleClient(System.Net.Sockets.TcpClient client) { // WebServerProcessRequestEventArgs e = new WebServerProcessRequestEventArgs(); @@ -172,7 +174,6 @@ public class WebServer while (true) { string headerLine = sr.ReadLine(); - Console.WriteLine(headerLine); if (String.IsNullOrEmpty(headerLine)) break; @@ -182,8 +183,6 @@ public class WebServer continue; headers[headerParts[0].Trim()] = headerParts[1].Trim(); - - Console.WriteLine("remaining: {0}", client.Available); } Dictionary form = new Dictionary(); @@ -205,16 +204,45 @@ public class WebServer } } + Dictionary session; + string cookie = "", cookieKey = "", cookieValue = ""; if (headers[HttpRequestHeader.Cookie] != null) { - string cookie = headers[HttpRequestHeader.Cookie]; + cookie = headers[HttpRequestHeader.Cookie]; + + string[] cookieParts = cookie.Split(new char[] { ';' }); + if (cookieParts.Length >= 1) + { + string[] cookieParts2 = cookieParts[0].Split(new char[] { '=' }); + if (cookieParts2.Length >= 2) + { + cookieKey = cookieParts2[0]; + cookieValue = cookieParts2[1]; //cookies[cookieKey] = cookieValue; + } + } + + if (!_sessions.ContainsKey(cookieValue)) + { + _sessions[cookieValue] = new Dictionary(); + } + + session = _sessions[cookieValue]; + } + else + { + session = new Dictionary(); + } + + if (cookieValue == "") + { + cookieValue = "0068F5AD24A89AB4AFCC4057F619EADF.authgwy-prod-mzzygbiy.prod-ui-auth.pr502.cust.pdx.wd"; } bool found = false; Dictionary pathVariables = new Dictionary(); - WebContext context = new WebContext((WebApplication)Application.Instance, new WebRequest(version, requestMethod, path, headers, pathVariables, form), new WebResponse()); - context.Response.Cookies.Add("JSESSIONID", "0068F5AD24A89AB4AFCC4057F619EADF.authgwy-prod-mzzygbiy.prod-ui-auth.pr502.cust.pdx.wd", WebCookieScope.FromPath("/"), WebCookieSecurity.Secure | WebCookieSecurity.HttpOnly, WebCookieSameSite.None); + WebContext context = new WebContext((WebApplication)Application.Instance, new WebRequest(version, requestMethod, path, headers, pathVariables, form), new WebResponse(), session); + context.Response.Cookies.Add("JSESSIONID", cookieValue, WebCookieScope.FromPath("/"), WebCookieSecurity.Secure | WebCookieSecurity.HttpOnly, WebCookieSameSite.None); WebServerProcessRequestEventArgs e = new WebServerProcessRequestEventArgs(client, context); OnProcessRequest(e); @@ -235,10 +263,13 @@ public class WebServer if (route.Matches(path, pathVariables)) { - route.Handler.ProcessRequest(context); + lock (route.Handler) + { + route.Handler.ProcessRequest(context); - WriteResponse(context, client.GetStream()); - found = true; + WriteResponse(context, client.GetStream()); + found = true; + } break; } }