简体   繁体   English

在表格插入时显示Windows气球提示

[英]Show windows balloon notification on table insert

I am developing a windows application using C# . 我正在使用C#开发Windows应用程序。 I want to show a balloon notification when a new row is inserted into a specific table. 我想在将新行插入特定表时显示气球通知。 The application will be installed on many computers and will share a common database through LAN. 该应用程序将安装在许多计算机上,并将通过LAN共享一个公共数据库。 Currently I am achieving this using polling. 目前,我正在使用轮询来实现此目的。 That is the application will query the database table each second to check if a new row is inserted.Please let me know whether this is the correct method or is there a better method for this? 那是应用程序每秒查询一次数据库表以检查是否插入了新行。请让我知道这是正确的方法还是有更好的方法? I know that using trigger we can execute queries in SQL server for table inserts, but is it possible to send a message back to the particular application from SQL server that has inserted the new row into the table? 我知道使用触发器可以在SQL Server中执行查询以进行表插入,但是是否可以将已将新行插入表中的消息从SQL Server发送回特定应用程序呢? Please help 请帮忙

I think you can accomplish this with a combination of a SQL CLR Trigger and a Win32 API Function. 我认为您可以结合使用SQL CLR触发器和Win32 API函数来完成此操作。 Using the CLR Trigger will help avoid polling. 使用CLR触发器将有助于避免轮询。

Here's an MSDN article on writing the CLR Trigger. 这是有关编写CLR触发器的MSDN文章

The sample code shown is logging to some audit table. 显示的示例代码正在记录到某些审核表中。 Swap that part to make a call to the Shell_NotifyIcon Win32 API function. 交换该部分以调用Shell_NotifyIcon Win32 API函数。 Here's a sample from MSDN on using the Shell_NotifyIcon to display the balloon notification. 这是MSDN上使用Shell_NotifyIcon显示气球通知的示例

The actual sample code is on this page (search for notificationicon.zip) and written in C++, but you should be able to modify it for C# once you do the DLL Import and use PInvoke. 实际的示例代码在此页上 (搜索notificationicon.zip),并使用C ++编写,但是一旦执行DLL导入并使用PInvoke,您就应该能够针对C#对其进行修改。 See this SO thread for more on that. 有关更多信息,请参见此SO线程

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

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