private static void WriteHeaders(IEnumerable<Row> rows, ICsvWriter writer)
 {
     foreach (var column in rows.First())
     {
         writer.WriteField(column.Header);
     }
     writer.NextRecord();
 }
 private static void WriteRowValues(Row row, ICsvWriter writer)
 {
     foreach (var column in row)
     {
         writer.WriteField(column.Value);
     }
     writer.NextRecord();
 }
예제 #3
0
 public void Write(string[] columns)
 {
     foreach (string column in columns)
     {
         _csvWriter.WriteField(column);
     }
     _csvWriter.NextRecord();
 }
예제 #4
0
 private void WriteHeader(ICsvWriter writer)
 {
     foreach (var item in _fieldMapping)
     {
         writer.WriteField(item.StrName());
     }
     writer.NextRecord();
 }
 private static void WriteRowValues(Row row, ICsvWriter writer)
 {
     foreach (var column in row)
     {
         writer.WriteField(column.Value);
     }
     writer.NextRecord();
 }
 private static void WriteHeaders(IEnumerable <Row> rows, ICsvWriter writer)
 {
     foreach (var column in rows.First())
     {
         writer.WriteField(column.Header);
     }
     writer.NextRecord();
 }
예제 #7
0
 public void NextRecord()
 {
     csvWriter.NextRecord();
 }
예제 #8
0
        private void WriteItem(ICsvWriter writer, Product product)
        {
            var meta = MetaInfoService.GetMetaInfo(product.ID, MetaType.Product) ??
                       new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty);

            foreach (var item in _fieldMapping)
            {
                if (item == ProductFields.Sku)
                {
                    writer.WriteField(product.ArtNo);
                }
                if (item == ProductFields.Name)
                {
                    writer.WriteField(product.Name);
                }

                if (item == ProductFields.ParamSynonym)
                {
                    writer.WriteField(product.UrlPath);
                }

                if (item == ProductFields.Category)
                {
                    writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator)));
                }

                if (item == ProductFields.Sorting)
                {
                    writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator, true)));
                }

                if (item == ProductFields.Enabled)
                {
                    writer.WriteField(product.Enabled ? "+" : "-");
                }

                if (!product.HasMultiOffer)
                {
                    var offer = product.Offers.FirstOrDefault() ?? new Offer();
                    if (item == ProductFields.Price)
                    {
                        writer.WriteField(offer.Price.ToString("F2"));
                    }
                    if (item == ProductFields.PurchasePrice)
                    {
                        writer.WriteField(offer.SupplyPrice.ToString("F2"));
                    }
                    if (item == ProductFields.Amount)
                    {
                        writer.WriteField(offer.Amount.ToString(CultureInfo.InvariantCulture));
                    }

                    if (item == ProductFields.MultiOffer)
                    {
                        writer.WriteField(string.Empty);
                    }
                }
                else
                {
                    if (item == ProductFields.Price)
                    {
                        writer.WriteField(string.Empty);
                    }
                    if (item == ProductFields.PurchasePrice)
                    {
                        writer.WriteField(string.Empty);
                    }
                    if (item == ProductFields.Amount)
                    {
                        writer.WriteField(string.Empty);
                    }
                    if (item == ProductFields.MultiOffer)
                    {
                        writer.WriteField(OfferService.OffersToString(product.Offers, _columSeparator, _propertySeparator));
                    }
                }

                if (item == ProductFields.Unit)
                {
                    writer.WriteField(product.Unit);
                }
                if (item == ProductFields.ShippingPrice)
                {
                    writer.WriteField(product.ShippingPrice.ToString("F2"));
                }
                if (item == ProductFields.Discount)
                {
                    writer.WriteField(product.Discount.ToString("F2"));
                }
                if (item == ProductFields.Weight)
                {
                    writer.WriteField(product.Weight.ToString("F2"));
                }
                if (item == ProductFields.Size)
                {
                    writer.WriteField(product.Size.Replace("|", " x "));
                }

                if (item == ProductFields.BriefDescription)
                {
                    writer.WriteField(product.BriefDescription);
                }
                if (item == ProductFields.Description)
                {
                    writer.WriteField(product.Description);
                }

                if (item == ProductFields.Title)
                {
                    writer.WriteField(meta.Title);
                }
                if (item == ProductFields.H1)
                {
                    writer.WriteField(meta.H1);
                }
                if (item == ProductFields.MetaKeywords)
                {
                    writer.WriteField(meta.MetaKeywords);
                }
                if (item == ProductFields.MetaDescription)
                {
                    writer.WriteField(meta.MetaDescription);
                }
                if (item == ProductFields.Markers)
                {
                    writer.WriteField(ProductService.MarkersToString(product, _columSeparator));
                }
                if (item == ProductFields.Photos)
                {
                    writer.WriteField(PhotoService.PhotoToString(product.ProductPhotos, _columSeparator, _propertySeparator));
                }
                if (item == ProductFields.Videos)
                {
                    writer.WriteField(ProductVideoService.VideoToString(product.ProductVideos, _columSeparator));
                }
                if (item == ProductFields.Properties)
                {
                    writer.WriteField(PropertyService.PropertiesToString(product.ProductPropertyValues, _columSeparator, _propertySeparator));
                }

                if (item == ProductFields.Producer)
                {
                    writer.WriteField(BrandService.BrandToString(product.BrandId));
                }

                if (item == ProductFields.OrderByRequest)
                {
                    writer.WriteField(product.AllowPreOrder ? "+" : "-");
                }

                if (item == ProductFields.SalesNotes)
                {
                    writer.WriteField(product.SalesNote);
                }

                if (item == ProductFields.Related)
                {
                    writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Related, _columSeparator));
                }

                if (item == ProductFields.Alternative)
                {
                    writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Alternative, _columSeparator));
                }

                if (item == ProductFields.CustomOption)
                {
                    writer.WriteField(CustomOptionsService.CustomOptionsToString(CustomOptionsService.GetCustomOptionsByProductId(product.ProductId)));
                }

                if (item == ProductFields.Gtin)
                {
                    writer.WriteField(product.Gtin);
                }

                if (item == ProductFields.GoogleProductCategory)
                {
                    writer.WriteField(product.GoogleProductCategory);
                }

                if (item == ProductFields.Adult)
                {
                    writer.WriteField(product.Adult ? "+" : "-");
                }

                if (item == ProductFields.ManufacturerWarranty)
                {
                    writer.WriteField(product.ManufacturerWarranty ? "+" : "-");
                }
            }
            writer.NextRecord();
        }