简体   繁体   English

如何在Epicor C#中引发异常

[英]How to throw exception in epicor C#

What is the equivalent to &THROW_PUBLIC in C# or what does &THROW_PUBLIC mean is ABL? C#中与&THROW_PUBLIC等效的东西是什么或&THROW_PUBLIC是什么意思是ABL? I don't know much about ABL but need to convert it to C#. 我对ABL不太了解,但需要将其转换为C#。

Code Snip from a Data Directive in Epicor 9.05 Epicor 9.05中数据指令的代码片段

If ttPart.ProdCode = '' then do:

   If lookup(SUBSTRING(ttPart.PartNum,1,3),'12-,13-,14-,15-',',') <> 0 then do:

    {lib\PublishEx.i &ExMsg = "'Please select a Product Group for this Part'"}
    {&THROW_PUBLIC}.

   End.

End.

&THROW_PUBLIC is not a Progress ABL keyword or any standard feature at all. &THROW_PUBLIC根本不是Progress ABL关键字,也不是任何标准功能。 Most likely it's something specific to Epicor. 最有可能是Epicor特有的。

For better understanding of the problem perhaps you should post more code! 为了更好地理解问题,也许您应该发布更多代码!

However: beginning with an ampersand might be a clue to it being a preprocessor. 但是:以&开头可能是它成为预处理器的线索。 A preprocessor can be defined with GLOBAL-DEFINE or SCOPED-DEFINE - look for that in your code. 可以使用GLOBAL-DEFINESCOPED-DEFINE定义预处理器-在代码中查找。

When the program is compiled any reference to the preprocessor (written like {&name-of-preprocesor} will be replaced with it's definition. Certain limited checks can be done (like for instance what OS is used for compiling). 编译程序时,对预处理器的任何引用(如{&name-of-preprocesor}都将替换为其定义。可以进行某些有限的检查(例如,使用什么OS进行编译)。

Here's an example of two preprocessors being defined and used. 这是定义和使用两个预处理器的示例。

&GLOBAL-DEFINE THROW_PUBLIC1 MESSAGE "HELLO 1".
&SCOPED-DEFINE THROW_PUBLIC2 MESSAGE "HELLO 2".

{&THROW_PUBLIC1}
{&THROW_PUBLIC2}

After the precompiler the program will simply look like this: 在预编译器之后,该程序将如下所示:

MESSAGE "HELLO 1".
MESSAGE "HELLO 2".

The THROW part might indicate some kind of error handling being used like a THROW-CATCH -situation or similar. THROW部分可能指示正在使用某种错误处理,例如THROW THROW-CATCH情况或类似情况。 They are written something like this: 他们是这样写的:

BLOCK-LEVEL ON ERROR UNDO, THROW. 

DEFINE VARIABLE i AS INTEGER     NO-UNDO.
ASSIGN 
    i = INTEGER("hello").

CATCH err AS Progress.Lang.Error:
    MESSAGE "Error is caught here" VIEW-AS ALERT-BOX.
END.

FINALLY:
    MESSAGE "This is run in the end" VIEW-AS ALERT-BOX.
END.

{&THROW_PUBLIC}. {&THROW_PUBLIC}。 is defined in the Epicor include file manager\\Exception.i (this is probably xcoded so you can't read it). 在Epicor包含文件管理器\\ Exception.i中定义(此文件可能是xcode的,因此您无法读取)。 This basically skips to the end of the {&TRY_PUBLIC} / {&CATCH_PUBLIC} block and publishes an exception. 这基本上跳到{&TRY_PUBLIC} / {&CATCH_PUBLIC}块的末尾,并发布一个异常。

In c# it is much easier: 在C#中,它要容易得多:

throw new Ice.BLException("Please select a Product Group for this Part");

You can use a standard System.Exception but Ice.BLException (defined in Epicor.ServiceModel.dll) has some overloads to record extra information which other parts of the framework can display/log. 您可以使用标准的System.Exception,但是Ice.BLException(在Epicor.ServiceModel.dll中定义)有一些重载来记录框架的其他部分可以显示/记录的额外信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM