Beispiel #1
0
        public void start()
        {
            if (jetty_flag % 2 == 0)
            {
                string Jetty_PATH = Set_OS_Path.GetSysEnvironmentByName("Jetty_PATH");
                // 创建文件
                FileStream   fs = new FileStream(@Jetty_PATH + "\\start.bat", FileMode.OpenOrCreate, FileAccess.ReadWrite); //可以指定盘符,也可以指定任意文件名,还可以为word等文件
                StreamWriter sw = new StreamWriter(fs);                                                                     // 创建写入流
                sw.WriteLine("cd " + Jetty_PATH);
                sw.WriteLine("java -jar start.jar jetty.http.port=" + comboBox1.Text);                                      // 写入Hello World
                sw.Close();                                                                                                 //关闭文件
                System.Diagnostics.ProcessStartInfo myStartInfo = new System.Diagnostics.ProcessStartInfo();
                myStartInfo.FileName = @Jetty_PATH + "\\start.bat";
                System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
                myProcess.StartInfo             = myStartInfo;
                myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                myProcess.Start();
                P_id = myProcess.Id.ToString();
                //MessageBox.Show(P_id);
                System.Diagnostics.Process.Start("http://localhost:" + comboBox1.Text + "/test");

                label4.Text      = "http://localhost:" + comboBox1.Text;
                jetty_flag      += 1;
                label7.ForeColor = System.Drawing.Color.Green;
                label7.Text      = "正在运行";
            }
            else
            {
                MessageBox.Show("你已经启动了一台Jetty!请先关闭再启动!!", "警告:");
            }
        }
Beispiel #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            string jetty = Set_OS_Path.GetSysEnvironmentByName("Jetty_PATH");

            if (jetty.Equals(""))
            {
                MessageBox.Show("请先安装Jetty服务器!", "提示:");
            }
            else
            {
                Regex  re   = new Regex(@"^\d{4}$");//实例化一个Regex对象
                String PORT = comboBox1.Text;
                if (PORT.Equals("80"))
                {
                    start();
                    outlog.out_log("正常启动了Jetty了", textBox1);
                }
                else
                {
                    bool port = re.IsMatch(PORT);
                    //MessageBox.Show(port.ToString());
                    if (port)
                    {
                        start();
                        outlog.out_log("正常启动了Jetty了", textBox1);
                        //return;
                    }
                    else
                    {
                        MessageBox.Show("启动失败!你端口必须是4位数字或者是80端口!", "提示:");
                    }
                }
            }
        }
Beispiel #3
0
        private void main_Load(object sender, EventArgs e)
        {
            string txtContent = GetVersion("https://api.ilaok.com/jetty/version.txt");

            outlog.out_log("程序启动初始化检测版本,当前服务器版本为:" + txtContent);
            string L = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            //MessageBox.Show(L);
            if (txtContent != L)
            {
                MessageBox.Show("软件已经发布更新!请去百度网盘下载!");
                System.Diagnostics.Process.Start("https://pan.baidu.com/s/1dGcJORn");
                System.Environment.Exit(0);
            }



            //获取系统变量
            string jh = Set_OS_Path.GetSysEnvironmentByName("JAVA_HOME");
            string cp = Set_OS_Path.GetSysEnvironmentByName("CLASS_PATH");

            //Set_OS_Path.SetPathAfter(jh + "\Bin");
            //MessageBox.Show(jh.ToString());
            //MessageBox.Show(cp.ToString());
            if (jh.Equals("") || cp.Equals(""))
            {
                outlog.out_log("MAIN检测系统环境变量,没有检测到!");
                MessageBox.Show("当前系统没有配置Java环境变量或者没有安装JDK!\n请安装JDK1.8以上版本并且配置环境变量!", "警告:");
                System.Diagnostics.Process.Start("http://www.oracle.com/technetwork/java/javase/downloads/index.html");
                //停止当前程序的所有线程
                Application.ExitThread();
                //程序退出运行
                System.Environment.Exit(0);
            }
            outlog.out_log("MAIN检测系统环境变量,环境正常!" + jh + "    ||  " + cp);

            outlog.out_log("\nRun_Path = " + System.IO.Directory.GetCurrentDirectory(), textBox1);
            outlog.out_log("\nJAVA_HOME = " + jh, textBox1);
            label1.Text = "OSversion:" + Environment.OSVersion.ToString();

            label2.Text = "公共语言运行时版本(CLR):" + Environment.Version.ToString();



            string[] port = new string[] { "80", "8080", "8088", "8091" };
            for (int i = 0; i < port.Length; i++)
            {
                comboBox1.Items.Add(port[i]);
            }
            www         = "http://localhost:" + comboBox1.Text;
            label4.Text = www;
        }
Beispiel #4
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            DialogResult result = MessageBox.Show("确定要退出系统吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                string Jetty_PATH = Set_OS_Path.GetSysEnvironmentByName("Jetty_PATH");
                string deleteflie = @Jetty_PATH + "\\start.bat";
                if (File.Exists(deleteflie))//必须判断要复制的文件是否存在
                {
                    utils.DeleteFile(deleteflie);
                }
                utils.kill_ID(P_id);
                outlog.out_log("退出程序并且停止线程", textBox1);
                System.Environment.Exit(0);
                Application.ExitThread();
            }
            outlog.out_log("退出程序,点击了取消按钮", textBox1);
        }
Beispiel #5
0
        private void button4_Click(object sender, EventArgs e)
        {
            string jetty = Set_OS_Path.GetSysEnvironmentByName("Jetty_PATH");

            if (jetty.Equals(""))
            {
                MessageBox.Show("请先安装Jetty服务器!", "提示:");
            }
            else
            {
                if (jetty_flag % 2 == 0)
                {
                    //如果是true说明,可以启动Jetty
                    string Jetty_PATH = Set_OS_Path.GetSysEnvironmentByName("Jetty_PATH");

                    /*string cmdshell_cdpath = "cd " + Jetty_PATH + "\\demo-base\\";
                     * string cmdshell_runjetty = "java -jar " + Jetty_PATH + "\\start.jar";
                     * string cmdmess =utils.Run_CMD(cmdshell_cdpath,cmdshell_runjetty);
                     * MessageBox.Show(cmdmess);*/
                    System.Diagnostics.ProcessStartInfo myStartInfo = new System.Diagnostics.ProcessStartInfo();
                    myStartInfo.FileName = @Jetty_PATH + "\\demo-base\\start_dome.bat";
                    //myStartInfo.FileName = "C:\\Users\\coding\\Desktop\\ip.bat";
                    System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
                    myProcess.StartInfo             = myStartInfo;
                    myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    myProcess.Start();
                    P_id = myProcess.Id.ToString();
                    //MessageBox.Show(P_id);
                    //"/c \"TASKKILL /F /PID" + p.Id + " /T\"";
                    System.Diagnostics.Process.Start("http://localhost:8080");
                    jetty_flag      += 1;
                    label7.ForeColor = System.Drawing.Color.Green;
                    label7.Text      = "正在运行";
                    label4.Text      = "http://localhost:8080";
                    outlog.out_log("默认启动了jetty", textBox1);
                }
                else
                {
                    MessageBox.Show("Jetty正在运行!", "警告:");
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// 写出jetty资源文件
        /// </summary>
        public static void outfile()
        {
            byte[] temp = Properties.Resources.jetty;
            System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\\jetty.zip", System.IO.FileMode.CreateNew);
            fileStream.Write(temp, 0, (int)(temp.Length));
            fileStream.Close();

            string path = @"C:\\jetty";

            if (Directory.Exists(path))
            {
                //Console.WriteLine("此文件夹已经存在,无需创建!");
            }
            else
            {
                Directory.CreateDirectory(path);
                //Console.WriteLine(path + " 创建成功!");
            }

            SharpZip.UnZip(@"C:\\jetty.zip", @"C:\\jetty");

            utils.DeleteFile(@"C:\\jetty.zip");
            Set_OS_Path.SetSysEnvironment("Jetty_PATH", "C:\\jetty\\jetty");
        }
Beispiel #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            string jetty = Set_OS_Path.GetSysEnvironmentByName("Jetty_PATH");

            if (jetty.Equals(""))
            {
                if (File.Exists(@System.IO.Directory.GetCurrentDirectory() + "\\ICSharpCode.SharpZipLib.dll"))
                {
                    //MessageBox.Show("文件存在");
                }
                else
                {
                    byte[] temp = Properties.Resources.ICSharpCode_SharpZipLib;
                    System.IO.FileStream fileStream = new System.IO.FileStream(@System.IO.Directory.GetCurrentDirectory() + "\\ICSharpCode.SharpZipLib.dll", System.IO.FileMode.CreateNew);
                    fileStream.Write(temp, 0, (int)(temp.Length));
                    fileStream.Close();
                }
                utils.outfile();
            }
            else
            {
                MessageBox.Show("你的计算机已经安装Jetty!请不要重复安装!", "提示:");
            }
        }