Exemplo n.º 1
0
        private void btnJAVAStopGateway_Click(object sender, EventArgs e)
        {
            if (process_gateway != null)
            {
                try
                {
                    ProcessHandling.StopProcess((uint)process_gateway.Id);
                }
                catch
                { }

                process_gateway.Close();
                process_gateway.Dispose();
            }
        }
Exemplo n.º 2
0
        private void btnJAVAStopAgent_Click(object sender, EventArgs e)
        {
            if (process_agent != null)
            {
                try
                {
                    ProcessHandling.StopProcess((uint)process_agent.Id);
                }
                catch
                { }

                process_agent.Close();
                process_agent.Dispose();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (process_agent != null)
            {
                try
                {
                    ProcessHandling.StopProcess((uint)process_agent.Id);
                }
                catch
                { }

                process_agent.Close();
                process_agent.Dispose();
            }

            if (process_gateway != null)
            {
                try
                {
                    ProcessHandling.StopProcess((uint)process_gateway.Id);
                }
                catch
                { }

                process_gateway.Close();
                process_gateway.Dispose();
            }

            if (worker != null)
            {
                worker.Stop();
            }


            Thread.Sleep(3000);


            if (disposing && (components != null))
            {
                components.Dispose();
            }

            base.Dispose(disposing);
        }
Exemplo n.º 4
0
        private void btnJAVAStartGateway_Click(object sender, EventArgs e)
        {
            process_gateway = null;
            process_agent   = null;

            string result = runCMD(@"netstat -ano | findstr "":8181 """);

            if (!string.IsNullOrEmpty(result))
            {
                string pid = getPID(result);
                if (!string.IsNullOrEmpty(pid))
                {
                    runCMD(@"taskkill /PID " + pid + " /F");
                }
            }

            result = runCMD(@"netstat -ano | findstr "":9997 """);
            if (!string.IsNullOrEmpty(result))
            {
                string pid = getPID(result);
                if (!string.IsNullOrEmpty(pid))
                {
                    runCMD(@"taskkill /PID " + pid + " /F");
                }
            }

            Task.Factory.StartNew(() =>
            {
                process_gateway = new Process();

                process_gateway.StartInfo.FileName         = "java";
                process_gateway.StartInfo.Arguments        = @"-jar target/ogwapi-jar-with-dependencies.jar";
                process_gateway.StartInfo.WorkingDirectory = @"C:\VICINITY\Gateway";

                process_gateway.StartInfo.RedirectStandardOutput = true;
                process_gateway.StartInfo.RedirectStandardError  = true;

                process_gateway.StartInfo.UseShellExecute = false;
                process_gateway.StartInfo.CreateNoWindow  = true;
                process_gateway.EnableRaisingEvents       = true;

                process_gateway.OutputDataReceived += Process_Gateway_OutputDataReceived;
                process_gateway.ErrorDataReceived  += Process_Gateway_ErrorDataReceived;


                process_gateway.Start();

                try
                {
                    process_gateway.BeginErrorReadLine();
                    process_gateway.BeginOutputReadLine();
                }
                catch
                {
                    if (process_gateway != null)
                    {
                        try
                        {
                            ProcessHandling.StopProcess((uint)process_gateway.Id);
                        }
                        catch
                        { }

                        process_gateway.Close();
                        process_gateway.Dispose();
                    }
                }
            });
        }