コード例 #1
0
        public Stream GetApprovalRequestsByStatus(string status)
        {
            try
            {
                Client.ApprovalStatus approvalStatus;

                if (Enum.TryParse(status, true, out approvalStatus))
                {
                    return(ResourceManagementWebServicev1.GetResponse(Global.Client.GetApprovals(approvalStatus).ToList()));
                }

                throw new ArgumentException("Invalid value for status parameter");
            }
            catch (WebFaultException)
            {
                throw;
            }
            catch (WebFaultException <ExceptionData> )
            {
                throw;
            }
            catch (ResourceManagementException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (ArgumentException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (Exception ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex);
            }
        }
コード例 #2
0
        public Stream GetResources()
        {
            try
            {
                string      attributes = WebOperationContext.Current?.IncomingRequest.UriTemplateMatch.QueryParameters["attributes"];
                string      objectType = WebOperationContext.Current?.IncomingRequest.UriTemplateMatch.QueryParameters["objectType"];
                string      filter     = WebOperationContext.Current?.IncomingRequest.UriTemplateMatch.QueryParameters["filter"];
                CultureInfo locale     = GetLocaleFromParameters();

                if (filter == null)
                {
                    if (objectType == null)
                    {
                        filter = "/*";
                    }
                    else
                    {
                        filter = $"/{objectType}";
                    }
                }

                if (attributes != null)
                {
                    return(ResourceManagementWebServicev1.GetResponse(Global.Client.GetResources(filter, attributes.Split(','), locale).ToList()));
                }

                if (objectType != null)
                {
                    return(ResourceManagementWebServicev1.GetResponse(Global.Client.GetResources(filter, ResourceManagementSchema.GetObjectType(objectType).Attributes.Select(t => t.SystemName), locale).ToList()));
                }
                else
                {
                    return(ResourceManagementWebServicev1.GetResponse(Global.Client.GetResources(filter, locale).ToList()));
                }
            }
            catch (WebFaultException)
            {
                throw;
            }
            catch (WebFaultException <ExceptionData> )
            {
                throw;
            }
            catch (ResourceManagementException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (ArgumentException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (Exception ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex);
            }
        }
コード例 #3
0
        public Stream GetRequestParameters(string id)
        {
            try
            {
                ResourceManagementWebServicev1.ValidateID(id);

                ResourceObject request = Global.Client.GetResourceByKey("Request", AttributeNames.ObjectID, id, new[] { "RequestParameter" });

                if (request == null)
                {
                    throw new WebFaultException(HttpStatusCode.NotFound);
                }

                if (!request.Attributes.ContainsAttribute("RequestParameter") || request.Attributes["RequestParameter"].IsNull)
                {
                    return(new MemoryStream());
                }

                IList <string>          parameters        = request.Attributes["RequestParameter"].StringValues;
                List <RequestParameter> requestParameters = new List <RequestParameter>();

                foreach (string param in parameters)
                {
                    requestParameters.Add(XmlDeserializeFromString <RequestParameter>(param));
                }

                return(ResourceManagementWebServicev1.GetResponse(requestParameters));
            }
            catch (WebFaultException)
            {
                throw;
            }
            catch (WebFaultException <ExceptionData> )
            {
                throw;
            }
            catch (ResourceManagementException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (ArgumentException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (Exception ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex);
            }
        }
コード例 #4
0
        public Stream GetResourceByKey(string objectType, string key, string keyValue)
        {
            ResourceObject resource;

            try
            {
                ResourceManagementSchema.ValidateAttributeName(key);
                ResourceManagementSchema.ValidateObjectTypeName(objectType);
                CultureInfo locale = GetLocaleFromParameters();

                resource = Global.Client.GetResourceByKey(objectType, key, keyValue, locale);

                if (resource == null)
                {
                    throw new ResourceNotFoundException();
                }
            }
            catch (WebFaultException)
            {
                throw;
            }
            catch (WebFaultException <ExceptionData> )
            {
                throw;
            }
            catch (ResourceNotFoundException)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.NotFound);
            }
            catch (ResourceManagementException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (ArgumentException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (Exception ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex);
            }

            return(ResourceManagementWebServicev1.GetResponse(resource));
        }
コード例 #5
0
        public Stream GetResourceByID(string id)
        {
            try
            {
                ResourceManagementWebServicev1.ValidateID(id);
                CultureInfo locale = GetLocaleFromParameters();

                ResourceObject resource = Global.Client.GetResource(id, locale);

                if (resource == null)
                {
                    throw new ResourceNotFoundException();
                }

                return(ResourceManagementWebServicev1.GetResponse(resource));
            }
            catch (WebFaultException)
            {
                throw;
            }
            catch (WebFaultException <ExceptionData> )
            {
                throw;
            }
            catch (ResourceNotFoundException)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.NotFound);
            }
            catch (ResourceManagementException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (ArgumentException ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex);
            }
            catch (Exception ex)
            {
                throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex);
            }
        }