1

我正在从“数据流”选项卡中的源读取数据。

数据通过条件拆分

订单 1 -> ColA = "Y"

订单 2 -> ColB = "Y"

如果默认输出条件被击中,既不是 ColA 也不是 ColB = "Y"... 那么我想抛出一个异常/错误,以便它击中 "Fail Component" 块。

4

1 回答 1

3

选择你的毒药并将其连接到默认输出。

快速而肮脏的方法是附加派生列转换并强制除以零错误。

我的偏好是路由到脚本组件。在脚本组件中,我将行的业务键作为 ReadOnly 传递。对于我看到的每一行,我都会引发一个警告事件,因此我记录了所有“坏”行。在 PostExecute 方法中,如果有任何行已发送到组件,然后我会引发 OnError 事件以强制数据流将错误报告回控制流。这将满足您对切换到“失败组件块”的控件的需求,并且您将在日志中获得足够的信息来研究臭鼬数据。

你在记录,对吧?(答案是肯定的。如果你没有做到的话:D)

下面是我在查找失败时使用的代码。我的业务键是员工 ID 和生效日期,因此我将它们添加到 ProcessInput 方法中的列表中,然后在 PostExecute 中触发警告/错误。您可以轻松地在 ProcessInput 方法中引发警告,并在其中设置一个标志来指示 PostExecute 它需要出错。

public class ScriptMain : UserComponent
{
    List<KeyValuePair<string, string>> notFound;    

    public override void PreExecute()
    {
        base.PreExecute();
        notFound = new List<KeyValuePair<string, string>>();
    }

    public override void PostExecute()
    {
        base.PostExecute();
        foreach (KeyValuePair<string, string> kvp in notFound)
        {
            string msg = string.Format("Research->{0}:{1}", kvp.Key, kvp.Value);
            ComponentMetaData.FireWarning(0, "Unmatched Employees", msg, string.Empty, 0);
        }

        if (notFound.Count != 0)
        {
            bool cancel = true;
            ComponentMetaData.FireError(0, "SCR Lookup Employee", "Unmatched Employees found. See warning for more context", string.Empty, 0, out cancel);
        }

    }


    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        KeyValuePair<string, string> kvp = new KeyValuePair<string,string>(Row.EmployeeID, string.Format("{0:yyyy-MM-dd}", Row.EffectiveDT));
        notFound.Add(kvp);        
    }

}
于 2013-08-14T15:31:21.950 回答