Esempio n. 1
0
        /// <summary>
        /// Returns a System.String containing an Xml representation of the current object
        /// </summary>
        /// <returns></returns>
        public string ToXml()
        {
            string pictureDataBase64Encoded;

            if (PictureUpdated && PictureData != null && PictureData.Length > 0)
            {
                pictureDataBase64Encoded = Convert.ToBase64String(PictureData);
            }
            else
            {
                pictureDataBase64Encoded = null;
            }

            var xml = new XElement(_objectName,
                                   Id != 0 ? new XElement("id", Id.ToString()) : null,
                                   ParentId != 0 ? new XElement("parent_id", ParentId.ToString()) : null,
                                   Name != null ? new XElement("name_nl", Name) : null,
                                   SortOrder != 0 ? new XElement("sort_order", SortOrder.ToString()) : null,
                                   PictureFilename != null ? new XElement("picture_file_name", PictureFilename) : null,
                                   pictureDataBase64Encoded != null ? new XElement("picture_data", pictureDataBase64Encoded) : null,
                                   TargetUrl != null ? new XElement("target_url", TargetUrl) : null,
                                   Test == true ? new XElement("test", Test.ToInt()) : null,
                                   !CreatedDttm.IsNullOrDefault() ? new XElement("created", ((DateTime)CreatedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   !UpdatedDttm.IsNullOrDefault() ? new XElement("updated", ((DateTime)UpdatedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   !DeletedDttm.IsNullOrDefault() ? new XElement("deleted", ((DateTime)DeletedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null
                                   );

            return(xml.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Converts the current object to an Xml representation
        /// </summary>
        /// <returns>System.String containing an Xml representation of the current object</returns>
        public string ToXml()
        {
            var xml = new XElement(_objectName,
                                   new XElement("id", Id),
                                   Name != null ? new XElement("name", Name) : null,
                                   Test == true ? new XElement("test", Test.ToInt()) : null,
                                   !CreatedDttm.IsNullOrDefault() ? new XElement("created", ((DateTime)CreatedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   !UpdatedDttm.IsNullOrDefault() ? new XElement("updated", ((DateTime)UpdatedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   !DeletedDttm.IsNullOrDefault() ? new XElement("deleted", ((DateTime)DeletedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null
                                   );

            return(xml.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// Converts the current object to an Xml representation
        /// </summary>
        /// <returns>Returns a System.String containing an Xml representation of the current object</returns>
        public string ToXml()
        {
            var xml = new XElement(_objectName,
                                   !WebshopId.IsNullOrZero() ? new XElement("id", WebshopId) : null,
                                   !StoreId.IsNullOrZero() ? new XElement("store_id", StoreId) : null,
                                   LastName != null ? new XElement("last_name", LastName) : null,
                                   FirstName != null ? new XElement("first_name", FirstName) : null,
                                   ShippingAddressStreet != null ? new XElement("shipping_address_street", ShippingAddressStreet) : null,
                                   ShippingAddressHomeNumber != null ? new XElement("shipping_address_home_number", ShippingAddressHomeNumber) : null,
                                   ShippingAddressZip != null ? new XElement("shipping_address_zip", ShippingAddressZip) : null,
                                   ShippingAddressCity != null ? new XElement("shipping_address_city", ShippingAddressCity) : null,
                                   ShippingAddressStateId != null ? new XElement("shipping_address_state_id", ShippingAddressStateId) : null,
                                   ShippingAddressState != null ? new XElement("shipping_address_state_name", ShippingAddressState) : null,
                                   ShippingAddressCountryId != null ? new XElement("shipping_address_country_id", ShippingAddressCountryId) : null,
                                   ShippingAddressCountry != null ? new XElement("shipping_address_country_name", ShippingAddressCountry) : null,
                                   Phone != null ? new XElement("phone", Phone) : null,
                                   Mobile != null ? new XElement("mobile", Mobile) : null,
                                   Email != null ? new XElement("email", Email) : null,
                                   BillingName != null ? new XElement("billing_name", BillingName) : null,
                                   BillingContact != null ? new XElement("billing_contact", BillingContact) : null,
                                   BillingAddress1 != null ? new XElement("billing_address1", BillingAddress1) : null,
                                   BillingAddress2 != null ? new XElement("billing_address2", BillingAddress2) : null,
                                   BillingAddress3 != null ? new XElement("billing_address3", BillingAddress3) : null,
                                   VatNumber != null ? new XElement("vat_number", VatNumber) : null,
                                   new XElement("std_discount_for_tax_rate_id1", WebshopDiscount6),
                                   new XElement("std_discount_for_tax_rate_id2", WebshopDiscount21),
                                   new XElement("is_teacher", IsTeacher.ToInt().ToString()),
                                   new XElement("is_reseller", IsReseller.ToInt().ToString()),
                                   Institution != null ? new XElement("institution", Institution) : null,
                                   TeachingSubjects != null ? new XElement("teaching_subjects", TeachingSubjects) : null,
                                   TeacherCardNumber != null ? new XElement("card_number", TeacherCardNumber) : null,
                                   TeacherCardValidFrom != null ? new XElement("card_valid_from", ((DateTime)TeacherCardValidFrom).ToString("yyyy-MM-dd")) : null,
                                   TeacherCardValidTo != null ? new XElement("card_valid_to", ((DateTime)TeacherCardValidTo).ToString("yyyy-MM-dd")) : null,
                                   TeacherRegistrationNote != null ? new XElement("teacher_registration_note", TeacherRegistrationNote) : null,
                                   !TeacherConfirmed.IsNullOrDefault() ? new XElement("teacher_confirmed", ((DateTime)TeacherConfirmed).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   !LastLoginDttm.IsNullOrDefault() ? new XElement("last_login", ((DateTime)LastLoginDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   Test == true ? new XElement("test", Test.ToInt()) : null,
                                   !CreatedDttm.IsNullOrDefault() ? new XElement("created", ((DateTime)CreatedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   !UpdatedDttm.IsNullOrDefault() ? new XElement("updated", ((DateTime)UpdatedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null,
                                   !DeletedDttm.IsNullOrDefault() ? new XElement("deleted", ((DateTime)DeletedDttm).ToString("yyyy-MM-dd HH:mm:ss")) : null
                                   );

            return(xml.ToString());
        }
Esempio n. 4
0
        /// <summary>
        /// Returns a System.String containing an Xml representation of the specified property of the current object
        /// </summary>
        /// <param name="property">name of a specific property that is to be written out as Xml.
        /// If this value is filled in, only the <id/> node and the node for property are output.
        /// At the time of this writing, this is only used for product_pictures.
        /// </param>
        /// <returns></returns>
        public string ToXml(string property)
        {
            var xml = new XElement(_objectName);

            xml.Add(new XElement("id", Id.ToString()));

            if ((property == null || property == "product_type_id") && LogBits.BitTest(Enums.Logfield.ProductTypeId))
            {
                xml.Add(new XElement("product_type_id", (int)ProductTypeId));
            }

            if ((property == null || property == "name_nl") && Name_NL != null && LogBits.BitTest(Enums.Logfield.PublicProductName_NL))
            {
                xml.Add(new XElement("name_nl", Name_NL));
            }

            //if ((property == null || property == "name_en") && Name_EN != null && LogBits.BitTest(Enums.Logfield.PublicProductName_EN))
            //    xml.Add(new XElement("name_en", Name_EN));

            if ((property == null || property == "songs") && LogBits.BitTest(Enums.Logfield.SongSortOrder))
            {
                xml.Add(new XElement("songs", from song in Songs
                                     select new XElement(XElement.Parse(song.ToXml()))));
            }

            if ((property == null || property == "subtitle_nl") && LogBits.BitTest(Enums.Logfield.Subtitle_NL))
            {
                xml.Add(new XElement("subtitle_nl", Subtitle_NL));
            }

            if ((property == null || property == "author_id") && LogBits.BitTest(Enums.Logfield.AuthorId))
            {
                xml.Add(new XElement("author_id", AuthorId.ToString()));
            }

            if ((property == null || property == "arranger_id") && LogBits.BitTest(Enums.Logfield.ArrangerId))
            {
                xml.Add(new XElement("arranger_id", ArrangerId.ToString()));
            }

            if ((property == null || property == "manufacturer_id") && LogBits.BitTest(Enums.Logfield.ManufacturerId))
            {
                xml.Add(new XElement("manufacturer_id", ManufacturerId.ToString()));
            }

            if ((property == null || property == "instrument_id") && LogBits.BitTest(Enums.Logfield.InstrumentId))
            {
                xml.Add(new XElement("instrument_id", InstrumentId.ToString()));
            }

            if ((property == null || property == "sell_price") && !SalesPrice.IsNullOrZero() && LogBits.BitTest(Enums.Logfield.SalesPrice))
            {
                xml.Add(new XElement("sell_price", SalesPrice));
            }

            if ((property == null || property == "reference") && LogBits.BitTest(Enums.Logfield.ReferenceNumber))
            {
                xml.Add(new XElement("reference", ReferenceNumber));
            }

            if ((property == null || property == "isbn") && LogBits.BitTest(Enums.Logfield.Isbn))
            {
                xml.Add(new XElement("isbn", Isbn));
            }

            if ((property == null || property == "ismn") && LogBits.BitTest(Enums.Logfield.Ismn))
            {
                xml.Add(new XElement("ismn", Ismn));
            }

            if ((property == null || property == "ean") && LogBits.BitTest(Enums.Logfield.Ean))
            {
                xml.Add(new XElement("ean", Ean));
            }

            if ((property == null || property == "upc") && LogBits.BitTest(Enums.Logfield.Upc))
            {
                xml.Add(new XElement("upc", Upc));
            }

            if ((property == null || property == "language_id") && LogBits.BitTest(Enums.Logfield.LanguageId))
            {
                xml.Add(new XElement("language_id", LanguageId != null ? ((int)LanguageId).ToString() : String.Empty));
            }

            if ((property == null || property == "binding_id") && LogBits.BitTest(Enums.Logfield.BindingId))
            {
                xml.Add(new XElement("binding_id", BindingId.ToString()));
            }

            if ((property == null || property == "grade_level") && LogBits.BitTest(Enums.Logfield.GradeLevel))
            {
                xml.Add(new XElement("grade_level", GradeLevel));
            }

            if ((property == null || property == "product_series_id") && LogBits.BitTest(Enums.Logfield.SeriesId))
            {
                xml.Add(new XElement("product_series_id", SeriesId.ToString()));
            }

            if ((property == null || property == "nr_of_pages") && LogBits.BitTest(Enums.Logfield.Pages))
            {
                xml.Add(new XElement("nr_of_pages", Pages.ToString()));
            }

            if ((property == null || property == "tax_rate_id") && LogBits.BitTest(Enums.Logfield.TaxRateId))
            {
                xml.Add(new XElement("tax_rate_id", ((int)TaxRateId).ToString()));
            }

            if ((property == null || property == "product_pictures") && LogBits.BitTest(Enums.Logfield.ProductPictureFilename))
            {
                xml.Add(new XElement("product_pictures", from picture in ProductPictures
                                     select new XElement(XElement.Parse(picture.ToXml()))));
            }

            if ((property == null || property == "description_nl") && LogBits.BitTest(Enums.Logfield.Description_NL))
            {
                xml.Add(new XElement("description_nl", Description_NL));
            }

            if ((property == null || property == "weight") && LogBits.BitTest(Enums.Logfield.Weight))
            {
                xml.Add(new XElement("weight", Weight.ToString()));
            }

            if ((property == null || property == "length") && LogBits.BitTest(Enums.Logfield.Length))
            {
                xml.Add(new XElement("length", Length.ToString()));
            }

            if ((property == null || property == "width") && LogBits.BitTest(Enums.Logfield.Width))
            {
                xml.Add(new XElement("width", Width.ToString()));
            }

            if ((property == null || property == "height") && LogBits.BitTest(Enums.Logfield.Height))
            {
                xml.Add(new XElement("height", Height.ToString()));
            }

            if ((property == null || property == "product_categories") && LogBits.BitTest(Enums.Logfield.ProductCategory))
            {
                xml.Add(new XElement("product_categories", from category in ProductCategories
                                     select new XElement("product_category", new XElement("id", category.Id),
                                                         new XElement("test", Test.ToInt()))));
            }

            if ((property == null || property == "internal_stock_qty") && LogBits.BitTest(Enums.Logfield.InternalStock))
            {
                xml.Add(new XElement("internal_stock_qty", InternalStock.ToString()));
            }

            if ((property == null || property == "external_stock_qty") && LogBits.BitTest(Enums.Logfield.ExternalStock))
            {
                xml.Add(new XElement("external_stock_qty", ExternalStock != null ? ExternalStock.ToString() : "1"));
            }

            if ((property == null || property == "supplier_id") && LogBits.BitTest(Enums.Logfield.SupplierId))
            {
                xml.Add(new XElement("supplier_id", SupplierId.ToString()));
            }

            if ((property == null || property == "promotion") && LogBits.BitTest(Enums.Logfield.Promotion))
            {
                xml.Add(new XElement("promotion", Promotion.ToInt().ToString()));
            }

            if ((property == null || property == "highlight_on_home") && LogBits.BitTest(Enums.Logfield.HighlightOnHome))
            {
                xml.Add(new XElement("highlight_on_home", HighlightOnHome.ToInt().ToString()));
            }

            if ((property == null || property == "available") && LogBits.BitTest(Enums.Logfield.ActiveInWebshop))
            {
                xml.Add(new XElement("available", ActiveInWebshop.ToInt().ToString()));
            }

            if ((property == null || property == "bestseller") && LogBits.BitTest(Enums.Logfield.BestSeller))
            {
                xml.Add(new XElement("bestseller", BestSeller.ToInt().ToString()));
            }

            if ((property == null || property == "minimum_order_qty") && LogBits.BitTest(Enums.Logfield.MinimumOrderQty))
            {
                xml.Add(new XElement("minimum_order_qty", (MinimumOrderQuantity != 0) ? MinimumOrderQuantity.ToString() : String.Empty));
            }

            if ((property == null || property == "teacher_discount") && LogBits.BitTest(Enums.Logfield.WebshopTeacherDiscount))
            {
                xml.Add(new XElement("teacher_discount", TeacherDiscount.ToString()));
            }

            if ((property == null || property == "reseller_discount") && LogBits.BitTest(Enums.Logfield.WebshopResellerDiscount))
            {
                xml.Add(new XElement("reseller_discount", ResellerDiscount.ToString()));
            }

            if ((property == null || property == "search_keywords") && LogBits.BitTest(Enums.Logfield.SearchKeywords))
            {
                xml.Add(new XElement("search_keywords", SearchKeywords));
            }

            if ((property == null || property == "store_pickup_only") && LogBits.BitTest(Enums.Logfield.StorePickupOnly))
            {
                xml.Add(new XElement("store_pickup_only", StorePickupOnly.ToInt().ToString()));
            }

            if ((property == null || property == "test"))
            {
                xml.Add(new XElement("test", Test.ToInt()));
            }

            if ((property == null || property == "created") && LogBits.BitTest(Enums.Logfield.CreateDttm))
            {
                xml.Add(new XElement("created", (!CreatedDttm.IsNullOrDefault()) ? ((DateTime)CreatedDttm).ToString("yyyy-MM-dd HH:mm:ss") : String.Empty));
            }

            if ((property == null || property == "updated") && LogBits.BitTest(Enums.Logfield.UpdateDttm))
            {
                xml.Add(new XElement("updated", (!UpdatedDttm.IsNullOrDefault()) ? ((DateTime)UpdatedDttm).ToString("yyyy-MM-dd HH:mm:ss") : String.Empty));
            }

            if ((property == null || property == "deleted") && LogBits.BitTest(Enums.Logfield.DeleteDttm))
            {
                xml.Add(new XElement("deleted", (!DeletedDttm.IsNullOrDefault()) ? ((DateTime)DeletedDttm).ToString("yyyy-MM-dd HH:mm:ss") : String.Empty));
            }

            string xmlString = xml.ToString();

            return(xmlString);
        }