Skip to content

Commit

Permalink
Fix whitelabel id generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-YousefiTelori committed Dec 13, 2023
1 parent cd26ee7 commit 17d9332
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.63</Version>
<Version>0.0.0.64</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.63</Version>
<Version>0.0.0.64</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet,aspcore,efcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public async Task<WhiteLabelInfo> Initialize(IHttpContextAccessor httpContext, s
foreach (var entityType in instanceOfContext.Model.GetEntityTypes())
{
string tableName = entityType.GetTableName();
uniqueIdentityManager.AddTableName(entityType.ClrType, tableName);
var tableFullName = uniqueIdentityManager.GetContextTableName(foundMicroservice.Id, contextType.Name, tableName);
if (!addedInWhitLabels.Contains(tableFullName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.63</Version>
<Version>0.0.0.64</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,client,clients</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.63</Version>
<Version>0.0.0.64</Version>
<Description>core contracts.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,contract,contracts,dto,dtos</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public DefaultUniqueIdentityManager(WhiteLabelInfo whiteLabelInfo)

readonly WhiteLabelInfo _whiteLabelInfo;
Dictionary<string, long> TableIds { get; set; } = new Dictionary<string, long>();
Dictionary<Type, string> TableNames { get; set; } = new Dictionary<Type, string>();
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -61,6 +62,16 @@ public bool UpdateUniqueIdentity<TEntity>(IContext context, TEntity entity)
return false;
}

/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <param name="name"></param>
public void AddTableName(Type type,string name)
{
TableNames.Add(type, name);
}

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -154,7 +165,7 @@ public static long[] DecodeUniqueIdentity(string uniqueIdentity)
/// <returns></returns>
public string GetContextTableName<TEntity>(Type contextType, long microserviceId)
{
return GetContextTableName(microserviceId, GetContextName(contextType), typeof(TEntity).Name);
return GetContextTableName(microserviceId, GetContextName(contextType), GetTableName(typeof(TEntity)));
}

/// <summary>
Expand All @@ -174,7 +185,7 @@ public string GetContextName(Type contextType)
/// <returns></returns>
public string GetTableName(Type tableType)
{
return tableType.Name;
return TableNames[tableType];
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.63</Version>
<Version>0.0.0.64</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.63</Version>
<Version>0.0.0.64</Version>
<Description>ef core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.63</Version>
<Version>0.0.0.64</Version>
<Description>ef core of Relational database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore,Relational</PackageTags>
Expand Down

0 comments on commit 17d9332

Please sign in to comment.