Skip to content

Commit dc7d4e4

Browse files
committed
An import file is mandatory for creating an import profile (to specify the file format).
Allow to upload further import files while editing a profile (because we allow to export data in multiple files).
1 parent 8619c2e commit dc7d4e4

17 files changed

Lines changed: 217 additions & 292 deletions

File tree

src/Libraries/SmartStore.Core/Domain/DataExchange/ImportProfile.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public class ImportProfile : BaseEntity
1515
/// </summary>
1616
public string FolderName { get; set; }
1717

18+
/// <summary>
19+
/// The name of the initially uploaded import file
20+
/// </summary>
21+
public string FileName { get; set; }
22+
1823
/// <summary>
1924
/// The identifier of the entity type
2025
/// </summary>
@@ -60,11 +65,6 @@ public ImportEntityType EntityType
6065
/// </summary>
6166
public string ColumnMapping { get; set; }
6267

63-
/// <summary>
64-
/// Whether to delete import files after import
65-
/// </summary>
66-
public bool Cleanup { get; set; }
67-
6868
/// <summary>
6969
/// The scheduling task identifier
7070
/// </summary>

src/Libraries/SmartStore.Data/Mapping/DataExchange/ImportProfileMap.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public ImportProfileMap()
1212

1313
this.Property(x => x.Name).IsRequired().HasMaxLength(100);
1414
this.Property(x => x.FolderName).IsRequired().HasMaxLength(100);
15+
this.Property(x => x.FileName).IsRequired().HasMaxLength(400);
1516
this.Property(x => x.FileTypeConfiguration).IsMaxLength();
1617
this.Property(x => x.ColumnMapping).IsMaxLength();
1718

src/Libraries/SmartStore.Data/Migrations/201512101150534_ImportFramework.resx

Lines changed: 0 additions & 126 deletions
This file was deleted.

src/Libraries/SmartStore.Data/Migrations/201512101150534_ImportFramework.Designer.cs renamed to src/Libraries/SmartStore.Data/Migrations/201512111134591_ImportFramework.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Libraries/SmartStore.Data/Migrations/201512101150534_ImportFramework.cs renamed to src/Libraries/SmartStore.Data/Migrations/201512111134591_ImportFramework.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ public override void Up()
1616
Id = c.Int(nullable: false, identity: true),
1717
Name = c.String(nullable: false, maxLength: 100),
1818
FolderName = c.String(nullable: false, maxLength: 100),
19+
FileName = c.String(nullable: false, maxLength: 400),
1920
EntityTypeId = c.Int(nullable: false),
2021
Enabled = c.Boolean(nullable: false),
2122
Skip = c.Int(nullable: false),
2223
Take = c.Int(nullable: false),
2324
FileTypeConfiguration = c.String(),
2425
ColumnMapping = c.String(),
25-
Cleanup = c.Boolean(nullable: false),
2626
SchedulingTaskId = c.Int(nullable: false),
2727
})
2828
.PrimaryKey(t => t.Id)
@@ -84,18 +84,6 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
8484
"Specifies the name of the import profile.",
8585
"Legt den Namen des Importprofils fest.");
8686

87-
builder.AddOrUpdate("Admin.DataExchange.Import.FolderName",
88-
"Folder name",
89-
"Ordnername",
90-
"Specifies the name of the folder where the import files are saved.",
91-
"Legt den Namen des Ordners fest, in den die Importdateien gespeichert werden.");
92-
93-
builder.AddOrUpdate("Admin.DataExchange.Import.Cleanup",
94-
"Clean up at the end",
95-
"Zum Schluss aufräumen",
96-
"Specifies whether to delete import files after an import.",
97-
"Legt fest, ob die Importdateien nach einem Import gelöscht werden sollen.");
98-
9987
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ImportEntityType.Product", "Product", "Produkt");
10088
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ImportEntityType.Customer", "Customer", "Kunde");
10189
builder.AddOrUpdate("Enums.SmartStore.Core.Domain.DataExchange.ImportEntityType.NewsLetterSubscription", "Newsletter Subscribers", "Newsletter Abonnenten");

src/Libraries/SmartStore.Data/Migrations/201512111134591_ImportFramework.resx

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

src/Libraries/SmartStore.Data/SmartStore.Data.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@
372372
<Compile Include="Migrations\201511271019577_ExportFramework3.Designer.cs">
373373
<DependentUpon>201511271019577_ExportFramework3.cs</DependentUpon>
374374
</Compile>
375-
<Compile Include="Migrations\201512101150534_ImportFramework.cs" />
376-
<Compile Include="Migrations\201512101150534_ImportFramework.Designer.cs">
377-
<DependentUpon>201512101150534_ImportFramework.cs</DependentUpon>
375+
<Compile Include="Migrations\201512111134591_ImportFramework.cs" />
376+
<Compile Include="Migrations\201512111134591_ImportFramework.Designer.cs">
377+
<DependentUpon>201512111134591_ImportFramework.cs</DependentUpon>
378378
</Compile>
379379
<Compile Include="Setup\Builder\PermissionMigrator.cs" />
380380
<Compile Include="Setup\Builder\SettingsBuilder.cs" />
@@ -699,8 +699,8 @@
699699
<EmbeddedResource Include="Migrations\201511271019577_ExportFramework3.resx">
700700
<DependentUpon>201511271019577_ExportFramework3.cs</DependentUpon>
701701
</EmbeddedResource>
702-
<EmbeddedResource Include="Migrations\201512101150534_ImportFramework.resx">
703-
<DependentUpon>201512101150534_ImportFramework.cs</DependentUpon>
702+
<EmbeddedResource Include="Migrations\201512111134591_ImportFramework.resx">
703+
<DependentUpon>201512111134591_ImportFramework.cs</DependentUpon>
704704
</EmbeddedResource>
705705
<EmbeddedResource Include="Sql\Indexes.sql" />
706706
<EmbeddedResource Include="Sql\StoredProcedures.sql" />

src/Libraries/SmartStore.Services/DataExchange/Import/IImportProfileService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ public interface IImportProfileService
99
/// <summary>
1010
/// Inserts an import profile
1111
/// </summary>
12+
/// <param name="fileName">Name of the import file</param>
1213
/// <param name="name">Profile name</param>
1314
/// <param name="entityType"></param>
1415
/// <returns>Inserted import profile</returns>
15-
ImportProfile InsertImportProfile(string name, ImportEntityType entityType);
16+
ImportProfile InsertImportProfile(string fileName, string name, ImportEntityType entityType);
1617

1718
/// <summary>
1819
/// Updates an import profile

src/Libraries/SmartStore.Services/DataExchange/Import/ImportExtensions.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,22 @@ public static string GetImportFolder(this ImportProfile profile, bool content =
3030
/// <returns>List of file paths</returns>
3131
public static List<string> GetImportFiles(this ImportProfile profile)
3232
{
33+
var result = new List<string>();
3334
var folder = profile.GetImportFolder(true);
3435

3536
if (System.IO.Directory.Exists(folder))
3637
{
37-
return System.IO.Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)
38+
var initialImportFile = Path.Combine(folder, profile.FileName);
39+
40+
result.Add(initialImportFile);
41+
42+
result.AddRange(System.IO.Directory.EnumerateFiles(folder, "*", SearchOption.TopDirectoryOnly)
43+
.Where(x => !x.IsCaseInsensitiveEqual(initialImportFile))
3844
.OrderBy(x => x)
39-
.ToList();
45+
.ToList());
4046
}
4147

42-
return new List<string>();
48+
return result;
4349
}
4450

4551
/// <summary>

src/Libraries/SmartStore.Services/DataExchange/Import/ImportProfileService.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public ImportProfileService(
2929
_dataExchangeSettings = dataExchangeSettings;
3030
}
3131

32-
public virtual ImportProfile InsertImportProfile(string name, ImportEntityType entityType)
32+
public virtual ImportProfile InsertImportProfile(string fileName, string name, ImportEntityType entityType)
3333
{
34+
Guard.ArgumentNotEmpty(() => fileName);
3435
Guard.ArgumentNotEmpty(() => name);
3536

3637
var task = new ScheduleTask
@@ -49,6 +50,7 @@ public virtual ImportProfile InsertImportProfile(string name, ImportEntityType e
4950
var profile = new ImportProfile
5051
{
5152
Name = name,
53+
FileName = fileName,
5254
EntityType = entityType,
5355
Enabled = true,
5456
SchedulingTaskId = task.Id
@@ -73,10 +75,6 @@ public virtual void UpdateImportProfile(ImportProfile profile)
7375
if (profile == null)
7476
throw new ArgumentNullException("profile");
7577

76-
profile.FolderName = profile.FolderName
77-
.ToValidPath()
78-
.Truncate(_dataExchangeSettings.MaxFileNameLength);
79-
8078
_importProfileRepository.Update(profile);
8179

8280
_eventPublisher.EntityUpdated(profile);

0 commit comments

Comments
 (0)