diff --git a/src/Plugins/SmartStore.Shipping/SmartStore.Shipping.csproj b/src/Plugins/SmartStore.Shipping/SmartStore.Shipping.csproj index cb03b8a070..e1c137ea0b 100644 --- a/src/Plugins/SmartStore.Shipping/SmartStore.Shipping.csproj +++ b/src/Plugins/SmartStore.Shipping/SmartStore.Shipping.csproj @@ -198,14 +198,14 @@ {6bda8332-939f-45b7-a25e-7a797260ae59} SmartStore.Core - - {210541AD-F659-47DA-8763-16F36C5CD2F4} - SmartStore.Services - {ccd7f2c9-6a2c-4cf0-8e89-076b8fc0f144} SmartStore.Data + + {210541ad-f659-47da-8763-16f36c5cd2f4} + SmartStore.Services + {75fd4163-333c-4dd5-854d-2ef294e45d94} SmartStore.Web.Framework diff --git a/src/Plugins/SmartStore.StrubeExport/AdminMenu.cs b/src/Plugins/SmartStore.StrubeExport/AdminMenu.cs new file mode 100644 index 0000000000..ac2dd5da81 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/AdminMenu.cs @@ -0,0 +1,21 @@ +using SmartStore.Collections; +using SmartStore.Web.Framework.UI; + +namespace SmartStore.StrubeExport +{ + //public class AdminMenu : AdminMenuProvider + //{ + // protected override void BuildMenuCore(TreeNode pluginsNode) + // { + // var menuItem = new MenuItem().ToBuilder() + // .Text("Google Merchant Center") + // .Icon("fab fa-google") + // .ResKey("Plugins.FriendlyName.SmartStore.StrubeExport") + // .Action("ConfigurePlugin", "Plugin", new { systemName = Plugin.SystemName, area = "Admin" }) + // .ToItem(); + + // pluginsNode.Prepend(menuItem); + // } + + //} +} diff --git a/src/Plugins/SmartStore.StrubeExport/Content/admin.scss b/src/Plugins/SmartStore.StrubeExport/Content/admin.scss new file mode 100644 index 0000000000..073eb5e29e --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Content/admin.scss @@ -0,0 +1,2 @@ +/// + diff --git a/src/Plugins/SmartStore.StrubeExport/Content/icon.png b/src/Plugins/SmartStore.StrubeExport/Content/icon.png new file mode 100644 index 0000000000..836abe9402 Binary files /dev/null and b/src/Plugins/SmartStore.StrubeExport/Content/icon.png differ diff --git a/src/Plugins/SmartStore.StrubeExport/Content/public.scss b/src/Plugins/SmartStore.StrubeExport/Content/public.scss new file mode 100644 index 0000000000..5f282702bb --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Content/public.scss @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Controllers/StrubeExportController.cs b/src/Plugins/SmartStore.StrubeExport/Controllers/StrubeExportController.cs new file mode 100644 index 0000000000..f8b0769e98 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Controllers/StrubeExportController.cs @@ -0,0 +1,67 @@ +using SmartStore.ComponentModel; +using SmartStore.Services; +using SmartStore.Services.Common; +using SmartStore.Services.DataExchange.Export; +using SmartStore.StrubeExport.Models; +using SmartStore.StrubeExport.Settings; +using SmartStore.Web.Framework.Controllers; +using SmartStore.Web.Framework.Security; +using SmartStore.Web.Framework.Settings; +using System; +using System.Web.Mvc; + + + +namespace SmartStore.Controllers +{ + public class StrubeExportController : AdminControllerBase + { + private readonly ICommonServices _services; + private readonly IGenericAttributeService _genericAttributeService; + private readonly Lazy _exportService; + + public StrubeExportController( + ICommonServices services, + IGenericAttributeService genericAttributeService,Lazy exportProfileService) + { + _services = services; + _genericAttributeService = genericAttributeService; + _exportService = exportProfileService; + } + + + [AdminAuthorize] + [ChildActionOnly] + [LoadSetting] + public ActionResult Configure(StrubeExportSettings settings) + { + var model = new ConfigurationModel(); + MiniMapper.Map(settings, model); + + + + return View(model); + } + + + [HttpPost] + [AdminAuthorize] + [ChildActionOnly] + [SaveSetting] + public ActionResult Configure(StrubeExportSettings settings, ConfigurationModel model, FormCollection form) + { + if (!ModelState.IsValid) + { + return Configure(settings); + } + + + MiniMapper.Map(model, settings); + return RedirectToConfiguration("SmartStore.StrubeExport"); + } + + + + + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Description.txt b/src/Plugins/SmartStore.StrubeExport/Description.txt new file mode 100644 index 0000000000..4729d25361 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Description.txt @@ -0,0 +1,10 @@ +FriendlyName: StrubeExport +SystemName: SmartStore.StrubeExport +Group: Analytics +Version: 4.1.1 +MinAppVersion: 4.1.1 +Author: Strube D&S GmbH +DisplayOrder: 1 +FileName: SmartStore.StrubeExport.dll +ResourceRootKey: Plugins.SmartStore.StrubeExport +Url: \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Localization/resources.de-de.xml b/src/Plugins/SmartStore.StrubeExport/Localization/resources.de-de.xml new file mode 100644 index 0000000000..bb4c1487a0 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Localization/resources.de-de.xml @@ -0,0 +1,45 @@ + + + StrubeExport + + + Konfigurierbarer Order Export in verschiednene Formaten + + + + + + + + + + + Einstellung + + + Hilfstext zur Konfigurationsmöglichkeit. + + + + Allgemeine Einstellungen + + + + Lieferadresse exportieren + + + Preise und Summen unterdrücken + + + Bankdaten unterdrücken + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Localization/resources.en-us.xml b/src/Plugins/SmartStore.StrubeExport/Localization/resources.en-us.xml new file mode 100644 index 0000000000..526f699e04 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Localization/resources.en-us.xml @@ -0,0 +1,44 @@ + + + StrubeExport + + + configurable exporte for orders in different formats + + + + + + + + + + + Setting + + + Help text for the setting + + + + General Settings + + + + export ship address + + + suppress price and amount + + + suppress Banking information's + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Models/ConfigurationModel.cs b/src/Plugins/SmartStore.StrubeExport/Models/ConfigurationModel.cs new file mode 100644 index 0000000000..e72d696f89 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Models/ConfigurationModel.cs @@ -0,0 +1,23 @@ +using SmartStore.Web.Framework; +using SmartStore.Web.Framework.Modelling; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Web.Mvc; + + +namespace SmartStore.StrubeExport.Models +{ + public class ConfigurationModel : ModelBase + { + + + [SmartResourceDisplayName("Plugins.SmartStore.StrubeExport.MyFirstSetting")] + [AllowHtml] + public string MyFirstSetting { get; set; } + + + + } + + +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Models/FieldOrderAttribute.cs b/src/Plugins/SmartStore.StrubeExport/Models/FieldOrderAttribute.cs new file mode 100644 index 0000000000..cc828d20d0 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Models/FieldOrderAttribute.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace SmartStore.StrubeExport.Models +{ + /// + /// Describes in which order marked Fields will be written to a String during CSV serialisation + /// + [System.AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)] + sealed class FieldOrderAttribute : Attribute + { + // See the attribute guidelines at + // http://go.microsoft.com/fwlink/?LinkId=85236 + private int index = 0; + + // This is a positional argument + public FieldOrderAttribute(int index) + { + this.index = index; + } + + // This is a named argument + public int Index + { + get { return index; } + set { this.index = value; } + } + + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Models/OrderDetail.cs b/src/Plugins/SmartStore.StrubeExport/Models/OrderDetail.cs new file mode 100644 index 0000000000..d3e137ef2b --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Models/OrderDetail.cs @@ -0,0 +1,182 @@ +using SmartStore.Core.Domain.Orders; +using SmartStore.Core.Domain.Security; +using SmartStore.Services; +using SmartStore.Services.Common; +using SmartStore.Services.Configuration; +using SmartStore.Services.Security; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Web; + +namespace SmartStore.StrubeExport.Models +{ + public class OrderDetail + { + [FieldOrder(0)] + public string Id { get; set; } + [FieldOrder(1)] + public string OrderId { get; set; } + [FieldOrder(2)] + public string Comment { get; set; } + [FieldOrder(3)] + public string Company { get; set; } + [FieldOrder(4)] + public string Name { get; set; } + [FieldOrder(5)] + public string Surname { get; set; } + [FieldOrder(6)] + public string Address1 { get; set; } + [FieldOrder(7)] + public string Address2 { get; set; } + [FieldOrder(8)] + public string ZipCode { get; set; } + [FieldOrder(9)] + public string City { get; set; } + [FieldOrder(10)] + public string Country { get; set; } + [FieldOrder(11)] + public string ItemId { get; set; } + [FieldOrder(12)] + public string Description { get; set; } + [FieldOrder(13)] + public string SKU { get; set; } + [FieldOrder(14)] + public string Gtin { get; set; } + [FieldOrder(15)] + public int Count { get; set; } + [FieldOrder(16)] + public string TrackingId { get; set; } + [FieldOrder(17)] + public DateTime? ShipDateTime { get; set; } + [FieldOrder(18)] + public string PaymentType { get; set; } + [FieldOrder(19)] + public string DirectDebitAccountHolder { get; set; } + [FieldOrder(20)] + public string DirectDebitIBAN { get; set; } + [FieldOrder(21)] + public string DirectDebitBIC { get; set; } + [FieldOrder(22)] + public string CustomerEmail { get; set; } + [FieldOrder(23)] + public decimal OrderAmount { get; set; } + + public OrderDetail() + { + + } + + public OrderDetail(OrderItem orderItem, ProfileConfigurationModel _config,IEncryptionService encryptionService=null,string encryptionKey="") + { + this.Id = orderItem.Order.OrderGuid.ToString(); + this.OrderId = orderItem.Order.GetOrderNumber(); + this.Comment = orderItem.Order.CustomerOrderComment; + if(_config.ExportShipAddress) + { + this.Company = orderItem.Order.ShippingAddress.Company; + this.Name = orderItem.Order.ShippingAddress.LastName; + this.Surname = orderItem.Order.ShippingAddress.FirstName; + this.Address1 = orderItem.Order.ShippingAddress.Address1; + this.Address2 = orderItem.Order.ShippingAddress.Address2; + this.ZipCode = orderItem.Order.ShippingAddress.ZipPostalCode; + this.City = orderItem.Order.ShippingAddress.City; + this.Country = orderItem.Order.ShippingAddress.Country.Name; + this.CustomerEmail = orderItem.Order.ShippingAddress.Email; + } + else + { + this.Company = orderItem.Order.BillingAddress.Company; + this.Name = orderItem.Order.BillingAddress.LastName; + this.Surname = orderItem.Order.BillingAddress.FirstName; + this.Address1 = orderItem.Order.BillingAddress.Address1; + this.Address2 = orderItem.Order.BillingAddress.Address2; + this.ZipCode = orderItem.Order.BillingAddress.ZipPostalCode; + this.City = orderItem.Order.BillingAddress.City; + this.Country = orderItem.Order.BillingAddress.Country.Name; + this.CustomerEmail = orderItem.Order.BillingAddress.Email; + } + if(string.IsNullOrEmpty(this.CustomerEmail)) + { + this.CustomerEmail = orderItem.Order.Customer.Email; + } + if(!_config.SuppressPrice) + { + this.OrderAmount = orderItem.Order.OrderTotal; + } + else + { + this.OrderAmount = 0; + } + this.ItemId = orderItem.Product.ManufacturerPartNumber; + this.SKU = orderItem.Product.Sku; + this.Gtin = orderItem.Product.Gtin; + this.Description = orderItem.Product.Name; + this.Count = orderItem.Quantity; + this.TrackingId = ""; + this.ShipDateTime = null; + this.PaymentType = orderItem.Order.PaymentMethodSystemName; + // some fields ar encrypted. Try to decrypt only if Service available + if(encryptionService!=null && !_config.SuppressBank) + { + this.DirectDebitAccountHolder = encryptionService.DecryptText(orderItem.Order.DirectDebitAccountHolder, encryptionKey); + this.DirectDebitBIC = encryptionService.DecryptText(orderItem.Order.DirectDebitBIC,encryptionKey); + this.DirectDebitIBAN = encryptionService.DecryptText(orderItem.Order.DirectDebitIban,encryptionKey); + } + //else + //{ + // this.DirectDebitAccountHolder = orderItem.Order.DirectDebitAccountHolder; + // this.DirectDebitBIC = orderItem.Order.DirectDebitBIC; + // this.DirectDebitIBAN = orderItem.Order.DirectDebitIban; + //} + } + + /// + /// Creates A Header Line for CSV depending on Properties and FieldOrder + /// + /// Seperator to use default ';' + /// a Seperator sperated String with property names + public string GetCSVHeader(string Seperator=";") + { + StringBuilder sb = new StringBuilder(); + PropertyInfo[] props = this.GetType().GetProperties(); + List propertyInfos = props.Where(p => p.GetCustomAttribute() != null).OrderBy(a => a.GetCustomAttribute().Index).ToList(); + + foreach (var item in propertyInfos) + { + sb.Append(item.Name); + sb.Append(Seperator); + } + return sb.ToString(); + } + + /// + /// Creates a Line for CSV depending on Properties and FieldOrder + /// + /// Seperator to use default ';' + /// a Seperator sperated String with property values + public string GetCSVLine(string Seperator=";") + { + StringBuilder sb = new StringBuilder(); + PropertyInfo[] props = this.GetType().GetProperties(); + List propertyInfos = props.Where(p => p.GetCustomAttribute() != null).OrderBy(a => a.GetCustomAttribute().Index).ToList(); + + foreach (var item in propertyInfos) + { + if (item.GetValue(this) != null) + { + sb.Append(item.GetValue(this).ToString()); + sb.Append(Seperator); + } + else + { + sb.Append(""); + sb.Append(Seperator); + } + } + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Models/OrderDetails.cs b/src/Plugins/SmartStore.StrubeExport/Models/OrderDetails.cs new file mode 100644 index 0000000000..932be18272 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Models/OrderDetails.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace SmartStore.StrubeExport.Models +{ + public class OrderDetails:List + { + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Models/ProfileConfigurationModel.cs b/src/Plugins/SmartStore.StrubeExport/Models/ProfileConfigurationModel.cs new file mode 100644 index 0000000000..3fb8c6f847 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Models/ProfileConfigurationModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Web.Mvc; +using System.Xml.Serialization; +using SmartStore.Web.Framework; +using SmartStore.Web.Framework.Modelling; + +namespace SmartStore.StrubeExport.Models +{ + [CustomModelPart] + [Serializable] + public class ProfileConfigurationModel + { + [SmartResourceDisplayName("Plugins.SmartStore.StrubeExport.ExportShipAddress")] + public bool ExportShipAddress { get; set; } = true; + + [SmartResourceDisplayName("Plugins.SmartStore.StrubeExport.SuppressPrice")] + public bool SuppressPrice { get; set; } = false; + + [SmartResourceDisplayName("Plugins.SmartStore.StrubeExport.SuppressBank")] + public bool SuppressBank { get; set; } = false; + + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Plugin.cs b/src/Plugins/SmartStore.StrubeExport/Plugin.cs new file mode 100644 index 0000000000..bb112f9917 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Plugin.cs @@ -0,0 +1,61 @@ +using SmartStore.Core.Plugins; +using SmartStore.Services; +using SmartStore.Services.Configuration; +using SmartStore.StrubeExport; +using SmartStore.StrubeExport.Settings; +using System; +using System.Collections.Generic; +using System.Web.Routing; + + + + +namespace SmartStore.StrubeExport +{ + public class Plugin : BasePlugin, IConfigurable + { + private readonly ISettingService _settingService; + private readonly ICommonServices _services; + + + public Plugin(ISettingService settingService, + ICommonServices services) + { + _settingService = settingService; + _services = services; + + } + + public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues) + { + actionName = "Configure"; + controllerName = "StrubeExport"; + routeValues = new RouteValueDictionary() { { "area", "SmartStore.StrubeExport" } }; + } + + public static string SystemName = "Strube_Export_Plugin"; + + + + public override void Install() + { + // Save settings with default values. + _services.Settings.SaveSetting(new StrubeExportSettings()); + + // Import localized plugin resources (you can edit or add these in /Localization/resources.[Culture].xml). + _services.Localization.ImportPluginResourcesFromXml(this.PluginDescriptor); + + + base.Install(); + } + + public override void Uninstall() + { + _services.Settings.DeleteSetting(); + _services.Localization.DeleteLocaleStringResources(this.PluginDescriptor.ResourceRootKey); + + + base.Uninstall(); + } + } +} diff --git a/src/Plugins/SmartStore.StrubeExport/Properties/AssemblyInfo.cs b/src/Plugins/SmartStore.StrubeExport/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..63a5b764f1 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Properties/AssemblyInfo.cs @@ -0,0 +1,2 @@ +using System.Reflection; +[assembly: AssemblyTitle("SmartStore.StrubeExport")] diff --git a/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullCsvImportProvider.cs b/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullCsvImportProvider.cs new file mode 100644 index 0000000000..35c9dbad96 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullCsvImportProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using SmartStore.Services.DataExchange.Import; + +namespace SmartStore.StrubeExport.Providers +{ + public class OrderFullCsvImportProvider + { + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullCsvProvider.cs b/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullCsvProvider.cs new file mode 100644 index 0000000000..dad42faa50 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullCsvProvider.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using SmartStore.Collections; +using SmartStore.Core.Domain.Catalog; +using SmartStore.Core.Domain.DataExchange; +using SmartStore.Core.Domain.Directory; +using SmartStore.Core.Localization; +using SmartStore.Core.Logging; +using SmartStore.Core.Plugins; +using SmartStore.Services; +using SmartStore.Services.Catalog; +using SmartStore.Services.DataExchange.Export; +using SmartStore.Services.Directory; +using SmartStore.Services.Localization; +using SmartStore.Services.Security; +using SmartStore.Services.Configuration; +using System.IO; +using SmartStore.Core.Domain.Orders; +using SmartStore.StrubeExport.Models; +using SmartStore.Core.Domain.Security; + +namespace SmartStore.StrubeExport.Providers +{ + /// + /// Provider for Export Order Infos without Prices as CSV File + /// + [SystemName("Strube.OrdersExportCSV")] + [FriendlyName("Strube Full Order csv-Export")] + [DisplayOrder(1)] + [ExportFeatures(Features = + ExportFeatures.CreatesInitialPublicDeployment | + ExportFeatures.CanOmitGroupedProducts | + ExportFeatures.CanProjectAttributeCombinations | + ExportFeatures.CanProjectDescription | + ExportFeatures.UsesSkuAsMpnFallback | + ExportFeatures.OffersBrandFallback | + ExportFeatures.UsesSpecialPrice | + ExportFeatures.UsesAttributeCombination | + ExportFeatures.CanOmitCompletionMail)] + public class OrderFullCsvProvider : ExportProviderBase + { + private readonly IEncryptionService _encryptionService; + private readonly ISettingService _settingService; + private readonly string _encryptionKey; + + public OrderFullCsvProvider(IEncryptionService encryptionService, ISettingService settingService) + { + _encryptionService = encryptionService; + _settingService = settingService; + var securitySettings = _settingService.LoadSetting(); + _encryptionKey = securitySettings.EncryptionKey; + } + + public override ExportEntityType EntityType + { + get { return ExportEntityType.Order; } + } + + public static string SystemName + { + get { return "Strube.OrdersExportCSV"; } + } + + public override string FileExtension + { + get { return "txt"; } + } + + protected override void Export(ExportExecuteContext context) + { + dynamic currency = context.Currency; + //string _FormatString = "{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12};{13}"; + var config = (context.ConfigurationData as ProfileConfigurationModel) ?? new ProfileConfigurationModel(); + + //Create Streamwriter + StreamWriter _sw = new StreamWriter(context.DataStream); + //Add Header Line + //_sw.WriteLine(String.Format(_FormatString, + // "ID", + // "OrderId", + // "Comment", + // "Company", + // "Name", + // "Surname", + // "Address1", + // "Address2", + // "Zip-Code", + // "City", + // "Country", + // "ItemId", + // "Description", + // "Count")); + _sw.WriteLine(new OrderDetail().GetCSVHeader()); + // export the lines + while (context.Abort==DataExchangeAbortion.None && context.DataSegmenter.ReadNextSegment()) + { + var segment = context.DataSegmenter.CurrentSegment; + foreach (dynamic order in segment) + { + Order orderEntity = order.Entity; + List orderItem = orderEntity.OrderItems.ToList(); + + if (context.Abort!= DataExchangeAbortion.None) + { + break; + } + + try + { + foreach (OrderItem item in orderItem) + { + OrderDetail orderDetail = new OrderDetail(item,config,_encryptionService,_encryptionKey); + _sw.WriteLine(orderDetail.GetCSVLine()); + //Product itemProduct = item.Product; + //_sw.WriteLine(String.Format(_FormatString, + // orderEntity.OrderGuid, + // orderEntity.GetOrderNumber(), + // orderEntity.CustomerOrderComment, + // orderEntity.ShippingAddress.Company, + // orderEntity.ShippingAddress.LastName, + // orderEntity.ShippingAddress.FirstName, + // orderEntity.ShippingAddress.Address1, + // orderEntity.ShippingAddress.Address2, + // orderEntity.ShippingAddress.ZipPostalCode, + // orderEntity.ShippingAddress.City, + // orderEntity.ShippingAddress.Country.Name, + // itemProduct.Sku, + // itemProduct.Name, + // item.Quantity + // )) ; + + ++context.RecordsSucceeded; + + } + } + catch(Exception ex) + { + context.RecordException(ex, orderEntity.Id); + } + } + } + _sw.Flush(); + //throw new NotImplementedException(); + } + + //public override ExportConfigurationInfo ConfigurationInfo + //{ + // get { return null; } + //} + + public override void OnExecuted(ExportExecuteContext context) + { + + } + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullXlsxProvider.cs b/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullXlsxProvider.cs new file mode 100644 index 0000000000..e32cd2f4bc --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Providers/OrderFullXlsxProvider.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using SmartStore.Collections; +using SmartStore.Core.Domain.Catalog; +using SmartStore.Core.Domain.DataExchange; +using SmartStore.Core.Domain.Directory; +using SmartStore.Core.Localization; +using SmartStore.Core.Logging; +using SmartStore.Core.Plugins; +using SmartStore.Services; +using SmartStore.Services.Catalog; +using SmartStore.Services.DataExchange.Export; +using SmartStore.Services.Directory; +using SmartStore.Services.Localization; +using SmartStore.Services.Configuration; +using SmartStore.Services.Security; +using System.IO; +using SmartStore.Core.Domain.Orders; +using OfficeOpenXml; +using SmartStore.StrubeExport.Models; +using SmartStore.Core.Domain.Security; + +namespace SmartStore.StrubeExport.Providers +{ + /// + /// Provider for Export Order Infos without Prices as XLSX File + /// + [SystemName("Strube.OrdersExportXLSX")] + [FriendlyName("Strube Full Order xlsx-Export")] + [DisplayOrder(2)] + [ExportFeatures(Features = + ExportFeatures.CreatesInitialPublicDeployment | + ExportFeatures.CanOmitGroupedProducts | + ExportFeatures.CanProjectAttributeCombinations | + ExportFeatures.CanProjectDescription | + ExportFeatures.UsesSkuAsMpnFallback | + ExportFeatures.OffersBrandFallback | + ExportFeatures.UsesSpecialPrice | + ExportFeatures.UsesAttributeCombination | + ExportFeatures.CanOmitCompletionMail)] + public class OrderFullXlsxProvider: ExportProviderBase + { + private readonly IEncryptionService _encryptionService; + private readonly ISettingService _settingService; + private readonly string _encryptionKey; + + public OrderFullXlsxProvider(IEncryptionService encryptionService, ISettingService settingService) + { + _encryptionService = encryptionService; + _settingService = settingService; + var securitySettings = _settingService.LoadSetting(); + _encryptionKey = securitySettings.EncryptionKey; + } + + public override ExportEntityType EntityType + { + get { return ExportEntityType.Order; } + } + + public static string SystemName + { + get { return "Strube.OrdersExportXLSX"; } + } + + public override string FileExtension + { + get { return "xlsx"; } + } + + public override ExportConfigurationInfo ConfigurationInfo => new ExportConfigurationInfo + { + PartialViewName = "~/Plugins/SmartStore.StrubeExport/Views/StrubeExport/ProfileConfiguration.cshtml", + ModelType = typeof(ProfileConfigurationModel), + Initialize = obj => + { + var model = (obj as ProfileConfigurationModel); + + //model.LanguageSeoCode = _services.WorkContext.WorkingLanguage.UniqueSeoCode.EmptyNull().ToLower(); + + //model.AvailableCategories = model.DefaultGoogleCategory.HasValue() + // ? new List { new SelectListItem { Text = model.DefaultGoogleCategory, Value = model.DefaultGoogleCategory, Selected = true } } + // : new List(); + } + }; + + protected override void Export(ExportExecuteContext context) + { + dynamic currency = context.Currency; + OrderDetails orderDetails = new OrderDetails(); + var config = (context.ConfigurationData as ProfileConfigurationModel) ?? new ProfileConfigurationModel(); + // convert the lines + while (context.Abort == DataExchangeAbortion.None && context.DataSegmenter.ReadNextSegment()) + { + var segment = context.DataSegmenter.CurrentSegment; + foreach (dynamic order in segment) + { + Order orderEntity = order.Entity; + List orderItem = orderEntity.OrderItems.ToList(); + + if (context.Abort != DataExchangeAbortion.None) + { + break; + } + + try + { + foreach (OrderItem item in orderItem) + { + OrderDetail tmp = new OrderDetail(item,config,_encryptionService,_encryptionKey); + orderDetails.Add(tmp); + ++context.RecordsSucceeded; + } + } + catch (Exception ex) + { + context.RecordException(ex, orderEntity.Id); + } + } + } + //create ExcelPackage + ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + using (ExcelPackage excelPackage = new ExcelPackage(context.DataStream)) + { + var workSheet = excelPackage.Workbook.Worksheets.Add( + DateTime.Now.Year.ToString() + + "_" + + DateTime.Now.Month.ToString() + + "_" + + DateTime.Now.Day.ToString() + + "_" + + DateTime.Now.Hour.ToString() + + "_" + + DateTime.Now.Minute.ToString()); + workSheet.Cells["A1"].LoadFromCollection(orderDetails, true, OfficeOpenXml.Table.TableStyles.Medium13); + excelPackage.Workbook.Properties.Company = "Strube D&S GmbH"; + excelPackage.Workbook.Properties.Author = "Strube Web Shop"; + excelPackage.Save(); + } + + } + + //public override ExportConfigurationInfo ConfigurationInfo + //{ + // get { return null; } + //} + + public override void OnExecuted(ExportExecuteContext context) + { + + } + + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/RouteProvider.cs b/src/Plugins/SmartStore.StrubeExport/RouteProvider.cs new file mode 100644 index 0000000000..0899f5ba8c --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/RouteProvider.cs @@ -0,0 +1,27 @@ +using SmartStore.Web.Framework.Routing; +using System.Web.Mvc; +using System.Web.Routing; + +namespace SmartStore.Plugin.StrubeExport +{ + public partial class RouteProvider : IRouteProvider + { + public void RegisterRoutes(RouteCollection routes) + { + routes.MapRoute("SmartStore.StrubeExport", + "Plugins/StrubeExport/{action}", + new { controller = "StrubeExport", action = "Configure" }, + new[] { "SmartStore.StrubeExport.Controllers" } + ) + .DataTokens["area"] = "SmartStore.StrubeExport"; + } + + public int Priority + { + get + { + return 0; + } + } + } +} diff --git a/src/Plugins/SmartStore.StrubeExport/Settings/StrubeExportSettings.cs b/src/Plugins/SmartStore.StrubeExport/Settings/StrubeExportSettings.cs new file mode 100644 index 0000000000..1c86fb141c --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Settings/StrubeExportSettings.cs @@ -0,0 +1,14 @@ +using SmartStore.Core.Configuration; + +namespace SmartStore.StrubeExport.Settings +{ + public class StrubeExportSettings : ISettings + { + public string MyFirstSetting { get; set; } + + + + + + } +} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/SmartStore.StrubeExport.csproj b/src/Plugins/SmartStore.StrubeExport/SmartStore.StrubeExport.csproj new file mode 100644 index 0000000000..b1c84a4105 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/SmartStore.StrubeExport.csproj @@ -0,0 +1,289 @@ + + + + + + False + + + False + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {0C6F1F80-193D-4545-89DF-FD2C30B1E738} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + SmartStore.StrubeExport + SmartStore.StrubeExport + + v4.7.2 + 512 + + ..\..\ + true + + + 4.0 + true + + + + + + False + + False + + + + + + true + full + false + ..\..\Presentation\SmartStore.Web\Plugins\SmartStore.StrubeExport\ + DEBUG;TRACE + prompt + 4 + false + False + + False + + + + pdbonly + true + ..\..\Presentation\SmartStore.Web\Plugins\SmartStore.StrubeExport\ + TRACE + prompt + 4 + false + False + + False + + + + true + ..\..\Presentation\SmartStore.Web\bin\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + False + + False + + + + true + bin\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + False + + False + + + + + ..\..\packages\EPPlus.5.7.4\lib\net45\EPPlus.dll + True + + + ..\..\packages\Microsoft.IO.RecyclableMemoryStream.1.4.1\lib\net46\Microsoft.IO.RecyclableMemoryStream.dll + True + + + False + ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + + + ..\..\packages\System.ComponentModel.Annotations.4.7.0\lib\net461\System.ComponentModel.Annotations.dll + True + + + + + + + + + + + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + False + + + ..\..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll + False + + + ..\..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + False + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll + False + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll + False + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll + False + + + + + + + ..\..\packages\Autofac.5.2.0\lib\net461\Autofac.dll + False + + + ..\..\packages\Autofac.Mvc5.5.0.0\lib\net461\Autofac.Integration.Mvc.dll + False + + + + + + {6bda8332-939f-45b7-a25e-7a797260ae59} + SmartStore.Core + False + + + {210541AD-F659-47DA-8763-16F36C5CD2F4} + SmartStore.Services + False + + + {75fd4163-333c-4dd5-854d-2ef294e45d94} + SmartStore.Web.Framework + False + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + web.config + + + web.config + + + web.config + + + web.config + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + Designer + PreserveNewest + + + Designer + PreserveNewest + + + + 10.0 + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + + + + False + True + 64666 + / + http://localhost:53132/ + False + True + https://smartstore.com + False + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Views/StrubeExport/Configure.cshtml b/src/Plugins/SmartStore.StrubeExport/Views/StrubeExport/Configure.cshtml new file mode 100644 index 0000000000..c24c9d1693 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Views/StrubeExport/Configure.cshtml @@ -0,0 +1,39 @@ +@model SmartStore.StrubeExport.Models.ConfigurationModel +@using SmartStore.Web.Framework; +@{ + Layout = ""; +} + +
+ +
+ +@Html.Action("StoreScopeConfiguration", "Setting", new { area = "Admin" }) + +
+ @Html.Raw(@T("Plugins.SmartStore.StrubeExport.AdminInstruction")) +
+ +@using (Html.BeginForm()) +{ +
+
+
+ @Html.SmartLabelFor(model => model.MyFirstSetting) +
+
+ @Html.SettingEditorFor(model => model.MyFirstSetting) + @Html.ValidationMessageFor(model => model.MyFirstSetting) +
+
+ + + + + + +
+} \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/Views/StrubeExport/ProfileConfiguration.cshtml b/src/Plugins/SmartStore.StrubeExport/Views/StrubeExport/ProfileConfiguration.cshtml new file mode 100644 index 0000000000..48e5713759 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Views/StrubeExport/ProfileConfiguration.cshtml @@ -0,0 +1,44 @@ +@using SmartStore.StrubeExport; +@using SmartStore.StrubeExport.Providers +@using SmartStore.StrubeExport.Models; +@model ProfileConfigurationModel +@{ + Layout = null; +} + + + + + + + + + + + + + + + + + +
+
+
@T("Plugins.SmartStore.StrubeExport.GeneralSettings")
+
+
+ @Html.SmartLabelFor(m => m.ExportShipAddress) + + @Html.EditorFor(m => m.ExportShipAddress) + @Html.ValidationMessageFor(m => m.ExportShipAddress) +
+ @Html.SmartLabelFor(m => m.SuppressPrice) + + @Html.EditorFor(m => m.SuppressPrice) + @Html.ValidationMessageFor(m => m.SuppressPrice) +
+ @Html.SmartLabelFor(m => m.SuppressBank) + + @Html.EditorFor(m => m.SuppressBank) + @Html.ValidationMessageFor(m => m.SuppressBank) +
diff --git a/src/Plugins/SmartStore.StrubeExport/Views/Web.config b/src/Plugins/SmartStore.StrubeExport/Views/Web.config new file mode 100644 index 0000000000..82cfd62c51 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/Views/Web.config @@ -0,0 +1,54 @@ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Plugins/SmartStore.StrubeExport/packages.config b/src/Plugins/SmartStore.StrubeExport/packages.config new file mode 100644 index 0000000000..2b116219c7 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/packages.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/web.Debug.config b/src/Plugins/SmartStore.StrubeExport/web.Debug.config new file mode 100644 index 0000000000..f01fcc5c0f --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/web.EFMigrations.config b/src/Plugins/SmartStore.StrubeExport/web.EFMigrations.config new file mode 100644 index 0000000000..86c687b229 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/web.EFMigrations.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/web.PluginDev.config b/src/Plugins/SmartStore.StrubeExport/web.PluginDev.config new file mode 100644 index 0000000000..86c687b229 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/web.PluginDev.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/web.Release.config b/src/Plugins/SmartStore.StrubeExport/web.Release.config new file mode 100644 index 0000000000..86c687b229 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/SmartStore.StrubeExport/web.config b/src/Plugins/SmartStore.StrubeExport/web.config new file mode 100644 index 0000000000..6993224374 --- /dev/null +++ b/src/Plugins/SmartStore.StrubeExport/web.config @@ -0,0 +1,160 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/Strube.Export.zip b/src/Plugins/Strube.Export.zip new file mode 100644 index 0000000000..e21d2bb910 Binary files /dev/null and b/src/Plugins/Strube.Export.zip differ diff --git a/src/Plugins/Strube.Export/DependencyRegistrar.cs b/src/Plugins/Strube.Export/DependencyRegistrar.cs new file mode 100644 index 0000000000..b7e2946cfe --- /dev/null +++ b/src/Plugins/Strube.Export/DependencyRegistrar.cs @@ -0,0 +1,22 @@ +using Autofac; +using Autofac.Core; +using SmartStore.Core.Data; +using SmartStore.Core; +using SmartStore.Core.Infrastructure; +using SmartStore.Core.Infrastructure.DependencyManagement; +using SmartStore.Services.Messages; +//using SmartStore.Data; + +namespace Strube.Export +{ + public class DependencyRegistrar : IDependencyRegistrar + { + public int Order { get { return 1; } } + + public void Register(ContainerBuilder builder, ITypeFinder typeFinder, bool isActiveModule) + { + //throw new System.NotImplementedException(); + builder.RegisterType().As().InstancePerRequest(); + } + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Description.txt b/src/Plugins/Strube.Export/Description.txt new file mode 100644 index 0000000000..a1e49153d6 --- /dev/null +++ b/src/Plugins/Strube.Export/Description.txt @@ -0,0 +1,10 @@ +FriendlyName: Strube-Order-Export +Description: Provides Export Formats for Strube Companies +SystemName: Strube.Export +Group: Developer +Version: 4.1.1 +MinAppVersion: 4.1.1 +Author: Strube DuS GmbH +DisplayOrder: 1 +FileName: Strube.Export.dll +ResourceRootKey: Plugins.Strube.Export diff --git a/src/Plugins/Strube.Export/Models/FieldOrderAttribute.cs b/src/Plugins/Strube.Export/Models/FieldOrderAttribute.cs new file mode 100644 index 0000000000..f135636943 --- /dev/null +++ b/src/Plugins/Strube.Export/Models/FieldOrderAttribute.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Strube.Export.Models +{ + /// + /// Describes in which order marked Fields will be written to a String during CSV serialisation + /// + [System.AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)] + sealed class FieldOrderAttribute : Attribute + { + // See the attribute guidelines at + // http://go.microsoft.com/fwlink/?LinkId=85236 + private int index = 0; + + // This is a positional argument + public FieldOrderAttribute(int index) + { + this.index = index; + } + + // This is a named argument + public int Index + { + get { return index; } + set { this.index = value; } + } + + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Models/OrderDetail.cs b/src/Plugins/Strube.Export/Models/OrderDetail.cs new file mode 100644 index 0000000000..f867363b29 --- /dev/null +++ b/src/Plugins/Strube.Export/Models/OrderDetail.cs @@ -0,0 +1,156 @@ +using SmartStore.Core.Domain.Orders; +using SmartStore.Core.Domain.Security; +using SmartStore.Services; +using SmartStore.Services.Common; +using SmartStore.Services.Configuration; +using SmartStore.Services.Security; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Web; + +namespace Strube.Export.Models +{ + public class OrderDetail + { + [FieldOrder(0)] + public string Id { get; set; } + [FieldOrder(1)] + public string OrderId { get; set; } + [FieldOrder(2)] + public string Comment { get; set; } + [FieldOrder(3)] + public string Company { get; set; } + [FieldOrder(4)] + public string Name { get; set; } + [FieldOrder(5)] + public string Surname { get; set; } + [FieldOrder(6)] + public string Address1 { get; set; } + [FieldOrder(7)] + public string Address2 { get; set; } + [FieldOrder(8)] + public string ZipCode { get; set; } + [FieldOrder(9)] + public string City { get; set; } + [FieldOrder(10)] + public string Country { get; set; } + [FieldOrder(11)] + public string ItemId { get; set; } + [FieldOrder(12)] + public string Description { get; set; } + [FieldOrder(13)] + public string SKU { get; set; } + [FieldOrder(14)] + public string Gtin { get; set; } + [FieldOrder(15)] + public int Count { get; set; } + [FieldOrder(16)] + public string TrackingId { get; set; } + [FieldOrder(17)] + public DateTime? ShipDateTime { get; set; } + [FieldOrder(18)] + public string PaymentType { get; set; } + [FieldOrder(19)] + public string DirectDebitAccountHolder { get; set; } + [FieldOrder(20)] + public string DirectDebitIBAN { get; set; } + [FieldOrder(21)] + public string DirectDebitBIC { get; set; } + [FieldOrder(22)] + public string CustomerEmail { get; set; } + [FieldOrder(23)] + public decimal OrderAmount { get; set; } + + public OrderDetail() + { + + } + + public OrderDetail(OrderItem orderItem, IEncryptionService encryptionService=null,string encryptionKey="") + { + this.Id = orderItem.Order.OrderGuid.ToString(); + this.OrderId = orderItem.Order.GetOrderNumber(); + this.Comment = orderItem.Order.CustomerOrderComment; + this.Company = orderItem.Order.ShippingAddress.Company; + this.Name = orderItem.Order.ShippingAddress.LastName; + this.Surname = orderItem.Order.ShippingAddress.FirstName; + this.Address1 = orderItem.Order.ShippingAddress.Address1; + this.Address2 = orderItem.Order.ShippingAddress.Address2; + this.ZipCode = orderItem.Order.ShippingAddress.ZipPostalCode; + this.City = orderItem.Order.ShippingAddress.City; + this.Country = orderItem.Order.ShippingAddress.Country.Name; + this.CustomerEmail = orderItem.Order.Customer.Email; + this.OrderAmount = orderItem.Order.OrderTotal; + this.ItemId = orderItem.Product.ManufacturerPartNumber; + this.SKU = orderItem.Product.Sku; + this.Gtin = orderItem.Product.Gtin; + this.Description = orderItem.Product.Name; + this.Count = orderItem.Quantity; + this.TrackingId = ""; + this.ShipDateTime = null; + this.PaymentType = orderItem.Order.PaymentMethodSystemName; + // some fields ar encrypted. Try to decrypt only if Service available + if(encryptionService!=null) + { + this.DirectDebitAccountHolder = encryptionService.DecryptText(orderItem.Order.DirectDebitAccountHolder, encryptionKey); + this.DirectDebitBIC = encryptionService.DecryptText(orderItem.Order.DirectDebitBIC,encryptionKey); + this.DirectDebitIBAN = encryptionService.DecryptText(orderItem.Order.DirectDebitIban,encryptionKey); + } + else + { + this.DirectDebitAccountHolder = orderItem.Order.DirectDebitAccountHolder; + this.DirectDebitBIC = orderItem.Order.DirectDebitBIC; + this.DirectDebitIBAN = orderItem.Order.DirectDebitIban; + } + } + + /// + /// Creates A Header Line for CSV depending on Properties and FieldOrder + /// + /// Seperator to use default ';' + /// a Seperator sperated String with property names + public string GetCSVHeader(string Seperator=";") + { + StringBuilder sb = new StringBuilder(); + PropertyInfo[] props = this.GetType().GetProperties(); + List propertyInfos = props.Where(p => p.GetCustomAttribute() != null).OrderBy(a => a.GetCustomAttribute().Index).ToList(); + + foreach (var item in propertyInfos) + { + sb.Append(item.Name); + sb.Append(Seperator); + } + return sb.ToString(); + } + + /// + /// Creates a Line for CSV depending on Properties and FieldOrder + /// + /// Seperator to use default ';' + /// a Seperator sperated String with property values + public string GetCSVLine(string Seperator=";") + { + StringBuilder sb = new StringBuilder(); + PropertyInfo[] props = this.GetType().GetProperties(); + List propertyInfos = props.Where(p => p.GetCustomAttribute() != null).OrderBy(a => a.GetCustomAttribute().Index).ToList(); + + foreach (var item in propertyInfos) + { + if (item.GetValue(this) != null) + { + sb.Append(item.GetValue(this).ToString()); + sb.Append(Seperator); + } + else + { + sb.Append(""); + sb.Append(Seperator); + } + } + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Models/OrderDetails.cs b/src/Plugins/Strube.Export/Models/OrderDetails.cs new file mode 100644 index 0000000000..5548154220 --- /dev/null +++ b/src/Plugins/Strube.Export/Models/OrderDetails.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Strube.Export.Models +{ + public class OrderDetails:List + { + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Plugin.cs b/src/Plugins/Strube.Export/Plugin.cs new file mode 100644 index 0000000000..8d37a01918 --- /dev/null +++ b/src/Plugins/Strube.Export/Plugin.cs @@ -0,0 +1,59 @@ +using SmartStore.Core.Plugins; +using SmartStore.Services; +using System; +using System.Collections.Generic; +using System.Data.Entity.Migrations; +using System.Linq; +using System.Web; + +namespace Strube.Export +{ + public class Plugin:BasePlugin + { + private readonly ICommonServices _services; + + public Plugin(ICommonServices services) + { + this._services = services; + } + + public static string SystemName + { + get { return "Strube.Export"; } + } + + /// + /// Install Plugin + /// + public override void Install() + { + var settings = _services.Settings; + var loc = _services.Localization; + + // add resources + loc.ImportPluginResourcesFromXml(this.PluginDescriptor); + + base.Install(); + } + + /// + /// Uninstall Plugin + /// + public override void Uninstall() + { + var settings = _services.Settings; + var loc = _services.Localization; + + // delete resources + loc.DeleteLocaleStringResources(this.PluginDescriptor.ResourceRootKey); + //loc.DeleteLocaleStringResources("Plugins.Tax.CountryStateZip"); + //loc.DeleteLocaleStringResources("Plugins.Tax.FixedRate"); + + //var migrator = new DbMigrator(new Configuration()); + //migrator.Update(DbMigrator.InitialDatabase); + + base.Uninstall(); + } + + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Properties/AssemblyInfo.cs b/src/Plugins/Strube.Export/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..12b225a30a --- /dev/null +++ b/src/Plugins/Strube.Export/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die +// Assemblyinformationen zu ändern. +[assembly: AssemblyTitle("Strube.Export")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Strube.Export")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. +[assembly: Guid("30e0ced9-57c7-4ddd-acbb-722104ba4246")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Revisions- und Buildnummern +// übernehmen, indem Sie "*" wie folgt verwenden: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Plugins/Strube.Export/Providers/OrderFullCsvImportProvider.cs b/src/Plugins/Strube.Export/Providers/OrderFullCsvImportProvider.cs new file mode 100644 index 0000000000..0bde4380c9 --- /dev/null +++ b/src/Plugins/Strube.Export/Providers/OrderFullCsvImportProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using SmartStore.Services.DataExchange.Import; + +namespace Strube.Export.Providers +{ + public class OrderFullCsvImportProvider + { + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Providers/OrderFullCsvProvider.cs b/src/Plugins/Strube.Export/Providers/OrderFullCsvProvider.cs new file mode 100644 index 0000000000..1ebb0fadf1 --- /dev/null +++ b/src/Plugins/Strube.Export/Providers/OrderFullCsvProvider.cs @@ -0,0 +1,157 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using SmartStore.Collections; +using SmartStore.Core.Domain.Catalog; +using SmartStore.Core.Domain.DataExchange; +using SmartStore.Core.Domain.Directory; +using SmartStore.Core.Localization; +using SmartStore.Core.Logging; +using SmartStore.Core.Plugins; +using SmartStore.Services; +using SmartStore.Services.Catalog; +using SmartStore.Services.DataExchange.Export; +using SmartStore.Services.Directory; +using SmartStore.Services.Localization; +using SmartStore.Services.Security; +using SmartStore.Services.Configuration; +using System.IO; +using SmartStore.Core.Domain.Orders; +using Strube.Export.Models; +using SmartStore.Core.Domain.Security; + +namespace Strube.Export.Providers +{ + /// + /// Provider for Export Order Infos without Prices as CSV File + /// + [SystemName("Strube.OrdersExportCSV")] + [FriendlyName("Strube Full Order csv-Export")] + [DisplayOrder(1)] + [ExportFeatures(Features = + ExportFeatures.CreatesInitialPublicDeployment | + ExportFeatures.CanOmitGroupedProducts | + ExportFeatures.CanProjectAttributeCombinations | + ExportFeatures.CanProjectDescription | + ExportFeatures.UsesSkuAsMpnFallback | + ExportFeatures.OffersBrandFallback | + ExportFeatures.UsesSpecialPrice | + ExportFeatures.UsesAttributeCombination | + ExportFeatures.CanOmitCompletionMail)] + public class OrderFullCsvProvider : ExportProviderBase + { + private readonly IEncryptionService _encryptionService; + private readonly ISettingService _settingService; + private readonly string _encryptionKey; + + public OrderFullCsvProvider(IEncryptionService encryptionService, ISettingService settingService) + { + _encryptionService = encryptionService; + _settingService = settingService; + var securitySettings = _settingService.LoadSetting(); + _encryptionKey = securitySettings.EncryptionKey; + } + + public override ExportEntityType EntityType + { + get { return ExportEntityType.Order; } + } + + public static string SystemName + { + get { return "Strube.OrdersExportCSV"; } + } + + public override string FileExtension + { + get { return "txt"; } + } + + protected override void Export(ExportExecuteContext context) + { + dynamic currency = context.Currency; + //string _FormatString = "{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12};{13}"; + + //Create Streamwriter + StreamWriter _sw = new StreamWriter(context.DataStream); + //Add Header Line + //_sw.WriteLine(String.Format(_FormatString, + // "ID", + // "OrderId", + // "Comment", + // "Company", + // "Name", + // "Surname", + // "Address1", + // "Address2", + // "Zip-Code", + // "City", + // "Country", + // "ItemId", + // "Description", + // "Count")); + _sw.WriteLine(new OrderDetail().GetCSVHeader()); + // export the lines + while (context.Abort==DataExchangeAbortion.None && context.DataSegmenter.ReadNextSegment()) + { + var segment = context.DataSegmenter.CurrentSegment; + foreach (dynamic order in segment) + { + Order orderEntity = order.Entity; + List orderItem = orderEntity.OrderItems.ToList(); + + if (context.Abort!= DataExchangeAbortion.None) + { + break; + } + + try + { + foreach (OrderItem item in orderItem) + { + OrderDetail orderDetail = new OrderDetail(item,_encryptionService,_encryptionKey); + _sw.WriteLine(orderDetail.GetCSVLine()); + //Product itemProduct = item.Product; + //_sw.WriteLine(String.Format(_FormatString, + // orderEntity.OrderGuid, + // orderEntity.GetOrderNumber(), + // orderEntity.CustomerOrderComment, + // orderEntity.ShippingAddress.Company, + // orderEntity.ShippingAddress.LastName, + // orderEntity.ShippingAddress.FirstName, + // orderEntity.ShippingAddress.Address1, + // orderEntity.ShippingAddress.Address2, + // orderEntity.ShippingAddress.ZipPostalCode, + // orderEntity.ShippingAddress.City, + // orderEntity.ShippingAddress.Country.Name, + // itemProduct.Sku, + // itemProduct.Name, + // item.Quantity + // )) ; + + ++context.RecordsSucceeded; + + } + } + catch(Exception ex) + { + context.RecordException(ex, orderEntity.Id); + } + } + } + _sw.Flush(); + //throw new NotImplementedException(); + } + + //public override ExportConfigurationInfo ConfigurationInfo + //{ + // get { return null; } + //} + + public override void OnExecuted(ExportExecuteContext context) + { + + } + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Providers/OrderFullXlsxProvider.cs b/src/Plugins/Strube.Export/Providers/OrderFullXlsxProvider.cs new file mode 100644 index 0000000000..826065dc6d --- /dev/null +++ b/src/Plugins/Strube.Export/Providers/OrderFullXlsxProvider.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using SmartStore.Collections; +using SmartStore.Core.Domain.Catalog; +using SmartStore.Core.Domain.DataExchange; +using SmartStore.Core.Domain.Directory; +using SmartStore.Core.Localization; +using SmartStore.Core.Logging; +using SmartStore.Core.Plugins; +using SmartStore.Services; +using SmartStore.Services.Catalog; +using SmartStore.Services.DataExchange.Export; +using SmartStore.Services.Directory; +using SmartStore.Services.Localization; +using SmartStore.Services.Configuration; +using SmartStore.Services.Security; +using System.IO; +using SmartStore.Core.Domain.Orders; +using OfficeOpenXml; +using Strube.Export.Models; +using SmartStore.Core.Domain.Security; + +namespace Strube.Export.Providers +{ + /// + /// Provider for Export Order Infos without Prices as XLSX File + /// + [SystemName("Strube.OrdersExportXLSX")] + [FriendlyName("Strube Full Order xlsx-Export")] + [DisplayOrder(2)] + [ExportFeatures(Features = + ExportFeatures.CreatesInitialPublicDeployment | + ExportFeatures.CanOmitGroupedProducts | + ExportFeatures.CanProjectAttributeCombinations | + ExportFeatures.CanProjectDescription | + ExportFeatures.UsesSkuAsMpnFallback | + ExportFeatures.OffersBrandFallback | + ExportFeatures.UsesSpecialPrice | + ExportFeatures.UsesAttributeCombination | + ExportFeatures.CanOmitCompletionMail)] + public class OrderFullXlsxProvider: ExportProviderBase + { + private readonly IEncryptionService _encryptionService; + private readonly ISettingService _settingService; + private readonly string _encryptionKey; + + public OrderFullXlsxProvider(IEncryptionService encryptionService, ISettingService settingService) + { + _encryptionService = encryptionService; + _settingService = settingService; + var securitySettings = _settingService.LoadSetting(); + _encryptionKey = securitySettings.EncryptionKey; + } + + public override ExportEntityType EntityType + { + get { return ExportEntityType.Order; } + } + + public static string SystemName + { + get { return "Strube.OrdersExportXLSX"; } + } + + public override string FileExtension + { + get { return "xlsx"; } + } + + protected override void Export(ExportExecuteContext context) + { + dynamic currency = context.Currency; + OrderDetails orderDetails = new OrderDetails(); + // convert the lines + while (context.Abort == DataExchangeAbortion.None && context.DataSegmenter.ReadNextSegment()) + { + var segment = context.DataSegmenter.CurrentSegment; + foreach (dynamic order in segment) + { + Order orderEntity = order.Entity; + List orderItem = orderEntity.OrderItems.ToList(); + + if (context.Abort != DataExchangeAbortion.None) + { + break; + } + + try + { + foreach (OrderItem item in orderItem) + { + OrderDetail tmp = new OrderDetail(item,_encryptionService,_encryptionKey); + orderDetails.Add(tmp); + ++context.RecordsSucceeded; + } + } + catch (Exception ex) + { + context.RecordException(ex, orderEntity.Id); + } + } + } + //create ExcelPackage + + using (ExcelPackage excelPackage = new ExcelPackage(context.DataStream)) + { + var workSheet = excelPackage.Workbook.Worksheets.Add( + DateTime.Now.Year.ToString() + + "_" + + DateTime.Now.Month.ToString() + + "_" + + DateTime.Now.Day.ToString() + + "_" + + DateTime.Now.Hour.ToString() + + "_" + + DateTime.Now.Minute.ToString()); + workSheet.Cells["A1"].LoadFromCollection(orderDetails, true, OfficeOpenXml.Table.TableStyles.Medium13); + excelPackage.Workbook.Properties.Company = "Strube D&S GmbH"; + excelPackage.Workbook.Properties.Author = "Strube Web Shop"; + excelPackage.Save(); + } + + } + + //public override ExportConfigurationInfo ConfigurationInfo + //{ + // get { return null; } + //} + + public override void OnExecuted(ExportExecuteContext context) + { + + } + + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/RouteProvider.cs b/src/Plugins/Strube.Export/RouteProvider.cs new file mode 100644 index 0000000000..68452b10d5 --- /dev/null +++ b/src/Plugins/Strube.Export/RouteProvider.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Strube.Export +{ + public class RouteProvider + { + } +} \ No newline at end of file diff --git a/src/Plugins/Strube.Export/Strube.Export.csproj b/src/Plugins/Strube.Export/Strube.Export.csproj new file mode 100644 index 0000000000..f52aa8ff4a --- /dev/null +++ b/src/Plugins/Strube.Export/Strube.Export.csproj @@ -0,0 +1,218 @@ + + + + + + Debug + AnyCPU + + + 2.0 + {30E0CED9-57C7-4DDD-ACBB-722104BA4246} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Strube.Export + Strube.Export + v4.7.2 + true + + 44371 + + + + + + + + + + true + full + false + ..\..\Presentation\SmartStore.Web\Plugins\Strube.Export\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\..\packages\Autofac.5.2.0\lib\net461\Autofac.dll + + + ..\..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\packages\EPPlus.4.5.3.1\lib\net40\EPPlus.dll + + + ..\..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + ..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + + + + + + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + + + ..\..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll + + + ..\..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll + + + ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll + + + + + + + + + + + + Always + + + Always + + + + + + + + + + + + + + + + + + web.config + Always + + + web.config + Always + + + + + + + + + + + + + {6bda8332-939f-45b7-a25e-7a797260ae59} + SmartStore.Core + + + {ccd7f2c9-6a2c-4cf0-8e89-076b8fc0f144} + SmartStore.Data + + + {210541ad-f659-47da-8763-16f36c5cd2f4} + SmartStore.Services + + + {75fd4163-333c-4dd5-854d-2ef294e45d94} + SmartStore.Web.Framework + + + {4f1f649c-1020-45be-a487-f416d9297ff3} + SmartStore.Web + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 23030 + / + https://localhost:44371/ + False + False + + + False + + + + + + + Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/Strube.Export/packages.config b/src/Plugins/Strube.Export/packages.config new file mode 100644 index 0000000000..3ce99c347c --- /dev/null +++ b/src/Plugins/Strube.Export/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/Strube.Export/web.Debug.config b/src/Plugins/Strube.Export/web.Debug.config new file mode 100644 index 0000000000..f01fcc5c0f --- /dev/null +++ b/src/Plugins/Strube.Export/web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/Strube.Export/web.Release.config b/src/Plugins/Strube.Export/web.Release.config new file mode 100644 index 0000000000..86c687b229 --- /dev/null +++ b/src/Plugins/Strube.Export/web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/Strube.Export/web.config b/src/Plugins/Strube.Export/web.config new file mode 100644 index 0000000000..544a30f8ea --- /dev/null +++ b/src/Plugins/Strube.Export/web.config @@ -0,0 +1,173 @@ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Presentation/SmartStore.Web/Administration/Views/Order/ShipmentDetails.Print.cshtml b/src/Presentation/SmartStore.Web/Administration/Views/Order/ShipmentDetails.Print.cshtml index 2fc538270c..50dadba48f 100644 --- a/src/Presentation/SmartStore.Web/Administration/Views/Order/ShipmentDetails.Print.cshtml +++ b/src/Presentation/SmartStore.Web/Administration/Views/Order/ShipmentDetails.Print.cshtml @@ -50,6 +50,10 @@
@Html.Raw(shipment.FormattedShippingAddress) +

+ @shipment.ShippingAddress.Email
+ @shipment.ShippingAddress.PhoneNumber +

@@ -115,7 +119,7 @@ @T("PDFPackagingSlip.Gtin") } @T("PDFPackagingSlip.QTY") - @T("PDFPackagingSlip.Weight") + @*@T("PDFPackagingSlip.Weight")*@ @foreach (var shipmentItem in shipment.Items) @@ -162,9 +166,9 @@ @item.QuantityInThisShipment - + @* @item.ItemWeight - + *@ } diff --git a/src/Presentation/SmartStore.Web/Views/Common/Partials/CurrencySelector.cshtml b/src/Presentation/SmartStore.Web/Views/Common/Partials/CurrencySelector.cshtml index 20cba38565..bc377d3fce 100644 --- a/src/Presentation/SmartStore.Web/Views/Common/Partials/CurrencySelector.cshtml +++ b/src/Presentation/SmartStore.Web/Views/Common/Partials/CurrencySelector.cshtml @@ -8,7 +8,8 @@ @if (Model.AvailableCurrencies.Count > 1) { var webHelper = EngineContext.Current.Resolve(); - var activeCurr = Model.AvailableCurrencies.Where(x => x.Id == Model.CurrentCurrencyId).FirstOrDefault(); + //var activeCurr = Model.AvailableCurrencies.Where(x => x.Id == Model.CurrentCurrencyId).FirstOrDefault(); + var activeCurr = Model.AvailableCurrencies.Where(x => x.Id == Model.CurrentCurrencyId).FirstOrDefault() ?? Model.AvailableCurrencies.FirstOrDefault();