/// <summary> /// Run a CMD. /// </summary> /// <param name="cmd">cmd.</param> /// <param name="param">param.</param> /// <param name="silently">whether silently.</param> /// <param name="waitForExit">whether wait for exit.</param> /// <returns>Return the output string.</returns> public static string RunFile(string cmd, string param, bool silently = true, bool waitForExit = true) { try { using (Process process = new Process()) { process.StartInfo.FileName = cmd; process.StartInfo.Arguments = param; process.StartInfo.UseShellExecute = !silently; process.StartInfo.CreateNoWindow = silently; process.StartInfo.RedirectStandardOutput = silently; process.Start(); if (waitForExit) { process.WaitForExit(); } return(process.StandardOutput.ReadToEnd()); } } catch (Exception ex) { Log.Error("RunFile, failed.", ex); return(""); } }
public async Task <bool> PauseMusic(string mark) { if (MusicMarks.FirstOrDefault(s => s == mark) != null) { return(await MusicSourceService.PauseMusic(mark)); } Logger.Error("并没有找到相关Mark。"); return(false); }
internal void WriteMsgWithLog(string msg, StatusNotificationType statusType) { Messenger.Default.Send(new StatusNotificationMessage(msg, statusType), LogMsgId); var logMsg = $"舞台灯光_{HeaderName}_{msg}"; switch (statusType) { case StatusNotificationType.RInfo: _logWraper.Info(logMsg); break; case StatusNotificationType.NInfo: _logWraper.Info(logMsg); break; case StatusNotificationType.Error: _logWraper.Error(logMsg); break; default: throw new ArgumentOutOfRangeException(nameof(statusType), statusType, null); } }
protected override void Exception(Exception ex) { _log.Error(ex.Message, ex); }