コード例 #1
0
        private static void OnNoParameters()
        {
            if (ServiceController.GetStatus() == "stopped")
            {
                StartService(null);
            }

            Commands["--help"].Function.Invoke(new string[] { "--help" });
            Commands["--getPath"].Function.Invoke(new string[] { "--getPath" });
            Commands["--getDelay"].Function.Invoke(new string[] { "--getDelay" });
            Commands["--getLicenseCode"].Function.Invoke(new string[] { "--getLicenseCode" });
            Commands["--connection"].Function.Invoke(new string[] { "--connection" });
        }
コード例 #2
0
        public void SendToServer(PipeCommand command, int TimeOut = 5000)
        {
            try
            {
                if (_service.GetStatus() == "stopped")
                {
                    Console.WriteLine("start service first");
                    return;
                }

                var serializedCommand            = JsonConvert.SerializeObject(command);
                NamedPipeClientStream pipeStream = new NamedPipeClientStream(".", _pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);

                pipeStream.Connect(TimeOut);
                StreamString ss = new StreamString(pipeStream);

                ss.SendCommand(serializedCommand);
                var answer = ss.ReadAnswer();

                Console.WriteLine(answer);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + "[" + ex.Source + "] " + ex.Message);
            }
        }