【问题标题】:create setup form for custom module为自定义模块创建设置表单
【发布时间】:2019-04-24 12:54:02
【问题描述】:

我有一个自定义模块在 PDFGenerator 完成后立即执行。我按照本指南了解如何创建自定义模块

https://stackoverflow.com/a/55799101/9945420

在处理批处理文档时,我想处理生成的 PDF 文件并为该文件添加页脚。该页脚的内容需要在管理模块中进行配置。

所以在我的名为“StampOnScanProcess”的项目中,我添加了一个名为“Setup”的文件夹,其中包含两个文件。一个名为“FrmSetup”的Form

public partial class FrmSetup : Form
{
    private IBatchClass batchClass;

    public FrmSetup()
    {
        InitializeComponent();
    }

    public DialogResult ShowDialog(IBatchClass batchClass)
    {
        this.batchClass = batchClass;

        // Load previous Settings ...

        return this.ShowDialog();
    }

    private void btnCancel_Click(object sender, EventArgs e)
    {
        this.Close();
    }

    private void btnSave_Click(object sender, EventArgs e)
    {
        // Save ...

        this.Close();
    }
}

还有一个名为“UserCtrlSetup”的UserControl

[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ISetupForm
{
    [DispId(1)]
    AdminApplication Application { set; }

    [DispId(2)]
    void ActionEvent(int EventNumber, object Argument, out int Cancel);
}

[ClassInterface(ClassInterfaceType.None)]
[ProgId(CUSTOM_MODULE_NAME_SETUP)]
public partial class UserCtrlSetup : UserControl, ISetupForm
{
    private const string CUSTOM_MODULE_NAME_SETUP = "StampOnScanProcess.Setup";

    private AdminApplication adminApplication;

    public AdminApplication Application
    {
        set
        {
            value.AddMenu(CUSTOM_MODULE_NAME_SETUP, CUSTOM_MODULE_NAME_SETUP, "BatchClass");
            adminApplication = value;
        }
    }

    public void ActionEvent(int EventNumber, object Argument, out int Cancel)
    {
        Cancel = 0;

        if ((KfxOcxEvent)EventNumber == KfxOcxEvent.KfxOcxEventMenuClicked && (string)Argument == CUSTOM_MODULE_NAME_SETUP)
        {
            FrmSetup form = new FrmSetup();
            form.ShowDialog(adminApplication.ActiveBatchClass);
        }
    }
}

我修改了我的注册文件并添加了设置表单

[Modules]
StampOnScanProcess

[StampOnScanProcess]
RuntimeProgram=StampOnScanProcess.exe
ModuleID=StampOnScanProcess.exe
Description=...
Version=10.2
SupportsNonImageFiles=True
SupportsTableFields=True
SetupProgram=StampOnScanProcess.Setup

[Setup Programs]
StampOnScanProcess.Setup

[StampOnScanProcess.Setup]
Visible=0
OCXFile=StampOnScanProcess.exe
ProgID=StampOnScanProcess.Setup

在启动管理模块时,我前往 Batch Class Properties => Queues 并希望通过单击 Properties 来调用此设置表单> 中间的按钮。

不幸的是,属性按钮被禁用,所以我无法打开设置表单。此表单被添加到批处理类的上下文菜单中

如何将此表单绑定到属性按钮?存储配置数据并在运行时应用程序执行时访问它的最佳方式是什么?

我需要考虑如何存储数据,因为有些用户有用户配置文件

并且运行时应用程序当前登录时没有凭据。

    public void LoginToRuntimeSession()
    {
        login = new Login();
        login.EnableSecurityBoost = true;
        login.Login();
        login.ApplicationName = CUSTOM_MODULE_ID;
        login.Version = "1.0";
        login.ValidateUser($"{CUSTOM_MODULE_ID}.exe", false, "", "");
        session = login.RuntimeSession;
    }

因此,我可能也必须在设置时存储凭据。

【问题讨论】:

    标签: kofax


    【解决方案1】:

    如何将此表单绑定到属性按钮?

    与菜单项的所有交互都由ISetupForm.ActionEvent 处理。使用AdminApplication 对象的AddMenu 方法添加新条目。 Kofax 按名称区分多个条目 - 假设您可以同时有多个菜单条目,一个在批处理类级别,另一个在文档类级别,另一个在功能区 - 仅举几个例子。 Kofax 在集成到管理中的任何组件(例如自定义模块或工作流代理)中都使用相同的方法。

    这是我们组件之一的示例。请注意,在 BatchClass 级别添加了三个条目,在 DocumentClass 级别添加了两个条目。

    value.AddMenu("BatchClass.GeneralConfig", "Field Panel - General Configuration", "BatchClass");
    value.AddMenu("BatchClass.FieldEditor", "Field Panel - Configure Batch Fields", "BatchClass");
    value.AddMenu("DocumentClass.FieldEditor", "Field Panel - Configure Index Fields", "DocumentClass");
    value.AddMenu("CopyBatchFieldConfig", "Field Panel - Copy Batch Field Configuration", "BatchClass");
    value.AddMenu("PasteBatchFieldConfig", "Field Panel - Paste Batch Field Configuration", "BatchClass");
    value.AddMenu("CopyIndexFieldConfig", "Field Panel - Copy Index Field Configuration", "DocumentClass");
    value.AddMenu("PasteIndexFieldConfig", "Field Panel - Paste Index Field Configuration", "DocumentClass");
    

    每个条目都没有通过其事件文本(第一个参数)来标识。例如,BatchClass.GeneralConfig 旨在打开一个通用配置对话框 - 在批处理类级别。

    现在,回到我们的 ActionEvent - 这就是我区分用户选择的条目的方式:

    if ((KfxOcxEvent)EventNumber == KfxOcxEvent.KfxOcxEventMenuClicked)
    {
        AdminForm form = new AdminForm();
        switch ((string)Argument)
        {
            case "BatchClass.GeneralConfig":
                ConfigureGeneral(kcApp.ActiveBatchClass);
                break;
    

    [我]想通过点击属性按钮来调用这个设置表单 中间。

    我不知道您是否可以使用此按钮 - 我认为可以 - 但我个人倾向于将设置放在批处理或文档类级别。例如 - 您的 PDF 注释设置可能因文档类而异 - 在此级别上添加条目似乎更自然。

    什么是存储配置数据并在何时访问它的最佳方式 运行时应用程序被执行了吗?

    自定义存储字符串,您可以在这里尽情发挥想象力。最简单的方法是在设置期间存储键值对,并在运行时检索它们。这是一个通用调用(BatchClass 是一个IBatchClass 对象,即指向AdminApplication 对象的ActiveBatchClass 属性的指针):

    // set a CSS
    BatchClass.set_CustomStorageString(name, value);
    // get a CSS
    BatchClass.get_CustomStorageString(name)
    

    我通常只使用单个自定义存储字符串并存储自定义对象 - 该对象是使用 XmlSerializer 的 base64 编码的序列化 XML - 但同样,这取决于您。唯一的建议是仅依赖 CSS - 不要使用外部文件来存储配置参数。 CSS 是批处理类不可或缺的一部分 - 因此,当导出所述类并将其导入不同的系统时,您的整个配置都将在那里。

    我需要考虑如何存储数据,因为有些用户有用户 简介

    通常,您不必担心这一点。 ValidateUser 中的用户和密码属性完全是可选的 - 因为您计划编写无人参与的模块 - 理想情况下是 Windows 服务,因此应在此处维护凭据。 Kofax 和 Windows 将自动确保传递凭据,并且您的模块将在此用户的上下文中运行。只需确保用户对模块和所有关联的批次类具有权限即可。如果您打算编写有人参与的模块,例如增强的验证模块,情况就不同了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 1970-01-01
      • 1970-01-01
      • 2010-11-17
      相关资源
      最近更新 更多