Exemple #1
0
        public static GroupElementRequestAPI CreateSwimlaneElement(String developerName, Int32 x, Int32 y, Int32 height, Int32 width, String serviceElementId, String authenticationId)
        {
            GroupAuthorizationGroupAPI groupAuthorizationGroup = null;
            GroupElementRequestAPI     groupElementRequest     = null;

            // Create the map element request for the input
            groupElementRequest = new GroupElementRequestAPI();
            groupElementRequest.developerName = developerName;
            groupElementRequest.elementType   = ManyWhoConstants.GROUP_ELEMENT_TYPE_IMPLEMENTATION_SWIMLANE;
            groupElementRequest.x             = x;
            groupElementRequest.y             = y;
            groupElementRequest.height        = height;
            groupElementRequest.width         = width;
            groupElementRequest.updateByName  = true;

            // Create the group authorization
            groupAuthorizationGroup                  = new GroupAuthorizationGroupAPI();
            groupAuthorizationGroup.attribute        = "MEMBERS";
            groupAuthorizationGroup.authenticationId = authenticationId;

            // Set the authorization object
            groupElementRequest.authorization = new GroupAuthorizationAPI();
            groupElementRequest.authorization.streamBehaviourType      = ManyWhoConstants.GROUP_AUTHORIZATION_STREAM_BEHAVIOUR_USE_EXISTING;
            groupElementRequest.authorization.globalAuthenticationType = ManyWhoConstants.GROUP_AUTHORIZATION_GLOBAL_AUTHENTICATION_TYPE_SPECIFIED;
            groupElementRequest.authorization.serviceElementId         = serviceElementId;
            groupElementRequest.authorization.groups = new List <GroupAuthorizationGroupAPI>();
            groupElementRequest.authorization.groups.Add(groupAuthorizationGroup);

            return(groupElementRequest);
        }
Exemple #2
0
        public GroupElementResponseAPI SaveGroupElement(INotifier notifier, IAuthenticatedWho authenticatedWho, String manywhoBaseUrl, String editingToken, String flowId, GroupElementRequestAPI groupElementRequest)
        {
            GroupElementResponseAPI groupElementResponse = 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(groupElementRequest));
                    httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

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

                    // Send the group 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 group element response back from the save
                        groupElementResponse = JsonConvert.DeserializeObject <GroupElementResponseAPI>(httpResponseMessage.Content.ReadAsStringAsync().Result);
                    }
                    else
                    {
                        throw new ServiceProblemException(new ServiceProblem(endpointUrl, httpResponseMessage, string.Empty));
                    }
                }
            });

            return(groupElementResponse);
        }