Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/nopSolutions/nopCommerce
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
AndreiMaz committed Jun 12, 2018
2 parents 6c4b21a + b9ef31e commit a0c7d63
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 11 deletions.
Binary file modified src/Build/ClearPluginAssemblies.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Build/ClearPluginAssemblies.proj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Copyright>Copyright © Nop Solutions, Ltd</Copyright>
<Company>Nop Solutions, Ltd</Company>
<Authors>Nop Solutions, Ltd</Authors>
Expand Down
4 changes: 2 additions & 2 deletions src/Build/ClearPluginAssemblies.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp2.0",
"tfm": "netcoreapp2.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.0.0"
"version": "2.1.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon />
<StartupObject />
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/Nop.Core/Caching/MemoryCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ protected string RemoveKey(string key)
protected void TryRemoveKey(string key)
{
//try to remove key from dictionary
if (!_allKeys.TryRemove(key, out bool _))
if (!_allKeys.TryRemove(key, out _))
//if not possible to remove key from dictionary, then try to mark key as not existing in cache
_allKeys.TryUpdate(key, false, false);
_allKeys.TryUpdate(key, false, true);
}

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Libraries/Nop.Services/Common/IMaintenanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@ public partial interface IMaintenanceService
/// <param name="backupFileName">The name of the backup file</param>
/// <returns>The path to the backup file</returns>
string GetBackupPath(string backupFileName);

/// <summary>
/// Re-indexing database tables
/// </summary>
void ReIndexingTables();
}
}
30 changes: 27 additions & 3 deletions src/Libraries/Nop.Services/Common/MaintenanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ protected virtual void CheckBackupSupported()

throw new DataException("This database does not support backup");
}

#endregion

#region Methods

/// <summary>
Expand Down Expand Up @@ -187,7 +187,31 @@ public virtual string GetBackupPath(string backupFileName)
{
return _fileProvider.Combine(GetBackupDirectoryPath(), backupFileName);
}


/// <summary>
/// Re-indexing database tables
/// </summary>
public virtual void ReIndexingTables()
{
var commandText = $@"
DECLARE @TableName sysname
DECLARE cur_reindex CURSOR FOR
SELECT table_name
FROM [{_dbContext.DbName()}].information_schema.tables
WHERE table_type = 'base table'
OPEN cur_reindex
FETCH NEXT FROM cur_reindex INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
exec('ALTER INDEX ALL ON [' + @TableName + '] REBUILD')
FETCH NEXT FROM cur_reindex INTO @TableName
END
CLOSE cur_reindex
DEALLOCATE cur_reindex";

_dbContext.ExecuteSqlCommand(commandText, true);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13332,6 +13332,21 @@
<LocaleResource Name="Admin.System.Maintenance.DeleteGuests.TotalDeleted">
<Value>{0} customers were deleted</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables">
<Value>Re-indexing database tables</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.Complete">
<Value>Re-indexing database tables complete</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.Lable">
<Value>Modifies existing tables by rebuilding the index. When you execute re-indexing in a table, only the statistics associated with the indexes are updated. Automatic or manual statistics created in the table (instead of an index) are not updated.</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.Progress">
<Value>Processing re-indexing...</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.ReIndexNow">
<Value>Re-index</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.QueuedEmails">
<Value>Message queue</Value>
</LocaleResource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,26 @@ public virtual IActionResult BackupDatabase(MaintenanceModel model)
return View(model);
}

[HttpPost, ActionName("Maintenance")]
[FormValueRequired("re-index")]
public virtual IActionResult ReIndexingTables(MaintenanceModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
return AccessDeniedView();

try
{
_maintenanceService.ReIndexingTables();
SuccessNotification(_localizationService.GetResource("Admin.System.Maintenance.ReIndexTables.Complete"));
}
catch (Exception exc)
{
ErrorNotification(exc);
}

return View(model);
}

[HttpPost, ActionName("Maintenance")]
[FormValueRequired("backupFileName", "action")]
public virtual IActionResult BackupAction(MaintenanceModel model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,32 @@
</div>
</div>
</div>
<div class="row margin-t-5">
<div class="col-md-4">
<div class="panel panel-default" style="min-height: 230px;">
<div class="panel-heading">
@T("Admin.System.Maintenance.ReIndexTables")
</div>
<div class="panel-body">
<div class="form-group">
<div class="col-md-12">
<div>
<p>
@T("Admin.System.Maintenance.ReIndexTables.Lable")
</p>
</div>
<div>
<button type="submit" name="re-index" class="btn btn-default">
<i class="fa fa-gears"></i>
@T("Admin.System.Maintenance.ReIndexTables.ReIndexNow")
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
Expand All @@ -176,6 +202,15 @@
</div>
<div id="backup-data" style="display: none"></div>

<script>
$(document).ready(function() {
$("button[name='re-index']").on("click", function () {
$("html, body").animate({ scrollTop: 0 }, 400);
showThrobber('@Html.Raw(JavaScriptEncoder.Default.Encode(T("Admin.System.Maintenance.ReIndexTables.Progress").Text))');
});
});
</script>

<script>
function submitBackupAction(fileName, action) {
$("#backup-data").children().remove();
Expand All @@ -188,7 +223,7 @@
$("html, body").animate({ scrollTop: 0 }, 400);
showThrobber('@Html.Raw(JavaScriptEncoder.Default.Encode(T("Admin.System.Maintenance.BackupDatabase.Progress").Text))');
};
$(document).ready(function () {
$("#backup-database").on("click", function () {
showProgress();
Expand Down
15 changes: 15 additions & 0 deletions upgradescripts/4.00-4.10 (under development)/upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,21 @@ set @resources='
<LocaleResource Name="Admin.Configuration.Settings.Catalog.ShowLinkToAllResultInSearchAutoComplete.Hint">
<Value>Determines whether the link to all results should be displayed in the autocomplete search box. Displayed if the number of items found is greater than the displayed quantity in the autocomplete box.</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables">
<Value>Re-indexing database tables</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.Complete">
<Value>Re-indexing database tables complete</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.Lable">
<Value>Modifies existing tables by rebuilding the index. When you execute re-indexing in a table, only the statistics associated with the indexes are updated. Automatic or manual statistics created in the table (instead of an index) are not updated.</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.Progress">
<Value>Processing re-indexing...</Value>
</LocaleResource>
<LocaleResource Name="Admin.System.Maintenance.ReIndexTables.ReIndexNow">
<Value>Re-index</Value>
</LocaleResource>
</Language>
'

Expand Down

0 comments on commit a0c7d63

Please sign in to comment.