From e8c4d38447420b66decb0f7c51b679db529cd221 Mon Sep 17 00:00:00 2001 From: Kirill Tairov Date: Wed, 17 Jan 2018 00:10:47 +0200 Subject: [PATCH 1/2] UIOMatic Delimiter from webConfig --- .../Configuration/UIOMaticConfiguration.cs | 28 +++++++++++++++++++ .../Controllers/ExportController.cs | 8 +++++- .../UIOMaticAddons.Export.csproj | 1 + src/UIOMaticAddons.Export/Web.config | 1 + .../bin/UIOMaticAddons.Export.dll.config | 1 + 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs diff --git a/src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs b/src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs new file mode 100644 index 0000000..b999551 --- /dev/null +++ b/src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Web; + +namespace UIOMaticAddons.Export.Configuration +{ + public class UIOMaticConfiguration + { + public static UIOMaticConfiguration FromWebConfig(NameValueCollection nameValueCollection) + { + try + { + return new UIOMaticConfiguration + { + Delimiter = nameValueCollection["DelimiterKey"] + }; + } + catch (Exception ex) + { + throw new ApplicationException("Invalid settings in web.config", ex); + } + } + + public string Delimiter { get; set; } + } +} \ No newline at end of file diff --git a/src/UIOMaticAddons.Export/Controllers/ExportController.cs b/src/UIOMaticAddons.Export/Controllers/ExportController.cs index b6025af..263e73f 100644 --- a/src/UIOMaticAddons.Export/Controllers/ExportController.cs +++ b/src/UIOMaticAddons.Export/Controllers/ExportController.cs @@ -7,11 +7,17 @@ using Umbraco.Core.IO; using Umbraco.Web.Editors; using System.Text; +using UIOMaticAddons.Export.Configuration; namespace UIOMaticAddons.Export.Controllers { public class ExportController: UmbracoAuthorizedJsonController { + private readonly UIOMaticConfiguration _config; + public ExportController(UIOMaticConfiguration config) + { + _config = config; + } public object GetExport(string typeAlias) { var guid = Guid.NewGuid(); @@ -27,7 +33,7 @@ public object GetExport(string typeAlias) var data = os.GetAll(UIOMatic.Helper.GetUIOMaticTypeByAlias(typeAlias)); - csv.Configuration.Delimiter = ";"; + csv.Configuration.Delimiter = _config.Delimiter; //csv.Configuration.QuoteAllFields = true; csv.Configuration.HasHeaderRecord = true; diff --git a/src/UIOMaticAddons.Export/UIOMaticAddons.Export.csproj b/src/UIOMaticAddons.Export/UIOMaticAddons.Export.csproj index add9253..fb45eaa 100644 --- a/src/UIOMaticAddons.Export/UIOMaticAddons.Export.csproj +++ b/src/UIOMaticAddons.Export/UIOMaticAddons.Export.csproj @@ -485,6 +485,7 @@ + diff --git a/src/UIOMaticAddons.Export/Web.config b/src/UIOMaticAddons.Export/Web.config index ee6285c..7bb0127 100644 --- a/src/UIOMaticAddons.Export/Web.config +++ b/src/UIOMaticAddons.Export/Web.config @@ -48,6 +48,7 @@ + diff --git a/src/UIOMaticAddons.Export/bin/UIOMaticAddons.Export.dll.config b/src/UIOMaticAddons.Export/bin/UIOMaticAddons.Export.dll.config index ee6285c..7bb0127 100644 --- a/src/UIOMaticAddons.Export/bin/UIOMaticAddons.Export.dll.config +++ b/src/UIOMaticAddons.Export/bin/UIOMaticAddons.Export.dll.config @@ -48,6 +48,7 @@ + From 3ece581842f464b054308b6bb125a5ba8ca67be1 Mon Sep 17 00:00:00 2001 From: Kirill Tairov Date: Wed, 17 Jan 2018 10:39:56 +0200 Subject: [PATCH 2/2] remame delimiterKey to iomatic:DelimeterKey --- .../Configuration/UIOMaticConfiguration.cs | 2 +- src/UIOMaticAddons.Export/Web.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs b/src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs index b999551..4da91a5 100644 --- a/src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs +++ b/src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs @@ -14,7 +14,7 @@ public static UIOMaticConfiguration FromWebConfig(NameValueCollection nameValueC { return new UIOMaticConfiguration { - Delimiter = nameValueCollection["DelimiterKey"] + Delimiter = nameValueCollection["iomatic:DelimeterKey"] }; } catch (Exception ex) diff --git a/src/UIOMaticAddons.Export/Web.config b/src/UIOMaticAddons.Export/Web.config index 7bb0127..0911ee6 100644 --- a/src/UIOMaticAddons.Export/Web.config +++ b/src/UIOMaticAddons.Export/Web.config @@ -48,7 +48,7 @@ - +