public static string FormatResponse(Cue cue, CueReply reply) { StringBuilder sb = new StringBuilder(); sb.Append("Action Received"); sb.Append($" | Signal Id = {reply.Id}"); sb.Append($" | Action Id = {reply.ActionId}"); foreach (MultiValueVariable variable in cue.Variables) { sb.Append($" | {variable.Name} = {String.Join(',', variable.Values)}"); } return(sb.ToString()); }
public CueReply ReceiveCue(Cue cue) { string actionId = Utils.GenerateId(); CueReply reply = new CueReply { ActionId = actionId, Id = cue.Id, StatusCode = StatusCode.Success, Time = DateTime.UtcNow, StatusMessage = "Cue Received" }; try { SignalDbRecord signal = DbEngine.Get <SignalDbRecord>(cue.Id); if (signal == null) { reply.StatusCode = StatusCode.Failure; reply.StatusMessage = $"Signal [{cue.Id}] Not Found."; } else if (signal.IsActive == false) { reply.StatusCode = StatusCode.NotActive; reply.StatusMessage = $"Signal [{cue.Id}] Is Not Active."; } else { reply.SignalDbRecord = signal; CueRequest request = new CueRequest { ActionId = actionId, Id = cue.Id, Cue = cue }; SendToCueProcessor(request); } } catch (Exception e) { reply.StatusCode = StatusCode.Failure; reply.StatusMessage = e.Message; } return(reply); }
public static string FormatResponse(Cue cue, CueReply reply) { SignalDbRecord signal = reply.SignalDbRecord; StringBuilder sb = new StringBuilder(); string signalTitle = $"{signal?.Signal?.Name} - {signal?.Signal?.Description}"; if (String.IsNullOrEmpty(signal?.Signal?.Name)) { signalTitle = signal?.Signal?.Description; } else if (String.IsNullOrEmpty(signal?.Signal?.Description)) { signalTitle = signal?.Signal?.Name; } else if (String.IsNullOrEmpty(signal?.Signal?.Name) && String.IsNullOrEmpty(signal?.Signal?.Description)) { signalTitle = null; } if (!String.IsNullOrWhiteSpace(signalTitle)) { sb.AppendLine($"Action Received From [{cue.Payload?.User?.Name}] To Signal [{signalTitle}]"); } else { sb.AppendLine($"Action Received From [{cue.Payload?.User?.Name}]"); } sb.AppendLine($"Signal Id : {reply.Id}"); sb.AppendLine($"Action Id : {reply.ActionId}"); foreach (MultiValueVariable variable in cue.Variables) { sb.AppendLine($"{variable.Name} = {String.Join(',', variable.Values)}"); } return(sb.ToString()); }