Beispiel #1
0
        public XmlDocument CreateXml()
        {
            if (!IsValid())
            {
                throw new Exception("Product Is not valid, XML will not be created");
            }

            //http://help.webcomcpq.com/doku.php?id=appendixd:simple_product_administration:input_xml_example

            XmlDocument retVal = new XmlDocument();

            XmlNode userProducts = retVal.CreateElement("Products");

            retVal.AppendChild(userProducts);

            ////These are attributes of Products, still WIP:////
            if (SkipCategoriesOnProductUpdate != false)
            {
                XmlAttribute scopu = retVal.CreateAttribute("SkipCategoriesOnProductUpdate");
                scopu.InnerText = SkipCategoriesOnProductUpdate.ToString().ToUpper();
                userProducts.Attributes.Append(scopu);
            }
            if (SkipPermissionsOnProductUpdate != false)
            {
                XmlAttribute spopu = retVal.CreateAttribute("SkipPermissionsOnProductUpdate");
                spopu.InnerText = SkipPermissionsOnProductUpdate.ToString().ToUpper();
                userProducts.Attributes.Append(spopu);
            }


            //Product Tag: <PRODUCTS><PRODUCT>
            XmlNode userProduct = retVal.CreateElement("Product");

            userProducts.AppendChild(userProduct);

            Utility.AddIfNotEmptyOrNull(userProduct, "Identificator", Identificator);
            Utility.AddIfNotEmptyOrNull(userProduct, "DisplayType", DisplayType);

            Utility.AddIfNotEmptyOrNull(userProduct, "ProductType", ProductType);

            if (ProductName != null)
            {
                ProductName.AddToXML(userProduct);
            }

            if (Categories != null)
            {
                Categories.AddToXML(userProduct);
            }

            Utility.AddIfNotEmptyOrNull(userProduct, "PartNumber", PartNumber);

            if (StartDate.HasValue)
            {
                Utility.AddIfNotEmptyOrNull(userProduct, "StartDate", StartDate);
            }

            if (EndDate.HasValue)
            {
                Utility.AddIfNotEmptyOrNull(userProduct, "EndDate", EndDate);
            }

            //Utility.AddIfNotEmptyOrNull(userProduct, "CATEGORIES", CategoryListString);
            Utility.AddIfNotEmptyOrNull(userProduct, "ShippingCosts", ShippingCosts);
            Utility.AddIfNotEmptyOrNull(userProduct, "Permissions", Permissions);
            Utility.AddIfNotEmptyOrNull(userProduct, "CPQProductId", CPQProductId);
            Utility.AddIfNotEmptyOrNull(userProduct, "UPC", UPC);
            Utility.AddIfNotEmptyOrNull(userProduct, "MPN", MPN);
            Utility.AddIfNotEmptyOrNull(userProduct, "ProductFamilyCode", ProductFamilyCode);
            Utility.AddIfNotEmptyOrNull(userProduct, "RecurringPriceFormula", RecurringPriceFormula);
            Utility.AddIfNotEmptyOrNull(userProduct, "RecurringCostFormula", RecurringCostFormula);
            Utility.AddIfNotEmptyOrNull(userProduct, "Inventory", Inventory);
            Utility.AddIfNotEmptyOrNull(userProduct, "LeadTime", LeadTime);
            Utility.AddIfNotEmptyOrNull(userProduct, "ProductVersion", ProductVersion);
            Utility.AddIfNotEmptyOrNull(userProduct, "ExternalId", ExternalId);
            Utility.AddIfNotEmptyOrNull(userProduct, "Active", Active);
            Utility.AddIfNotEmptyOrNull(userProduct, "IsSAPProduct", IsSAPProduct);
            Utility.AddIfNotEmptyOrNull(userProduct, "Weight", Weight);
            Utility.AddIfNotEmptyOrNull(userProduct, "Image", Image);
            Utility.AddIfNotEmptyOrNull(userProduct, "UserCanEnterQuantity", UserCanEnterQuantity);
            Utility.AddIfNotEmptyOrNull(userProduct, "UnitOfMeasure", UnitOfMeasure);
            Utility.AddIfNotEmptyOrNull(userProduct, "PricingMechanism", PricingMechanism);
            Utility.AddIfNotEmptyOrNull(userProduct, "PricingCode", PricingCode);
            Utility.AddIfNotEmptyOrNull(userProduct, "BaseRecurringPrice", BaseRecurringPrice);
            Utility.AddIfNotEmptyOrNull(userProduct, "Price", Price);
            Utility.AddIfNotEmptyOrNull(userProduct, "PriceFormula", PriceFormula);
            Utility.AddIfNotEmptyOrNull(userProduct, "CostFormula", CostFormula);
            Utility.AddIfNotEmptyOrNull(userProduct, "Description", Description);
            Utility.AddIfNotEmptyOrNull(userProduct, "LongDescription", LongDescription);
            Utility.AddIfNotEmptyOrNull(userProduct, "CartDescription", CartDescription);

            //The Attribute Input Parameters conflict with Input XML Examples. Some Parameters show up in Examples that are not part of the Input Parameters list.
            //see: http://help.webcomcpq.com/doku.php?id=appendixd:simple_product_administration:input_xml_example vs http://help.webcomcpq.com/doku.php?id=appendixd:simple_product_administration:product_admin_webmethod_inputxml

            if (AttributeName != null)
            {
                //<Attributes></Attributes>
                XmlNode userProductAttributes = retVal.CreateElement("Attributes");
                userProduct.AppendChild(userProductAttributes);

                //<Attributes><Attribute></Attribute></Attributes>
                XmlNode userProductAttribute = retVal.CreateElement("Attribute");
                userProductAttributes.AppendChild(userProductAttribute);

                AttributeName.AddToXML(userProductAttribute);
                XmlNode userProductAttributeValues = retVal.CreateElement("Values");
                userProductAttribute.AppendChild(userProductAttributeValues);

                if (AttributeValue != null)
                {
                    AttributeValue.AddToXML(userProductAttributeValues);
                }

                //Attributes is a parent container, nested within Products, that may contain additional child products; need to rethink this one:
                //XmlNode userAttributes = Utility.AddIfNotEmptyOrNull(userProducts, "Attributes", Attributes);
                ////Attribute Child nodes, still WIP:////
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "Type", AttributeType);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "DisplayType", AttributeDisplayType);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "MeasurementType", AttributeMeasurementType);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "Rank", AttributeRank);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "LineItem", AttributeLineItem);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "LineItemDescription", AttributeLineItemDescription);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "RankWithinCart", AttributeRankWithinCart);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "SpansAcrossEntireRow", AttributeSpansAcrossEntireRow);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "Required", AttributeRequired);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "Label", AttributeLabel);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "Hint", AttributeHint);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "ShowOneTimePrice", AttributeShowOneTimePrice);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "ShowRecurringPrice", AttributeShowRecurringPrice);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "ButtonText", AttributeButtonText);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "AttachScriptButton", AttributeAttachScriptButton);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "ValuesPreselected", AttributeValuesPreselected);

                //Buttons is child of Attributes;
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "ButtonScriptsAttached", AttributeButtonScriptsAttached);

                ////ButtonScriptsAttached Child Nodes, still WIP:////
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "ButtonScript", AttributeButtonScript);
                Utility.AddIfNotEmptyOrNull(userProductAttributes, "ButtonScriptAttachedRank", ButtonScriptAttachedRank);
            }
            //tabs node is not allowed with Simple products;
            //Utility.AddIfNotEmptyOrNull(userProduct, "Tabs", Tabs);
            ////Tabs Child Nodes, still WIP:////
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsSystemId", TabsSystemId);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsName", TabsName);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsProductTabRank", TabsProductTabRank);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsLayoutTemplate", TabsLayoutTemplate);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsVisibilityPermission", TabsVisibilityPermission);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsVisibilityCondition", TabsVisibilityCondition);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsShowTabHeader", TabsShowTabHeader);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsAttributes", TabsAttributes);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsAttributesName", TabsAttributesName);
            Utility.AddIfNotEmptyOrNull(userProduct, "TabsAttributesRank", TabsAttributesRank);

            //Utility.AddIfNotEmptyOrNull(userProduct, "GlobalScripts", GlobalScripts);
            ////GlobalScripts Child Nodes, still WIP:////
            Utility.AddIfNotEmptyOrNull(userProduct, "GlobalScriptsName", GlobalScriptsName);
            Utility.AddIfNotEmptyOrNull(userProduct, "GlobalScriptsRank", GlobalScriptsRank);
            Utility.AddIfNotEmptyOrNull(userProduct, "GlobalScriptsEvents", GlobalScriptsEvents);
            Utility.AddIfNotEmptyOrNull(userProduct, "GlobalScriptsEventsEvent", GlobalScriptsEventsEvent);

            return(retVal);
        }