public override async Task <bool> Run(bool arg, CommercePipelineExecutionContext context) { if (arg) { return(true); } SearchIndexArgument argument = context.CommerceContext.GetObjects <SearchIndexArgument>().FirstOrDefault(); if (argument == null) { return(true); } var result = await _initIndexPipeline.Run(argument, context); if (result != null) { return(true); } CommercePipelineExecutionContext executionContext = context; CommerceContext commerceContext = context.CommerceContext; string error = context.GetPolicy <KnownResultCodes>().Error; string commerceTermKey = "CreateIndexError"; object[] args = { argument.IndexName }; string defaultMessage = $"Search index '{argument.IndexName as object}' was not created."; executionContext.Abort(await commerceContext.AddMessage(error, commerceTermKey, args, defaultMessage), context); return(false); }
public override async Task <bool> Run(bool arg, CommercePipelineExecutionContext context) { if (!arg) { return(false); } SearchIndexArgument argument = context.CommerceContext.GetObjects <SearchIndexArgument>().FirstOrDefault(); if (argument == null) { context.Abort($"{nameof(Name)}: SearchIndexArgument was not found in the context objects collection.", context); return(false); } SearchScopePolicy policyByName = SearchScopePolicy.GetPolicyByName(context.CommerceContext, context.CommerceContext.Environment, argument.IndexName); if (policyByName == null) { context.Abort($"{nameof(Name)}: SearchScopePolicy was not found for index {argument.IndexName}.", context); return(false); } IndexablePolicy policyByScope = IndexablePolicy.GetPolicyByScope(context.CommerceContext, context.CommerceContext.Environment, policyByName.Name); if (policyByScope?.Properties == null) { // ISSUE: explicit non-virtual call context.Abort($"{nameof(Name)}: IndexablePolicy was not found for index {argument.IndexName}.", context); return(false); } return(await _command.DeleteAllDocumentsInIndex(context.CommerceContext, argument.IndexName)); }