private async Task From470To480() { #region Install String resources await InstallStringResources("EN_470_480.nopres.xml"); #endregion #region Update customer settings var _settingService = _serviceProvider.GetRequiredService <ISettingService>(); var customerSettings = _serviceProvider.GetRequiredService <CustomerSettings>(); customerSettings.HideSubAccountsTab = true; await _settingService.SaveSetting(customerSettings); #endregion #region Update permissions - Actions IPermissionProvider provider = new StandardPermissionProvider(); //install new permissions await _mediator.Send(new InstallNewPermissionsCommand() { PermissionProvider = provider }); var permissions = provider.GetPermissions(); var permissionService = _serviceProvider.GetRequiredService <IPermissionService>(); foreach (var permission in permissions) { var p = await permissionService.GetPermissionRecordBySystemName(permission.SystemName); if (p != null) { p.Actions = permission.Actions; await permissionService.UpdatePermissionRecord(p); } } #endregion #region Update cancel order Scheduled Task var tasks = _serviceProvider.GetRequiredService <IRepository <ScheduleTask> >(); var cancelOrderTask = new ScheduleTask { ScheduleTaskName = "Cancel unpaid and pending orders", Type = "Grand.Services.Tasks.CancelOrderScheduledTask, Grand.Services", Enabled = false, StopOnError = false, TimeInterval = 1440 }; await tasks.InsertAsync(cancelOrderTask); #endregion }
public async Task <IActionResult> PermissionsSave(IFormCollection form, bool install) { if (!await _permissionService.Authorize(StandardPermissionProvider.ManageAcl)) { return(AccessDeniedView()); } if (!install) { var permissionRecords = await _permissionService.GetAllPermissionRecords(); var customerRoles = await _customerService.GetAllCustomerRoles(showHidden : true); foreach (var cr in customerRoles) { string formKey = "allow_" + cr.Id; var permissionRecordSystemNamesToRestrict = form[formKey].ToString() != null ? form[formKey].ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() : new List <string>(); foreach (var pr in permissionRecords) { bool allow = permissionRecordSystemNamesToRestrict.Contains(pr.SystemName); if (allow) { if (pr.CustomerRoles.FirstOrDefault(x => x == cr.Id) == null) { pr.CustomerRoles.Add(cr.Id); await _permissionService.UpdatePermissionRecord(pr); } } else { if (pr.CustomerRoles.FirstOrDefault(x => x == cr.Id) != null) { pr.CustomerRoles.Remove(cr.Id); await _permissionService.UpdatePermissionRecord(pr); } } } } SuccessNotification(_localizationService.GetResource("Admin.Configuration.ACL.Updated")); } else { IPermissionProvider provider = new StandardPermissionProvider(); await _mediator.Send(new InstallNewPermissionsCommand() { PermissionProvider = provider }); SuccessNotification(_localizationService.GetResource("Admin.Configuration.ACL.Installed")); } return(RedirectToAction("Permissions")); }
private async Task From470To480() { #region Install String resources await InstallStringResources("EN_470_480.nopres.xml"); #endregion #region Update customer settings var _settingService = _serviceProvider.GetRequiredService <ISettingService>(); var customerSettings = _serviceProvider.GetRequiredService <CustomerSettings>(); customerSettings.HideSubAccountsTab = true; await _settingService.SaveSetting(customerSettings); #endregion #region Update permissions - Actions IPermissionProvider provider = new StandardPermissionProvider(); var permissions = provider.GetPermissions(); var permissionService = _serviceProvider.GetRequiredService <IPermissionService>(); foreach (var permission in permissions) { var p = await permissionService.GetPermissionRecordBySystemName(permission.SystemName); if (p != null) { p.Actions = permission.Actions; await permissionService.UpdatePermissionRecord(p); } } #endregion }
private async Task From450To460() { #region Install String resources await InstallStringResources("EN_450_460.nopres.xml"); #endregion #region Add new customer action - paid order var customerActionType = _serviceProvider.GetRequiredService <IRepository <CustomerActionType> >(); await customerActionType.InsertAsync( new CustomerActionType() { Name = "Paid order", SystemKeyword = "PaidOrder", Enabled = false, ConditionType = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13 } }); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); await _mediator.Send(new InstallNewPermissionsCommand() { PermissionProvider = provider }); #endregion #region Activity Log Type var _activityLogTypeRepository = _serviceProvider.GetRequiredService <IRepository <ActivityLogType> >(); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "AddNewDocument", Enabled = false, Name = "Add a new document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "AddNewDocumentType", Enabled = false, Name = "Add a new document type" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "EditDocument", Enabled = false, Name = "Edit document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "EditDocumentType", Enabled = false, Name = "Edit document type" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "DeleteDocument", Enabled = false, Name = "Delete document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "DeleteDocumentType", Enabled = false, Name = "Delete document type" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "PublicStore.ViewCourse", Enabled = false, Name = "Public store. View a course" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "PublicStore.ViewLesson", Enabled = false, Name = "Public store. View a lesson" }); #endregion #region Update customer settings var _settingService = _serviceProvider.GetRequiredService <ISettingService>(); var customerSettings = _serviceProvider.GetRequiredService <CustomerSettings>(); customerSettings.HideDocumentsTab = true; customerSettings.HideReviewsTab = false; customerSettings.HideCoursesTab = true; await _settingService.SaveSetting(customerSettings); #endregion #region Update catalog settings var catalogSettings = _serviceProvider.GetRequiredService <CatalogSettings>(); catalogSettings.PeriodBestsellers = 6; await _settingService.SaveSetting(catalogSettings); #endregion #region Update topics IRepository <Topic> _topicRepository = _serviceProvider.GetRequiredService <IRepository <Topic> >(); foreach (var topic in _topicRepository.Table) { topic.Published = true; _topicRepository.Update(topic); } #endregion #region Update url seo to lowercase IRepository <UrlRecord> _urlRecordRepository = _serviceProvider.GetRequiredService <IRepository <UrlRecord> >(); foreach (var urlrecord in _urlRecordRepository.Table) { urlrecord.Slug = urlrecord.Slug.ToLowerInvariant(); _urlRecordRepository.Update(urlrecord); } #endregion #region Update product - rename fields var renameFields = Builders <object> .Update .Rename("IsTelecommunicationsOrBroadcastingOrElectronicServices", "IsTele"); var dbContext = _serviceProvider.GetRequiredService <IMongoDatabase>(); await dbContext.GetCollection <object>(typeof(Product).Name).UpdateManyAsync(new BsonDocument(), renameFields); #endregion }
private async Task From440To450() { #region Install String resources await InstallStringResources("EN_440_450.nopres.xml"); #endregion #region Update task var tasks = _serviceProvider.GetRequiredService <IRepository <ScheduleTask> >(); foreach (var task in tasks.Table) { if (task.TimeInterval == 0) { task.TimeInterval = 1440; await tasks.UpdateAsync(task); } if (task.Type == "Grand.Services.Tasks.ClearLogScheduleTask") { task.Type = "Grand.Services.Tasks.ClearLogScheduleTask, Grand.Services"; await tasks.UpdateAsync(task); } } #endregion #region Update shipments - storeId var shipments = _serviceProvider.GetRequiredService <IRepository <Shipment> >(); var orders = _serviceProvider.GetRequiredService <IRepository <Order> >(); foreach (var shipment in shipments.Table) { var order = orders.Table.Where(x => x.Id == shipment.OrderId).FirstOrDefault(); if (order != null) { shipment.StoreId = order.StoreId; await shipments.UpdateAsync(shipment); } } #endregion #region Update topics - rename fields var renameFields = Builders <object> .Update .Rename("IncludeInFooterColumn1", "IncludeInFooterRow1") .Rename("IncludeInFooterColumn2", "IncludeInFooterRow2") .Rename("IncludeInFooterColumn3", "IncludeInFooterRow3"); var dbContext = _serviceProvider.GetRequiredService <IMongoDatabase>(); await dbContext.GetCollection <object>(typeof(Topic).Name).UpdateManyAsync(new BsonDocument(), renameFields); #endregion #region Update order - primary currency code var pc = await _serviceProvider.GetRequiredService <ICurrencyService>().GetPrimaryStoreCurrency(); var updateOrder = Builders <Order> .Update .Set(x => x.PrimaryCurrencyCode, pc.CurrencyCode); var orderRepository = _serviceProvider.GetRequiredService <IRepository <Order> >(); await orderRepository.Collection.UpdateManyAsync(new BsonDocument(), updateOrder); #endregion #region Insert new system customer role - staff var crStaff = new CustomerRole { Name = "Staff", Active = true, IsSystemRole = true, SystemName = SystemCustomerRoleNames.Staff, }; await _serviceProvider.GetRequiredService <IRepository <CustomerRole> >().InsertAsync(crStaff); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); await _mediator.Send(new InstallNewPermissionsCommand() { PermissionProvider = provider }); #endregion }
private async Task From430To440() { #region Install String resources await InstallStringResources("430_440.nopres.xml"); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); await _mediator.Send(new InstallPermissionsCommand() { PermissionProvider = provider }); #endregion #region Update tags on the products var productTagService = _serviceProvider.GetRequiredService <IProductTagService>(); var productRepository = _serviceProvider.GetRequiredService <IRepository <Product> >(); foreach (var tag in await productTagService.GetAllProductTags()) { var builder = Builders <Product> .Filter; var filter = new BsonDocument { new BsonElement("ProductTags", tag.Id) }; var update = Builders <Product> .Update .Set(x => x.ProductTags.ElementAt(-1), tag.Name); await productRepository.Collection.UpdateManyAsync(filter, update); tag.SeName = SeoExtensions.GetSeName(tag.Name, false, false); await productTagService.UpdateProductTag(tag); } #endregion #region User api _serviceProvider.GetRequiredService <IRepository <UserApi> >().Collection.Indexes.CreateOne(new CreateIndexModel <UserApi>((Builders <UserApi> .IndexKeys.Ascending(x => x.Email)), new CreateIndexOptions() { Name = "Email", Unique = true, Background = true })); #endregion #region Update message templates (tokens) string ReplaceValue(string value) { string Evaluator(Match match) { return($"{{{{{match.Value.Replace("%", "")}}}}}"); } var evaluator = new MatchEvaluator(Evaluator); return(Regex.Replace(value, @"%([A-Za-z0-9_.]*?)%", new MatchEvaluator(Evaluator))); } var orderProducts = File.ReadAllText(CommonHelper.MapPath("~/App_Data/Upgrade/Order.Products.txt")); var shipmentProducts = File.ReadAllText(CommonHelper.MapPath("~/App_Data/Upgrade/Shipment.Products.txt")); var messagetemplateService = _serviceProvider.GetRequiredService <Grand.Services.Messages.IMessageTemplateService>(); var messagetemplates = await messagetemplateService.GetAllMessageTemplates(string.Empty); foreach (var messagetemplate in messagetemplates) { messagetemplate.Subject = ReplaceValue(messagetemplate.Subject); if (messagetemplate.Body.Contains("%Order.Product(s)%")) { messagetemplate.Body = messagetemplate.Body.Replace("%Order.Product(s)%", orderProducts); } if (messagetemplate.Body.Contains("%Shipment.Product(s)%")) { messagetemplate.Body = messagetemplate.Body.Replace("%Shipment.Product(s)%", shipmentProducts); } messagetemplate.Body = ReplaceValue(messagetemplate.Body); await messagetemplateService.UpdateMessageTemplate(messagetemplate); } #endregion #region Insert message template var eaGeneral = _serviceProvider.GetRequiredService <IRepository <EmailAccount> >().Table.FirstOrDefault(); if (eaGeneral == null) { throw new Exception("Default email account cannot be loaded"); } var messageTemplates = new List <MessageTemplate> { new MessageTemplate { Name = "AuctionExpired.StoreOwnerNotification", Subject = "Your auction to product {{Product.Name}} has expired.", Body = "Hello, <br> Your auction to product {{Product.Name}} has expired without bid.", //this template is disabled by default IsActive = false, EmailAccountId = eaGeneral.Id, } }; await _serviceProvider.GetRequiredService <IRepository <MessageTemplate> >().InsertAsync(messageTemplates); #endregion }
private async Task From410To420() { var _settingService = _serviceProvider.GetRequiredService <ISettingService>(); #region Install String resources await InstallStringResources("EN_410_420.nopres.xml"); #endregion #region Update string resources var _localeStringResource = _serviceProvider.GetRequiredService <IRepository <LocaleStringResource> >(); await _localeStringResource.Collection.Find(new BsonDocument()).ForEachAsync(async(e) => { e.ResourceName = e.ResourceName.ToLowerInvariant(); await _localeStringResource.UpdateAsync(e); }); #endregion #region ActivityLog var _activityLogTypeRepository = _serviceProvider.GetRequiredService <IRepository <ActivityLogType> >(); await _activityLogTypeRepository.InsertAsync(new ActivityLogType() { SystemKeyword = "PublicStore.DeleteAccount", Enabled = false, Name = "Public store. Delete account" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "UpdateKnowledgebaseCategory", Enabled = true, Name = "Update knowledgebase category" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "CreateKnowledgebaseCategory", Enabled = true, Name = "Create knowledgebase category" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "DeleteKnowledgebaseCategory", Enabled = true, Name = "Delete knowledgebase category" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "CreateKnowledgebaseArticle", Enabled = true, Name = "Create knowledgebase article" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "UpdateKnowledgebaseArticle", Enabled = true, Name = "Update knowledgebase article" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "DeleteKnowledgebaseArticle", Enabled = true, Name = "Delete knowledgebase category" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "AddNewContactAttribute", Enabled = true, Name = "Add a new contact attribute" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "EditContactAttribute", Enabled = true, Name = "Edit a contact attribute" }); await _activityLogTypeRepository.InsertAsync(new ActivityLogType { SystemKeyword = "DeleteContactAttribute", Enabled = true, Name = "Delete a contact attribute" }); #endregion #region MessageTemplates var emailAccount = _serviceProvider.GetRequiredService <IRepository <EmailAccount> >().Table.FirstOrDefault(); if (emailAccount == null) { throw new Exception("Default email account cannot be loaded"); } var messageTemplates = new List <MessageTemplate> { new MessageTemplate { Name = "CustomerDelete.StoreOwnerNotification", Subject = "%Store.Name%. Customer has been deleted.", Body = "<p><a href=\"%Store.URL%\">%Store.Name%</a> ,<br />%Customer.FullName% (%Customer.Email%) has just deleted from your database. </p>", IsActive = true, EmailAccountId = emailAccount.Id, }, }; await _serviceProvider.GetRequiredService <IRepository <MessageTemplate> >().InsertAsync(messageTemplates); #endregion #region Install new Topics var defaultTopicTemplate = _serviceProvider.GetRequiredService <IRepository <TopicTemplate> >().Table.FirstOrDefault(tt => tt.Name == "Default template"); if (defaultTopicTemplate == null) { defaultTopicTemplate = _serviceProvider.GetRequiredService <IRepository <TopicTemplate> >().Table.FirstOrDefault(); } var knowledgebaseHomepageTopic = new Topic { SystemName = "KnowledgebaseHomePage", IncludeInSitemap = false, IsPasswordProtected = false, DisplayOrder = 1, Title = "", Body = "<p>Knowledgebase homepage. You can edit this in the admin site.</p>", TopicTemplateId = defaultTopicTemplate.Id }; var topicService = _serviceProvider.GetRequiredService <ITopicService>(); await topicService.InsertTopic(knowledgebaseHomepageTopic); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); await _mediator.Send(new InstallPermissionsCommand() { PermissionProvider = provider }); #endregion #region Knowledge settings var knowledgesettings = _serviceProvider.GetRequiredService <KnowledgebaseSettings>(); knowledgesettings.Enabled = false; knowledgesettings.AllowNotRegisteredUsersToLeaveComments = true; knowledgesettings.NotifyAboutNewArticleComments = false; await _settingService.SaveSetting(knowledgesettings); #endregion #region Push notifications settings var pushNotificationSettings = _serviceProvider.GetRequiredService <PushNotificationsSettings>(); pushNotificationSettings.Enabled = false; pushNotificationSettings.AllowGuestNotifications = true; await _settingService.SaveSetting(pushNotificationSettings); #endregion #region Knowledge table await _serviceProvider.GetRequiredService <IRepository <KnowledgebaseArticle> >().Collection.Indexes.CreateOneAsync(new CreateIndexModel <KnowledgebaseArticle>((Builders <KnowledgebaseArticle> .IndexKeys.Ascending(x => x.DisplayOrder)), new CreateIndexOptions() { Name = "DisplayOrder", Unique = false })); await _serviceProvider.GetRequiredService <IRepository <KnowledgebaseCategory> >().Collection.Indexes.CreateOneAsync(new CreateIndexModel <KnowledgebaseCategory>((Builders <KnowledgebaseCategory> .IndexKeys.Ascending(x => x.DisplayOrder)), new CreateIndexOptions() { Name = "DisplayOrder", Unique = false })); #endregion #region Update gift card IRepository <GiftCard> _giftCardRepository = _serviceProvider.GetRequiredService <IRepository <GiftCard> >(); foreach (var gift in _giftCardRepository.Table) { gift.GiftCardCouponCode = gift.GiftCardCouponCode.ToLowerInvariant(); _giftCardRepository.Update(gift); } #endregion }
private async Task From450To460() { #region Install String resources await InstallStringResources("EN_450_460.nopres.xml"); #endregion #region Add new customer action - paid order var customerActionType = _serviceProvider.GetRequiredService <IRepository <CustomerActionType> >(); await customerActionType.InsertAsync( new CustomerActionType() { Name = "Paid order", SystemKeyword = "PaidOrder", Enabled = false, ConditionType = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13 } }); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); await _serviceProvider.GetRequiredService <IPermissionService>().InstallNewPermissions(provider); #endregion #region Activity Log Type var _activityLogTypeRepository = _serviceProvider.GetRequiredService <IRepository <ActivityLogType> >(); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "AddNewDocument", Enabled = false, Name = "Add a new document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "AddNewDocumentType", Enabled = false, Name = "Add a new document type" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "EditDocument", Enabled = false, Name = "Edit document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "EditDocumentType", Enabled = false, Name = "Edit document type" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "DeleteDocument", Enabled = false, Name = "Delete document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "DeleteDocumentType", Enabled = false, Name = "Delete document type" }); #endregion #region Update customer settings var _settingService = _serviceProvider.GetRequiredService <ISettingService>(); var customerSettings = _serviceProvider.GetRequiredService <CustomerSettings>(); customerSettings.HideDocumentsTab = true; await _settingService.SaveSetting(customerSettings); #endregion }
private void From380To390() { #region Run scripts //var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory+"App_Data\\Upgrade\\", "UpgradeScript_380_390.js"); //string upgrade_script = File.ReadAllText(filePath); //var bscript = new BsonJavaScript(upgrade_script); //var operation = new EvalOperation(_versionRepository.Database.DatabaseNamespace, bscript, null); //var writeBinding = new WritableServerBinding(_versionRepository.Database.Client.Cluster); //operation.Execute(writeBinding, CancellationToken.None); #endregion #region Install String resources InstallStringResources("380_390.nopres.xml"); #endregion #region Install forum Vote var _forumPostVote = Grand.Core.Infrastructure.EngineContextExperimental.Current.Resolve <IRepository <ForumPostVote> >(); _forumPostVote.Collection.Indexes.DropAll(); _forumPostVote.Collection.Indexes.CreateOneAsync(Builders <ForumPostVote> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _forumPostVote.Collection.Indexes.CreateOneAsync(Builders <ForumPostVote> .IndexKeys.Ascending(x => x.ForumPostId).Ascending(x => x.CustomerId), new CreateIndexOptions() { Name = "Vote", Unique = true }); #endregion #region Install new task var shtask1 = new ScheduleTask { ScheduleTaskName = "Customer reminder - Completed order", Type = "Grand.Services.Tasks.CustomerReminderCompletedOrderScheduleTask, Grand.Services", Enabled = true, StopOnError = false, LastStartUtc = DateTime.MinValue, LastNonSuccessEndUtc = DateTime.MinValue, LastSuccessUtc = DateTime.MinValue, TimeIntervalChoice = TimeIntervalChoice.EVERY_DAYS, TimeInterval = 1, MinuteOfHour = 1, HourOfDay = 1, DayOfWeek = DayOfWeek.Thursday, MonthOptionChoice = MonthOptionChoice.ON_SPECIFIC_DAY, DayOfMonth = 1 }; EngineContextExperimental.Current.Resolve <IRepository <ScheduleTask> >().Insert(shtask1); var shtask2 = new ScheduleTask { ScheduleTaskName = "Customer reminder - Unpaid order", Type = "Grand.Services.Tasks.CustomerReminderUnpaidOrderScheduleTask, Grand.Services", Enabled = true, StopOnError = false, LastStartUtc = DateTime.MinValue, LastNonSuccessEndUtc = DateTime.MinValue, LastSuccessUtc = DateTime.MinValue, TimeIntervalChoice = TimeIntervalChoice.EVERY_DAYS, TimeInterval = 1, MinuteOfHour = 1, HourOfDay = 1, DayOfWeek = DayOfWeek.Thursday, MonthOptionChoice = MonthOptionChoice.ON_SPECIFIC_DAY, DayOfMonth = 1 }; EngineContextExperimental.Current.Resolve <IRepository <ScheduleTask> >().Insert(shtask2); #endregion #region MessageTemplates var emailAccount = EngineContextExperimental.Current.Resolve <IRepository <EmailAccount> >().Table.FirstOrDefault(); if (emailAccount == null) { throw new Exception("Default email account cannot be loaded"); } var messageTemplates = new List <MessageTemplate> { new MessageTemplate { Name = "NewReturnRequest.CustomerNotification", Subject = "%Store.Name%. New return request.", Body = "<p><a href=\"%Store.URL%\">%Store.Name%</a> <br /><br />Hello %Customer.FullName%!<br /> You have just submitted a new return request. Details are below:<br />Request ID: %ReturnRequest.CustomNumber%<br />Product: %ReturnRequest.Product.Quantity% x Product: %ReturnRequest.Product.Name%<br />Reason for return: %ReturnRequest.Reason%<br />Requested action: %ReturnRequest.RequestedAction%<br />Customer comments:<br />%ReturnRequest.CustomerComment%</p>", IsActive = true, EmailAccountId = emailAccount.Id, }, new MessageTemplate { Name = "Service.ContactUs", Subject = "%Store.Name%. Contact us", Body = string.Format("<p>From %ContactUs.SenderName% - %ContactUs.SenderEmail% {0} %ContactUs.Body%{0}</p>{0}", Environment.NewLine), IsActive = true, EmailAccountId = emailAccount.Id, }, new MessageTemplate { Name = "Service.ContactVendor", Subject = "%Store.Name%. Contact us", Body = string.Format("<p>From %ContactUs.SenderName% - %ContactUs.SenderEmail% {0} %ContactUs.Body%{0}</p>{0}", Environment.NewLine), IsActive = true, EmailAccountId = emailAccount.Id, }, }; EngineContextExperimental.Current.Resolve <IRepository <MessageTemplate> >().Insert(messageTemplates); #endregion #region Recently Viewed products var _recentlyViewedProductRepository = Grand.Core.Infrastructure.EngineContextExperimental.Current.Resolve <IRepository <RecentlyViewedProduct> >(); _recentlyViewedProductRepository.Collection.Indexes.DropAll(); _recentlyViewedProductRepository.Collection.Indexes.CreateOneAsync(Builders <RecentlyViewedProduct> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _recentlyViewedProductRepository.Collection.Indexes.CreateOneAsync(Builders <RecentlyViewedProduct> .IndexKeys.Ascending(x => x.CustomerId).Ascending(x => x.ProductId).Descending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "CustomerId.ProductId" }); #endregion #region Rebuild index //customer var _customerRepository = EngineContextExperimental.Current.Resolve <IRepository <Customer> >(); _customerRepository.Collection.Indexes.DropAll(); _customerRepository.Collection.Indexes.CreateOneAsync(Builders <Customer> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _customerRepository.Collection.Indexes.CreateOneAsync(Builders <Customer> .IndexKeys.Descending(x => x.CreatedOnUtc).Ascending(x => x.Deleted).Ascending("CustomerRoles._id"), new CreateIndexOptions() { Name = "CreatedOnUtc_1_CustomerRoles._id_1", Unique = false }); _customerRepository.Collection.Indexes.CreateOneAsync(Builders <Customer> .IndexKeys.Ascending(x => x.LastActivityDateUtc), new CreateIndexOptions() { Name = "LastActivityDateUtc_1", Unique = false }); _customerRepository.Collection.Indexes.CreateOneAsync(Builders <Customer> .IndexKeys.Ascending(x => x.CustomerGuid), new CreateIndexOptions() { Name = "CustomerGuid_1", Unique = false }); _customerRepository.Collection.Indexes.CreateOneAsync(Builders <Customer> .IndexKeys.Ascending(x => x.Email), new CreateIndexOptions() { Name = "Email_1", Unique = false }); //customer history password var _customerHistoryPasswordRepository = EngineContextExperimental.Current.Resolve <IRepository <CustomerHistoryPassword> >(); _customerHistoryPasswordRepository.Collection.Indexes.CreateOneAsync(Builders <CustomerHistoryPassword> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _customerHistoryPasswordRepository.Collection.Indexes.CreateOneAsync(Builders <CustomerHistoryPassword> .IndexKeys.Ascending(x => x.CustomerId).Descending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "CustomerId", Unique = false }); //category var _categoryRepository = EngineContextExperimental.Current.Resolve <IRepository <Category> >(); _categoryRepository.Collection.Indexes.DropAll(); _categoryRepository.Collection.Indexes.CreateOneAsync(Builders <Category> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _categoryRepository.Collection.Indexes.CreateOneAsync(Builders <Category> .IndexKeys.Ascending(x => x.DisplayOrder), new CreateIndexOptions() { Name = "DisplayOrder_1", Unique = false }); _categoryRepository.Collection.Indexes.CreateOneAsync(Builders <Category> .IndexKeys.Ascending(x => x.ParentCategoryId).Ascending(x => x.DisplayOrder), new CreateIndexOptions() { Name = "ParentCategoryId_1_DisplayOrder_1", Unique = false }); //manufacturer var _manufacturerRepository = EngineContextExperimental.Current.Resolve <IRepository <Manufacturer> >(); _manufacturerRepository.Collection.Indexes.DropAll(); _manufacturerRepository.Collection.Indexes.CreateOneAsync(Builders <Manufacturer> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _manufacturerRepository.Collection.Indexes.CreateOneAsync(Builders <Manufacturer> .IndexKeys.Ascending(x => x.DisplayOrder), new CreateIndexOptions() { Name = "DisplayOrder_1", Unique = false }); _manufacturerRepository.Collection.Indexes.CreateOneAsync(Builders <Manufacturer> .IndexKeys.Ascending("AppliedDiscounts"), new CreateIndexOptions() { Name = "AppliedDiscounts._id_1", Unique = false }); //Product var _productRepository = EngineContextExperimental.Current.Resolve <IRepository <Product> >(); _productRepository.Collection.Indexes.DropAll(); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending(x => x.MarkAsNew).Ascending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "MarkAsNew_1_CreatedOnUtc_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending(x => x.ShowOnHomePage).Ascending(x => x.Published).Ascending(x => x.DisplayOrder).Ascending(x => x.Name), new CreateIndexOptions() { Name = "ShowOnHomePage_1_Published_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending(x => x.ParentGroupedProductId).Ascending(x => x.DisplayOrder), new CreateIndexOptions() { Name = "ParentGroupedProductId_1_DisplayOrder_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending(x => x.ProductTags).Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.Name), new CreateIndexOptions() { Name = "ProductTags._id_1_Name_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending(x => x.Name), new CreateIndexOptions() { Name = "Name_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductCategories.CategoryId").Ascending("ProductCategories.DisplayOrder"), new CreateIndexOptions() { Name = "ProductCategories.CategoryId_1_DisplayOrder_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductCategories.CategoryId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.DisplayOrderCategory), new CreateIndexOptions() { Name = "ProductCategories.CategoryId_1_OrderCategory_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductCategories.CategoryId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.Name), new CreateIndexOptions() { Name = "ProductCategories.CategoryId_1_Name_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductCategories.CategoryId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.Sold), new CreateIndexOptions() { Name = "ProductCategories.CategoryId_1_Sold_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductCategories.CategoryId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.Price), new CreateIndexOptions() { Name = "ProductCategories.CategoryId_1_Price_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductCategories.CategoryId").Ascending("ProductCategories.IsFeaturedProduct").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually), new CreateIndexOptions() { Name = "ProductCategories.CategoryId_1_IsFeaturedProduct_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductManufacturers.ManufacturerId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.DisplayOrderManufacturer), new CreateIndexOptions() { Name = "ProductManufacturers.ManufacturerId_1_OrderCategory_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductManufacturers.ManufacturerId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.Name), new CreateIndexOptions() { Name = "ProductManufacturers.ManufacturerId_1_Name_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductManufacturers.ManufacturerId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.Sold), new CreateIndexOptions() { Name = "ProductManufacturers.ManufacturerId_1_Sold_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductManufacturers.ManufacturerId").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending(x => x.Price), new CreateIndexOptions() { Name = "ProductManufacturers.ManufacturerId_1_Price_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending("ProductManufacturers.ManufacturerId").Ascending("ProductManufacturers.IsFeaturedProduct").Ascending(x => x.Published).Ascending(x => x.VisibleIndividually), new CreateIndexOptions() { Name = "ProductManufacturers.ManufacturerId_1_IsFeaturedProduct_1", Unique = false }); _productRepository.Collection.Indexes.CreateOneAsync(Builders <Product> .IndexKeys.Ascending(x => x.Published).Ascending(x => x.VisibleIndividually).Ascending("ProductSpecificationAttributes.SpecificationAttributeOptionId").Ascending("ProductSpecificationAttributes.AllowFiltering"), new CreateIndexOptions() { Name = "ProductSpecificationAttributes", Unique = false }); //ProductReview var _productReviewRepository = EngineContextExperimental.Current.Resolve <IRepository <ProductReview> >(); _productReviewRepository.Collection.Indexes.DropAll(); _productReviewRepository.Collection.Indexes.CreateOneAsync(Builders <ProductReview> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _productReviewRepository.Collection.Indexes.CreateOneAsync(Builders <ProductReview> .IndexKeys.Ascending(x => x.ProductId).Ascending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "ProductId", Unique = false }); //topic var _topicRepository = EngineContextExperimental.Current.Resolve <IRepository <Topic> >(); _topicRepository.Collection.Indexes.DropAll(); _topicRepository.Collection.Indexes.CreateOneAsync(Builders <Topic> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _topicRepository.Collection.Indexes.CreateOneAsync(Builders <Topic> .IndexKeys.Ascending(x => x.SystemName), new CreateIndexOptions() { Name = "SystemName", Unique = false }); //news var _newsItemRepository = EngineContextExperimental.Current.Resolve <IRepository <NewsItem> >(); _newsItemRepository.Collection.Indexes.DropAll(); _newsItemRepository.Collection.Indexes.CreateOneAsync(Builders <NewsItem> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _newsItemRepository.Collection.Indexes.CreateOneAsync(Builders <NewsItem> .IndexKeys.Descending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "CreatedOnUtc", Unique = false }); //newsletter var _newslettersubscriptionRepository = EngineContextExperimental.Current.Resolve <IRepository <NewsLetterSubscription> >(); _newslettersubscriptionRepository.Collection.Indexes.DropAll(); _newslettersubscriptionRepository.Collection.Indexes.CreateOneAsync(Builders <NewsLetterSubscription> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _newslettersubscriptionRepository.Collection.Indexes.CreateOneAsync(Builders <NewsLetterSubscription> .IndexKeys.Ascending(x => x.CustomerId), new CreateIndexOptions() { Name = "CustomerId", Unique = false }); _newslettersubscriptionRepository.Collection.Indexes.CreateOneAsync(Builders <NewsLetterSubscription> .IndexKeys.Ascending(x => x.Email), new CreateIndexOptions() { Name = "Email", Unique = false }); //Log var _logRepository = EngineContextExperimental.Current.Resolve <IRepository <Log> >(); _logRepository.Collection.Indexes.DropAll(); _logRepository.Collection.Indexes.CreateOneAsync(Builders <Log> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _logRepository.Collection.Indexes.CreateOneAsync(Builders <Log> .IndexKeys.Descending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "CreatedOnUtc", Unique = false }); //search term var _searchtermRepository = EngineContextExperimental.Current.Resolve <IRepository <SearchTerm> >(); _searchtermRepository.Collection.Indexes.DropAll(); _searchtermRepository.Collection.Indexes.CreateOneAsync(Builders <SearchTerm> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _searchtermRepository.Collection.Indexes.CreateOneAsync(Builders <SearchTerm> .IndexKeys.Descending(x => x.Count), new CreateIndexOptions() { Name = "Count", Unique = false }); //setting var _searchtermsRepository = EngineContextExperimental.Current.Resolve <IRepository <Setting> >(); _searchtermsRepository.Collection.Indexes.DropAll(); _searchtermsRepository.Collection.Indexes.CreateOneAsync(Builders <Setting> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _searchtermsRepository.Collection.Indexes.CreateOneAsync(Builders <Setting> .IndexKeys.Ascending(x => x.Name), new CreateIndexOptions() { Name = "Name", Unique = false }); //order var _orderRepository = EngineContextExperimental.Current.Resolve <IRepository <Order> >(); _orderRepository.Collection.Indexes.DropAll(); _orderRepository.Collection.Indexes.CreateOneAsync(Builders <Order> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _orderRepository.Collection.Indexes.CreateOneAsync(Builders <Order> .IndexKeys.Ascending(x => x.CustomerId).Descending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "CustomerId_1_CreatedOnUtc_-1", Unique = false }); _orderRepository.Collection.Indexes.CreateOneAsync(Builders <Order> .IndexKeys.Descending(x => x.CreatedOnUtc), new CreateIndexOptions() { Name = "CreatedOnUtc_-1", Unique = false }); _orderRepository.Collection.Indexes.CreateOneAsync(Builders <Order> .IndexKeys.Descending(x => x.OrderNumber), new CreateIndexOptions() { Name = "OrderNumber", Unique = true }); _orderRepository.Collection.Indexes.CreateOneAsync(Builders <Order> .IndexKeys.Ascending("OrderItems.ProductId"), new CreateIndexOptions() { Name = "OrderItemsProductId" }); _orderRepository.Collection.Indexes.CreateOneAsync(Builders <Order> .IndexKeys.Ascending("OrderItems._id"), new CreateIndexOptions() { Name = "OrderItemId" }); //url record var _urlRecordRepository = EngineContextExperimental.Current.Resolve <IRepository <UrlRecord> >(); _urlRecordRepository.Collection.Indexes.DropAll(); _urlRecordRepository.Collection.Indexes.CreateOneAsync(Builders <UrlRecord> .IndexKeys.Ascending(x => x.Id), new CreateIndexOptions() { Name = "Id", Unique = true }); _urlRecordRepository.Collection.Indexes.CreateOneAsync(Builders <UrlRecord> .IndexKeys.Ascending(x => x.Slug).Ascending(x => x.IsActive), new CreateIndexOptions() { Name = "Slug" }); _urlRecordRepository.Collection.Indexes.CreateOneAsync(Builders <UrlRecord> .IndexKeys.Ascending(x => x.EntityId).Ascending(x => x.EntityName).Ascending(x => x.LanguageId).Ascending(x => x.IsActive), new CreateIndexOptions() { Name = "UrlRecord" }); #endregion #region Settings var settingService = EngineContextExperimental.Current.Resolve <ISettingService>(); var catalogSettings = EngineContextExperimental.Current.Resolve <CatalogSettings>(); catalogSettings.LimitOfFeaturedProducts = 30; settingService.SaveSetting(catalogSettings, x => x.LimitOfFeaturedProducts, "", false); var adminAreaSettings = EngineContextExperimental.Current.Resolve <AdminAreaSettings>(); adminAreaSettings.UseIsoDateTimeConverterInJson = true; settingService.SaveSetting(adminAreaSettings, x => x.UseIsoDateTimeConverterInJson, "", false); settingService.SaveSetting(new MenuItemSettings { DisplayHomePageMenu = false, DisplayNewProductsMenu = false, DisplaySearchMenu = false, DisplayCustomerMenu = false, DisplayBlogMenu = false, DisplayForumsMenu = false, DisplayContactUsMenu = false }); #endregion #region ActivityLog var _activityLogTypeRepository = EngineContextExperimental.Current.Resolve <IRepository <ActivityLogType> >(); _activityLogTypeRepository.Insert(new ActivityLogType() { SystemKeyword = "PublicStore.Url", Enabled = false, Name = "Public store. Viewed Url" }); _activityLogTypeRepository.Insert(new ActivityLogType() { SystemKeyword = "InteractiveFormDelete", Enabled = true, Name = "Delete a interactive form" }); _activityLogTypeRepository.Insert(new ActivityLogType() { SystemKeyword = "InteractiveFormEdit", Enabled = true, Name = "Edit a interactive form" }); _activityLogTypeRepository.Insert(new ActivityLogType() { SystemKeyword = "InteractiveFormAdd", Enabled = true, Name = "Add a interactive form" }); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); EngineContextExperimental.Current.Resolve <IPermissionService>().InstallPermissions(provider); #endregion }
private async Task From450To460() { #region Install String resources await InstallStringResources("EN_450_460.nopres.xml"); #endregion #region Add new customer action - paid order var customerActionType = _serviceProvider.GetRequiredService <IRepository <CustomerActionType> >(); await customerActionType.InsertAsync( new CustomerActionType() { Name = "Paid order", SystemKeyword = "PaidOrder", Enabled = false, ConditionType = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13 } }); #endregion #region Permisions IPermissionProvider provider = new StandardPermissionProvider(); await _serviceProvider.GetRequiredService <IPermissionService>().InstallNewPermissions(provider); #endregion #region Activity Log Type var _activityLogTypeRepository = _serviceProvider.GetRequiredService <IRepository <ActivityLogType> >(); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "AddNewDocument", Enabled = false, Name = "Add a new document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "AddNewDocumentType", Enabled = false, Name = "Add a new document type" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "EditDocument", Enabled = false, Name = "Edit document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "EditDocumentType", Enabled = false, Name = "Edit document type" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "DeleteDocument", Enabled = false, Name = "Delete document" }); await _activityLogTypeRepository.InsertAsync( new ActivityLogType { SystemKeyword = "DeleteDocumentType", Enabled = false, Name = "Delete document type" }); #endregion #region Update customer settings var _settingService = _serviceProvider.GetRequiredService <ISettingService>(); var customerSettings = _serviceProvider.GetRequiredService <CustomerSettings>(); customerSettings.HideDocumentsTab = true; await _settingService.SaveSetting(customerSettings); customerSettings.HideReviewsTab = false; #endregion #region Update topics IRepository <Topic> _topicRepository = _serviceProvider.GetRequiredService <IRepository <Topic> >(); foreach (var topic in _topicRepository.Table) { topic.Published = true; _topicRepository.Update(topic); } #endregion #region Update url seo to lowercase IRepository <UrlRecord> _urlRecordRepository = _serviceProvider.GetRequiredService <IRepository <UrlRecord> >(); foreach (var urlrecord in _urlRecordRepository.Table) { urlrecord.Slug = urlrecord.Slug.ToLowerInvariant(); _urlRecordRepository.Update(urlrecord); } #endregion }