/// <summary> /// 开启 http 服务监听 9910 /// </summary> public static void StartHttp() { var url = string.Format("http://{0}:{1}/", ConfigTools.Get("addr"), ConfigTools.Get("httpPort")); HttpServices httpServer; httpServer = new HttpServices(url); var thread = new Thread(new ThreadStart(httpServer.Run)); thread.Start(); }
/// <summary> /// 从控制台启动Electron程序 /// </summary> public static void StartElectronApp() { var cmd = ConfigTools.Get("ElectronAppPath"); if (cmd.IndexOf("|DataDirectory|") >= 0) { cmd = cmd.Replace("|DataDirectory|", Application.StartupPath); } var str = CmdTools.RunCmd(cmd); Console.WriteLine(str); }
public void StartServer() { try { if (SockterServerEngine == null) { var port = ConfigTools.Get("port"); var _port = port == null || port.Length <= 0 ? 9909 : int.Parse(port); SockterServerEngine = NetworkEngineFactory.CreateTextTcpServerEngine(_port, new DefaultTextContractHelper("\0"));//DefaultTextContractHelper是StriveEngine内置的ITextContractHelper实现。使用UTF-8对EndToken进行编码。 } //判断 相关的监听事件是否注册 if (IsSocketServerInitialized) { SockterServerEngine.ChangeListenerState(true); } else { InitializeTcpServerEngine(); } //this.ShowListenStatus(); } catch (Exception ee) { Console.WriteLine(ee.Message); if (ee.Message.IndexOf("there's one StriveEngine server instance running") >= 0) { var res = MessageBox.Show("已打开一个实例或者前面实例的进程为未完全退出,是否重启?\r\n是:重启\r\n否:关闭\r\n取消:不做任何处理", "警告", MessageBoxButtons.YesNoCancel); if (DialogResult.Yes == res) { Application.ExitThread(); Application.Exit(); Application.Restart(); Process.GetCurrentProcess().Kill(); } else if (DialogResult.No == res) { Application.ExitThread(); Application.Exit(); Process.GetCurrentProcess().Kill(); } } } services = this; }
private void GetConfig() { var tDir = ConfigTools.Get("TemplatesDirectory"); if (string.IsNullOrEmpty(tDir)) { tDir = ConfigTools.OriginalGet("TemplatesDirectory"); while (tDir.LastIndexOf(@"\\") == tDir.Length - 2) { tDir = tDir.Substring(0, tDir.Length - 1); } } if (string.IsNullOrEmpty(tDir)) { TemplatesDirectory = Environment.SpecialFolder.Desktop.ToString(); } else { TemplatesDirectory = tDir; } }
private static string connectionString = ConfigTools.Get("Connection"); //数据库连接字符串 public void SetConnection(string connectionStr) { connectionString = connectionStr.Length <= 0?ConfigTools.Get("Connection"):connectionStr; }