Exemplo n.º 1
0
        private async Task TriggerGenericWebhook(Guid id, string payload)
        {
            try
            {
                var command = ChannelSession.Services.Command.WebhookCommands.FirstOrDefault(c => c.ID == id);
                if (command != null && command.IsEnabled)
                {
                    if (string.IsNullOrEmpty(payload))
                    {
                        payload = "{}";
                    }

                    Dictionary <string, string> eventCommandSpecialIdentifiers = new Dictionary <string, string>();
                    eventCommandSpecialIdentifiers["webhookpayload"] = payload;

                    // Do JSON => Special Identifier logic
                    CommandParametersModel      parameters     = new CommandParametersModel(ChannelSession.GetCurrentUser(), eventCommandSpecialIdentifiers);
                    Dictionary <string, string> jsonParameters = command.JSONParameters.ToDictionary(param => param.JSONParameterName, param => param.SpecialIdentifierName);
                    await WebRequestActionModel.ProcessJSONToSpecialIdentifiers(payload, jsonParameters, parameters);

                    await ChannelSession.Services.Command.Queue(command, parameters);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
 public WebRequestActionEditorControlViewModel(WebRequestActionModel action)
     : base(action)
 {
     this.RequestURL = action.Url;
     this.SelectedResponseParseType = action.ResponseType;
     if (this.ShowJSONGrid)
     {
         this.JSONParameters.AddRange(action.JSONToSpecialIdentifiers.Select(kvp => new WebRequestActionJSONToSpecialIdentifierViewModel(kvp.Key, kvp.Value, this)));
     }
 }