コード例 #1
0
ファイル: ProductService.cs プロジェクト: gkovalev/nastia
 public static Product GetProductFromReader(SqlDataReader reader)
 {
     return(new Product
     {
         ProductId = SQLDataHelper.GetInt(reader, "ProductId"),
         ArtNo = SQLDataHelper.GetString(reader, "ArtNo"),
         Name = SQLDataHelper.GetString(reader, "Name"),
         BriefDescription = SQLDataHelper.GetString(reader, "BriefDescription", string.Empty),
         Description = SQLDataHelper.GetString(reader, "Description", string.Empty),
         Photo = SQLDataHelper.GetString(reader, "Photo"),
         Discount = SQLDataHelper.GetDecimal(reader, "Discount"),
         Size = SQLDataHelper.GetString(reader, "Size"),
         Weight = SQLDataHelper.GetDecimal(reader, "Weight"),
         Ratio = SQLDataHelper.GetDouble(reader, "Ratio"),
         Enabled = SQLDataHelper.GetBoolean(reader, "Enabled", true),
         OrderByRequest = SQLDataHelper.GetBoolean(reader, "OrderByRequest"),
         Recomended = SQLDataHelper.GetBoolean(reader, "Recomended"),
         New = SQLDataHelper.GetBoolean(reader, "New"),
         BestSeller = SQLDataHelper.GetBoolean(reader, "Bestseller"),
         OnSale = SQLDataHelper.GetBoolean(reader, "OnSale"),
         BrandId = SQLDataHelper.GetInt(reader, "BrandID", 0),
         UrlPath = SQLDataHelper.GetString(reader, "UrlPath"),
         HirecalEnabled = SQLDataHelper.GetBoolean(reader, "HirecalEnabled"),
         //Added by Evgeni to add EAN and SubbrandiD
         EAN = SQLDataHelper.GetString(reader, "EAN"),
         SubBrandId = SQLDataHelper.GetInt(reader, "SubBrandID", 0),
         ManufactureArtNo = SQLDataHelper.GetString(reader, "ManufactureArtNo")
                            //
     });
 }
コード例 #2
0
 private static GiftCertificate GetFromReader(SqlDataReader reader)
 {
     return(new GiftCertificate
     {
         CertificateId = SQLDataHelper.GetInt(reader, "CertificateID"),
         CertificateCode = SQLDataHelper.GetString(reader, "CertificateCode"),
         FromName = SQLDataHelper.GetString(reader, "FromName"),
         ToName = SQLDataHelper.GetString(reader, "ToName"),
         OrderNumber = SQLDataHelper.GetString(reader, "OrderNumber"),
         Sum = SQLDataHelper.GetDecimal(reader, "Sum"),
         Paid = SQLDataHelper.GetBoolean(reader, "Paid"),
         Used = SQLDataHelper.GetBoolean(reader, "Used"),
         Enable = SQLDataHelper.GetBoolean(reader, "Enable"),
         Type = (CertificatePostType)(SQLDataHelper.GetInt(reader, "Type")),
         CertificateMessage = SQLDataHelper.GetString(reader, "Message"),
         Email = SQLDataHelper.GetString(reader, "Email"),
         Country = SQLDataHelper.GetString(reader, "Country"),
         Zone = SQLDataHelper.GetString(reader, "Zone"),
         City = SQLDataHelper.GetString(reader, "City"),
         Zip = SQLDataHelper.GetString(reader, "Zip"),
         Address = SQLDataHelper.GetString(reader, "Address"),
         CreationDate = SQLDataHelper.GetDateTime(reader, "CreationDate"),
         CurrencyCode = SQLDataHelper.GetString(reader, "CurrencyCode"),
         CurrencyValue = SQLDataHelper.GetDecimal(reader, "CurrencyValue"),
         FromEmail = SQLDataHelper.GetString(reader, "FromEmail")
     });
 }
コード例 #3
0
 public static decimal GetCertificatePriceById(int id)
 {
     return(SQLDataHelper.GetDecimal(SQLDataAccess.ExecuteScalar("Select Sum From Catalog.Certificate Where CertificateId = @CertificateId",
                                                                 CommandType.Text,
                                                                 new SqlParameter {
         ParameterName = "@CertificateId", Value = id
     })));
 }
コード例 #4
0
        private static void ProcessCurrencyRow(DataRow row, XmlWriter writer)
        {
            writer.WriteStartElement("currency");
            writer.WriteAttributeString("id", SQLDataHelper.GetString(row["CurrencyIso3"]));
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            writer.WriteAttributeString("rate", SQLDataHelper.GetDecimal(row["CurrencyValue"]).ToString(nfi));
            writer.WriteEndElement();
        }
コード例 #5
0
 private static CustomerGroup GetCustomerGroupFromReader(SqlDataReader reader)
 {
     return(new CustomerGroup
     {
         CustomerGroupId = SQLDataHelper.GetInt(reader, "CustomerGroupId"),
         OfferListId = SQLDataHelper.GetInt(reader, "OfferListId"),
         GroupName = SQLDataHelper.GetString(reader, "GroupName"),
         GroupDiscount = SQLDataHelper.GetDecimal(reader, "GroupDiscount")
     });
 }
コード例 #6
0
ファイル: TaxServices.cs プロジェクト: gkovalev/nastia
 public static ICollection <RegionalRate> GetRegionalRatesForTax(int t)
 {
     return(SQLDataAccess.ExecuteReadList("SELECT * FROM [Catalog].[TaxRegionRate] WHERE [TaxId] = @id",
                                          CommandType.Text,
                                          reader => new RegionalRate
     {
         RegionId = SQLDataHelper.GetInt(reader, "RegionID"),
         Rate = SQLDataHelper.GetDecimal(reader, "RegionRate")
     },
                                          new SqlParameter("@id", t)));
 }
コード例 #7
0
 private static OptionItem GetOptionItemFromReader(SqlDataReader reader)
 {
     return(new OptionItem
     {
         OptionId = SQLDataHelper.GetInt(reader, "OptionID"),
         //CustomOptionsId = SQLDataHelper.GetInt(reader, "CustomOptionsId"),
         Title = SQLDataHelper.GetString(reader, "Title"),
         PriceBc = SQLDataHelper.GetDecimal(reader, "PriceBC"),
         PriceType = (OptionPriceType)SQLDataHelper.GetInt(reader, "PriceType"),
         SortOrder = SQLDataHelper.GetInt(reader, "SortOrder")
     });
 }
コード例 #8
0
 /// <summary>
 /// Метод загружает данные о просмотрах для  пользователя из полученного SqlReader
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 /// <remarks></remarks>
 private static RecentlyViewRecord ReadViewRecordForReader(SqlDataReader reader)
 {
     return(new RecentlyViewRecord
     {
         ProductID = SQLDataHelper.GetInt(reader["ProductID"]),
         ViewTime = SQLDataHelper.GetDateTime(reader["ViewDate"]),
         ImgPath = SQLDataHelper.GetString(reader["Photo"]),
         Name = SQLDataHelper.GetString(reader["Name"]),
         Price = SQLDataHelper.GetDecimal(reader["Price"]),
         Discount = SQLDataHelper.GetDecimal(reader["Discount"]),
         UrlPath = SQLDataHelper.GetString(reader["UrlPath"])
     });
 }
コード例 #9
0
ファイル: TaxServices.cs プロジェクト: gkovalev/nastia
        public static ICollection <TaxElement> GetTaxesForProduct(int productId, CustomerContact sellerContact, CustomerContact billingContact, CustomerContact shippingContact)
        {
            using (var da = new SQLDataAccess())
            {
                da.cmd.CommandText = @"
                                        SELECT [Catalog].[Tax].*, [Catalog].[TaxRegionRate].[RegionID], [Catalog].[TaxRegionRate].[RegionRate]
                                        FROM [Catalog].[Tax]
                                        JOIN [Catalog].[TaxMappingOnProduct] ON [Tax].[TaxId] = [TaxMappingOnProduct].[TaxId]
                                        LEFT JOIN [Catalog].[TaxRegionRate] ON [Tax].[TaxId] = [TaxRegionRate].[TaxId] AND (
		                                        ([DependsOnAddress] = @default  AND [CountryID] = @sellerCountry   AND [RegionID] = @sellerRegion) OR
		                                        ([DependsOnAddress] = @shipping AND [CountryID] = @shippingCountry AND [RegionID] = @shippingRegion) OR
		                                        ([DependsOnAddress] = @billing  AND [CountryID] = @billingCountry  AND [RegionID] = @billingRegion)
	                                        )
                                        WHERE [ProductID] = @ProductID AND [Enabled] = 'True'
                                    ";
                da.cmd.CommandType = CommandType.Text;
                da.cmd.Parameters.AddWithValue("@default", (int)TypeRateDepends.Default);
                da.cmd.Parameters.AddWithValue("@shipping", (int)TypeRateDepends.ByShippingAddress);
                da.cmd.Parameters.AddWithValue("@billing", (int)TypeRateDepends.ByBillingAddress);
                da.cmd.Parameters.AddWithValue("@sellerCountry", sellerContact.CountryId);
                da.cmd.Parameters.AddWithValue("@sellerRegion", sellerContact.RegionId.HasValue ? sellerContact.RegionId : (object)DBNull.Value);
                da.cmd.Parameters.AddWithValue("@shippingCountry", shippingContact.CountryId);
                da.cmd.Parameters.AddWithValue("@shippingRegion", shippingContact.RegionId.HasValue ? shippingContact.RegionId : (object)DBNull.Value);
                da.cmd.Parameters.AddWithValue("@billingCountry", billingContact.CountryId);
                da.cmd.Parameters.AddWithValue("@billingRegion", billingContact.RegionId.HasValue ? billingContact.RegionId : (object)DBNull.Value);
                da.cmd.Parameters.AddWithValue("@ProductID", productId);

                da.cnOpen();
                var result = new List <TaxElement>();
                using (SqlDataReader reader = da.cmd.ExecuteReader())
                    while (reader.Read())
                    {
                        var t = ReadTax(reader);

                        var regionalRateCollection = new List <RegionalRate>();
                        t.RegionalRates = regionalRateCollection;
                        if (!(reader["RegionID"] is DBNull))
                        {
                            var regionalRate = new RegionalRate
                            {
                                RegionId = SQLDataHelper.GetInt(reader, "RegionID"),
                                Rate     = SQLDataHelper.GetDecimal(reader, "RegionRate")
                            };
                            regionalRateCollection.Add(regionalRate);
                        }
                        result.Add(t);
                    }

                return(result);
            }
        }
コード例 #10
0
ファイル: TaxServices.cs プロジェクト: gkovalev/nastia
        public static List <TaxValue> GetOrderTaxes(int orderid)
        {
            List <TaxValue> returnList = SQLDataAccess.ExecuteReadList("select taxId, taxName, taxSum, taxShowInPrice from [Order].[OrderTax] where orderid=@orderid",
                                                                       CommandType.Text, read => new TaxValue
            {
                TaxID          = SQLDataHelper.GetInt(read, "taxId"),
                TaxName        = SQLDataHelper.GetString(read, "taxName"),
                TaxSum         = SQLDataHelper.GetDecimal(read, "taxSum"),
                TaxShowInPrice = SQLDataHelper.GetBoolean(read, "taxShowInPrice")
            },
                                                                       new SqlParameter("@orderid", orderid));

            return(returnList);
        }
コード例 #11
0
ファイル: CurrencyService.cs プロジェクト: gkovalev/nastia
 private static Currency GetCurrencyFromReader(IDataReader reader)
 {
     return(new Currency
     {
         CurrencyID = SQLDataHelper.GetInt(reader, "CurrencyID"),
         Value = SQLDataHelper.GetDecimal(reader, "CurrencyValue"),
         Iso3 = SQLDataHelper.GetString(reader, "CurrencyIso3"),
         Symbol = SQLDataHelper.GetString(reader, "Code"),
         Name = SQLDataHelper.GetString(reader, "Name"),
         PriceFormat = SQLDataHelper.GetString(reader, "PriceFormat", string.Empty),
         IsCodeBefore = SQLDataHelper.GetBoolean(reader, "IsCodeBefore"),
         NumIso3 = SQLDataHelper.GetInt(reader, "CurrencyNumIso3")
     });
 }
コード例 #12
0
 private static Coupon GetFromReader(SqlDataReader reader)
 {
     return(new Coupon
     {
         CouponID = SQLDataHelper.GetInt(reader, "CouponID"),
         Code = SQLDataHelper.GetString(reader, "Code"),
         Type = (CouponType)SQLDataHelper.GetInt(reader, "Type"),
         Value = SQLDataHelper.GetDecimal(reader, "Value"),
         AddingDate = SQLDataHelper.GetDateTime(reader, "AddingDate"),
         ExpirationDate = SQLDataHelper.GetNullableDateTime(reader, "ExpirationDate"),
         PossibleUses = SQLDataHelper.GetInt(reader, "PossibleUses"),
         ActualUses = SQLDataHelper.GetInt(reader, "ActualUses"),
         Enabled = SQLDataHelper.GetBoolean(reader, "Enabled"),
         MinimalOrderPrice = SQLDataHelper.GetDecimal(reader, "MinimalOrderPrice")
     });
 }
コード例 #13
0
 public static Offer GetOfferFromReader(SqlDataReader reader)
 {
     return(new Offer
     {
         Price = SQLDataHelper.GetDecimal(reader, "Price"),
         Amount = SQLDataHelper.GetInt(reader, "Amount"),
         Unit = SQLDataHelper.GetString(reader, "Unit"),
         SupplyPrice = SQLDataHelper.GetDecimal(reader, "SupplyPrice"),
         OfferListId = SQLDataHelper.GetInt(reader, "OfferListId"),
         ProductId = SQLDataHelper.GetInt(reader, "ProductID"),
         OfferId = SQLDataHelper.GetInt(reader, "OfferID"),
         ShippingPrice = SQLDataHelper.GetDecimal(reader, "ShippingPrice"),
         MinAmount = SQLDataHelper.GetNullableInt(reader, "MinAmount"),
         MaxAmount = SQLDataHelper.GetNullableInt(reader, "MaxAmount")
     });
 }
コード例 #14
0
 public static void GetProfitPlan()
 {
     using (var db = new SQLDataAccess())
     {
         db.cmd.CommandText = "[Settings].[sp_GetLastProfitPlan]";
         db.cmd.CommandType = CommandType.StoredProcedure;
         db.cmd.Parameters.Clear();
         db.cnOpen();
         using (SqlDataReader reader = db.cmd.ExecuteReader())
         {
             reader.Read();
             SalesPlan  = SQLDataHelper.GetDecimal(reader, "SalesPlan");
             ProfitPlan = SQLDataHelper.GetDecimal(reader, "ProfitPlan");
         }
         db.cnClose();
     }
 }
コード例 #15
0
ファイル: ProductService.cs プロジェクト: gkovalev/nastia
        public static List <Product> GetProductsByCategoryForExport(int categoryId)
        {
            var productList = new List <Product>();

            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText =
                    @" SELECT [TProduct].[ProductId], [Name], [Enabled], [Price], [Amount],[Unit] FROM [Catalog].[Product] AS [TProduct]
                                            INNER JOIN [Catalog].[ProductCategories] on [ProductCategories].[ProductId] = [TProduct].[ProductId]
                                            INNER JOIN [Catalog].[Offer] on [Offer].[ProductID] = [TProduct].[ProductId]
                                        WHERE [ProductCategories].[CategoryId] = @CategoryId AND [TProduct].[Enabled] = 1 AND [TProduct].[HirecalEnabled] = 1 AND [Price] > 0 AND [Amount] > 0 AND [OfferListId] = 6 AND
                                            (SELECT TOP(1) [ProductCategories].[CategoryId] FROM [Catalog].[ProductCategories] INNER JOIN [Catalog].[Category] on [Category].[CategoryId] = [ProductCategories].[CategoryId] WHERE [ProductID] = [TProduct].[ProductID] AND [Enabled] = 1 AND [HirecalEnabled] = 1 AND [Main] = 1) = @CategoryId";
                db.cmd.CommandType = CommandType.Text;
                db.cmd.Parameters.Clear();
                db.cmd.Parameters.AddWithValue("@CategoryId", categoryId);

                db.cnOpen();
                using (var reader = db.cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var offer = new Offer
                        {
                            OfferListId = 6,
                            Amount      = SQLDataHelper.GetInt(reader, "Amount"),
                            Price       = SQLDataHelper.GetDecimal(reader, "Price"),
                            Unit        = SQLDataHelper.GetString(reader, "Unit")
                        };

                        productList.Add(new Product
                        {
                            ProductId = SQLDataHelper.GetInt(reader, "ProductId"),
                            Name      = SQLDataHelper.GetString(reader, "Name"),
                            Enabled   = SQLDataHelper.GetBoolean(reader, "Enabled"),
                            Offers    = new List <Offer> {
                                offer
                            }
                        });
                    }
                    reader.Close();
                }
                db.cnClose();
            }
            return(productList);
        }
コード例 #16
0
ファイル: TaxServices.cs プロジェクト: gkovalev/nastia
        private static TaxElement ReadTax(SqlDataReader reader)
        {
            var t = new TaxElement
            {
                TaxId            = SQLDataHelper.GetInt(reader, "TaxId"),
                CountryID        = SQLDataHelper.GetInt(reader, "CountryID"),
                Enabled          = SQLDataHelper.GetBoolean(reader, "Enabled"),
                DependsOnAddress = (TypeRateDepends)SQLDataHelper.GetInt(reader, "DependsOnAddress"),
                Name             = SQLDataHelper.GetString(reader, "Name"),
                Priority         = SQLDataHelper.GetInt(reader, "Priority"),
                FederalRate      = SQLDataHelper.GetDecimal(reader, "FederalRate"),
                Type             = (RateType)SQLDataHelper.GetInt(reader, "RateType"),
                RegNumber        = SQLDataHelper.GetString(reader, "RegNumber"),
                ShowInPrice      = SQLDataHelper.GetBoolean(reader, "ShowInPrice")
            };

            return(t);
        }
コード例 #17
0
        public static IList <Offer> GetOffersByProductId(int productId)
        {
            List <Offer> p = SQLDataAccess.ExecuteReadList <Offer>("[Catalog].[sp_GetProductOffersByProductID]",
                                                                   CommandType.StoredProcedure,
                                                                   reader => new Offer
            {
                Price         = SQLDataHelper.GetDecimal(reader, "Price"),
                OfferListId   = SQLDataHelper.GetInt(reader, "OfferListId"),
                Unit          = SQLDataHelper.GetString(reader, "Unit"),
                Amount        = SQLDataHelper.GetInt(reader, "Amount"),
                SupplyPrice   = SQLDataHelper.GetDecimal(reader, "SupplyPrice"),
                ShippingPrice = SQLDataHelper.GetDecimal(reader, "ShippingPrice"),
                Multiplicity  = SQLDataHelper.GetInt(reader, "Multiplicity"),
                MinAmount     = SQLDataHelper.GetNullableInt(reader, "MinAmount"),
                MaxAmount     = SQLDataHelper.GetNullableInt(reader, "MaxAmount")
            }, new SqlParameter("@ProductID", productId));

            return(p);
        }
コード例 #18
0
        public static Dictionary <DateTime, decimal> GetOrdersProfitByDays(DateTime minDate, DateTime maxDate)
        {
            var sums = new Dictionary <DateTime, decimal>();

            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText = "[Order].[sp_GetProfitByDays]";
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.Parameters.Clear();
                db.cmd.Parameters.AddWithValue("@MinDate", minDate);
                db.cmd.Parameters.AddWithValue("@MaxDate", maxDate);
                db.cnOpen();
                using (SqlDataReader reader = db.cmd.ExecuteReader())
                    while (reader.Read())
                    {
                        sums.Add(SQLDataHelper.GetDateTime(reader, "Date"), SQLDataHelper.GetDecimal(reader, "Profit"));
                    }
                db.cnClose();
                return(sums);
            }
        }
コード例 #19
0
ファイル: ProductService.cs プロジェクト: gkovalev/nastia
        /// <summary>
        /// Get related products
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="relatedType"></param>
        /// <returns></returns>
        public static List <Product> GetRelatedProducts(int productId, RelatedType relatedType)
        {
            List <Product> res = SQLDataAccess.ExecuteReadList <Product>("[Catalog].[sp_GetRelatedProducts]", CommandType.StoredProcedure,
                                                                         reader => new Product
            {
                ProductId        = SQLDataHelper.GetInt(reader, "ProductId"),
                ArtNo            = SQLDataHelper.GetString(reader, "ArtNo"),
                Photo            = SQLDataHelper.GetString(reader, "Photo"),
                PhotoDesc        = SQLDataHelper.GetString(reader, "PhotoDesc"),
                Name             = SQLDataHelper.GetString(reader, "Name"),
                BriefDescription = SQLDataHelper.GetString(reader, "BriefDescription"),
                Discount         = SQLDataHelper.GetDecimal(reader, "Discount"),
                UrlPath          = SQLDataHelper.GetString(reader, "UrlPath"),
            },
                                                                         new SqlParameter("@ProductID", productId),
                                                                         new SqlParameter("@RelatedType", (int)relatedType),
                                                                         new SqlParameter("@Type", PhotoType.Product.ToString())
                                                                         );

            return(res);
        }
コード例 #20
0
 protected IEnumerable <ExportFeedProduts> GetProduts(string moduleName)
 {
     return(SQLDataAccess.ExecuteReadIEnumerable <ExportFeedProduts>("[Settings].[sp_GetExportFeedProducts]",
                                                                     CommandType.StoredProcedure,
                                                                     reader => new ExportFeedProduts
     {
         ProductID = SQLDataHelper.GetInt(reader, "ProductID"),
         Amount = SQLDataHelper.GetInt(reader, "Amount"),
         UrlPath = SQLDataHelper.GetString(reader, "UrlPath"),
         Price = SQLDataHelper.GetDecimal(reader, "Price"),
         Discount = SQLDataHelper.GetDecimal(reader, "Discount"),
         ParentCategory = SQLDataHelper.GetInt(reader, "ParentCategory"),
         Name = SQLDataHelper.GetString(reader, "Name"),
         Description = SQLDataHelper.GetString(reader, "Description"),
         BriefDescription = SQLDataHelper.GetString(reader, "BriefDescription"),
         Photo = SQLDataHelper.GetString(reader, "Photo"),
         //Added by Evgeni
         BrandName = SQLDataHelper.GetString(reader, "BrandName"),
         ArtNo = SQLDataHelper.GetString(reader, "ArtNo"),
     },
                                                                     new SqlParameter("@moduleName", moduleName),
                                                                     new SqlParameter("@selectedCurrency", ExportFeed.GetModuleSetting(moduleName, "Currency")),
                                                                     new SqlParameter("@onlyCount", false)));
 }
コード例 #21
0
        public static KeyValuePair <decimal, decimal> GetMonthProgress()
        {
            KeyValuePair <decimal, decimal> res;

            using (var db = new SQLDataAccess())
            {
                db.cmd.CommandText = "[Order].[sp_GetOrdersMonthProgress]";
                db.cmd.CommandType = CommandType.StoredProcedure;
                db.cmd.Parameters.Clear();
                db.cnOpen();

                using (SqlDataReader reader = db.cmd.ExecuteReader())
                {
                    reader.Read();
                    res = new KeyValuePair <decimal, decimal>(SQLDataHelper.GetDecimal(reader, "Sum"),
                                                              SQLDataHelper.GetDecimal(reader, "Profit"));
                    reader.Close();
                }

                db.cnClose();
            }

            return(res);
        }
コード例 #22
0
        private static void ProcessProductRow(DataRow row, XmlWriter writer)
        {
            writer.WriteStartElement("offer");
            writer.WriteAttributeString("available", SQLDataHelper.GetBoolean(row["Enabled"]).ToString().ToLower());
            writer.WriteAttributeString("id", row["ArtNo"].ToString());

            writer.WriteStartElement("url");
            if (string.IsNullOrEmpty(HttpContext.Current.Request.Url.Query))
            {
                writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "") + "/" + UrlService.GetLink(ParamType.Product, (string)row["UrlPath"], (int)row["ProductID"]));
            }
            else
            {
                writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "").Replace(HttpContext.Current.Request.Url.Query, "") + "/" + UrlService.GetLink(ParamType.Product, (string)row["UrlPath"], (int)row["ProductID"]));
            }
            writer.WriteEndElement();


            writer.WriteStartElement("price");
            var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            nfi.NumberDecimalSeparator = ".";
            writer.WriteString(CatalogService.CalculatePrice(SQLDataHelper.GetDecimal(row["Price"]), SQLDataHelper.GetDecimal(row["discount"])).ToString(nfi));
            writer.WriteEndElement();

            writer.WriteStartElement("currencyId");
            writer.WriteString(_currency);
            writer.WriteEndElement();

            writer.WriteStartElement("categoryId");
            writer.WriteString(row["ParentCategory"].ToString().Replace("ID", ""));
            writer.WriteEndElement();

            writer.WriteStartElement("picture");
            var temp = SQLDataHelper.GetString(row["photo"]);

            if (!string.IsNullOrEmpty(temp))
            {
                if (string.IsNullOrEmpty(HttpContext.Current.Request.Url.Query))
                {
                    writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "") + "/" + FoldersHelper.GetImageProductPath(ProductImageType.Middle, temp, false));
                }
                else
                {
                    writer.WriteString(HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "").Replace(HttpContext.Current.Request.Url.Query, "") + "/" + FoldersHelper.GetImageProductPath(ProductImageType.Middle, temp, false));
                }
            }
            writer.WriteEndElement();

            writer.WriteStartElement("name");
            writer.WriteString(SQLDataHelper.GetString(row["Name"]));
            writer.WriteEndElement();

            writer.WriteStartElement("description");
            string desc = SQLDataHelper.GetString(_description == "full" ? row["Description"] : row["BriefDescription"]);

            writer.WriteString(!string.IsNullOrEmpty(desc) ? desc : Resource.ExportFeed_NoDescription);

            writer.WriteEndElement();

            writer.WriteStartElement("sales_notes");
            writer.WriteString(_salesNotes);
            writer.WriteEndElement();

            // расширение от Ritmz
            writer.WriteStartElement("rz_Active");
            writer.WriteString(SQLDataHelper.GetString(row["Enabled"]));
            writer.WriteEndElement();

            writer.WriteStartElement("rz_Quantity");
            writer.WriteString(SQLDataHelper.GetString(row["Amount"]));
            writer.WriteEndElement();

            writer.WriteStartElement("rz_Weight");
            writer.WriteString(SQLDataHelper.GetString(row["Weight"]));
            writer.WriteEndElement();

            writer.WriteStartElement("rz_Length");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_Width");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_Height");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();

            writer.WriteStartElement("rz_SupplierName");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_SupplierCode");
            writer.WriteString(string.Empty);
            writer.WriteEndElement();
            writer.WriteStartElement("rz_SupplierPrice");
            writer.WriteString(SQLDataHelper.GetString(row["SupplyPrice"]));
            writer.WriteEndElement();

            //add fields
            //rz_Active - принимает значение «true», если товар активен и
            //участвует в продажах, «false» - если товар неактивен,
            //даже если количество товара положительное.
            //Значение по умолчанию - «true»;
            //rz_Quantity - cодержит количество товара на складе ИМ в штуках (не обязательное);
            //rz_Weight - cодержит вес товара с упаковкой в килограммах (не обязательное);
            //rz_Length - cодержит длину упаковки в метрах (не обязательное);
            //rz_Width - cодержит ширину упаковки в метрах (не обязательное);
            //rz_Height - содержит высоту упаковки в метрах (не обязательное);
            //rz_SupplierName - наименование поставщика;
            //rz_SupplierCode - код поставщика;
            //rz_SupplierPrice - цена поставщика. Указывается в случае, если
            //требуется получать отчетность по маржинальной
            //прибыли или установить приоритетность выбора
            //поставщиков одного и того же товара по приоритету цены (не обязательное).

            writer.WriteEndElement();
        }
コード例 #23
0
        private static void MakeExportFile(string[] myParams)
        {
            try
            {
                var moduleName      = myParams[0];
                var applicationPath = myParams[1];

                FileName = ExportFeed.GetModuleSetting(moduleName, "FileName");
                var filePath  = applicationPath + "/" + FileName;
                var directory = filePath.Substring(0, filePath.LastIndexOf('/'));


                if (directory != null && !Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                //if (File.Exists(filePath))
                //{
                //    File.Delete(filePath);
                //}

                ExportFeedModule exportFeedModule = null;
                switch (moduleName)
                {
                case "YandexMarket":
                    exportFeedModule = new ExportFeedModuleYandex();
                    break;

                case "GoogleBase":
                    exportFeedModule = new ExportFeedModuleGoogleBase();
                    break;

                case "PriceGrabber":
                    exportFeedModule = new ExportFeedModulePriceGrabber();
                    break;

                case "ShoppingCom":
                    exportFeedModule = new ExportFeedModuleShoppingCom();
                    break;

                case "YahooShopping":
                    exportFeedModule = new ExportFeedModuleYahooShopping();
                    break;

                case "Amazon":
                    exportFeedModule = new ExportFeedModuleAmazon();
                    break;

                case "Shopzilla":
                    exportFeedModule = new ExportFeedModuleShopzilla();
                    break;
                }

                if (exportFeedModule != null)
                {
                    exportFeedModule.GetExportFeedString(filePath);
                }

                var fileInfo = new FileInfo(filePath);

                CommonStatistic.FileName = SettingsMain.SiteUrl + "/" + FileName;
                CommonStatistic.FileSize = " (" + Math.Ceiling(SQLDataHelper.GetDecimal(fileInfo.Length) / 1024) + " Kb)";
            }
            catch (Exception ex)
            {
                AdvantShop.Diagnostics.Debug.LogError(ex, "on MakeExportFile in exportFeed");
            }
            finally
            {
                CommonStatistic.IsRun = false;
            }
        }