Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIOMatic Delimiter from webConfig #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/UIOMaticAddons.Export/Configuration/UIOMaticConfiguration.cs
Original file line number Diff line number Diff line change
@@ -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["iomatic:DelimeterKey"]
};
}
catch (Exception ex)
{
throw new ApplicationException("Invalid settings in web.config", ex);
}
}

public string Delimiter { get; set; }
}
}
8 changes: 7 additions & 1 deletion src/UIOMaticAddons.Export/Controllers/ExportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/UIOMaticAddons.Export/UIOMaticAddons.Export.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="App.cs" />
<Compile Include="Configuration\UIOMaticConfiguration.cs" />
<Compile Include="Controllers\ExportController.cs" />
<Compile Include="ExportAction.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/UIOMaticAddons.Export/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
<add key="Umbraco.ModelsBuilder.Enable" value="true" />
<add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
<add key="iomatic:DelimeterKey" value=";" />
</appSettings>
<connectionStrings>
<remove name="umbracoDbDSN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
<add key="Umbraco.ModelsBuilder.Enable" value="true" />
<add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
<add key="DelimiterKey" value=";" />
</appSettings>
<connectionStrings>
<remove name="umbracoDbDSN" />
Expand Down