Add ResultType to InsertResultCommand in all handlers
Added the Type property (ResultType) to every InsertResultCommand sent in PostprocessingBehavior, PreprocessingBehavior, and InvokeRecActionViewCommand. This ensures each result now includes its context (Post, Pre, or Main), both in normal and exception flows.
This commit is contained in:
@@ -24,7 +24,8 @@ public class PostprocessingBehavior(IRecDbContext context, ISender sender) : IPi
|
|||||||
await sender.Send(new InsertResultCommand()
|
await sender.Send(new InsertResultCommand()
|
||||||
{
|
{
|
||||||
ActionId = request.Action.Id,
|
ActionId = request.Action.Id,
|
||||||
Info = info
|
Info = info,
|
||||||
|
Type = ResultType.Post
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +36,8 @@ public class PostprocessingBehavior(IRecDbContext context, ISender sender) : IPi
|
|||||||
await sender.Send(new InsertResultCommand()
|
await sender.Send(new InsertResultCommand()
|
||||||
{
|
{
|
||||||
ActionId = request.Action.Id,
|
ActionId = request.Action.Id,
|
||||||
Error = error
|
Error = error,
|
||||||
|
Type = ResultType.Post
|
||||||
}, cancel);
|
}, cancel);
|
||||||
|
|
||||||
if (request.Action.ErrorAction == ErrorAction.Stop)
|
if (request.Action.ErrorAction == ErrorAction.Stop)
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPip
|
|||||||
await sender.Send(new InsertResultCommand()
|
await sender.Send(new InsertResultCommand()
|
||||||
{
|
{
|
||||||
ActionId = request.Action.Id,
|
ActionId = request.Action.Id,
|
||||||
Info = JsonSerializer.Serialize(result)
|
Info = JsonSerializer.Serialize(result),
|
||||||
|
Type = ResultType.Pre
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +31,8 @@ public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPip
|
|||||||
await sender.Send(new InsertResultCommand()
|
await sender.Send(new InsertResultCommand()
|
||||||
{
|
{
|
||||||
ActionId = request.Action.Id,
|
ActionId = request.Action.Id,
|
||||||
Error = ex.ToString()
|
Error = ex.ToString(),
|
||||||
|
Type = ResultType.Pre
|
||||||
}, cancel);
|
}, cancel);
|
||||||
|
|
||||||
if (request.Action.ErrorAction == ErrorAction.Stop)
|
if (request.Action.ErrorAction == ErrorAction.Stop)
|
||||||
|
|||||||
@@ -149,7 +149,8 @@ public class InvokeRecActionViewCommandHandler(
|
|||||||
StatusId = statusCode,
|
StatusId = statusCode,
|
||||||
ActionId = action.Id,
|
ActionId = action.Id,
|
||||||
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
|
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
|
||||||
Body = resBody
|
Body = resBody,
|
||||||
|
Type = ResultType.Main
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
@@ -157,7 +158,8 @@ public class InvokeRecActionViewCommandHandler(
|
|||||||
await sender.Send(new InsertResultCommand()
|
await sender.Send(new InsertResultCommand()
|
||||||
{
|
{
|
||||||
ActionId = action.Id,
|
ActionId = action.Id,
|
||||||
Error = ex.ToString()
|
Error = ex.ToString(),
|
||||||
|
Type = ResultType.Main
|
||||||
}, cancel);
|
}, cancel);
|
||||||
|
|
||||||
if (action.ErrorAction == ErrorAction.Stop)
|
if (action.ErrorAction == ErrorAction.Stop)
|
||||||
|
|||||||
Reference in New Issue
Block a user