Skip to content

Commit

Permalink
v1.0.0.7
Browse files Browse the repository at this point in the history
A couple of breaking changes, especially how Entity- and Mapping- Assembliy Names may be supplied by the user.
  • Loading branch information
smbadiwe committed Sep 29, 2016
1 parent b8105a8 commit 62c1491
Show file tree
Hide file tree
Showing 43 changed files with 863 additions and 449 deletions.
4 changes: 2 additions & 2 deletions ConsoleTests/ConsoleTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="SimpleInjector, Version=3.2.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.3.2.0\lib\net45\SimpleInjector.dll</HintPath>
<Reference Include="SimpleInjector, Version=3.2.2.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.3.2.2\lib\net45\SimpleInjector.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion ConsoleTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SimpleInjector" version="3.2.0" targetFramework="net45" />
<package id="SimpleInjector" version="3.2.2" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
<DocumentationFile>bin\Release Package\MultiTenancyFramework.SimpleInjector.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="SimpleInjector">
<HintPath>..\..\packages\SimpleInjector.3.2.0\lib\net45\SimpleInjector.dll</HintPath>
<Reference Include="SimpleInjector, Version=3.2.2.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\..\packages\SimpleInjector.3.2.2\lib\net45\SimpleInjector.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>$id$</id>
<version>1.0.0.6</version>
<version>1.0.0.7</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
Expand All @@ -13,7 +13,7 @@
<copyright>Copyright 2016</copyright>
<tags>SaaS MultiTenant MultiTenancy Framework Software-as-a-Service IoC SimpleInjector</tags>
<dependencies>
<dependency id="MultiTenancyFramework.Core" version="1.0.0.6" />
<dependency id="MultiTenancyFramework.Core" version="1.0.0.7" />
</dependencies>
</metadata>
</package>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SimpleInjector" version="3.2.0" targetFramework="net45" />
<package id="SimpleInjector" version="3.2.2" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</Reference>
<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" />
Expand All @@ -68,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Maps\ActionAccessPrivilegeMap.cs" />
<Compile Include="RegisterAssemblyHttpModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Queries\GetActionAccessPrivilegesByGridSearchParamsQueryHandler.cs" />
<Compile Include="Queries\GetControllersQueryHandler.cs" />
Expand All @@ -92,6 +94,7 @@
<None Include="app.config" />
<None Include="MultiTenancyFramework.Mvc.NHibernate.nuspec" />
<None Include="packages.config" />
<None Include="web.config.transform" />
</ItemGroup>
<ItemGroup>
<Content Include="readme.txt" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>$id$</id>
<version>1.0.0.6</version>
<version>1.0.0.7</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
Expand All @@ -13,14 +13,15 @@
<copyright>$copyright$</copyright>
<tags>SaaS MultiTenant MultiTenancy Framework Software-as-a-Service MVC5 NHibernate FluentNHibernate</tags>
<dependencies>
<dependency id="MultiTenancyFramework.Core" version="1.0.0.6" />
<dependency id="MultiTenancyFramework.Mvc" version="1.0.0.6" />
<dependency id="MultiTenancyFramework.NHibernate" version="1.0.0.6" />
<dependency id="MultiTenancyFramework.Core" version="1.0.0.7" />
<dependency id="MultiTenancyFramework.Mvc" version="1.0.0.7" />
<dependency id="MultiTenancyFramework.NHibernate" version="1.0.0.7" />
</dependencies>
</metadata>
<files>
<file src="\bin\ReleasePackage\MultiTenancyFramework.Mvc.NHibernate.dll" target="lib\net45" />
<file src="\bin\ReleasePackage\MultiTenancyFramework.Mvc.NHibernate.XML" target="lib\net45" />
<file src="readme.txt" target="" />
<file src="web.config.transform" target="content" />
</files>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using MultiTenancyFramework.NHibernate.NHManager;
using System;
using System.Web;

namespace MultiTenancyFramework.Mvc.NHibernate
{
/// <summary>
/// This module simply adds 'MultiTenancyFramework.Mvc' to the list of entity assemblies
/// and "MultiTenancyFramework.Mvc.NHibernate" to the list of mapping assemblies
/// </summary>
public class RegisterAssemblyHttpModule : IHttpModule
{
public void Dispose()
{

}

public void Init(HttpApplication context)
{
NHSessionManager.AddEntityAssemblies(new[] { "MultiTenancyFramework.Mvc" });
NHSessionManager.AddMappingAssemblies(new[] { "MultiTenancyFramework.Mvc.NHibernate" });
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<configuration>
<system.webServer>
<modules>
<add name="MvcNhibAssemblyModule"
type="MultiTenancyFramework.Mvc.NHibernate.RegisterAssemblyHttpModule, MultiTenancyFramework.Mvc.NHibernate" />
</modules>
</system.webServer>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace System.Web.Mvc.Html
{
public static class MvcExtensions3
public static class HtmlHelperExtensions
{
public static IDictionary<string, object> MergeHtmlAttributes(this HtmlHelper helper, object htmlAttributesObject, object defaultHtmlAttributesObject)
{
Expand Down Expand Up @@ -58,7 +58,7 @@ public static MvcHtmlString MyEnumDropDownListFor<TModel, TEnum>(this HtmlHelper
enumType = Nullable.GetUnderlyingType(enumType);
}
var list = MultiTenancyFramework.EnumHelper.GetEnumNames(enumType);
return htmlHelper.MyEnumDropDownListFor(expression, list, null, htmlAttributes);
return htmlHelper.MyEnumDropDownListFor(expression, list, optionalLabel, htmlAttributes);
}

public static MvcHtmlString MyEnumDropDownListFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression, IEnumerable enumList, string optionalLabel, object htmlAttributes)
Expand Down Expand Up @@ -88,7 +88,7 @@ public static MvcHtmlString MyEnumDropDownListFor<TModel, TEnum>(this HtmlHelper

if (currentValue == null && string.IsNullOrWhiteSpace(optionalLabel))
{
optionalLabel = "---Select Item---";
optionalLabel = "Choose an item...";
}
var selectList = new SelectList(enumList, "Value", "Name", currentValue);

Expand Down
2 changes: 2 additions & 0 deletions MVC5/MultiTenancyFramework.Mvc/Logic/DataCacheMVC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static Dictionary<string, Institution> AllInstitutions
if (allInstitutions == null || allInstitutions.Count == 0)
{
var instDAO = MyServiceLocator.GetInstance<IInstitutionDAO<Institution>>();
//instDAO.SetEntityName<Institution>();
allInstitutions = instDAO.RetrieveAll()?.ToDictionary(x => x.Code);
MemoryCache.Default[ALL_INSTITUTIONS] = allInstitutions;
}
Expand All @@ -40,6 +41,7 @@ public static Dictionary<long, ActionAccessPrivilege> AllPrivileges
if (allPrivileges == null || allPrivileges.Count == 0)
{
var _dao = MyServiceLocator.GetInstance<IPrivilegeDAO<ActionAccessPrivilege>>();
//_dao.SetEntityName<ActionAccessPrivilege>();
allPrivileges = _dao.RetrieveAll()?.ToDictionary(x => x.Id);
MemoryCache.Default[ALL_PRIVILEGES] = allPrivileges;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>$id$</id>
<version>1.0.0.6</version>
<version>1.0.0.7</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
Expand All @@ -13,7 +13,7 @@
<copyright>Copyright 2016</copyright>
<tags>SaaS MultiTenant MultiTenancy Framework Software-as-a-Service MVC5</tags>
<dependencies>
<dependency id="MultiTenancyFramework.Core" version="1.0.0.6" />
<dependency id="MultiTenancyFramework.Core" version="1.0.0.7" />
</dependencies>
</metadata>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class InstitutionRouteConfig
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*staticfile}", new { staticfile = @".*\.(css|less|sass|js|gif|png|jpg|jpeg|ico|svg|ttf|eot\woff|woff2|xml|csv|txt|map|json|pdf|doc|docx|xls|xlsx|dll|exe|pdb)(/.*)?" });
routes.IgnoreRoute("{*staticfile}", new { staticfile = @".*\.(css|less|sass|js|gif|png|jpg|jpeg|ico|svg|ttf|eot|woff|woff2|xml|csv|txt|map|json|pdf|doc|docx|xls|xlsx|dll|exe|pdb)(/.*)?" });

//routes.LowercaseUrls = true; //This worked, but caused some View rendering issues. So I'm using the extension method: .MapRouteLowerCase

Expand Down
1 change: 1 addition & 0 deletions MVC5/MultiTenancyFramework.Mvc/WebUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static string InstitutionCode
set
{
if (string.IsNullOrWhiteSpace(value)) value = Utilities.INST_DEFAULT_CODE;
HttpContext.Current.Request.RequestContext.RouteData.Values["institution"] = value;
HttpContext.Current.Session[SS_CODE] = value;
}
}
Expand Down
5 changes: 5 additions & 0 deletions MultiTenancyFramework.Core/Data/ICoreDAO.General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ public interface ICoreGeneralDAO
/// <param name="query">The query to run.</param>
void RunDirectQueryADODotNET(string query, bool closeConnection = false);

/// <summary>
/// When more than one entity can be mapped to a table, this will scan and select the correct one, based mostly on the inheritance structure.
/// </summary>
void SetEntityName<T>();
}

}
2 changes: 1 addition & 1 deletion MultiTenancyFramework.Core/IoC/IoCUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static HashSet<Assembly> GetAssembliesForRegistration(string iocAssemblyN
if (frameworkDlls == null || !frameworkDlls.Any())
{
// Maybe it's Web and we're not looking into the bin folder. So...
execFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin");
execFolder = Path.Combine(execFolder, "bin");
frameworkDlls = Directory.EnumerateFiles(execFolder, "MultiTenancyFramework*.dll", SearchOption.TopDirectoryOnly);
}
if (frameworkDlls != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>$id$</id>
<version>1.0.0.6</version>
<version>1.0.0.7</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
Expand Down
11 changes: 9 additions & 2 deletions MultiTenancyFramework.Core/Utility/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public static string GenerateRandomAlphanumericText(int length)
public const string SoftDeleteFilterName = "SoftDeleteFilter";
public const string InstitutionCodePropertyName = "InstitutionCode";
public const string InstitutionCodeQueryParamName = "instCode";


/// <summary>
/// The default value is "Password@1". To change it, add key: 'DefaultPassword' to your appSettings in your config file.
/// <para>When changing, stick to the password rules setup</para>para>
/// </summary>
public static string DefaultPassword
{
get
Expand All @@ -49,6 +53,9 @@ public static string DefaultPassword
}
}

/// <summary>
/// To set it, add key: 'EntityAssemblies' to your appSettings in your config file. If value is more than one items, use comma-separated list
/// </summary>
public static string[] EntityAssemblies
{
get
Expand All @@ -72,7 +79,7 @@ public static ILogger Logger
public static IDbQueryProcessor QueryProcessor { get { return MyServiceLocator.GetInstance<IDbQueryProcessor>(); } }


public const string SS_SYS_SETTINGS = "::SystemSettings::";
private const string SS_SYS_SETTINGS = "::SystemSettings::";

public static SystemSetting SystemSettings
{
Expand Down
11 changes: 10 additions & 1 deletion MultiTenancyFramework.NHibernate/CoreGeneralDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System;

namespace MultiTenancyFramework.NHibernate
{
Expand All @@ -26,7 +27,7 @@ public string InstitutionCode
_institutionCode = value;
}
}

public string EntityName { get; set; }

public CoreGeneralDAO()
Expand Down Expand Up @@ -54,6 +55,7 @@ public void ClearCurrentSession()
/// WARNING:
/// <para>DO NOT use this session directly for anything other than retrieves (like constructing QueryOver or CreateCriteria).
/// For every other case, use what is provided in the base class</para>
/// <para>NB: The returned session only Flushes when you commit. You can always change to .FlushMode to your taste.</para>
/// </summary>
/// <returns></returns>
public virtual ISession BuildSession()
Expand Down Expand Up @@ -118,5 +120,12 @@ public bool IsMySql()
return NHSessionManager.IsMySqlDatabase();
}

/// <summary>
/// When more than one entity can be mapped to a table, this will scan and select the correct one, based mostly on the inheritance structure.
/// </summary>
public void SetEntityName<T>()
{
EntityName = NHSessionManager.GetEntityNameToUseInNHSession(typeof(T));
}
}
}
2 changes: 1 addition & 1 deletion MultiTenancyFramework.NHibernate/InstitutionDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class InstitutionDAO<T> : CoreDAO<T>, IInstitutionDAO<T> where T : Instit
{
public InstitutionDAO()
{
EntityName = NHManager.NHSessionManager.GetEntityNameToUseInNHSession(typeof(Institution));
EntityName = NHManager.NHSessionManager.GetEntityNameToUseInNHSession(typeof(T));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>$id$</id>
<version>1.0.0.6</version>
<version>1.0.0.7</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
Expand All @@ -13,7 +13,7 @@
<copyright>$copyright$</copyright>
<tags>SaaS MultiTenant MultiTenancy Framework Software-as-a-Service MVC5 NHibernate FluentNHibernate</tags>
<dependencies>
<dependency id="MultiTenancyFramework.Core" version="1.0.0.6" />
<dependency id="MultiTenancyFramework.Core" version="1.0.0.7" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentNHibernate.Mapping;
using NHibernate;
using System;

namespace MultiTenancyFramework.NHibernate.NHManager.Listeners
{
Expand Down
Loading

0 comments on commit 62c1491

Please sign in to comment.