110
StartInfo = new ProcessStartInfo
{
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = LaunchArgs,
FileName =
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
},
EnableRaisingEvents = true,
};
SAC_Proc.OutputDataReceived += (sender, e) => { if
(this.IsEnabled) handleData(e.Data); };
SAC_Proc.Exited += (sac, e) => { IsStarted = false;
if (!this.IsEnabled) { this.Dispose(); return; }
if (this.IsRestart) { Launch(SlavePID == null? null :
((char)(0x2) + SlavePID)); return; }
if (this.IsEnabled && UnexpectedTermination != null)
UnexpectedTermination((Process)sac, this.ServerID, e);
};
}
public void Update(string sn, string spn, string srp, string
smf, bool force)
{
string ola = this.LaunchArgs;
this.LaunchArgs = string.Format("\"{0}\" \"{1}\" \"{2}\"
\"{3}\" \"{4}\"", ServerID, sn, spn, srp, smf);
if (force || !ola.Equals(this.LaunchArgs))
{
this.IsRestart = true;
this.sendData("stop");
}
ola = null;
}
/// <param name="flag">chars sequence contains one char -
flag(0,1,2) and 4 chars - pid; null if no flag </param>
public void Launch(string flag)
{
if (IsStarted) return;
this.IsRestart = false;
this.IsStarted = true;
if (CentralSockPort == null || CentralSockAddr == null)
return; //send notify about incorrect config
SAC_Proc.StartInfo.Arguments = string.Format("-sac
\"{0}\" {1} \"{2}\" \"{3}\"",