- 使用正确的Aveva.ApplicationFramework.IAddin接口 - 在Start方法中直接弹出欢迎对话框 - 移除自定义接口定义,使用AVEVA官方接口 - 插件现在可以在PDMS启动时正常加载并显示 - 添加.gitignore忽略VS临时文件 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using Aveva.ApplicationFramework;
|
||
using System;
|
||
using System.Windows.Forms;
|
||
|
||
namespace TellmePdmsPluging
|
||
{
|
||
public class TellmePdmsAddin : IAddin
|
||
{
|
||
public string Name
|
||
{
|
||
get
|
||
{
|
||
return "TellmePdmsAddin";
|
||
}
|
||
}
|
||
|
||
public string Description
|
||
{
|
||
get
|
||
{
|
||
return "PDMS远程控制插件";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 程序打开时,会调用这个方法
|
||
/// </summary>
|
||
/// <param name="serviceManager"></param>
|
||
public void Start(ServiceManager serviceManager)
|
||
{
|
||
try
|
||
{
|
||
// 直接弹出窗口,不需要按钮
|
||
MessageBox.Show("TellmePdms插件已成功加载!\n准备启动HTTP服务器...", "插件加载成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
||
// 记录日志
|
||
System.IO.File.WriteAllText(@"C:\temp\pdms_plugin_log.txt",
|
||
$"Plugin loaded successfully at {DateTime.Now}\r\n");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
try
|
||
{
|
||
System.IO.File.WriteAllText(@"C:\temp\pdms_plugin_error.txt",
|
||
$"Plugin Error at {DateTime.Now}: {ex.Message}\r\n{ex.StackTrace}\r\n");
|
||
}
|
||
catch { }
|
||
MessageBox.Show($"插件加载错误: {ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 程序关闭时,会调用这个方法
|
||
/// </summary>
|
||
public void Stop()
|
||
{
|
||
// 插件停止时的清理操作
|
||
}
|
||
}
|
||
}
|