/// <summary> /// Wykonuje akcje zdefiniowane w źródłowym JObject. /// </summary> /// <param name="actionsData"> /// Definicja akcji. Struktura: /// { /// "actions": [ /// { /// "name": "action-name-1", /// "data": { ... } /// }, /// { /// "name": "action-name-2", /// "data": { ... } /// }, /// ... /// ] /// } /// </param> /// <returns> /// Wyniki każdej akcji w kolejności takiej, w jakiej zdefiniowane były akcje w źródłowym JObject. /// Struktura: /// { /// "actions": [ /// { /// "name": "action-name-1", /// "data": (response) /// }, /// { /// "name": "action-name-2", /// "data": (response) /// }, /// ... /// ] /// } /// </returns> public JObject PerformActions(ClientConnection conn, JObject actionsData) { var serializer = new ActionsSerializer(actionsData); serializer.Validate(); var actionsMeta = serializer.GetActionsMeta(); return(PerformActions(conn, actionsMeta)); }
public JObject PerformActions(ClientConnection conn, IEnumerable <ActionMeta> actions) { var response = new ActionsSerializer(); response.Actions = new ActionSerializer[actions.Count()]; JObject jObjPtr; int index = 0; foreach (var action in actions) { jObjPtr = new JObject(); try { jObjPtr = PerformAction(conn, action.Name, action.Data); } catch (ActionNotFoundException e) { jObjPtr = new JObject(); jObjPtr.Add("status", "ERROR"); jObjPtr.Add("error_code", ERROR_CODE_NOT_FOUND); jObjPtr.Add("error_message", e.Message); } catch (ActionManagerException e) { jObjPtr = new JObject(); jObjPtr.Add("status", "ERROR"); jObjPtr.Add("error_code", ERROR_CODE_MANAGER_GENERIC); jObjPtr.Add("error_message", e.Message); } catch (JsonValidationException e) { jObjPtr = new JObject(); jObjPtr.Add("status", "ERROR"); jObjPtr.Add("errors", e.Errors); } catch (Exception e) { jObjPtr = new JObject(); jObjPtr.Add("status", "ERROR"); jObjPtr.Add("error_code", ERROR_CODE_INTERNAL); jObjPtr.Add("error_message", e.Message); } response.Actions[index] = new ActionSerializer() { ActionName = action.Name, ActionData = jObjPtr }; index++; } return(response.GetApiObject()); }