【问题标题】:detect if Kofax launched custom module or User检测 Kofax 是否启动了自定义模块或用户
【发布时间】:2019-05-13 05:12:44
【问题描述】:

当自定义模块启动时,我可以使用

if (Environment.UserInteractive)
{
   // Run as WinForms app
}
else
{
   // Run as service
}

在后台服务和 WinForms 应用程序之间切换。但我也可以在不启动 Kofax 的情况下运行 .exe 文件。

是否可以检查 Kofax 是否启动了该模块?我的示例代码看起来像

if (Environment.UserInteractive)
{
   // Run as WinForms app

   if (Application.LaunchedByKofax)
   {
      // Do something additional
   }
}
else
{
   // Run as service
}

【问题讨论】:

    标签: kofax


    【解决方案1】:

    Kofax Capture 启动自定义模块的唯一情况是用户尝试从批处理管理器处理批次,并且该批次当前在您的自定义模块的队列中。如果您指的是其他内容,那么您需要澄清您的问题。

    发生这种情况时,为您的自定义模块注册的路径会使用附加参数调用,其中最值得注意的是 -B###,其中 ### 是十进制批次 ID。有关这方面的更多详细信息,请参阅 Kofax 知识库文章 1713,该文章较旧,但仍适用于当前版本。

    因此,您可以使用这样的函数来检查预期的参数。

    public bool LaunchedFromBatchManager()
    {
        var args = Environment.GetCommandLineArgs();
    
        //args[0] will contain the path to your exe, subsquent items are the actual args
        if (args.Count() > 1)
        {
            // When a user tries to process a batch from batch manager, 
            // it launches the module with -B###, where ### is the decimal batch ID
            // see: http://knowledgebase.kofax.com/faqsearch/results.aspx?QAID=1713
            if (args[1].StartsWith("-B"))
            {
                return true;
            }
        }
    
        return false;
    }
    

    【讨论】:

    • 只是好奇,用户不能直接调用CM的exe吗?
    • 当然:三种场景是1.作为服务运行(!Environment.UserInteractive),2.用户直接启动(Environment.UserInteractive),3用户从批次处理批次启动经理(Environment.UserInteractive && LaunchedFromBatchManager())。这是否回答了问题,还是我忽略了什么?
    • 应该更彻底地阅读。 OP 已经检查了Environment.UserInteractive。谢谢,斯蒂芬!
    • 沃尔夫冈没问题!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-20
    • 1970-01-01
    相关资源
    最近更新 更多