Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor changes

KrzysztofPajak02455a06b43b
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs b/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
index 0c110363a..aaa1c413a 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
@@ -303,7 +303,7 @@ namespace Grand.Business.System.Services.Installation
await customerManagerService.ChangePassword(new ChangePasswordRequest(defaultUserEmail, false, PasswordFormat.Hashed, defaultUserPassword));
}
- private async Task CreateIndexes(MongoDBContext dbContext)
+ private async Task CreateIndexes(MongoDBContext dbContext, DataSettings dataSettings)
{
//version
await dbContext.CreateIndex(_versionRepository, OrderBuilder<GrandNodeVersion>.Create().Ascending(x => x.DataBaseVersion), "DataBaseVersion", true);
@@ -638,14 +638,22 @@ namespace Grand.Business.System.Services.Installation
await dbContext.CreateIndex(_courseRepository, OrderBuilder<Course>.Create().Ascending(x => x.CreatedOnUtc), "CreatedOnUtc");
await dbContext.CreateIndex(_courseLevelRepository, OrderBuilder<CourseLevel>.Create().Ascending(x => x.DisplayOrder), "DisplayOrder");
+ //if(dataSettings.DbProvider == DbProvider.CosmosDB)
+ //{
+ // //
+ // //db.fs.chunks.createIndex({'n': 1})
+ // //To Fix problem with download files from GridFSBucket
+ // //
+ //}
+
}
private async Task CreateTables(string local)
{
try
{
- var connectionString = DataSettingsManager.LoadSettings().ConnectionString;
- var dbContext = new MongoDBContext(connectionString);
+ var dataSettings = DataSettingsManager.LoadSettings();
+ var dbContext = new MongoDBContext(dataSettings.ConnectionString);
var typeSearcher = _serviceProvider.GetRequiredService<ITypeSearcher>();
var q = typeSearcher.GetAssemblies().FirstOrDefault(x => x.GetName().Name == "Grand.Domain");
@@ -655,7 +663,7 @@ namespace Grand.Business.System.Services.Installation
if (item.BaseType != null && item.IsClass && item.BaseType == typeof(BaseEntity))
await dbContext.CreateTable(item.Name, local);
}
- await CreateIndexes(dbContext);
+ await CreateIndexes(dbContext, dataSettings);
}
catch (Exception ex)
diff --git a/src/Core/Grand.Domain/Data/Mongo/MongoDBContext.cs b/src/Core/Grand.Domain/Data/Mongo/MongoDBContext.cs
index f37ba0725..398dd35f5 100644
--- a/src/Core/Grand.Domain/Data/Mongo/MongoDBContext.cs
+++ b/src/Core/Grand.Domain/Data/Mongo/MongoDBContext.cs
@@ -49,7 +49,7 @@ namespace Grand.Domain.Data.Mongo
public async Task<byte[]> GridFSBucketDownload(string id)
{
var bucket = new MongoDB.Driver.GridFS.GridFSBucket(_database);
- var binary = await bucket.DownloadAsBytesAsync(new ObjectId(id), new MongoDB.Driver.GridFS.GridFSDownloadOptions() { CheckMD5 = true, Seekable = true });
+ var binary = await bucket.DownloadAsBytesAsync(new ObjectId(id), new MongoDB.Driver.GridFS.GridFSDownloadOptions() { CheckMD5 = true});
return binary;
}