fixed #1989 - installation on SQLite failing due to DropColumn, fixed #1986 - IClientStartup not getting called for External Modules, added ability to correlate new visitors by IP address
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
@ -75,6 +76,11 @@ namespace Oqtane.Databases
|
||||
|
||||
}
|
||||
|
||||
public virtual void DropColumn(MigrationBuilder builder, string name, string table)
|
||||
{
|
||||
builder.DropColumn(name, table);
|
||||
}
|
||||
|
||||
public abstract DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
|
||||
@ -31,6 +32,8 @@ namespace Oqtane.Databases.Interfaces
|
||||
|
||||
public void UpdateIdentityStoreTableNames(ModelBuilder builder);
|
||||
|
||||
public void DropColumn(MigrationBuilder builder, string name, string table);
|
||||
|
||||
public DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ using Oqtane.Infrastructure;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
@ -222,12 +223,15 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
}
|
||||
}
|
||||
|
||||
// register server startup services
|
||||
var startUps = assembly.GetInstances<IServerStartup>();
|
||||
foreach (var startup in startUps)
|
||||
{
|
||||
startup.ConfigureServices(services);
|
||||
}
|
||||
// dynamically register server startup services
|
||||
assembly.GetInstances<IServerStartup>()
|
||||
.ToList()
|
||||
.ForEach(x => x.ConfigureServices(services));
|
||||
|
||||
// dynamically register client startup services (these services will only be used when running on Blazor Server)
|
||||
assembly.GetInstances<IClientStartup>()
|
||||
.ToList()
|
||||
.ForEach(x => x.ConfigureServices(services));
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Interfaces;
|
||||
// ReSharper disable BuiltInTypeReferenceStyleForMemberAccess
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
@ -126,7 +124,7 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
public void DropColumn(string name)
|
||||
{
|
||||
_migrationBuilder.DropColumn(RewriteName(name), RewriteName(EntityTableName));
|
||||
ActiveDatabase.DropColumn(_migrationBuilder, RewriteName(name), RewriteName(EntityTableName));
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,6 +253,35 @@ namespace Oqtane.Pages
|
||||
|
||||
var VisitorCookie = "APP_VISITOR_" + SiteId.ToString();
|
||||
if (!int.TryParse(Request.Cookies[VisitorCookie], out VisitorId))
|
||||
{
|
||||
VisitorId = -1;
|
||||
bool correlate = true;
|
||||
setting = _settings.GetSetting(EntityNames.Site, SiteId, "VisitorCorrelation");
|
||||
if (setting != null)
|
||||
{
|
||||
correlate = bool.Parse(setting.SettingValue);
|
||||
}
|
||||
if (correlate)
|
||||
{
|
||||
var visitor = _visitors.GetVisitor(SiteId, RemoteIPAddress);
|
||||
if (visitor != null)
|
||||
{
|
||||
VisitorId = visitor.VisitorId;
|
||||
|
||||
Response.Cookies.Append(
|
||||
VisitorCookie,
|
||||
VisitorId.ToString(),
|
||||
new CookieOptions()
|
||||
{
|
||||
Expires = DateTimeOffset.UtcNow.AddYears(1),
|
||||
IsEssential = true
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (VisitorId == -1)
|
||||
{
|
||||
var visitor = new Visitor();
|
||||
visitor.SiteId = SiteId;
|
||||
|
@ -10,6 +10,7 @@ namespace Oqtane.Repository
|
||||
Visitor AddVisitor(Visitor visitor);
|
||||
Visitor UpdateVisitor(Visitor visitor);
|
||||
Visitor GetVisitor(int visitorId);
|
||||
Visitor GetVisitor(int siteId, string IPAddress);
|
||||
void DeleteVisitor(int visitorId);
|
||||
int DeleteVisitors(int age);
|
||||
}
|
||||
|
@ -41,6 +41,11 @@ namespace Oqtane.Repository
|
||||
return _db.Visitor.Find(visitorId);
|
||||
}
|
||||
|
||||
public Visitor GetVisitor(int siteId, string IPAddress)
|
||||
{
|
||||
return _db.Visitor.FirstOrDefault(item => item.SiteId == siteId && item.IPAddress == IPAddress);
|
||||
}
|
||||
|
||||
public void DeleteVisitor(int visitorId)
|
||||
{
|
||||
Visitor visitor = _db.Visitor.Find(visitorId);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user