Exemplo n.º 1
0
        /// <summary>
        /// 开启Mongodb
        /// </summary>
        public static Process StartDB()
        {
            Ismongodb = HostSettingConfig.GetValue("mongodb") == "1" ? true : false;
            if (Ismongodb)
            {
                string config = String.Format(HostMongoDBConfig.GetConfig_Temp(), (HostSettingConfig.GetValue("mongodb_dbpath") == "" ? AppDomain.CurrentDomain.BaseDirectory : HostSettingConfig.GetValue("mongodb_dbpath")));
                HostMongoDBConfig.SetConfig(config);

                mongodExe = HostSettingConfig.GetValue("mongodb_binpath") + @"\mongod.exe";
                string mongoConf = AppDomain.CurrentDomain.BaseDirectory + @"Config\mongo.conf";

                System.Diagnostics.Process pro = new System.Diagnostics.Process();
                pro.StartInfo.FileName        = mongodExe;
                pro.StartInfo.Arguments       = "--config " + mongoConf;
                pro.StartInfo.UseShellExecute = false;
                //pro.StartInfo.RedirectStandardInput = true;
                //pro.StartInfo.RedirectStandardOutput = true;
                //pro.StartInfo.RedirectStandardError = true;
                pro.StartInfo.CreateNoWindow = true;
                pro.Start();
                //pro.WaitForExit();

                ShowMsg("Mongodb已启动");

                return(pro);
            }

            return(null);
        }
Exemplo n.º 2
0
        /*读取注册表*/
        public static string ReadSetting()
        {
            string key1 = HostSettingConfig.GetValue("cdkey");

            if (key1 != "")
            {
                return(Encryption.DisEncryPW(key1, "kakake888"));
            }
            return("-1");
        }
Exemplo n.º 3
0
        /// <summary>
        /// 开启Nginx
        /// </summary>
        public static Process StartWeb()
        {
            try
            {
                Isnginx = HostSettingConfig.GetValue("nginx") == "1" ? true : false;
                if (Isnginx)
                {
                    nginxExe = HostSettingConfig.GetValue("nginx_binpath");
                    System.IO.FileInfo file = new System.IO.FileInfo(nginxExe);

                    //System.Diagnostics.Process pro = new System.Diagnostics.Process();
                    //pro.StartInfo.FileName = "cmd.exe";
                    ////pro.StartInfo.Arguments = "--config " + mongoConf;
                    //pro.StartInfo.UseShellExecute = false;
                    //pro.StartInfo.RedirectStandardInput = true;
                    //pro.StartInfo.RedirectStandardOutput = true;
                    //pro.StartInfo.RedirectStandardError = true;
                    //pro.StartInfo.CreateNoWindow = true;
                    //pro.Start();
                    ////pro.WaitForExit();
                    //pro.StandardInput.WriteLine("cd " + file.Directory.Root);
                    //pro.StandardInput.WriteLine("cd " + file.DirectoryName);
                    //pro.StandardInput.WriteLine("start " + file.Name);
                    //pro.StandardInput.WriteLine("exit");
                    //pro.StandardInput.AutoFlush = true;
                    ////string output = pro.StandardOutput.ReadToEnd();
                    ////pro.Close();

                    System.Diagnostics.Process pro = new System.Diagnostics.Process();
                    pro.StartInfo.FileName        = nginxExe;
                    pro.StartInfo.UseShellExecute = false;
                    //pro.StartInfo.RedirectStandardInput = true;
                    //pro.StartInfo.RedirectStandardOutput = true;
                    //pro.StartInfo.RedirectStandardError = true;
                    pro.StartInfo.CreateNoWindow   = true;
                    pro.StartInfo.WorkingDirectory = file.DirectoryName;
                    pro.Start();
                    //pro.WaitForExit();
                    //pro.StandardInput.AutoFlush = true;

                    ShowMsg("Web程序已启动");

                    return(pro);
                }

                return(null);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 停止efwplusBase
        /// </summary>
        public static void StopBase()
        {
            Iswcfservice = HostSettingConfig.GetValue("wcfservice") == "1" ? true : false;
            if (Iswcfservice == false)
            {
                return;
            }

            Process[] proc = Process.GetProcessesByName("efwplusBase");//创建一个进程数组,把与此进程相关的资源关联。
            for (int i = 0; i < proc.Length; i++)
            {
                proc[i].Kill();  //逐个结束进程.
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 停止Mongodb
        /// </summary>
        public static void StopDB()
        {
            Ismongodb = HostSettingConfig.GetValue("mongodb") == "1" ? true : false;
            if (Ismongodb == false)
            {
                return;
            }

            Process[] proc = Process.GetProcessesByName("mongod");//创建一个进程数组,把与此进程相关的资源关联。
            for (int i = 0; i < proc.Length; i++)
            {
                proc[i].Kill();  //逐个结束进程.
            }
        }
Exemplo n.º 6
0
        //private static System.Diagnostics.Process pro;
        /// <summary>
        /// 开启Mongodb
        /// </summary>
        public static void StartDB()
        {
            string mongodExe = HostSettingConfig.GetValue("mongodb_binpath") + @"\mongod.exe";
            string mongoConf = AppDomain.CurrentDomain.BaseDirectory + @"\Config\mongo.conf";

            System.Diagnostics.Process pro = new System.Diagnostics.Process();
            pro.StartInfo.FileName        = mongodExe;
            pro.StartInfo.Arguments       = "--config " + mongoConf;
            pro.StartInfo.UseShellExecute = false;
            //pro.StartInfo.RedirectStandardInput = true;
            //pro.StartInfo.RedirectStandardOutput = true;
            //pro.StartInfo.RedirectStandardError = true;
            pro.StartInfo.CreateNoWindow = true;
            pro.Start();
            //pro.WaitForExit();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 停止Nginx
        /// </summary>
        public static void StopWeb()
        {
            Isnginx = HostSettingConfig.GetValue("nginx") == "1" ? true : false;
            if (Isnginx == false)
            {
                return;
            }

            Process[] proc;
            try
            {
                proc = Process.GetProcessesByName("nginx");//创建一个进程数组,把与此进程相关的资源关联。
                for (int i = 0; i < proc.Length; i++)
                {
                    proc[i].Kill();  //逐个结束进程.
                }
            }
            catch { }
            try
            {
                //杀两次,因为nginx自带守护进程
                proc = Process.GetProcessesByName("nginx");//创建一个进程数组,把与此进程相关的资源关联。
                for (int i = 0; i < proc.Length; i++)
                {
                    proc[i].Kill();  //逐个结束进程.
                }
            }
            catch { }

            try
            {
                proc = Process.GetProcessesByName("efwplusNginxHost");//创建一个进程数组,把与此进程相关的资源关联。
                for (int i = 0; i < proc.Length; i++)
                {
                    proc[i].Kill();  //逐个结束进程.
                }
            }
            catch { }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 开启efwplusBase
        /// </summary>
        public static Process StartBase()
        {
            Iswcfservice = HostSettingConfig.GetValue("wcfservice") == "1" ? true : false;
            if (Iswcfservice)
            {
                baseExe = AppDomain.CurrentDomain.BaseDirectory + @"efwplusBase.exe";

                System.Diagnostics.Process pro = new System.Diagnostics.Process();
                pro.StartInfo.FileName        = baseExe;
                pro.StartInfo.UseShellExecute = false;
                //pro.StartInfo.RedirectStandardInput = true;
                //pro.StartInfo.RedirectStandardOutput = true;
                //pro.StartInfo.RedirectStandardError = true;
                pro.StartInfo.CreateNoWindow = true;
                pro.Start();
                //pro.WaitForExit();
                //pro.StandardInput.AutoFlush = true;

                ShowMsg("服务程序已启动");
                return(pro);
            }

            return(null);
        }
        /// <summary>
        /// 开启efwplusRoute
        /// </summary>
        public static Process StartRoute()
        {
            Isrouter = HostSettingConfig.GetValue("router") == "1" ? true : false;
            if (Isrouter)
            {
                routeExe = AppDomain.CurrentDomain.BaseDirectory + @"efwplusRoute.exe";

                System.Diagnostics.Process pro = new System.Diagnostics.Process();
                pro.StartInfo.FileName        = routeExe;
                pro.StartInfo.UseShellExecute = false;
                //pro.StartInfo.RedirectStandardInput = true;
                //pro.StartInfo.RedirectStandardOutput = true;
                //pro.StartInfo.RedirectStandardError = true;
                pro.StartInfo.CreateNoWindow = true;
                pro.Start();
                //pro.WaitForExit();

                ShowMsg("路由程序已启动");

                return(pro);
            }

            return(null);
        }
Exemplo n.º 10
0
 /*写入注册表*/
 public static void WriteSetting(string Setting)
 {
     HostSettingConfig.SetValue("cdkey", Setting);
     HostSettingConfig.SaveConfig();
 }