Abp.Zero框架升级
本次采用的是项目迁移,注意问题
AppPermissions 文件内容
AppSettingProvider 文件内容
UiCustomizationSettingsAppService 文件内容
Startup.cs文件
注意内容及顺序
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews(options =>
{
options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
})
#if DEBUG
.AddRazorRuntimeCompilation()
#endif
.AddNewtonsoftJson();
//配置Cookie策略,不然部分浏览器非SSL无法登录系统
services.Configure<CookiePolicyOptions>(options =>
{
options.MinimumSameSitePolicy = SameSiteMode.Lax;
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<AbpCommonHub>("/signalr");
endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
}
迁移脚本命令
迁移脚本需注意文件处理
WebContentDirectoryFinder.cs
EF Core迁移命令
dotnet ef database update --startup-project=./x.Web.Mvc --project=./x.EntityFrameworkCore --context=xDbContext
EF CoreSQL
dotnet ef migrations script Upgrated_To_ABP_4_8_0 Upgraded_To_Abp_6_4_0 --startup-project=./x.Web.Mvc --project=./x.EntityFrameworkCore --context=xDbContext
BEGIN TRANSACTION;
GO
ALTER TABLE [AbpEditions] ADD [DailyPrice] decimal(18,2) NULL;
GO
ALTER TABLE [AbpEditions] ADD [WeeklyPrice] decimal(18,2) NULL;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20190801133107_Updated_SubscribableEdition', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
CREATE TABLE [AppSubscriptionPaymentsExtensionData] (
[Id] bigint NOT NULL IDENTITY,
[SubscriptionPaymentId] bigint NOT NULL,
[Key] nvarchar(450) NULL,
[Value] nvarchar(max) NULL,
[IsDeleted] bit NOT NULL,
CONSTRAINT [PK_AppSubscriptionPaymentsExtensionData] PRIMARY KEY ([Id])
);
GO
CREATE UNIQUE INDEX [IX_AppSubscriptionPaymentsExtensionData_SubscriptionPaymentId_Key_IsDeleted] ON [AppSubscriptionPaymentsExtensionData] ([SubscriptionPaymentId], [Key], [IsDeleted]) WHERE [Key] IS NOT NULL;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20191015062846_Add_Subscription_Payment_Extension_Data', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
ALTER TABLE [AppSubscriptionPayments] ADD [EditionPaymentType] int NOT NULL DEFAULT 0;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20191120123128_Add-EditionPaymentType-To-SubscriptionPayment', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
DROP INDEX [IX_AbpUserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result] ON [AbpUserLoginAttempts];
DECLARE @var0 sysname;
SELECT @var0 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AbpUserLoginAttempts]') AND [c].[name] = N'UserNameOrEmailAddress');
IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [AbpUserLoginAttempts] DROP CONSTRAINT [' + @var0 + '];');
ALTER TABLE [AbpUserLoginAttempts] ALTER COLUMN [UserNameOrEmailAddress] nvarchar(256) NULL;
CREATE INDEX [IX_AbpUserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result] ON [AbpUserLoginAttempts] ([TenancyName], [UserNameOrEmailAddress], [Result]);
GO
DECLARE @var1 sysname;
SELECT @var1 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AbpSettings]') AND [c].[name] = N'Value');
IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [AbpSettings] DROP CONSTRAINT [' + @var1 + '];');
ALTER TABLE [AbpSettings] ALTER COLUMN [Value] nvarchar(max) NULL;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20191213093244_Upgraded_To_ABP_5_1', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
CREATE TABLE [AbpWebhookEvents] (
[Id] uniqueidentifier NOT NULL,
[WebhookName] nvarchar(max) NOT NULL,
[Data] nvarchar(max) NULL,
[CreationTime] datetime2 NOT NULL,
[TenantId] int NULL,
[IsDeleted] bit NOT NULL,
[DeletionTime] datetime2 NULL,
CONSTRAINT [PK_AbpWebhookEvents] PRIMARY KEY ([Id])
);
GO
CREATE TABLE [AbpWebhookSubscriptions] (
[Id] uniqueidentifier NOT NULL,
[CreationTime] datetime2 NOT NULL,
[CreatorUserId] bigint NULL,
[TenantId] int NULL,
[WebhookUri] nvarchar(max) NOT NULL,
[Secret] nvarchar(max) NOT NULL,
[IsActive] bit NOT NULL,
[Webhooks] nvarchar(max) NULL,
[Headers] nvarchar(max) NULL,
CONSTRAINT [PK_AbpWebhookSubscriptions] PRIMARY KEY ([Id])
);
GO
CREATE TABLE [AbpWebhookSendAttempts] (
[Id] uniqueidentifier NOT NULL,
[WebhookEventId] uniqueidentifier NOT NULL,
[WebhookSubscriptionId] uniqueidentifier NOT NULL,
[Response] nvarchar(max) NULL,
[ResponseStatusCode] int NULL,
[CreationTime] datetime2 NOT NULL,
[LastModificationTime] datetime2 NULL,
[TenantId] int NULL,
CONSTRAINT [PK_AbpWebhookSendAttempts] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AbpWebhookSendAttempts_AbpWebhookEvents_WebhookEventId] FOREIGN KEY ([WebhookEventId]) REFERENCES [AbpWebhookEvents] ([Id]) ON DELETE CASCADE
);
GO
CREATE INDEX [IX_AbpWebhookSendAttempts_WebhookEventId] ON [AbpWebhookSendAttempts] ([WebhookEventId]);
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200117141413_Upgraded_To_ABP_5_2_0', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200305082815_Upgraded_To_Abp_5_3', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
CREATE TABLE [AppUserDelegations] (
[Id] bigint NOT NULL IDENTITY,
[CreationTime] datetime2 NOT NULL,
[CreatorUserId] bigint NULL,
[LastModificationTime] datetime2 NULL,
[LastModifierUserId] bigint NULL,
[IsDeleted] bit NOT NULL,
[DeleterUserId] bigint NULL,
[DeletionTime] datetime2 NULL,
[SourceUserId] bigint NOT NULL,
[TargetUserId] bigint NOT NULL,
[TenantId] int NULL,
[StartTime] datetime2 NOT NULL,
[EndTime] datetime2 NOT NULL,
CONSTRAINT [PK_AppUserDelegations] PRIMARY KEY ([Id])
);
GO
CREATE INDEX [IX_AppUserDelegations_TenantId_SourceUserId] ON [AppUserDelegations] ([TenantId], [SourceUserId]);
GO
CREATE INDEX [IX_AppUserDelegations_TenantId_TargetUserId] ON [AppUserDelegations] ([TenantId], [TargetUserId]);
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200315101156_Added_UserDelegations_Entity', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
CREATE TABLE [AbpDynamicParameters] (
[Id] int NOT NULL IDENTITY,
[ParameterName] nvarchar(450) NULL,
[InputType] nvarchar(max) NULL,
[Permission] nvarchar(max) NULL,
[TenantId] int NULL,
CONSTRAINT [PK_AbpDynamicParameters] PRIMARY KEY ([Id])
);
GO
CREATE TABLE [AbpDynamicParameterValues] (
[Id] int NOT NULL IDENTITY,
[Value] nvarchar(max) NOT NULL,
[TenantId] int NULL,
[DynamicParameterId] int NOT NULL,
CONSTRAINT [PK_AbpDynamicParameterValues] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AbpDynamicParameterValues_AbpDynamicParameters_DynamicParameterId] FOREIGN KEY ([DynamicParameterId]) REFERENCES [AbpDynamicParameters] ([Id]) ON DELETE CASCADE
);
GO
CREATE TABLE [AbpEntityDynamicParameters] (
[Id] int NOT NULL IDENTITY,
[EntityFullName] nvarchar(450) NULL,
[DynamicParameterId] int NOT NULL,
[TenantId] int NULL,
CONSTRAINT [PK_AbpEntityDynamicParameters] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AbpEntityDynamicParameters_AbpDynamicParameters_DynamicParameterId] FOREIGN KEY ([DynamicParameterId]) REFERENCES [AbpDynamicParameters] ([Id]) ON DELETE CASCADE
);
GO
CREATE TABLE [AbpEntityDynamicParameterValues] (
[Id] int NOT NULL IDENTITY,
[Value] nvarchar(max) NOT NULL,
[EntityId] nvarchar(max) NULL,
[EntityDynamicParameterId] int NOT NULL,
[TenantId] int NULL,
CONSTRAINT [PK_AbpEntityDynamicParameterValues] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AbpEntityDynamicParameterValues_AbpEntityDynamicParameters_EntityDynamicParameterId] FOREIGN KEY ([EntityDynamicParameterId]) REFERENCES [AbpEntityDynamicParameters] ([Id]) ON DELETE CASCADE
);
GO
CREATE UNIQUE INDEX [IX_AbpDynamicParameters_ParameterName_TenantId] ON [AbpDynamicParameters] ([ParameterName], [TenantId]) WHERE [ParameterName] IS NOT NULL AND [TenantId] IS NOT NULL;
GO
CREATE INDEX [IX_AbpDynamicParameterValues_DynamicParameterId] ON [AbpDynamicParameterValues] ([DynamicParameterId]);
GO
CREATE INDEX [IX_AbpEntityDynamicParameters_DynamicParameterId] ON [AbpEntityDynamicParameters] ([DynamicParameterId]);
GO
CREATE UNIQUE INDEX [IX_AbpEntityDynamicParameters_EntityFullName_DynamicParameterId_TenantId] ON [AbpEntityDynamicParameters] ([EntityFullName], [DynamicParameterId], [TenantId]) WHERE [EntityFullName] IS NOT NULL AND [TenantId] IS NOT NULL;
GO
CREATE INDEX [IX_AbpEntityDynamicParameterValues_EntityDynamicParameterId] ON [AbpEntityDynamicParameterValues] ([EntityDynamicParameterId]);
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200317114116_Add_Dynamic_Entity_Parameters', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200406060103_Remove_OrganizationUnit_Unique_Index', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
DROP TABLE [AbpDynamicParameterValues];
GO
DROP TABLE [AbpEntityDynamicParameterValues];
GO
DROP TABLE [AbpEntityDynamicParameters];
GO
DROP TABLE [AbpDynamicParameters];
GO
CREATE TABLE [AbpDynamicProperties] (
[Id] int NOT NULL IDENTITY,
[PropertyName] nvarchar(450) NULL,
[InputType] nvarchar(max) NULL,
[Permission] nvarchar(max) NULL,
[TenantId] int NULL,
CONSTRAINT [PK_AbpDynamicProperties] PRIMARY KEY ([Id])
);
GO
CREATE TABLE [AbpDynamicEntityProperties] (
[Id] int NOT NULL IDENTITY,
[EntityFullName] nvarchar(450) NULL,
[DynamicPropertyId] int NOT NULL,
[TenantId] int NULL,
CONSTRAINT [PK_AbpDynamicEntityProperties] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AbpDynamicEntityProperties_AbpDynamicProperties_DynamicPropertyId] FOREIGN KEY ([DynamicPropertyId]) REFERENCES [AbpDynamicProperties] ([Id]) ON DELETE CASCADE
);
GO
CREATE TABLE [AbpDynamicPropertyValues] (
[Id] int NOT NULL IDENTITY,
[Value] nvarchar(max) NOT NULL,
[TenantId] int NULL,
[DynamicPropertyId] int NOT NULL,
CONSTRAINT [PK_AbpDynamicPropertyValues] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AbpDynamicPropertyValues_AbpDynamicProperties_DynamicPropertyId] FOREIGN KEY ([DynamicPropertyId]) REFERENCES [AbpDynamicProperties] ([Id]) ON DELETE CASCADE
);
GO
CREATE TABLE [AbpDynamicEntityPropertyValues] (
[Id] int NOT NULL IDENTITY,
[Value] nvarchar(max) NOT NULL,
[EntityId] nvarchar(max) NULL,
[DynamicEntityPropertyId] int NOT NULL,
[TenantId] int NULL,
CONSTRAINT [PK_AbpDynamicEntityPropertyValues] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AbpDynamicEntityPropertyValues_AbpDynamicEntityProperties_DynamicEntityPropertyId] FOREIGN KEY ([DynamicEntityPropertyId]) REFERENCES [AbpDynamicEntityProperties] ([Id]) ON DELETE CASCADE
);
GO
CREATE INDEX [IX_AbpDynamicEntityProperties_DynamicPropertyId] ON [AbpDynamicEntityProperties] ([DynamicPropertyId]);
GO
CREATE UNIQUE INDEX [IX_AbpDynamicEntityProperties_EntityFullName_DynamicPropertyId_TenantId] ON [AbpDynamicEntityProperties] ([EntityFullName], [DynamicPropertyId], [TenantId]) WHERE [EntityFullName] IS NOT NULL AND [TenantId] IS NOT NULL;
GO
CREATE INDEX [IX_AbpDynamicEntityPropertyValues_DynamicEntityPropertyId] ON [AbpDynamicEntityPropertyValues] ([DynamicEntityPropertyId]);
GO
CREATE UNIQUE INDEX [IX_AbpDynamicProperties_PropertyName_TenantId] ON [AbpDynamicProperties] ([PropertyName], [TenantId]) WHERE [PropertyName] IS NOT NULL AND [TenantId] IS NOT NULL;
GO
CREATE INDEX [IX_AbpDynamicPropertyValues_DynamicPropertyId] ON [AbpDynamicPropertyValues] ([DynamicPropertyId]);
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200805083139_Upgraded_To_Abp_5_11', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
ALTER TABLE [AppBinaryObjects] ADD [Description] nvarchar(max) NULL;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20200928121432_Add_Description_To_Binary_Object', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
ALTER TABLE [AbpPersistedGrants] ADD [ConsumedTime] datetime2 NULL;
GO
ALTER TABLE [AbpPersistedGrants] ADD [Description] nvarchar(200) NULL;
GO
ALTER TABLE [AbpPersistedGrants] ADD [SessionId] nvarchar(100) NULL;
GO
CREATE INDEX [IX_AbpPersistedGrants_Expiration] ON [AbpPersistedGrants] ([Expiration]);
GO
CREATE INDEX [IX_AbpPersistedGrants_SubjectId_SessionId_Type] ON [AbpPersistedGrants] ([SubjectId], [SessionId], [Type]);
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20201020131501_Upgraded_To_IdentityServer_v4', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
ALTER TABLE [AbpEntityPropertyChanges] ADD [NewValueHash] nvarchar(max) NULL;
GO
ALTER TABLE [AbpEntityPropertyChanges] ADD [OriginalValueHash] nvarchar(max) NULL;
GO
ALTER TABLE [AbpDynamicProperties] ADD [DisplayName] nvarchar(max) NULL;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20201111120911_Upgraded_To_Abp_6_0', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
ALTER TABLE [AbpDynamicPropertyValues] DROP CONSTRAINT [PK_AbpDynamicPropertyValues];
GO
DECLARE @var2 sysname;
SELECT @var2 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AbpDynamicPropertyValues]') AND [c].[name] = N'Id');
IF @var2 IS NOT NULL EXEC(N'ALTER TABLE [AbpDynamicPropertyValues] DROP CONSTRAINT [' + @var2 + '];');
ALTER TABLE [AbpDynamicPropertyValues] DROP COLUMN [Id];
GO
ALTER TABLE [AbpDynamicPropertyValues] ADD [Id] bigint NOT NULL IDENTITY;
GO
ALTER TABLE [AbpDynamicPropertyValues] ADD CONSTRAINT [PK_AbpDynamicPropertyValues] PRIMARY KEY ([Id]);
GO
ALTER TABLE [AbpDynamicEntityPropertyValues] DROP CONSTRAINT [PK_AbpDynamicEntityPropertyValues];
GO
DECLARE @var3 sysname;
SELECT @var3 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AbpDynamicEntityPropertyValues]') AND [c].[name] = N'Id');
IF @var3 IS NOT NULL EXEC(N'ALTER TABLE [AbpDynamicEntityPropertyValues] DROP CONSTRAINT [' + @var3 + '];');
ALTER TABLE [AbpDynamicEntityPropertyValues] DROP COLUMN [Id];
GO
ALTER TABLE [AbpDynamicEntityPropertyValues] ADD [Id] bigint NOT NULL IDENTITY;
GO
ALTER TABLE [AbpDynamicEntityPropertyValues] ADD CONSTRAINT [PK_AbpDynamicEntityPropertyValues] PRIMARY KEY ([Id]);
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20201217075257_Upgrade_To_ABP_6_1', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
DROP INDEX [IX_AbpDynamicProperties_PropertyName_TenantId] ON [AbpDynamicProperties];
DECLARE @var4 sysname;
SELECT @var4 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AbpDynamicProperties]') AND [c].[name] = N'PropertyName');
IF @var4 IS NOT NULL EXEC(N'ALTER TABLE [AbpDynamicProperties] DROP CONSTRAINT [' + @var4 + '];');
ALTER TABLE [AbpDynamicProperties] ALTER COLUMN [PropertyName] nvarchar(256) NULL;
CREATE UNIQUE INDEX [IX_AbpDynamicProperties_PropertyName_TenantId] ON [AbpDynamicProperties] ([PropertyName], [TenantId]) WHERE [PropertyName] IS NOT NULL AND [TenantId] IS NOT NULL;
GO
DROP INDEX [IX_AbpDynamicEntityProperties_EntityFullName_DynamicPropertyId_TenantId] ON [AbpDynamicEntityProperties];
DECLARE @var5 sysname;
SELECT @var5 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AbpDynamicEntityProperties]') AND [c].[name] = N'EntityFullName');
IF @var5 IS NOT NULL EXEC(N'ALTER TABLE [AbpDynamicEntityProperties] DROP CONSTRAINT [' + @var5 + '];');
ALTER TABLE [AbpDynamicEntityProperties] ALTER COLUMN [EntityFullName] nvarchar(256) NULL;
CREATE UNIQUE INDEX [IX_AbpDynamicEntityProperties_EntityFullName_DynamicPropertyId_TenantId] ON [AbpDynamicEntityProperties] ([EntityFullName], [DynamicPropertyId], [TenantId]) WHERE [EntityFullName] IS NOT NULL AND [TenantId] IS NOT NULL;
GO
ALTER TABLE [AbpAuditLogs] ADD [ExceptionMessage] nvarchar(1024) NULL;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20210224123746_Upgraded_To_Abp_6_3', N'5.0.10');
GO
COMMIT;
GO
BEGIN TRANSACTION;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20210622135427_Upgraded_To_Abp_6_4_0', N'5.0.10');
GO
COMMIT;
GO
其中x为当前项目名
var coreAssemblyDirectoryPath = Path.GetDirectoryName(typeof(SauryCoreModule).GetAssembly().Location);
if (coreAssemblyDirectoryPath == null)
{
throw new Exception("Could not find location of Saury.Core assembly!");
}
var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
while (!DirectoryContains(directoryInfo.FullName, "x.sln"))
{
if (directoryInfo.Parent == null)
{
throw new Exception("Could not find content root folder!");
}
directoryInfo = directoryInfo.Parent;
}
var webMvcFolder = Path.Combine(directoryInfo.FullName, $"x.Web.Mvc");
if (Directory.Exists(webMvcFolder))
{
return webMvcFolder;
}
throw new Exception("Could not find root folder of the web project!");
Core.Localization 下的多语言命令
WorkFlow 升级注意
workflow 需升级
<PackageReference Include="WorkflowCore" Version="3.6.0" />
<PackageReference Include="WorkflowCore.DSL" Version="3.6.0" />
<PackageReference Include="WorkflowCore.Persistence.SqlServer" Version="3.6.0" />
WorkflowCore.DSL 包安装
如果重写了IExecutionResultProcessor
请注意 根据官方文件补齐内容
https://github.dev/danielgerlag/workflow-core
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
using WorkflowCore.Interface;
using WorkflowCore.Models;
using WorkflowCore.Models.LifeCycleEvents;
namespace WorkflowCore.Services
{
public class ExecutionResultProcessor : IExecutionResultProcessor
{
private readonly IExecutionPointerFactory _pointerFactory;
private readonly IDateTimeProvider _datetimeProvider;
private readonly ILogger _logger;
private readonly ILifeCycleEventPublisher _eventPublisher;
private readonly IEnumerable<IWorkflowErrorHandler> _errorHandlers;
private readonly WorkflowOptions _options;
public ExecutionResultProcessor(IExecutionPointerFactory pointerFactory, IDateTimeProvider datetimeProvider, ILifeCycleEventPublisher eventPublisher, IEnumerable<IWorkflowErrorHandler> errorHandlers, WorkflowOptions options, ILoggerFactory loggerFactory)
{
_pointerFactory = pointerFactory;
_datetimeProvider = datetimeProvider;
_eventPublisher = eventPublisher;
_errorHandlers = errorHandlers;
_options = options;
_logger = loggerFactory.CreateLogger<ExecutionResultProcessor>();
}
public void ProcessExecutionResult(WorkflowInstance workflow, WorkflowDefinition def, ExecutionPointer pointer, WorkflowStep step, ExecutionResult result, WorkflowExecutorResult workflowResult)
{
pointer.PersistenceData = result.PersistenceData;
pointer.Outcome = result.OutcomeValue;
if (result.SleepFor.HasValue)
{
pointer.SleepUntil = _datetimeProvider.UtcNow.Add(result.SleepFor.Value);
pointer.Status = PointerStatus.Sleeping;
}
if (!string.IsNullOrEmpty(result.EventName))
{
pointer.EventName = result.EventName;
pointer.EventKey = result.EventKey;
pointer.Active = false;
pointer.Status = PointerStatus.WaitingForEvent;
workflowResult.Subscriptions.Add(new EventSubscription
{
WorkflowId = workflow.Id,
StepId = pointer.StepId,
ExecutionPointerId = pointer.Id,
EventName = pointer.EventName,
EventKey = pointer.EventKey,
SubscribeAsOf = result.EventAsOf,
SubscriptionData = result.SubscriptionData
});
}
if (result.Proceed)
{
pointer.Active = false;
pointer.EndTime = _datetimeProvider.UtcNow;
pointer.Status = PointerStatus.Complete;
foreach (var outcomeTarget in step.Outcomes.Where(x => x.Matches(result, workflow.Data)))
{
workflow.ExecutionPointers.Add(_pointerFactory.BuildNextPointer(def, pointer, outcomeTarget));
}
var pendingSubsequents = workflow.ExecutionPointers
.FindByStatus(PointerStatus.PendingPredecessor)
.Where(x => x.PredecessorId == pointer.Id);
foreach (var subsequent in pendingSubsequents)
{
subsequent.Status = PointerStatus.Pending;
subsequent.Active = true;
}
_eventPublisher.PublishNotification(new StepCompleted
{
EventTimeUtc = _datetimeProvider.UtcNow,
Reference = workflow.Reference,
ExecutionPointerId = pointer.Id,
StepId = step.Id,
WorkflowInstanceId = workflow.Id,
WorkflowDefinitionId = workflow.WorkflowDefinitionId,
Version = workflow.Version
});
}
else
{
foreach (var branch in result.BranchValues)
{
foreach (var childDefId in step.Children)
{
workflow.ExecutionPointers.Add(_pointerFactory.BuildChildPointer(def, pointer, childDefId, branch));
}
}
}
}
public void HandleStepException(WorkflowInstance workflow, WorkflowDefinition def, ExecutionPointer pointer, WorkflowStep step, Exception exception)
{
_eventPublisher.PublishNotification(new WorkflowError
{
EventTimeUtc = _datetimeProvider.UtcNow,
Reference = workflow.Reference,
WorkflowInstanceId = workflow.Id,
WorkflowDefinitionId = workflow.WorkflowDefinitionId,
Version = workflow.Version,
ExecutionPointerId = pointer.Id,
StepId = step.Id,
Message = exception.Message
});
pointer.Status = PointerStatus.Failed;
var queue = new Queue<ExecutionPointer>();
queue.Enqueue(pointer);
while (queue.Count > 0)
{
var exceptionPointer = queue.Dequeue();
var exceptionStep = def.Steps.FindById(exceptionPointer.StepId);
var shouldCompensate = ShouldCompensate(workflow, def, exceptionPointer);
var errorOption = (exceptionStep.ErrorBehavior ?? (shouldCompensate ? WorkflowErrorHandling.Compensate : def.DefaultErrorBehavior));
foreach (var handler in _errorHandlers.Where(x => x.Type == errorOption))
{
handler.Handle(workflow, def, exceptionPointer, exceptionStep, exception, queue);
}
}
}
private bool ShouldCompensate(WorkflowInstance workflow, WorkflowDefinition def, ExecutionPointer currentPointer)
{
var scope = new Stack<string>(currentPointer.Scope);
scope.Push(currentPointer.Id);
while (scope.Count > 0)
{
var pointerId = scope.Pop();
var pointer = workflow.ExecutionPointers.FindById(pointerId);
var step = def.Steps.FindById(pointer.StepId);
if ((step.CompensationStepId.HasValue) || (step.RevertChildrenAfterCompensation))
return true;
}
return false;
}
}
}
AppFeatureProvider 检查
AppConsts检查
对比Web.Core 下Controllers文件夹下内容
特别是FileController
时区设置
CoreModule.cs
public class CoreModule : AbpModule
{
public override void PreInitialize()
{
Clock.Provider = ClockProviders.Utc;}
}
注意2.2升级导致的linq计算方式出错
- 对比Application.Authorization文件夹下文件
- 对比Application.Organizations文件夹下文件
检查Json转换库
System.Text.Json
JsonDocument.Parse(await response.Content.ReadAsStringAsync())
var result = jsonDoc.RootElement;
var errorCode = result.GetString("errcode");
OAuthTokenResponse tokens
tokens.Response.RootElement.GetString("code")
Swagger错误处理
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1",new Microsoft.OpenApi.Models.OpenApiInfo() { });
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Name = "Authorization",
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer",
BearerFormat = "JWT",
In = ParameterLocation.Header,
Description = "JWT token Bearer"
});
//Resolve conflicting schemaIds - yue.fei 20190723.
//options.CustomSchemaIds(x => x.FullName);
options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
IncludeXmlComments(options);
});
private void IncludeXmlComments(SwaggerGenOptions options)
{
var xmlFiles = System.IO.Directory.GetFiles(AppContext.BaseDirectory, "*.xml");
foreach (var file in xmlFiles)
{
options.IncludeXmlComments(file);
}
}