Computing > 11 - Private Cloud > Get purchased Custom Products

11.8 Get purchased Custom Products

By the method IWSCommon GetPurchasedCustomProducts you can retrieve the list of all purchased custom products.
 
    /// IWsCommon.GetPurchasedCustomProducts Method (c# .NET)
    public static string GetPurchasedCustomProducts(WsCommonClient client)
    {
        //specify the account login details 
        client.ClientCredentials.UserName.UserName = "ARU-0000";
        client.ClientCredentials.UserName.Password = "0123456789";

        StringBuilder stringBuilder = new StringBuilder();

        try
        {
            // call method GetPurchasedCustomProducts 
            // obtaining a WsResultOfCustomProductsData item
            WsResultOfCustomProductsData result =
                client.GetPurchasedCustomProducts();

            // if the call is Success print returned values
            if (result.Success)
            {
                stringBuilder.Append("Operation ends successfully\n");

                // get Value returned from server
                CustomProductsData items = result.Value;

                if (items.CustomProducts != null)
                {
                    // category id for computing products 
                    int computingCategory = 1;

                    // query for the productId                        
                    var query = from CustomProduct product in items.CustomProducts
                                where product.ProductCategory.CustomProductCategoryID 
                                    == computingCategory 
                                select product;

                    // for each item print the information
                    foreach (CustomProduct item in query)
                    {
                        stringBuilder.Append("\nProductID: ");
                        stringBuilder.Append(item.ProductID);
                        stringBuilder.Append("\nCustomProductID: ");
                        stringBuilder.Append(item.CustomProductID);
                        stringBuilder.Append("\nName: ");
                        stringBuilder.Append(item.ProductName);
                        stringBuilder.Append("\nQuantity: ");
                        stringBuilder.Append(item.Quantity);
                        stringBuilder.Append("\nDescription: ");
                        stringBuilder.Append(item.ProductDescription);
                        stringBuilder.Append("\ncategory id: ");
                        stringBuilder.Append(item.ProductCategory.CustomProductCategoryID);
                        stringBuilder.Append("\ncategory description: ");
                        stringBuilder.Append(item.ProductCategory.Description);

                    }
                }
            }
            else
            {
                throw new ApplicationException(result.ResultMessage);
            }
        }
        catch (Exception ex)
        {
            // re-run the error
            throw new ApplicationException(ex.Message);
        }

        return stringBuilder.ToString();
    }
    
    /// IWsCommon.getPurchasedCustomProducts Method (JAVA)
    public static String getPurchasedCustomProducts(IWsCommon client)
    {
        //specify the account login details 
        ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
        ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");

        StringBuilder stringBuilder = new StringBuilder();

        try
        {
            // call method getPurchasedCustomProducts 
            // obtaining a WsResultOfCustomProductsData item
            WsResultOfCustomProductsData result =
                client.getPurchasedCustomProducts();

            // if the call is Success print returned values
            if (result.isSuccess())
            {
                stringBuilder.append("Operation ends successfully\n");

                // get Value returned from server
                if (result.getValue()!= null)
                {
                    ArrayOfCustomProduct items = result.getValue().getCustomProducts();                    

                        
                    if (items != null)
                    {
                        stringBuilder.append("Custom Products\n");

                        // category id for computing products 
                        int computingCategory = 1;
                        
                        // for each item print the information
                        for (CustomProduct item : items.getCustomProduct()) 
                        {
                            if (item.getProductCategory().getCustomProductCategoryID() 
                                    != computingCategory)
                                continue;
                                
                            stringBuilder.append("\nProductID: ");
                            stringBuilder.append(item.getProductID());
                            stringBuilder.append("\nCustomProductID: ");
                            stringBuilder.append(item.getCustomProductID());
                            stringBuilder.append("\nName: ");
                            stringBuilder.append(item.getProductName());
                            stringBuilder.append("\nQuantity: ");
                            stringBuilder.append(item.getQuantity());
                            stringBuilder.append("\nDescription: ");
                            stringBuilder.append(item.getProductDescription());
                            
                        }
                    }
                }
            }
            else
            {
                throw new Exception(result.getResultMessage());
            }
        }
        catch (Exception ex)
        {
            // re-run the error
                System.out.println(ex);
        }

        return stringBuilder.toString();
    }
    
Version
API: v2.8 URL:https://api.dc1.computing.cloud.it/WsCommon/v2.8/WsCommon.svc?wsdl