自动活动不执行 [英] Automatic activity not performing

查看:22
本文介绍了自动活动不执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建了一个基本的工作流程,如下所示.

Created a workflow with basic as below.

创建了一个 calss 库,使用了 ProgId,将 comvisible 设置为 true 并在 Tridion 服务器中注册了程序集.

Created a calss library, used ProgId, set comvisible true and registerd the assembly in the Tridion server.

这是我测试过的方式:

  1. 创建了一个组件
  2. 完成工作清单中的活动.
  3. 导航到全局工作列表"并通过选择返回作者"步骤并单击完成"按钮由自己完成审阅者活动.

该项目未移至作者.但是当我从全局工作列表中再次完成该活动时,该项目已移至作者.

似乎我的代码没有执行该活动,因为我尝试删除以下 VB 脚本代码并尝试使用默认的自动脚本代码.

It seems that my code is not performing the activity because i tried removed the below VB script code and tried with the default automatic script code.

' Script for Automatic Activity Content Manager Workflow
FinishActivity "Automatic Activity Finished"

它的行为与上面相同.所以我决定我的代码不起作用.任何人都可以帮忙吗?

It behaves the same as above. so i decided my code is not worked. Can any one please help on this?

下面是我在返回作者"的脚本框中使用的VBScript:

Option Explicit

Dim workflowHandler
Set workflowHandler = CreateObject("CoreComponentWorkflow.WorkflowHandler");

If Not workflowHandler Is Nothing Then
    Call workflowHandler.MoveBackToActivity(Cstr(CurrentWorkItem.ID, "Create or Edit     Component")
End If
Set workflowHandler = Nothing

以下是 C# 代码:

public void MoveBackToActivity(string workitemid, string strActivitytoMove)
    {

        try
        {
            Session session = new Session();
            WorkItem workitem = new WorkItem(new TcmUri("workitemid"), session);
            ActivityInstance currentactivity = workitem.Activity as ActivityInstance;
            ProcessInstance procInstance = currentactivity.Process as ProcessInstance;

            IEnumerable<ActivityInstance> ieActivities = procInstance.Activities                    
            .Select (s => s)
            .Where (w => w.Title.IndexOf(strActivitytoMove) !=-1)
            .OrderByDescending(w =>w.StartDate);

            if (ieActivities != null && ieActivities.Count<ActivityInstance>() > 0)
            {
                ActivityInstance targetactivity = ieActivities.ElementAt(0);
                User lastperformuser = targetactivity.Performers.ElementAt(targetactivity.Performers.Count<User>() - 1);
                ActivityFinish finish = new ActivityFinish(targetactivity.FinishMessage, lastperformuser, workitem.Session);
                currentactivity.Finish(finish);

            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

推荐答案

请注意,您正在使用自动活动不支持的 API.唯一允许您使用 TOM.NET 的进程是事件系统处理程序和模板构建块,如此处.

Be aware that you are using an API that is NOT supported in Automatic Activities. The only processes where you are allowed to use TOM.NET are Event System handlers and Template Building Blocks as documented here.

自动工作流活动 - 如果不是用 VBScript 开发的 - 必须使用 CoreService 接口.

Automatic Workflow Activities - if not developed with VBScript - must use the CoreService interface.

好消息是,我知道这是一个有效的事实 - 很多人让它在许多实现中工作.坏消息(对您而言)是错误在您的代码中.您是否尝试过调试/逐步调试您的代码?您可以附加到工作流程 (cm_wf_svc.exe) 并以比我们更快的速度找出代码的问题.

The good news is that I know for a fact this works - plenty of people got it to work in many implementations. The bad news (for you) is that the error is in your code. Have you tried debugging/step-by-step through your code yet? You can attach to to the workflow process (cm_wf_svc.exe) and figure out what's wrong with the code much faster than we can.

这是一个非常简单的片段,用于使用 CoreService 完成一个活动:

Here's a really simple snippet to finish an activity with CoreService:

ActivityFinishData activityFinish = new ActivityFinishData
    {
        Message = "Automatically Finished from Expiration Workflow Extension"
    };
ActivityInstanceData activityInstance = 
    (ActivityInstanceData)processInstance.Activities[0];
client.FinishActivity(activityInstance.Id, activityFinish, readOptions);

顺便说一句 - 如果你无论如何都打算使用 TOM.NET,你为什么要打扰 询问使用哪个 API?

BTW - If you intended to use TOM.NET anyway, why did you bother asking which API to use?

这篇关于自动活动不执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆