コード例 #1
0
        public MapElementResponseAPI LoadMapElement(INotifier notifier, IAuthenticatedWho authenticatedWho, String manywhoBaseUrl, String editingToken, String flowId, String mapElementId)
        {
            MapElementResponseAPI mapElementResponse  = null;
            HttpClient            httpClient          = null;
            HttpResponseMessage   httpResponseMessage = null;
            String endpointUrl = null;

            Policy.Handle <ServiceProblemException>().Retry(HttpUtils.MAXIMUM_RETRIES).Execute(() =>
            {
                using (httpClient = HttpUtils.CreateHttpClient(authenticatedWho, authenticatedWho.ManyWhoTenantId.ToString(), null))
                {
                    // Construct the URL for the save
                    endpointUrl = manywhoBaseUrl + String.Format(MANYWHO_DRAW_URI_PART_MAP_ELEMENT, flowId, editingToken) + "/" + mapElementId;

                    // Get the map element data to from the service
                    httpResponseMessage = httpClient.GetAsync(endpointUrl).Result;

                    // Check the status of the response and respond appropriately
                    if (httpResponseMessage.IsSuccessStatusCode)
                    {
                        // Get the map element response back from the load request
                        mapElementResponse = JsonConvert.DeserializeObject <MapElementResponseAPI>(httpResponseMessage.Content.ReadAsStringAsync().Result);
                    }
                    else
                    {
                        throw new ServiceProblemException(new ServiceProblem(endpointUrl, httpResponseMessage, string.Empty));
                    }
                }
            });

            return(mapElementResponse);
        }
コード例 #2
0
        public MapElementResponseAPI SaveMapElement(INotifier notifier, IAuthenticatedWho authenticatedWho, String manywhoBaseUrl, String editingToken, String flowId, MapElementRequestAPI mapElementRequest)
        {
            MapElementResponseAPI mapElementResponse  = null;
            HttpClient            httpClient          = null;
            HttpContent           httpContent         = null;
            HttpResponseMessage   httpResponseMessage = null;
            String endpointUrl = null;

            Policy.Handle <ServiceProblemException>().Retry(HttpUtils.MAXIMUM_RETRIES).Execute(() =>
            {
                using (httpClient = HttpUtils.CreateHttpClient(authenticatedWho, authenticatedWho.ManyWhoTenantId.ToString(), null))
                {
                    // Use the JSON formatter to create the content of the request body.
                    httpContent = new StringContent(JsonConvert.SerializeObject(mapElementRequest));
                    httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                    // Construct the URL for the save
                    endpointUrl = manywhoBaseUrl + String.Format(MANYWHO_DRAW_URI_PART_MAP_ELEMENT, flowId, editingToken);

                    // Send the map element data to save over to the service
                    httpResponseMessage = httpClient.PostAsync(endpointUrl, httpContent).Result;

                    // Check the status of the response and respond appropriately
                    if (httpResponseMessage.IsSuccessStatusCode)
                    {
                        // Get the map element response back from the save
                        mapElementResponse = JsonConvert.DeserializeObject <MapElementResponseAPI>(httpResponseMessage.Content.ReadAsStringAsync().Result);
                    }
                    else
                    {
                        throw new ServiceProblemException(new ServiceProblem(endpointUrl, httpResponseMessage, string.Empty));
                    }
                }
            });

            return(mapElementResponse);
        }
コード例 #3
0
        public static void CreateOutcome(String developerName, String label, MapElementRequestAPI mapElementRequest, MapElementResponseAPI nextMapElementResponse)
        {
            OutcomeRequestAPI outcomeRequest = null;

            // Create the new outcome connecting the map element
            outcomeRequest = new OutcomeRequestAPI();
            outcomeRequest.developerName         = developerName;
            outcomeRequest.label                 = label;
            outcomeRequest.nextMapElementId      = nextMapElementResponse.id;
            outcomeRequest.pageActionBindingType = ManyWhoConstants.ACTION_BINDING_SAVE;

            // Map sure we have an outcomes list to user
            if (mapElementRequest.outcomes == null)
            {
                mapElementRequest.outcomes = new List <OutcomeAPI>();
            }

            // Add the outcome to the request
            mapElementRequest.outcomes.Add(outcomeRequest);
        }