public EntityView Process(CommerceContext commerceContext, EntityView entityView, CommerceEnvironment environment) { using (CommandActivity.Start(commerceContext, this)) { try { if (environment == null) { return(entityView); } entityView.Properties .Add(new ViewProperty { Name = "Environment", RawValue = environment.Name, UiType = "EntityLink" }); entityView.Properties .Add(new ViewProperty { Name = "Policies", RawValue = environment.Policies.Count }); entityView.Properties .Add(new ViewProperty { Name = "Components", RawValue = environment.Components.Count }); entityView.Properties .Add(new ViewProperty { Name = "ArtifactStoreId", RawValue = environment.ArtifactStoreId.ToString("N") }); entityView.Properties .Add(new ViewProperty { Name = "GlobalEnvironmentName", RawValue = this._commerceCommander.CurrentNodeContext(commerceContext).GlobalEnvironmentName }); entityView.GetPolicy <ActionsPolicy>().Actions.Add( new EntityActionView { Name = "DoAction", IsEnabled = true, Description = "Description", DisplayName = "Do Action", RequiresConfirmation = false, UiHint = "RelatedList", EntityView = "/entityView/GetListView-CompletedOrders" }); } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewEnvironments.Exception: Message={ex.Message}"); } return(entityView); } }
/// <summary> /// The execute. /// </summary> /// <param name="arg"> /// The pipeline argument. /// </param> /// <param name="context"> /// The context. /// </param> /// <returns> /// The <see cref="PipelineArgument"/>. /// </returns> public override Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: The argument can not be null"); var request = this.ViewCommander.CurrentEntityViewArgument(context.CommerceContext); if (request == null) { return(Task.FromResult(arg)); } var entity = request.Entity as TEntity; if (entity == null) { return(Task.FromResult(arg)); } if (!_actionView.ShouldAddAction(context, arg, entity)) { return(Task.FromResult(arg)); } var actionPolicy = arg.GetPolicy <ActionsPolicy>(); actionPolicy.AddAction( new EntityActionView { Name = _actionView.ActionName, DisplayName = _actionView.ActionDisplayName, Description = string.Empty, IsEnabled = _actionView.IsEnabled, EntityView = _actionView.GetEntityView(context, arg), Icon = _actionView.ActionIcon, RequiresConfirmation = _actionView.RequiresConfirmation }); return(Task.FromResult(arg)); }