Ejemplo n.º 1
0
        public IRestResponse Post(string name, string insideCode, string objectId, TriggerDataAction triggerDataAction, WorkflowAction workflowAction)
        {
            string code = "/* globals\n" +
                          "$http - Service for AJAX calls \n" +
                          "CONSTS - CONSTS.apiUrl for Backands API URL\n" +
                          "Config - Global Configuration\n" +
                          "*/\n" +
                          "'use strict';\n" +
                          "function backandCallback(userInput, dbRow, parameters, userProfile) {\n" +
                          "   \n" +
                          insideCode +
                          "}";

            code = code.Replace("+", "%2B");

            return(base.Post(new ActionData()
            {
                name = name, code = code, useSqlParser = false, viewTable = objectId, workflowAction = workflowAction.ToString(), dataAction = triggerDataAction.ToString(), additionalView = "", databaseViewName = "", inputParameters = "", whereCondition = "true"
            }));
        }
Ejemplo n.º 2
0
        public void Endless()
        {
            string objectNameUpdated   = "items2";
            string objectId            = null;
            var    getObjectIdResponse = admin.Objects.GetId(objectNameUpdated, out objectId);

            Assert.IsTrue(getObjectIdResponse.StatusCode == System.Net.HttpStatusCode.OK);
            admin.Actions.DeleteAll(objectId);


            string code = "\n" +
                          admin.Actions.GetPostActionTemplate(objectNameUpdated, "post1", data) + "\n";

            TriggerDataAction trigger  = TriggerDataAction.AfterCreateBeforeCommit;
            string            name     = objectNameUpdated + "Endless" + trigger.ToString();
            string            actionId = null;
            var getActionIdResponse    = admin.Actions.GetId(name, out actionId);

            Assert.IsTrue(getActionIdResponse.StatusCode == System.Net.HttpStatusCode.OK);
            if (actionId != null)
            {
                var getDeleteActionResponse = admin.Actions.Delete(actionId);
                Assert.IsTrue(getDeleteActionResponse.StatusCode == System.Net.HttpStatusCode.OK);
            }
            var createActionResponse = admin.Actions.Post(name, code, objectId, trigger, WorkflowAction.JavaScript);
            var result = JsonConvert.DeserializeObject <Dictionary <string, object> >(createActionResponse.Content);

            actionId = ((Newtonsoft.Json.Linq.JObject)result["__metadata"])["id"].ToString();
            Assert.IsTrue(createActionResponse.StatusCode == System.Net.HttpStatusCode.OK);
            var response = crud.Post(objectNameUpdated, data);

            Assert.IsTrue(createActionResponse.Content == "The following action: \"items2EndlessAfterCreateBeforeCommit\" failed to perform: The following action: \"items2EndlessAfterCreateBeforeCommit\" failed to perform: The request 'http://localhost:4110//1/objects/items2' is repeating calling itself. Please change the action items2EndlessAfterCreateBeforeCommit");
            var getDeleteActionResponse2 = admin.Actions.Delete(actionId);

            Assert.IsTrue(getDeleteActionResponse2.StatusCode == System.Net.HttpStatusCode.OK);
        }