/// <summary> /// 删除进程文件复制 /// </summary> /// <param name="processCopyer">进程文件复制</param> /// <param name="type">调用类型</param> internal ProcessCopyerServerCall(ProcessCopyer processCopyer, CallType type) { server = processCopyer.Server; this.processCopyer = processCopyer; this.type = type; processCopyer.Server = null; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (server != null) { server.Remove(this); server = null; } }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (Server != null) { Server.Remove(this); Server = null; //new ProcessCopyerServerCall(this, ProcessCopyerServerCall.CallType.Remove).CheckCall(Net.TcpServer.ServerTaskType.QueueLink, Server.TcpServer); } }
/// <summary> /// 守护进程 /// </summary> /// <param name="server"></param> /// <returns></returns> internal bool Guard(ProcessCopyServer server) { this.server = server; try { if ((process = System.Diagnostics.Process.GetProcessById(ProcessId)) != null && process.ProcessName == ProcessName) { process.EnableRaisingEvents = true; process.Exited += guard; server.TcpServer.Log.Add(AutoCSer.Log.LogType.Info, "添加守护进程 " + Process); return(true); } } catch (Exception error) { server.TcpServer.Log.Add(AutoCSer.Log.LogType.Error, error); } return(false); }
/// <summary> /// 守护进程 /// </summary> /// <param name="server"></param> /// <returns></returns> internal bool Guard(ProcessCopyServer server) { Server = server; try { if ((process = System.Diagnostics.Process.GetProcessById(ProcessId)) != null && process.ProcessName == ProcessName) { if (guardEvent == null) { guardEvent = guard; } process.EnableRaisingEvents = true; process.Exited += guardEvent; server.TcpServer.Log.Info("添加守护进程 " + Process, LogLevel.Info | LogLevel.AutoCSer); return(true); } } catch (Exception error) { server.TcpServer.Log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer); } return(false); }
/// <summary> /// 守护启动进程 /// </summary> internal void Start() { try { ProcessCopyServer server = Server; if (server != null) { Server = null; server.Remove(this); } if (System.IO.File.Exists(Process)) { start(); } else { log.Add(AutoCSer.Log.LogType.Error, "没有找到文件 " + Process); } } catch (Exception error) { log.Add(AutoCSer.Log.LogType.Error, error, "进程启动失败 " + Process); } }
/// <summary> /// 保存进程守护信息集合到缓存文件 /// </summary> /// <param name="server">进程复制重启服务</param> internal ProcessCopySaveCache(ProcessCopyServer server) { this.server = server; }