MySql触发器不会执行整个程序

问题描述

所以我在 MysqL 中有一个触发器,当它被调用时,用参数执行一个外部 C# 应用程序,它是一个 NamedPipeClient,它应该将这些参数发送到一个已经运行的 PipeServer 应用程序,但它不会正确执行。 显然它不会创建管道客户端实例。 PS:如果手动执行程序可以正常工作,但不会完全从触发器中执行。

触发代码

installed_rank;version;
description;type;script;checksum;installed_by;installed_on;
execution_time;success
1;1;<< Flyway Baseline >>;BASELINE;<< Flyway Baseline >>;?;null;Apr 28,2021 12:01:32.616 PM;0;1

服务器管道代码

    CREATE DEFINER=`root`@`localhost` TRIGGER `Test_Trigger` BEFORE UPDATE ON `event` FOR EACH ROW 
BEGIN
DECLARE cmd CHAR(255);
 DECLARE result int(10);
 DECLARE Arg char(20);
 SET ARG = new.DoorNumber;
 SET cmd ='cmd /c "cd /d D:\\PipeExSer\\PipeExClient\\bin\\Debug && PipeExClient.exe"';
SET result = sys_exec(cmd);
END

ClientPipe 代码

using System;
using System.IO;
using System.IO.Pipes;
using System.Threading;

class PipeServer
{
    static void Main()
    {
        
        
            using (NamedPipeServerStream pipeServer =
            new NamedPipeServerStream("TP"))
        {

            
                Console.WriteLine("NamedPipeSe  rverStream object created.");
                
                // Wait for a client to connect
                Console.Write("Waiting for client connection...");
                pipeServer.WaitForConnection();

                Console.WriteLine("Client connected.");
                try
                {
                    // Read user input and send that to the client process.
                     /* using (StreamWriter sw = new StreamWriter(pipeServer))
                     {
                         sw.AutoFlush = true;
                         Console.Write("Enter text: ");
                         sw.WriteLine(Console.ReadLine());
                     }*/
                    using (StreamReader sr = new StreamReader(pipeServer))
                    {
                        // display the read text to the console
                        string temp;
                        while ((temp = sr.ReadLine()) != null)
                        {
                            Console.WriteLine("Received from client: {0}",temp);
                        }
                    }
                }
                // Catch the IOException that is raised if the pipe is broken
                // or disconnected.
                catch (IOException e)
                {
                    Console.WriteLine("ERROR: {0}",e.Message);
                }
                Console.WriteLine("It reached this");

              
                   Console.WriteLine(pipeServer.IsConnected);
                Thread.Sleep(5000);
                pipeServer.dispose();
            }
       
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)