Split VAR.WebForms.Common to a class library.
This commit is contained in:
@@ -84,6 +84,26 @@ namespace VAR.Focus.Web.Code
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Session_IsUserAuthenticated(HttpContext context)
|
||||
{
|
||||
Session session = Session_GetCurrent(context);
|
||||
if (session == null) { return false; }
|
||||
User user = Users.Current.User_GetByName(session.UserName);
|
||||
if (user == null) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
public User Session_GetCurrentUser(HttpContext context)
|
||||
{
|
||||
Session session = Session_GetCurrent(context);
|
||||
if (session == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
User user = Users.Current.User_GetByName(session.UserName);
|
||||
return user;
|
||||
}
|
||||
|
||||
#endregion Public methods
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Pages;
|
||||
using VAR.Json;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
|
||||
@@ -3,8 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Json;
|
||||
using VAR.WebForms.Common.Code;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.BusinessLogic.Persistence;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.BusinessLogic.Persistence;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
|
||||
29
VAR.Focus.Web/FocusGlobalConfig.cs
Normal file
29
VAR.Focus.Web/FocusGlobalConfig.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Pages;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web
|
||||
{
|
||||
public class FocusGlobalConfig : IGlobalConfig
|
||||
{
|
||||
public string Title { get; } = "Focus";
|
||||
public string TitleSeparator { get; } = " :: ";
|
||||
public string Author { get; } = "Valeriano Alfonso Rodriguez";
|
||||
public string Copyright { get; } = "Copyright (c) 2015-2018 by Valeriano Alfonso, All Right Reserved";
|
||||
public string DefaultHandler { get; } = nameof(FrmBoard);
|
||||
public string LoginHandler { get; } = nameof(FrmLogin);
|
||||
public List<string> AllowedExtensions { get; } = new List<string> { ".png", ".jpg", ".jpeg", ".gif", ".ico", ".wav", ".mp3", ".ogg", ".mp4", ".webm", ".webp", ".mkv", ".avi" };
|
||||
|
||||
public bool IsUserAuthenticated(HttpContext context)
|
||||
{
|
||||
return WebSessions.Current.Session_IsUserAuthenticated(context);
|
||||
}
|
||||
|
||||
public void UserUnauthenticate(HttpContext context)
|
||||
{
|
||||
WebSessions.Current.Session_FinalizeCurrent(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VAR.Focus.Web
|
||||
{
|
||||
public static class Globals
|
||||
{
|
||||
public const string Title = "Focus";
|
||||
public const string TitleSeparator = " :: ";
|
||||
public const string Author = "Valeriano Alfonso Rodriguez";
|
||||
public const string Copyright = "Copyright (c) 2015-2018 by Valeriano Alfonso, All Right Reserved";
|
||||
public const string DefaultHandler = "FrmBoard";
|
||||
public static List<string> AllowedExtensions = new List<string> { ".png", ".jpg", ".jpeg", ".gif", ".ico", ".wav", ".mp3", ".ogg", ".mp4", ".webm", ".webp", ".mkv", ".avi" };
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@ using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Controls;
|
||||
using VAR.WebForms.Common.Code;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
using VAR.WebForms.Common.Pages;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
@@ -52,7 +55,8 @@ namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
if (FormUtils.Controls_AreValid(Controls) == false) { return; }
|
||||
|
||||
Board board = Boards.Current.Boards_SetBoard(0, _txtTitle.Text, _txtDescription.Text, null, CurrentUser.Name);
|
||||
User user = WebSessions.Current.Session_GetCurrentUser(Context);
|
||||
Board board = Boards.Current.Boards_SetBoard(0, _txtTitle.Text, _txtDescription.Text, null, user.Name);
|
||||
_idBoard = board.IDBoard;
|
||||
|
||||
Response.Redirect(GetUrl(_idBoard));
|
||||
@@ -77,7 +81,8 @@ namespace VAR.Focus.Web.Pages
|
||||
CButton btnEdit = (CButton)sender;
|
||||
int idBoard = Convert.ToInt32(btnEdit.CommandArgument);
|
||||
|
||||
if (Boards.Current.Boards_DelBoard(idBoard, CurrentUser.Name))
|
||||
User user = WebSessions.Current.Session_GetCurrentUser(Context);
|
||||
if (Boards.Current.Boards_DelBoard(idBoard, user.Name))
|
||||
{
|
||||
Controls.Clear();
|
||||
FrmBoard_InitIndex();
|
||||
@@ -146,7 +151,8 @@ namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
Title = "Boards";
|
||||
|
||||
List<Board> boards = Boards.Current.Boards_GetListForUser(CurrentUser.Name);
|
||||
User user = WebSessions.Current.Session_GetCurrentUser(Context);
|
||||
List<Board> boards = Boards.Current.Boards_GetListForUser(user?.Name);
|
||||
foreach (Board board in boards)
|
||||
{
|
||||
Panel pnlBoardSelector = BoardSelector_Create(board);
|
||||
@@ -167,6 +173,7 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
private void FrmBoard_InitBoard()
|
||||
{
|
||||
User user = WebSessions.Current.Session_GetCurrentUser(Context);
|
||||
Board board = Boards.Current.Board_GetByIDBoard(_idBoard);
|
||||
|
||||
Title = board.Title;
|
||||
@@ -175,7 +182,7 @@ namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
ID = "ctrCardBoard",
|
||||
IDBoard = board.IDBoard,
|
||||
UserName = CurrentUser.Name,
|
||||
UserName = user.Name,
|
||||
};
|
||||
Controls.Add(cardBoardControl);
|
||||
|
||||
@@ -183,7 +190,7 @@ namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
ID = "ctrChat",
|
||||
IDMessageBoard = string.Format("CardBoard_{0}", board.IDBoard),
|
||||
UserName = CurrentUser.Name,
|
||||
UserName = user.Name,
|
||||
};
|
||||
Controls.Add(chatControl);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ using System.Web.UI.WebControls;
|
||||
using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Controls;
|
||||
using VAR.WebForms.Common.Code;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
using VAR.WebForms.Common.Pages;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
@@ -59,12 +61,13 @@ namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
if (FormUtils.Controls_AreValid(Controls) == false) { return; }
|
||||
|
||||
User user = WebSessions.Current.Session_GetCurrentUser(Context);
|
||||
Board board = Boards.Current.Boards_SetBoard(
|
||||
_idBoard,
|
||||
_txtTitle.Text,
|
||||
_txtDescription.Text,
|
||||
_txtDescription.GetClientsideHeight(),
|
||||
CurrentUser.Name);
|
||||
user.Name);
|
||||
|
||||
// FIXME: Notify User of "Save Succesfully"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Controls;
|
||||
using VAR.WebForms.Common.Code;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
using VAR.WebForms.Common.Pages;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
@@ -44,7 +46,7 @@ namespace VAR.Focus.Web.Pages
|
||||
}
|
||||
|
||||
WebSessions.Current.Session_Init(Context, _txtNameEmail.Text);
|
||||
Response.Redirect(Globals.DefaultHandler);
|
||||
Response.Redirect(GlobalConfig.Get().DefaultHandler);
|
||||
}
|
||||
|
||||
#endregion UI Events
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Controls;
|
||||
using VAR.WebForms.Common.Code;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
using VAR.WebForms.Common.Pages;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
@@ -66,7 +67,7 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
private void btnExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect(Globals.DefaultHandler);
|
||||
Response.Redirect(GlobalConfig.Get().DefaultHandler);
|
||||
}
|
||||
|
||||
#endregion UI Events
|
||||
|
||||
@@ -45,9 +45,8 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="VAR.Json, Version=1.0.6252.27492, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\VAR.Json.1.0.6252.27492\lib\net461\VAR.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="VAR.Json, Version=1.1.1.36534, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\VAR.Json.1.1.1.36534\lib\net461\VAR.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -82,45 +81,24 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Code\Bundler.cs" />
|
||||
<Compile Include="Code\ExtensionMethods.cs" />
|
||||
<Compile Include="Code\MultiLang.cs" />
|
||||
<Compile Include="Code\StaticFileHelper.cs" />
|
||||
<Compile Include="Code\WebSessions.cs" />
|
||||
<Compile Include="Controls\CtrCardBoard.cs" />
|
||||
<Compile Include="Controls\HndCardBoard.cs" />
|
||||
<Compile Include="Controls\CButton.cs" />
|
||||
<Compile Include="Controls\CtrChat.cs" />
|
||||
<Compile Include="Controls\HndChat.cs" />
|
||||
<Compile Include="Controls\CLabel.cs" />
|
||||
<Compile Include="Controls\CTextBox.cs" />
|
||||
<Compile Include="Controls\IValidableControl.cs" />
|
||||
<Compile Include="Code\GlobalErrorHandler.cs" />
|
||||
<Compile Include="GlobalModule.cs" />
|
||||
<Compile Include="Pages\FormUtils.cs" />
|
||||
<Compile Include="Pages\FrmBoard.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Pages\FrmBoardEdit.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Pages\FrmEcho.cs" />
|
||||
<Compile Include="Pages\FrmLogin.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Pages\FrmRegister.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Pages\PageCommon.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Code\ScriptsBundler.cs" />
|
||||
<Compile Include="Code\StylesBundler.cs" />
|
||||
<Compile Include="GlobalRouter.cs" />
|
||||
<Compile Include="Pages\FrmError.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Globals.cs" />
|
||||
<Compile Include="FocusGlobalConfig.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -128,6 +106,10 @@
|
||||
<Project>{d88af21d-1c60-4b27-abff-a133d6afc51c}</Project>
|
||||
<Name>VAR.Focus.BusinessLogic</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\VAR.WebForms.Common\VAR.WebForms.Common.csproj">
|
||||
<Project>{328bb4e2-58f2-4beb-a619-ce3fa842ef43}</Project>
|
||||
<Name>VAR.WebForms.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="VAR.Json" version="1.0.6252.27492" targetFramework="net461" />
|
||||
<package id="VAR.Json" version="1.1.1.36534" targetFramework="net461" />
|
||||
</packages>
|
||||
@@ -4,11 +4,11 @@
|
||||
<compilation debug="true" targetFramework="4.6.1" />
|
||||
<httpModules>
|
||||
<remove name="GlobalModule" />
|
||||
<add name="GlobalModule" type="VAR.Focus.Web.GlobalModule" />
|
||||
<add name="GlobalModule" type="VAR.WebForms.Common.GlobalModule" />
|
||||
</httpModules>
|
||||
<httpHandlers>
|
||||
<clear />
|
||||
<add path="*" verb="*" type="VAR.Focus.Web.GlobalRouter" />
|
||||
<add path="*" verb="*" type="VAR.WebForms.Common.GlobalRouter" />
|
||||
</httpHandlers>
|
||||
<pages clientIDMode="AutoID" enableViewState="false" enableSessionState="false" enableViewStateMac="false" />
|
||||
<httpRuntime enableVersionHeader="false" />
|
||||
@@ -16,11 +16,11 @@
|
||||
<system.webServer>
|
||||
<modules>
|
||||
<remove name="GlobalModule" />
|
||||
<add name="GlobalModule" type="VAR.Focus.Web.GlobalModule" />
|
||||
<add name="GlobalModule" type="VAR.WebForms.Common.GlobalModule" />
|
||||
</modules>
|
||||
<handlers>
|
||||
<clear />
|
||||
<add name="GlobalRouter" path="*" verb="*" type="VAR.Focus.Web.GlobalRouter" />
|
||||
<add name="GlobalRouter" path="*" verb="*" type="VAR.WebForms.Common.GlobalRouter" />
|
||||
</handlers>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
<httpProtocol>
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace VAR.Focus.Web.Code
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public class Bundler
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Web;
|
||||
using VAR.Json;
|
||||
|
||||
namespace VAR.Focus.Web.Code
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public static class ExtensionMethods
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace VAR.Focus.Web.Code
|
||||
|
||||
public static void ResponseObject(this HttpContext context, object obj)
|
||||
{
|
||||
var jsonWritter = new JsonWriter(true);
|
||||
var jsonWritter = new JsonWriter();
|
||||
context.Response.ContentType = "text/json";
|
||||
string strObject = jsonWritter.Write(obj);
|
||||
context.Response.Write(strObject);
|
||||
29
VAR.WebForms.Common/Code/GlobalConfig.cs
Normal file
29
VAR.WebForms.Common/Code/GlobalConfig.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public static class GlobalConfig
|
||||
{
|
||||
private static IGlobalConfig _globalConfig = null;
|
||||
|
||||
public static IGlobalConfig Get()
|
||||
{
|
||||
if (_globalConfig == null)
|
||||
{
|
||||
Type iGlobalConfig = typeof(IGlobalConfig);
|
||||
Type foundGlobalConfig = AppDomain.CurrentDomain
|
||||
.GetAssemblies()
|
||||
.SelectMany(x => x.GetTypes())
|
||||
.Where(x =>
|
||||
x.IsAbstract == false &&
|
||||
x.IsInterface == false &&
|
||||
iGlobalConfig.IsAssignableFrom(x) &&
|
||||
true)
|
||||
.FirstOrDefault();
|
||||
_globalConfig = ObjectActivator.CreateInstance(foundGlobalConfig) as IGlobalConfig;
|
||||
}
|
||||
return _globalConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using VAR.Focus.Web.Pages;
|
||||
using VAR.WebForms.Common.Pages;
|
||||
|
||||
namespace VAR.Focus.Web.Code
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public static class GlobalErrorHandler
|
||||
{
|
||||
19
VAR.WebForms.Common/Code/IGlobalConfig.cs
Normal file
19
VAR.WebForms.Common/Code/IGlobalConfig.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public interface IGlobalConfig
|
||||
{
|
||||
string Title { get; }
|
||||
string TitleSeparator { get; }
|
||||
string Author { get; }
|
||||
string Copyright { get; }
|
||||
string DefaultHandler { get; }
|
||||
string LoginHandler { get; }
|
||||
List<string> AllowedExtensions { get; }
|
||||
|
||||
bool IsUserAuthenticated(HttpContext context);
|
||||
void UserUnauthenticate(HttpContext context);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Reflection;
|
||||
using System.Web;
|
||||
using VAR.Json;
|
||||
|
||||
namespace VAR.Focus.Web.Code
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public class MultiLang
|
||||
{
|
||||
35
VAR.WebForms.Common/Code/ObjectActivator.cs
Normal file
35
VAR.WebForms.Common/Code/ObjectActivator.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public class ObjectActivator
|
||||
{
|
||||
private static Dictionary<Type, Func<object>> _creators = new Dictionary<Type, Func<object>>();
|
||||
|
||||
public static Func<object> GetLambdaNew(Type type)
|
||||
{
|
||||
if (_creators.ContainsKey(type))
|
||||
{
|
||||
return _creators[type];
|
||||
}
|
||||
|
||||
lock (_creators)
|
||||
{
|
||||
NewExpression newExp = Expression.New(type);
|
||||
LambdaExpression lambda = Expression.Lambda(typeof(Func<object>), newExp);
|
||||
Func<object> compiledLambdaNew = (Func<object>)lambda.Compile();
|
||||
|
||||
_creators.Add(type, compiledLambdaNew);
|
||||
}
|
||||
return _creators[type];
|
||||
}
|
||||
|
||||
public static object CreateInstance(Type type)
|
||||
{
|
||||
Func<object> creator = GetLambdaNew(type);
|
||||
return creator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Web;
|
||||
|
||||
namespace VAR.Focus.Web.Code
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public class ScriptsBundler : IHttpHandler
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
|
||||
namespace VAR.Focus.Web.Code
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public class StaticFileHelper
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Web;
|
||||
|
||||
namespace VAR.Focus.Web.Code
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public class StylesBundler : IHttpHandler
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
namespace VAR.WebForms.Common.Controls
|
||||
{
|
||||
public class CButton : Button
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
namespace VAR.WebForms.Common.Controls
|
||||
{
|
||||
public class CLabel : Label
|
||||
{
|
||||
@@ -5,7 +5,7 @@ using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Json;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
namespace VAR.WebForms.Common.Controls
|
||||
{
|
||||
public class CTextBox : Control, INamingContainer, IValidableControl
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace VAR.Focus.Web.Controls
|
||||
namespace VAR.WebForms.Common.Controls
|
||||
{
|
||||
public interface IValidableControl
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
|
||||
namespace VAR.Focus.Web
|
||||
namespace VAR.WebForms.Common
|
||||
{
|
||||
public class GlobalModule : IHttpModule
|
||||
{
|
||||
@@ -4,10 +4,9 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using VAR.Focus.BusinessLogic.Utils;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web
|
||||
namespace VAR.WebForms.Common
|
||||
{
|
||||
public class GlobalRouter : IHttpHandler
|
||||
{
|
||||
@@ -112,12 +111,12 @@ namespace VAR.Focus.Web
|
||||
string file = Path.GetFileName(context.Request.FilePath);
|
||||
if (string.IsNullOrEmpty(file))
|
||||
{
|
||||
file = Globals.DefaultHandler;
|
||||
file = GlobalConfig.Get().DefaultHandler;
|
||||
}
|
||||
|
||||
// Pass allowed extensions requests
|
||||
string extension = Path.GetExtension(context.Request.FilePath).ToLower();
|
||||
if (Globals.AllowedExtensions.Contains(extension))
|
||||
if (GlobalConfig.Get().AllowedExtensions.Contains(extension))
|
||||
{
|
||||
string filePath = context.Request.PhysicalPath;
|
||||
if (File.Exists(filePath))
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Controls;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
namespace VAR.WebForms.Common.Pages
|
||||
{
|
||||
public class FormUtils
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Web;
|
||||
using VAR.Json;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
namespace VAR.WebForms.Common.Pages
|
||||
{
|
||||
public class FrmEcho : IHttpHandler
|
||||
{
|
||||
@@ -14,7 +14,7 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
public void ProcessRequest(HttpContext context)
|
||||
{
|
||||
var jsonWritter = new JsonWriter(true);
|
||||
var jsonWritter = new JsonWriter(new JsonWriterConfiguration(indent: true));
|
||||
context.Response.Write("<pre><code>");
|
||||
context.Response.Write(jsonWritter.Write(context.Request));
|
||||
context.Response.Write("</code></pre>");
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Controls;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
namespace VAR.WebForms.Common.Pages
|
||||
{
|
||||
public class FrmError : PageCommon
|
||||
{
|
||||
@@ -4,12 +4,10 @@ using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Controls;
|
||||
using VAR.WebForms.Common.Code;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
|
||||
namespace VAR.Focus.Web.Pages
|
||||
namespace VAR.WebForms.Common.Pages
|
||||
{
|
||||
public class PageCommon : Page
|
||||
{
|
||||
@@ -23,7 +21,7 @@ namespace VAR.Focus.Web.Pages
|
||||
private CButton _btnLogout = new CButton();
|
||||
|
||||
private bool _mustBeAutenticated = true;
|
||||
private User _currentUser = null;
|
||||
private bool _isAuthenticated = false;
|
||||
|
||||
#endregion Declarations
|
||||
|
||||
@@ -40,11 +38,6 @@ namespace VAR.Focus.Web.Pages
|
||||
set { _mustBeAutenticated = value; }
|
||||
}
|
||||
|
||||
public User CurrentUser
|
||||
{
|
||||
get { return _currentUser; }
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Life cycle
|
||||
@@ -60,18 +53,10 @@ namespace VAR.Focus.Web.Pages
|
||||
{
|
||||
Context.Response.PrepareUncacheableResponse();
|
||||
|
||||
Session session = WebSessions.Current.Session_GetCurrent(Context);
|
||||
if (session != null)
|
||||
_isAuthenticated = GlobalConfig.Get().IsUserAuthenticated(Context);
|
||||
if (_mustBeAutenticated && _isAuthenticated == false)
|
||||
{
|
||||
_currentUser = Users.Current.User_GetByName(session.UserName);
|
||||
if (_mustBeAutenticated)
|
||||
{
|
||||
WebSessions.Current.Session_SetCookie(Context, session);
|
||||
}
|
||||
}
|
||||
if (_currentUser == null && _mustBeAutenticated)
|
||||
{
|
||||
Response.Redirect(nameof(FrmLogin));
|
||||
Response.Redirect(GlobalConfig.Get().LoginHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +67,8 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
private void PageCommon_PreRender(object sender, EventArgs e)
|
||||
{
|
||||
_head.Title = string.IsNullOrEmpty(Title) ? Globals.Title : string.Format("{0}{1}{2}", Title, Globals.TitleSeparator, Globals.Title);
|
||||
_btnLogout.Visible = (_currentUser != null);
|
||||
_head.Title = string.IsNullOrEmpty(Title) ? GlobalConfig.Get().Title : string.Concat(Title, GlobalConfig.Get().TitleSeparator, GlobalConfig.Get().Title);
|
||||
_btnLogout.Visible = _isAuthenticated;
|
||||
}
|
||||
|
||||
#endregion Life cycle
|
||||
@@ -92,11 +77,10 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
private void btnLogout_Click(object sender, EventArgs e)
|
||||
{
|
||||
WebSessions.Current.Session_FinalizeCurrent(Context);
|
||||
_currentUser = null;
|
||||
GlobalConfig.Get().UserUnauthenticate(Context);
|
||||
if (_mustBeAutenticated)
|
||||
{
|
||||
Response.Redirect(nameof(FrmLogin));
|
||||
Response.Redirect(GlobalConfig.Get().LoginHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +103,8 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
_head.Controls.Add(new HtmlMeta { HttpEquiv = "X-UA-Compatible", Content = "IE=Edge" });
|
||||
_head.Controls.Add(new HtmlMeta { HttpEquiv = "content-type", Content = "text/html; charset=utf-8" });
|
||||
_head.Controls.Add(new HtmlMeta { Name = "author", Content = Globals.Author });
|
||||
_head.Controls.Add(new HtmlMeta { Name = "Copyright", Content = Globals.Copyright });
|
||||
_head.Controls.Add(new HtmlMeta { Name = "author", Content = GlobalConfig.Get().Author });
|
||||
_head.Controls.Add(new HtmlMeta { Name = "Copyright", Content = GlobalConfig.Get().Copyright });
|
||||
_head.Controls.Add(new HtmlMeta { Name = "viewport", Content = "width=device-width, initial-scale=1, maximum-scale=4, user-scalable=1" });
|
||||
|
||||
string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
@@ -139,7 +123,7 @@ namespace VAR.Focus.Web.Pages
|
||||
lnkTitle.NavigateUrl = ".";
|
||||
pnlHeader.Controls.Add(lnkTitle);
|
||||
|
||||
var lblTitle = new CLabel { Text = Globals.Title, Tag = "h1" };
|
||||
var lblTitle = new CLabel { Text = GlobalConfig.Get().Title, Tag = "h1" };
|
||||
lnkTitle.Controls.Add(lblTitle);
|
||||
|
||||
_btnPostback.ID = "btnPostback";
|
||||
36
VAR.WebForms.Common/Properties/AssemblyInfo.cs
Normal file
36
VAR.WebForms.Common/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("VAR.WebForms.Common")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("VAR.WebForms.Common")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("328bb4e2-58f2-4beb-a619-ce3fa842ef43")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
78
VAR.WebForms.Common/VAR.WebForms.Common.csproj
Normal file
78
VAR.WebForms.Common/VAR.WebForms.Common.csproj
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{328BB4E2-58F2-4BEB-A619-CE3FA842EF43}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VAR.WebForms.Common</RootNamespace>
|
||||
<AssemblyName>VAR.WebForms.Common</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="VAR.Json, Version=1.1.1.36534, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\VAR.Json.1.1.1.36534\lib\net461\VAR.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Code\Bundler.cs" />
|
||||
<Compile Include="Code\ExtensionMethods.cs" />
|
||||
<Compile Include="Code\GlobalErrorHandler.cs" />
|
||||
<Compile Include="Code\IGlobalConfig.cs" />
|
||||
<Compile Include="Code\MultiLang.cs" />
|
||||
<Compile Include="Code\ObjectActivator.cs" />
|
||||
<Compile Include="Code\ScriptsBundler.cs" />
|
||||
<Compile Include="Code\StaticFileHelper.cs" />
|
||||
<Compile Include="Code\StylesBundler.cs" />
|
||||
<Compile Include="Controls\CButton.cs" />
|
||||
<Compile Include="Controls\CLabel.cs" />
|
||||
<Compile Include="Controls\CTextBox.cs" />
|
||||
<Compile Include="Controls\IValidableControl.cs" />
|
||||
<Compile Include="Code\GlobalConfig.cs" />
|
||||
<Compile Include="GlobalModule.cs" />
|
||||
<Compile Include="GlobalRouter.cs" />
|
||||
<Compile Include="Pages\FormUtils.cs" />
|
||||
<Compile Include="Pages\FrmEcho.cs" />
|
||||
<Compile Include="Pages\FrmError.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Pages\PageCommon.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
4
VAR.WebForms.Common/packages.config
Normal file
4
VAR.WebForms.Common/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="VAR.Json" version="1.1.1.36534" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user