public bool UpdateExecuteStatus(CommandTask commandTask, TaskExceteStatus exceteStatus) { using (var repo = Repo <CommandTaskRepository>()) { return(repo.UpdateExecuteStatus(commandTask, exceteStatus)); } }
public static void testRequest() { Request request = new Request(); request.IsHttps = true; request.Method = "GET"; request.Url = "https://cloud.tencent.com/"; HttpClientConfig config = new HttpClientConfig.Builder() .AllowAutoRedirect(true) .SetConnectionLimit(100) .SetConnectionTimeoutMs(45000) .SetReadWriteTimeoutMs(45000) .SetMaxRetry(3) //.SetProxyHost("web-proxy.tencent.com") .SetProxyPort(8080) .Build(); CommandTask.Init(config); Response response = new Response(); response.Body = null; CommandTask.excute(request, response, config); Console.WriteLine(response.Code + "|" + response.Message); foreach (KeyValuePair <string, List <string> > pair in response.Headers) { Console.WriteLine(pair.Key + " : " + pair.Value[0]); } }
public bool UPdateTaskStatus(CommandTask commandTask, TaskStatus status) { using (var repo = Repo <CommandTaskRepository>()) { return(repo.UpdateTaskStatus(commandTask, status)); } }
public void PreemptSkillCommand(CommandTask commandTask) { selectCommand.bPaused = true; if (moveCommand != null) { moveCommand.bPaused = true; moveCommand.HideFloorHUD(); } if (skillCommand != null) { skillCommand.Abort(); } skillCommand = commandTask; skillCommand.eTaskComplete.AddListener(() => { skillCommand = null; selectCommand.bPaused = false; if (moveCommand != null) { moveCommand.bPaused = false; moveCommand.ShowFloorHUD(); } UIManager.instance.eRefreshFloorHUD.Invoke(); }); }
/// <inheritdoc/> public IAsyncResult BeginRun(AcadCommand command, IProcess process, AsyncCallback completionCallback, object asyncState) { if (command == null) throw new ArgumentNullException("command"); if (process == null) throw new ArgumentNullException("process"); if (process.HasExited) throw new ArgumentNullException("process", "Process has exited."); var task = new CommandTask(command, process, completionCallback, asyncState); return task.Begin(); }
public void AddUnique(string command, CommandTask task) { if (m_IOStackDictionary.ExistsInUnique(command)) { $"[IO]: Trying added now exists command. Error while adding.".ToColor(String.Colors.DarkRed); } else { m_IOStackDictionary.AddUniqueCommand(command, task); $"[IO]: Command '{command}' (unique) was successfully added.".ToColor(String.Colors.DarkCyan); } }
protected void TerminateSkillCommand() { selectCommand.bPaused = false; if (moveCommand != null) { moveCommand.bPaused = false; moveCommand.ShowFloorHUD(); } if (skillCommand != null) { skillCommand.Abort(); } skillCommand = null; }
public String executeCmd(XCommand cmd) { this.executeState = "Executing..."; String ans = "OK"; AlertUtil.StartWait(); Notify(); if (cmd != null) { CommandTask task = new CommandTask(cmd, user); ans = task.doTask(); } this.executeState = "OK"; Notify(); AlertUtil.StopWait(); return(ans); }
/// <inheritdoc/> public IAsyncResult BeginRun(AcadCommand command, IProcess process, AsyncCallback completionCallback, object asyncState) { if (command == null) { throw new ArgumentNullException("command"); } if (process == null) { throw new ArgumentNullException("process"); } if (process.HasExited) { throw new ArgumentNullException("process", "Process has exited."); } var task = new CommandTask(command, process, completionCallback, asyncState); return(task.Begin()); }
//[HttpGet()] public string InFile(string inputfileName) { string inputPath = Path.Combine(Configuration["FFMpeg:InputPath"], inputfileName); string outPath = Path.Combine(Configuration["FFMpeg:OutPath"], inputfileName); CommandTask <int> t = Cli.Wrap(Configuration["FFMpeg:BinPath"]) .WithArguments(" -i " + inputPath + " -vf scale=320:240 " + outPath) .ExecuteAsync() .Select(r => r.ExitCode); CommandTask <int> t2 = Cli.Wrap(Configuration["FFMpeg:BinPath"]) .WithArguments(" -ss 00:00:03 -i " + inputPath + " -vframes 1 -q:v 2 -vf scale=107:107 " + Path.Combine(Configuration["FFMpeg:OutPath"], Path.GetFileNameWithoutExtension(inputPath) + ".png")) .ExecuteAsync() .Select(r => r.ExitCode); try { t.Task.Wait(); } catch (Exception ex) { } finally { } try { t2.Task.Wait(); } catch (Exception ex) { } finally { } return("Completed"); }
private async Task _PlayAsync(string deviceUniqueId, CancellationTokenSource cancellationTokenSource, int attempts = 0) { Device device = await FindDeviceAsync(deviceUniqueId); if (device == null) { await Task.FromException(new NullReferenceException("Couldn't get device with uniqueId " + deviceUniqueId)).ConfigureAwait(false); } else { int deviceInstanceId = SnapSettings.DetermineInstanceId(deviceUniqueId, device.Index); DeviceSettings deviceSettings = SnapSettings.GetDeviceSettings(deviceUniqueId); if (deviceInstanceId != -1) { // update device's last seen: deviceSettings.LastSeen = DateTime.Now; SnapSettings.SaveDeviceSettings(deviceUniqueId, deviceSettings); StringBuilder stdError = new StringBuilder(); string lastLine = ""; Action <string> stdOut = (line) => { lastLine = line; // we only care about the last line from the output - in case there's an error (snapclient should probably be sending these to stderr though) }; string resampleArg = ""; string hostIdArg = ""; CommandTask <CommandResult> task = null; if (deviceSettings.UseSnapClientNet == false) { // Launch native client: if (string.IsNullOrEmpty(deviceSettings.ResampleFormat) == false) { resampleArg = $"--sampleformat {deviceSettings.ResampleFormat}:0"; } if (string.IsNullOrWhiteSpace(deviceSettings.HostId) == false) { hostIdArg = $"--hostID \"{deviceSettings.HostId}\""; } string command = $"-h {SnapSettings.Server} -p {SnapSettings.PlayerPort} -s {device.Index} -i {deviceInstanceId} --sharingmode={deviceSettings.ShareMode.ToString().ToLower()} {resampleArg} {hostIdArg}"; Logger.Debug("Snapclient command: {0}", command); task = Cli.Wrap(_SnapClient()) .WithArguments(command) .WithStandardOutputPipe(PipeTarget.ToDelegate(stdOut)) .ExecuteAsync(cancellationTokenSource.Token); } else { // launch experimental .NET port of snapclient: string command = $"-h {SnapSettings.Server} -p {SnapSettings.PlayerPort} -s {device.Index} -i {deviceInstanceId}"; Logger.Debug("SnapClient.Net command: {0}", command); task = Cli.Wrap(_SnapClientDotNet()) .WithArguments(command) .WithStandardOutputPipe(PipeTarget.ToDelegate(stdOut)) .ExecuteAsync(cancellationTokenSource.Token); } Logger.Debug("Snapclient PID: {0}", task.ProcessId); ChildProcessTracker.AddProcess(Process.GetProcessById(task.ProcessId)); // this utility helps us make sure the player process doesn't keep going if our process is killed / crashes try { await task; } catch (CliWrap.Exceptions.CommandExecutionException e) { OnSnapClientErrored?.Invoke(); // add type to ShowNotification (level?), show notification with type and print log at type level Snapcast.Instance.ShowNotification("Snapclient error", _BuildErrorMessage(device, lastLine)); // todo: parse WASAPI error code here and provide human friendly output Logger.Error("Snapclient exited with non-zero exit code. Exception:"); Logger.Error(e.Message); DevicePlayStateChanged?.Invoke(deviceUniqueId, EState.Stopped); m_ActivePlayers.Remove(deviceUniqueId); // settings might have changed while we were playing - refetch them DeviceSettings nDeviceSettings = SnapSettings.GetDeviceSettings(deviceUniqueId); if (nDeviceSettings.AutoRestartOnFailure == true && (attempts <= nDeviceSettings.RestartAttempts || nDeviceSettings.RestartAttempts == 0)) { m_ActivePlayers.Add(deviceUniqueId, cancellationTokenSource); DevicePlayStateChanged?.Invoke(deviceUniqueId, EState.Playing); await _PlayAsync(deviceUniqueId, cancellationTokenSource, attempts + 1).ConfigureAwait(false); } } } } DevicePlayStateChanged?.Invoke(deviceUniqueId, EState.Stopped); m_ActivePlayers.Remove(deviceUniqueId); }
protected override void Context() { _executionContext = A.Fake <IOSPSuiteExecutionContext>(); sut = new CommandTask(); }
public void PutTask(CommandTask commandTask) { Tasks.Enqueue(commandTask); _resetEvent.Set(); }