/// <summary>
        /// used by Workflows to get get actions defined by the Connector. Run when a user registers or refreshes a Connector.
        /// </summary>
        /// <param name="request">The request received from the client.</param>
        /// <param name="context">The context of the server-side call handler being invoked.</param>
        /// <returns>The response to send back to the client (wrapped by a task).</returns>
        public override Task <ActionsResponse> actions(ActionsRequest request, ServerCallContext context)
        {
            //throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
            Field fullName = new Field
            {
                DisplayName = "Full Name",
                Key         = "full_name",
                Description = "User's full name",
                Type        = "text"
            };

            Field salutation = new Field
            {
                DisplayName = "Salutation",
                Key         = "custom_field_value",
                Description = "User-specific salutation",
                Type        = "text"
            };

            Grpc.Action sayHello = new Grpc.Action
            {
                DisplayName = "Say Hello",
                Description = "Returns a friendly hello"
            };
            sayHello.Inputs.Add(fullName);
            sayHello.Outputs.Add(salutation);

            Grpc.ActionsResponse resp = new ActionsResponse();
            resp.Actions.Add(sayHello);

            //return new Task<ActionsResponse>(() => { return resp; });
            //_logger.LogInformation($"Sending hello to {request.Name}");
            return(Task.FromResult(resp));
        }
示例#2
0
        public void AcionaRele_Json()
        {
            LoginRequest acesso = new LoginRequest();

            acesso.login    = Login;
            acesso.password = Password;

            object result1 = WebJson.JsonCommand <LoginResult>(URL + "login.fcgi", acesso);

            if (result1 is LoginResult)
            {
                LoginResult dados = (LoginResult)result1;
                Console.WriteLine("Sessão: " + dados.session);
                if (dados.session != null)
                {
                    ActionsRequest ar = new ActionsRequest();
                    ar.actions = new ActionItem[] { new ActionItem()
                                                    {
                                                        action = "door", parameters = "door=1"
                                                    } };
                    // Não retorna saida
                    WebJson.JsonCommand <string>(URL + "execute_actions.fcgi?session=" + dados.session, ar);
                }
                else
                {
                    Assert.Inconclusive("Login invalido");
                }
            }
            else
            {
                Assert.Fail((string)result1);
            }
        }
示例#3
0
 private void UpdateActionPaths(
     ActionsRequest request,
     DownloadingResult downloadResult)
 {
     foreach (var action in request.Actions)
     {
         action.InputPath  = downloadResult.LocalPath;
         action.OutputPath = BuildOutputPath(action);
     }
 }
示例#4
0
        private void ParseActions(JObject parsed, ActionsRequest result)
        {
            var actions  = new List <IAction>();
            var jActions = parsed.GetPropertyValueCaseInsensetive <object>("actions") as JArray ?? new JArray();

            foreach (var jAction in jActions)
            {
                actions.Add(ParseActions(jAction));
            }

            result.Actions = actions;
        }
示例#5
0
        public ActionsRequest Parse(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                return(new ActionsRequest());
            }

            var parsed = JObject.Parse(json);
            var result = new ActionsRequest();

            ParseRequestInfo(parsed, result);
            ParseActions(parsed, result);

            return(result);
        }
示例#6
0
        public async Task Process(ActionsRequest request)
        {
            if (request?.Actions?.Any() == false)
            {
                return;
            }

            var downloadResult = await _filesComponent.DownloadLocally(request.RecordId);

            UpdateActionPaths(request, downloadResult);

            foreach (var action in request.Actions)
            {
                await ProcessAction(action);
            }

            await DeleteLocalFile(downloadResult.LocalPath);
        }
示例#7
0
 private void ParseRequestInfo(JObject parsed, ActionsRequest result)
 {
     result.RecordId = parsed.GetPropertyValueCaseInsensetive <string>("recordId");
 }