mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Removed Orchard.Reports.
This commit is contained in:
@@ -1 +1 @@
|
||||
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=.;Initial Catalog=Orchard;Integrated Security=True" /EnabledFeatures:Profiling,Orchard.Framework,Common,Containers,Contents,Dashboard,Feeds,Navigation,Reports,Scheduling,Settings,Shapes,Title,PackagingServices,Gallery,Orchard.PublishLater,Orchard.Blogs,Orchard.Comments,Orchard.ContentTypes,Orchard.jQuery,Orchard.Lists,Orchard.MediaLibrary,Orchard.ContentPicker,Orchard.MediaPicker,Orchard.Modules,Orchard.Packaging,Orchard.Pages,Orchard.Recipes,Orchard.Roles,Orchard.Tags,Orchard.Themes,Orchard.Users,Orchard.Scripting,Orchard.Scripting.Lightweight,Orchard.Widgets,TinyMce,TheThemeMachine,Orchard.Tokens,Orchard.Alias,Orchard.Autoroute
|
||||
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=.;Initial Catalog=Orchard;Integrated Security=True" /EnabledFeatures:Profiling,Orchard.Framework,Common,Containers,Contents,Dashboard,Feeds,Navigation,Scheduling,Settings,Shapes,Title,PackagingServices,Gallery,Orchard.PublishLater,Orchard.Blogs,Orchard.Comments,Orchard.ContentTypes,Orchard.jQuery,Orchard.Lists,Orchard.MediaLibrary,Orchard.ContentPicker,Orchard.MediaPicker,Orchard.Modules,Orchard.Packaging,Orchard.Pages,Orchard.Recipes,Orchard.Roles,Orchard.Tags,Orchard.Themes,Orchard.Users,Orchard.Scripting,Orchard.Scripting.Lightweight,Orchard.Widgets,TinyMce,TheThemeMachine,Orchard.Tokens,Orchard.Alias,Orchard.Autoroute
|
||||
|
@@ -25,7 +25,7 @@ namespace Orchard.Specs.Bindings {
|
||||
virtualDirectory,
|
||||
TableData(
|
||||
new { extension = "Module", names = "Lucene, Markdown, Orchard.Alias, Orchard.AntiSpam, Orchard.ArchiveLater, Orchard.Autoroute, Orchard.Azure, Orchard.Blogs, Orchard.Caching, Orchard.CodeGeneration, Orchard.Comments, Orchard.ContentPermissions, Orchard.ContentPicker, Orchard.ContentTypes, Orchard.CustomForms, Orchard.DesignerTools, Orchard.Email, Orchard.Fields, Orchard.Forms, Orchard.ImageEditor, Orchard.ImportExport, Orchard.Indexing, Orchard.JobsQueue, Orchard.jQuery, Orchard.Layouts, Orchard.Lists, Orchard.Localization, Orchard.Media, Orchard.MediaLibrary, Orchard.MediaPicker, Orchard.MediaProcessing, Orchard.Migrations, Orchard.Modules, Orchard.MultiTenancy, Orchard.OutputCache, Orchard.Packaging, Orchard.Pages, Orchard.Projections, Orchard.PublishLater, Orchard.Recipes, Orchard.Roles, Orchard.Rules, Orchard.Scripting, Orchard.Scripting.CSharp, Orchard.Scripting.Dlr, Orchard.Search, Orchard.SecureSocketsLayer, Orchard.Setup, Orchard.Tags, Orchard.TaskLease, Orchard.Taxonomies, Orchard.Templates, Orchard.Themes, Orchard.Tokens, Orchard.Users, Orchard.Warmup, Orchard.Widgets, Orchard.Workflows, SysCache, TinyMce, Upgrade" },
|
||||
new { extension = "Core", names = "Common, Containers, Contents, Dashboard, Feeds, Navigation, Reports, Scheduling, Settings, Shapes, Title, XmlRpc" },
|
||||
new { extension = "Core", names = "Common, Containers, Contents, Dashboard, Feeds, Navigation, Scheduling, Settings, Shapes, Title, XmlRpc" },
|
||||
new { extension = "Theme", names = "SafeMode, TheAdmin, TheThemeMachine" }));
|
||||
|
||||
webApp.WhenIGoTo("Setup");
|
||||
|
@@ -7,7 +7,7 @@ Scenario: Root request shows setup form
|
||||
Given I have a clean site with
|
||||
| extension | names |
|
||||
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
|
||||
| Theme | SafeMode |
|
||||
When I go to "/"
|
||||
Then I should see "Welcome to Orchard"
|
||||
@@ -18,7 +18,7 @@ Scenario: Setup folder also shows setup form
|
||||
Given I have a clean site with
|
||||
| extension | names |
|
||||
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
|
||||
| Theme | SafeMode |
|
||||
When I go to "/Setup"
|
||||
Then I should see "Welcome to Orchard"
|
||||
@@ -29,7 +29,7 @@ Scenario: Some of the initial form values are required
|
||||
Given I have a clean site with
|
||||
| extension | names |
|
||||
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
|
||||
| Theme | SafeMode |
|
||||
When I go to "/Setup"
|
||||
And I hit "Finish Setup"
|
||||
@@ -41,7 +41,7 @@ Scenario: Calling setup on a brand new install
|
||||
Given I have a clean site with
|
||||
| extension | names |
|
||||
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
|
||||
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
|
||||
| Theme | SafeMode, TheAdmin, TheThemeMachine |
|
||||
And I am on "/Setup"
|
||||
When I fill in
|
||||
|
8
src/Orchard.Specs/Setup.feature.cs
generated
8
src/Orchard.Specs/Setup.feature.cs
generated
@@ -82,7 +82,7 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table1.AddRow(new string[] {
|
||||
"Core",
|
||||
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
|
||||
" Shapes, XmlRpc, Title, Reports"});
|
||||
" Shapes, XmlRpc, Title"});
|
||||
table1.AddRow(new string[] {
|
||||
"Theme",
|
||||
"SafeMode"});
|
||||
@@ -117,7 +117,7 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table2.AddRow(new string[] {
|
||||
"Core",
|
||||
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
|
||||
" Shapes, XmlRpc, Title, Reports"});
|
||||
" Shapes, XmlRpc, Title"});
|
||||
table2.AddRow(new string[] {
|
||||
"Theme",
|
||||
"SafeMode"});
|
||||
@@ -152,7 +152,7 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table3.AddRow(new string[] {
|
||||
"Core",
|
||||
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
|
||||
" Shapes, XmlRpc, Title, Reports"});
|
||||
" Shapes, XmlRpc, Title"});
|
||||
table3.AddRow(new string[] {
|
||||
"Theme",
|
||||
"SafeMode"});
|
||||
@@ -189,7 +189,7 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table4.AddRow(new string[] {
|
||||
"Core",
|
||||
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
|
||||
" Shapes, XmlRpc, Title, Reports"});
|
||||
" Shapes, XmlRpc, Title"});
|
||||
table4.AddRow(new string[] {
|
||||
"Theme",
|
||||
"SafeMode, TheAdmin, TheThemeMachine"});
|
||||
|
@@ -12,14 +12,13 @@ using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using System.IO;
|
||||
using Orchard.Tests.Environment;
|
||||
using Orchard.Tests.FileSystems.AppData;
|
||||
using Orchard.Tests.Stubs;
|
||||
|
||||
namespace Orchard.Tests.DataMigration {
|
||||
namespace Orchard.Tests.DataMigration
|
||||
{
|
||||
[TestFixture]
|
||||
public class SchemaBuilderTestsBase {
|
||||
private IContainer _container;
|
||||
@@ -45,7 +44,6 @@ namespace Orchard.Tests.DataMigration {
|
||||
builder.RegisterInstance(appDataFolder).As<IAppDataFolder>();
|
||||
builder.RegisterType<SqlCeDataServicesProvider>().As<IDataServicesProvider>();
|
||||
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
|
||||
builder.RegisterType<StubReportsCoordinator>().As<IReportsCoordinator>();
|
||||
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>();
|
||||
builder.RegisterType<SqlCeCommandInterpreter>().As<ICommandInterpreter>();
|
||||
builder.RegisterType<SessionConfigurationCache>().As<ISessionConfigurationCache>();
|
||||
|
@@ -281,7 +281,6 @@
|
||||
<Compile Include="Stubs\StubHttpContextAccessor.cs" />
|
||||
<Compile Include="Stubs\StubWorkContextAccessor.cs" />
|
||||
<Compile Include="Stubs\StubExtensionManager.cs" />
|
||||
<Compile Include="Stubs\StubReportsCoordinator.cs" />
|
||||
<Compile Include="Stubs\StubVirtualPathProvider.cs" />
|
||||
<Compile Include="Stubs\StubFileSystem.cs" />
|
||||
<Compile Include="Stubs\StubAppDataFolder.cs" />
|
||||
|
@@ -1,14 +0,0 @@
|
||||
using Orchard.Reports;
|
||||
using Orchard.Reports.Services;
|
||||
|
||||
namespace Orchard.Tests.Stubs {
|
||||
public class StubReportsCoordinator : IReportsCoordinator {
|
||||
public void Add(string reportKey, ReportEntryType type, string message) {
|
||||
|
||||
}
|
||||
|
||||
public int Register(string reportKey, string activityName, string title) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -25,6 +25,7 @@
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -175,12 +176,7 @@
|
||||
<Compile Include="Contents\ViewModels\ListContentTypesViewModel.cs" />
|
||||
<Compile Include="Navigation\ViewModels\MenuPartViewModel.cs" />
|
||||
<Compile Include="Navigation\ViewModels\MenuWidgetViewModel.cs" />
|
||||
<Compile Include="Reports\AdminMenu.cs" />
|
||||
<Compile Include="Reports\Controllers\AdminController.cs" />
|
||||
<Compile Include="Reports\Routes.cs" />
|
||||
<Compile Include="Navigation\Migrations.cs" />
|
||||
<Compile Include="Reports\ViewModels\DisplayReportViewModel.cs" />
|
||||
<Compile Include="Reports\ViewModels\ReportsAdminIndexViewModel.cs" />
|
||||
<Compile Include="Common\Utilities\LazyField.cs" />
|
||||
<Compile Include="Common\Handlers\CommonPartHandler.cs" />
|
||||
<Compile Include="Common\Models\CommonPart.cs" />
|
||||
@@ -314,11 +310,6 @@
|
||||
<Content Include="Navigation\Styles\navigation-admin.css" />
|
||||
<Content Include="Navigation\Styles\images\menu.navigation.png" />
|
||||
<Content Include="Navigation\Styles\menu.navigation-admin.css" />
|
||||
<Content Include="Reports\Module.txt" />
|
||||
<Content Include="Reports\Styles\images\menu.reports.png" />
|
||||
<Content Include="Reports\Styles\menu.reports-admin.css" />
|
||||
<Content Include="Reports\Views\Admin\Display.cshtml" />
|
||||
<Content Include="Reports\Views\Admin\Index.cshtml" />
|
||||
<Content Include="Settings\Module.txt" />
|
||||
<Content Include="Settings\Styles\admin.css" />
|
||||
<Content Include="Settings\Styles\images\menu.settings.png" />
|
||||
@@ -434,9 +425,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Reports\Styles\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Common\Views\Parts.Common.Metadata.SummaryAdmin.cshtml" />
|
||||
</ItemGroup>
|
||||
|
@@ -1,17 +0,0 @@
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.Core.Reports {
|
||||
public class AdminMenu : INavigationProvider {
|
||||
public Localizer T { get; set; }
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.AddImageSet("reports")
|
||||
.Add(T("Reports"), "12",
|
||||
menu => menu.Add(T("View"), "0", item => item.Action("Index", "Admin", new { area = "Reports" })
|
||||
.Permission(StandardPermissions.SiteOwner)));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Core.Reports.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Core.Reports.Controllers {
|
||||
public class AdminController : Controller {
|
||||
private readonly IReportsManager _reportsManager;
|
||||
|
||||
public AdminController(
|
||||
IOrchardServices services,
|
||||
IReportsManager reportsManager) {
|
||||
Services = services;
|
||||
_reportsManager = reportsManager;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list reports")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = new ReportsAdminIndexViewModel { Reports = _reportsManager.GetReports().ToList() };
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public ActionResult Display(int id) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to display report")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = new DisplayReportViewModel { Report = _reportsManager.Get(id) };
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
Name: Reports
|
||||
AntiForgery: enabled
|
||||
Author: The Orchard Team
|
||||
Website: http://orchardproject.net
|
||||
Version: 1.9.1
|
||||
OrchardVersion: 1.9
|
||||
Description: The dashboard module is providing the reports screen of the application.
|
||||
FeatureDescription: Reports management.
|
||||
Category: Core
|
@@ -1,33 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Core.Reports {
|
||||
public class Routes : IRouteProvider {
|
||||
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
||||
foreach (var routeDescriptor in GetRoutes())
|
||||
routes.Add(routeDescriptor);
|
||||
}
|
||||
|
||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||
return new[] {
|
||||
new RouteDescriptor {
|
||||
Priority = -5,
|
||||
Route = new Route(
|
||||
"Admin/Reports",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Reports"},
|
||||
{"controller", "Admin"},
|
||||
{"action", "Index"}
|
||||
},
|
||||
new RouteValueDictionary(),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Reports"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<staticContent>
|
||||
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
|
||||
</staticContent>
|
||||
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
Binary file not shown.
Before Width: | Height: | Size: 219 B |
@@ -1,6 +0,0 @@
|
||||
.navicon-reports {
|
||||
background-image:url(images/menu.reports.png) !important;
|
||||
}
|
||||
.navicon-reports:hover {
|
||||
background-position:0 -30px !important;
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
using Orchard.Reports;
|
||||
|
||||
namespace Orchard.Core.Reports.ViewModels {
|
||||
public class DisplayReportViewModel {
|
||||
public Report Report { get; set; }
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Reports;
|
||||
|
||||
namespace Orchard.Core.Reports.ViewModels {
|
||||
public class ReportsAdminIndexViewModel {
|
||||
public IList<Report> Reports { get; set; }
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
@model DisplayReportViewModel
|
||||
@using Orchard.Core.Reports.ViewModels;
|
||||
|
||||
@{ Layout.Title = T("Display Report").ToString(); }
|
||||
|
||||
@using(Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<table class="items" summary="@T("This is a table of the reports in your application")">
|
||||
<colgroup>
|
||||
<col id="Col1" />
|
||||
<col id="Col2" />
|
||||
<col id="Col3" />
|
||||
<col id="Col4" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">@T("Type")</th>
|
||||
<th scope="col">@T("Message")</th>
|
||||
<th scope="col">@T("Date")</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var reportEntry in Model.Report.Entries) {
|
||||
<tr>
|
||||
<td>
|
||||
@reportEntry.Type
|
||||
</td>
|
||||
<td>
|
||||
@reportEntry.Message
|
||||
</td>
|
||||
<td>
|
||||
@reportEntry.Utc.ToLocalTime().ToShortDateString() @reportEntry.Utc.ToLocalTime().ToShortTimeString()
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</fieldset>
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
@model ReportsAdminIndexViewModel
|
||||
@using Orchard.Core.Reports.ViewModels;
|
||||
|
||||
@{ Layout.Title = T("Reports").ToString(); }
|
||||
|
||||
@using(Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<table class="items" summary="@T("This is a table of the reports in your application")">
|
||||
<colgroup>
|
||||
<col id="Col1" />
|
||||
<col id="Col2" />
|
||||
<col id="Col3" />
|
||||
<col id="Col4" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">@T("Name")</th>
|
||||
<th scope="col">@T("Title")</th>
|
||||
<th scope="col">@T("Date")</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var report in Model.Reports) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.ActionLink(report.ActivityName, "Display", new {id = report.ReportId})
|
||||
</td>
|
||||
<td>
|
||||
@report.Title
|
||||
</td>
|
||||
<td>
|
||||
@report.Utc.ToLocalTime().ToShortDateString() @report.Utc.ToLocalTime().ToShortTimeString()
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</fieldset>
|
||||
}
|
@@ -19,7 +19,6 @@ using Orchard.Mvc;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.UI.Notify;
|
||||
@@ -29,7 +28,6 @@ namespace Orchard.Modules.Controllers {
|
||||
private readonly IExtensionDisplayEventHandler _extensionDisplayEventHandler;
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IDataMigrationManager _dataMigrationManager;
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
private readonly IFeatureManager _featureManager;
|
||||
private readonly IRecipeHarvester _recipeHarvester;
|
||||
@@ -42,7 +40,6 @@ namespace Orchard.Modules.Controllers {
|
||||
IOrchardServices services,
|
||||
IModuleService moduleService,
|
||||
IDataMigrationManager dataMigrationManager,
|
||||
IReportsCoordinator reportsCoordinator,
|
||||
IExtensionManager extensionManager,
|
||||
IFeatureManager featureManager,
|
||||
IRecipeHarvester recipeHarvester,
|
||||
@@ -55,7 +52,6 @@ namespace Orchard.Modules.Controllers {
|
||||
_extensionDisplayEventHandler = extensionDisplayEventHandlers.FirstOrDefault();
|
||||
_moduleService = moduleService;
|
||||
_dataMigrationManager = dataMigrationManager;
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
_extensionManager = extensionManager;
|
||||
_featureManager = featureManager;
|
||||
_recipeHarvester = recipeHarvester;
|
||||
@@ -233,7 +229,8 @@ namespace Orchard.Modules.Controllers {
|
||||
foreach (var feature in selectedFeaturesThatNeedUpdate) {
|
||||
var id = feature.Descriptor.Id;
|
||||
try {
|
||||
_reportsCoordinator.Register("Data Migration", "Upgrade " + id, "Orchard installation");
|
||||
// TODO: LOGGING
|
||||
//_reportsCoordinator.Register("Data Migration", "Upgrade " + id, "Orchard installation");
|
||||
_dataMigrationManager.Update(id);
|
||||
Services.Notifier.Information(T("The feature {0} was updated successfully", id));
|
||||
}
|
||||
|
@@ -11,14 +11,14 @@ using Orchard.Mvc.Extensions;
|
||||
using Orchard.Packaging.Models;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.Packaging.ViewModels;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI.Admin;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Packaging.Controllers {
|
||||
namespace Orchard.Packaging.Controllers
|
||||
{
|
||||
[OrchardFeature("Gallery.Updates")]
|
||||
[Themed, Admin]
|
||||
public class GalleryUpdatesController : Controller {
|
||||
|
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Settings.Descriptor.Records;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Data.Migration;
|
||||
@@ -15,19 +14,18 @@ using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.ShellBuilders;
|
||||
using Orchard.Environment.State;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Setup.Services {
|
||||
namespace Orchard.Setup.Services
|
||||
{
|
||||
public class SetupService : ISetupService {
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly IOrchardHost _orchardHost;
|
||||
@@ -87,7 +85,7 @@ namespace Orchard.Setup.Services {
|
||||
// Framework
|
||||
"Orchard.Framework",
|
||||
// Core
|
||||
"Common", "Containers", "Contents", "Dashboard", "Feeds", "Navigation", "Reports", "Scheduling", "Settings", "Shapes", "Title",
|
||||
"Common", "Containers", "Contents", "Dashboard", "Feeds", "Navigation","Scheduling", "Settings", "Shapes", "Title",
|
||||
// Modules
|
||||
"Orchard.Pages", "Orchard.ContentPicker", "Orchard.Themes", "Orchard.Users", "Orchard.Roles", "Orchard.Modules",
|
||||
"PackagingServices", "Orchard.Packaging", "Gallery", "Orchard.Recipes"
|
||||
@@ -144,9 +142,8 @@ namespace Orchard.Setup.Services {
|
||||
// Make a workaround to avoid the Transaction issue for PostgreSQL
|
||||
environment.Resolve<ITransactionManager>().RequireNew();
|
||||
|
||||
var reportsCoordinator = environment.Resolve<IReportsCoordinator>();
|
||||
|
||||
reportsCoordinator.Register("Data Migration", "Setup", "Orchard installation");
|
||||
// TODO: LOGGING
|
||||
//reportsCoordinator.Register("Data Migration", "Setup", "Orchard installation");
|
||||
|
||||
schemaBuilder.CreateTable("Orchard_Framework_DataMigrationRecord",
|
||||
table => table
|
||||
|
@@ -12,7 +12,6 @@ using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes.Events;
|
||||
using Orchard.Themes.Models;
|
||||
@@ -34,7 +33,6 @@ namespace Orchard.Themes.Controllers {
|
||||
private readonly ShellDescriptor _shellDescriptor;
|
||||
private readonly IPreviewTheme _previewTheme;
|
||||
private readonly IThemeService _themeService;
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
|
||||
public AdminController(
|
||||
@@ -47,7 +45,6 @@ namespace Orchard.Themes.Controllers {
|
||||
ShellDescriptor shellDescriptor,
|
||||
IPreviewTheme previewTheme,
|
||||
IThemeService themeService,
|
||||
IReportsCoordinator reportsCoordinator,
|
||||
ShellSettings shellSettings) {
|
||||
Services = services;
|
||||
|
||||
@@ -59,7 +56,6 @@ namespace Orchard.Themes.Controllers {
|
||||
_featureManager = featureManager;
|
||||
_previewTheme = previewTheme;
|
||||
_themeService = themeService;
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
_shellSettings = shellSettings;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -232,7 +228,7 @@ namespace Orchard.Themes.Controllers {
|
||||
return HttpNotFound();
|
||||
|
||||
try {
|
||||
_reportsCoordinator.Register("Data Migration", "Upgrade " + themeId, "Orchard installation");
|
||||
// TODO: LOGGING
|
||||
_dataMigrationManager.Update(themeId);
|
||||
Services.Notifier.Information(T("The theme {0} was updated successfully", themeId));
|
||||
} catch (Exception exception) {
|
||||
|
@@ -13,7 +13,6 @@ using Orchard.Core.Title.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Admin;
|
||||
using Orchard.UI.Notify;
|
||||
@@ -27,21 +26,18 @@ namespace Upgrade.Controllers {
|
||||
private readonly ISessionFactoryHolder _sessionFactoryHolder;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly IAutorouteService _autorouteService;
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
|
||||
public RouteController(
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
IOrchardServices orchardServices,
|
||||
ISessionFactoryHolder sessionFactoryHolder,
|
||||
ShellSettings shellSettings,
|
||||
IAutorouteService autorouteService,
|
||||
IReportsCoordinator reportsCoordinator) {
|
||||
IAutorouteService autorouteService) {
|
||||
_contentDefinitionManager = contentDefinitionManager;
|
||||
_orchardServices = orchardServices;
|
||||
_sessionFactoryHolder = sessionFactoryHolder;
|
||||
_shellSettings = shellSettings;
|
||||
_autorouteService = autorouteService;
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
@@ -71,8 +67,8 @@ namespace Upgrade.Controllers {
|
||||
|
||||
if(TryUpdateModel(viewModel)) {
|
||||
|
||||
// creating report
|
||||
_reportsCoordinator.Register("Migration", "Upgrade", "Migrating " + string.Join(" ,", viewModel.ContentTypes.Where(x => x.IsChecked).Select(x => x.ContentTypeName).ToArray()));
|
||||
// TODO: LOGGING
|
||||
//_reportsCoordinator.Register("Migration", "Upgrade", "Migrating " + string.Join(" ,", viewModel.ContentTypes.Where(x => x.IsChecked).Select(x => x.ContentTypeName).ToArray()));
|
||||
|
||||
var contentTypesToMigrate = viewModel.ContentTypes.Where(c => c.IsChecked).Select(c => c.ContentTypeName);
|
||||
|
||||
@@ -81,7 +77,8 @@ namespace Upgrade.Controllers {
|
||||
|
||||
foreach (var contentType in contentTypesToMigrate) {
|
||||
|
||||
_reportsCoordinator.Information("Migration", "Adding parts to " + contentType);
|
||||
// TODO: LOGGING
|
||||
//_reportsCoordinator.Information("Migration", "Adding parts to " + contentType);
|
||||
|
||||
// migrating parts
|
||||
_contentDefinitionManager.AlterTypeDefinition(contentType,
|
||||
@@ -134,7 +131,8 @@ namespace Upgrade.Controllers {
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
_reportsCoordinator.Error("Migration", "Migrating content item " + autoroutePart.ContentItem.Id + " failed with: " + e.Message);
|
||||
// TODO: LOGGING
|
||||
//_reportsCoordinator.Error("Migration", "Migrating content item " + autoroutePart.ContentItem.Id + " failed with: " + e.Message);
|
||||
errors = true;
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ namespace Orchard.Data.Migration {
|
||||
|
||||
// Let's make sure that the basic set of features is enabled. If there are any that are not enabled, then let's enable them first.
|
||||
var theseFeaturesShouldAlwaysBeActive = new[] {
|
||||
"Common", "Containers", "Contents", "Dashboard", "Feeds", "Navigation", "Reports", "Scheduling", "Settings", "Shapes", "Title"
|
||||
"Common", "Containers", "Contents", "Dashboard", "Feeds", "Navigation", "Scheduling", "Settings", "Shapes", "Title"
|
||||
};
|
||||
|
||||
var enabledFeatures = _featureManager.GetEnabledFeatures().Select(f => f.Id).ToList();
|
||||
|
@@ -11,7 +11,6 @@ using Orchard.Data.Migration.Schema;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Reports.Services;
|
||||
|
||||
namespace Orchard.Data.Migration.Interpreters {
|
||||
public class DefaultDataMigrationInterpreter : AbstractDataMigrationInterpreter, IDataMigrationInterpreter {
|
||||
@@ -21,7 +20,6 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
private readonly Lazy<Dialect> _dialectLazy;
|
||||
private readonly List<string> _sqlStatements;
|
||||
private readonly ISessionFactoryHolder _sessionFactoryHolder;
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
|
||||
private const char Space = ' ';
|
||||
|
||||
@@ -29,14 +27,12 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
ShellSettings shellSettings,
|
||||
ISessionLocator sessionLocator,
|
||||
IEnumerable<ICommandInterpreter> commandInterpreters,
|
||||
ISessionFactoryHolder sessionFactoryHolder,
|
||||
IReportsCoordinator reportsCoordinator) {
|
||||
ISessionFactoryHolder sessionFactoryHolder) {
|
||||
_shellSettings = shellSettings;
|
||||
_sessionLocator = sessionLocator;
|
||||
_commandInterpreters = commandInterpreters;
|
||||
_sqlStatements = new List<string>();
|
||||
_sessionFactoryHolder = sessionFactoryHolder;
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -341,7 +337,8 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
_reportsCoordinator.Information("Data Migration", String.Format("Executing SQL Query: {0}", sqlStatement));
|
||||
// TODO: LOGGING
|
||||
//_reportsCoordinator.Information("Data Migration", String.Format("Executing SQL Query: {0}", sqlStatement));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
@@ -723,15 +723,6 @@
|
||||
<Compile Include="Environment\Extensions\Compilers\IProjectFileParser.cs" />
|
||||
<Compile Include="Indexing\MetaDataExtensions.cs" />
|
||||
<Compile Include="Localization\Commands\CultureCommands.cs" />
|
||||
<Compile Include="Reports\Report.cs" />
|
||||
<Compile Include="Reports\ReportEntry.cs" />
|
||||
<Compile Include="Reports\ReportExtentions.cs" />
|
||||
<Compile Include="Reports\Services\IReportsCoordinator.cs" />
|
||||
<Compile Include="Reports\Services\IReportsManager.cs" />
|
||||
<Compile Include="Reports\Services\IReportsPersister.cs" />
|
||||
<Compile Include="Reports\Services\ReportsCoordinator.cs" />
|
||||
<Compile Include="Reports\Services\ReportsManager.cs" />
|
||||
<Compile Include="Reports\Services\ReportsPersister.cs" />
|
||||
<Compile Include="UI\Admin\Notification\NotificationFilter.cs" />
|
||||
<Compile Include="Data\Migration\DataMigrationNotificationProvider.cs" />
|
||||
<Compile Include="UI\Admin\Notification\INotificationManager.cs" />
|
||||
|
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Reports {
|
||||
public class Report {
|
||||
public Report() {
|
||||
Entries = new List<ReportEntry>();
|
||||
}
|
||||
|
||||
public IList<ReportEntry> Entries { get; set;}
|
||||
public int ReportId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string ActivityName { get; set; }
|
||||
public DateTime Utc { get; set; }
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.Reports {
|
||||
public enum ReportEntryType {
|
||||
Information,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
|
||||
public class ReportEntry {
|
||||
public ReportEntryType Type { get; set; }
|
||||
public string Message { get; set; }
|
||||
public DateTime Utc { get; set; }
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
using Orchard.Reports;
|
||||
using Orchard.Reports.Services;
|
||||
|
||||
public static class ReportExtentions {
|
||||
/// <summary>
|
||||
/// Adds a new report entry of type information to a report that was previously registered.
|
||||
/// </summary>
|
||||
/// <seealso cref="Register()"/>
|
||||
/// <param name="reportKey">Key, i.e. technical name of the report. Should be the same as the one used when registering the report.</param>
|
||||
/// <param name="message">The message to include in the entry.</param>
|
||||
public static void Information(this IReportsCoordinator reportCoordinator, string reportKey, string message) {
|
||||
reportCoordinator.Add(reportKey, ReportEntryType.Information, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new report entry of type warning to a report that was previously registered.
|
||||
/// </summary>
|
||||
/// <seealso cref="Register()"/>
|
||||
/// <param name="reportKey">Key, i.e. technical name of the report. Should be the same as the one used when registering the report.</param>
|
||||
/// <param name="message">The message to include in the entry.</param>
|
||||
public static void Warning(this IReportsCoordinator reportCoordinator, string reportKey, string message) {
|
||||
reportCoordinator.Add(reportKey, ReportEntryType.Warning, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new report entry of type error to a report that was previously registered.
|
||||
/// </summary>
|
||||
/// <seealso cref="Register()"/>
|
||||
/// <param name="reportKey">Key, i.e. technical name of the report. Should be the same as the one used when registering the report.</param>
|
||||
/// <param name="message">The message to include in the entry.</param>
|
||||
public static void Error(this IReportsCoordinator reportCoordinator, string reportKey, string message) {
|
||||
reportCoordinator.Add(reportKey, ReportEntryType.Error, message);
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +0,0 @@
|
||||
namespace Orchard.Reports.Services {
|
||||
/// <summary>
|
||||
/// Exposes a simplified interface for creating reports. Reports provide user-accessible log-like functionality.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="Orchard.Reports.Services.IReportsManager"/> can be used too to create reports directly.
|
||||
/// </remarks>
|
||||
public interface IReportsCoordinator : IDependency {
|
||||
/// <summary>
|
||||
/// Adds a new report entry to a report that was previously registered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Entries can be only added to a report that was previously registered through Register().
|
||||
/// </remarks>
|
||||
/// <seealso cref="Register()"/>
|
||||
/// <param name="reportKey">Key, i.e. technical name of the report. Should be the same as the one used when registering the report.</param>
|
||||
/// <param name="type">Type of the entry.</param>
|
||||
/// <param name="message">The message to include in the entry.</param>
|
||||
void Add(string reportKey, ReportEntryType type, string message);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new report so entries can be added to it.
|
||||
/// </summary>
|
||||
/// <param name="reportKey">Key, i.e. technical name of the report.</param>
|
||||
/// <param name="activityName">Name of the activity the report is about (e.g. "Upgrade").</param>
|
||||
/// <param name="title">A title better describing what the report is about (e.g. "Migrating routes of Pages, Blog Posts").</param>
|
||||
/// <returns>The report's numerical ID.</returns>
|
||||
int Register(string reportKey, string activityName, string title);
|
||||
}
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Reports.Services {
|
||||
/// <summary>
|
||||
/// Service for handling reports. Reports provide user-accessible log-like functionality.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// You can use <see cref="Orchard.Reports.Services.IReportsCoordinator"/> to create reports through a simplified interface.
|
||||
/// </remarks>
|
||||
public interface IReportsManager : ISingletonDependency {
|
||||
void Add(int reportId, ReportEntryType type, string message);
|
||||
int CreateReport(string title, string activityName);
|
||||
Report Get(int reportId);
|
||||
IEnumerable<Report> GetReports();
|
||||
void Flush();
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Reports.Services {
|
||||
/// <summary>
|
||||
/// Defines a service that can be used to persist reports.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Implementations of this interface are commonly used from <see cref="Orchard.Reports.Services.IReportsManager"/> implementations.
|
||||
/// </remarks>
|
||||
public interface IReportsPersister : IDependency {
|
||||
IEnumerable<Report> Fetch();
|
||||
void Save(IEnumerable<Report> reports);
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Reports.Services {
|
||||
public class ReportsCoordinator : IReportsCoordinator, IDisposable {
|
||||
private readonly IReportsManager _reportsManager;
|
||||
private readonly IDictionary<string, int> _reports;
|
||||
|
||||
public ReportsCoordinator(IReportsManager reportsManager) {
|
||||
_reportsManager = reportsManager;
|
||||
Logger = NullLogger.Instance;
|
||||
_reports = new Dictionary<string, int>();
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public void Dispose() {
|
||||
_reportsManager.Flush();
|
||||
}
|
||||
|
||||
public void Add(string reportKey, ReportEntryType type, string message) {
|
||||
if(!_reports.ContainsKey(reportKey)) {
|
||||
// ignore message if no corresponding report
|
||||
return;
|
||||
}
|
||||
|
||||
_reportsManager.Add(_reports[reportKey], type, message);
|
||||
}
|
||||
|
||||
public int Register(string reportKey, string activityName, string title) {
|
||||
int reportId = _reportsManager.CreateReport(title, activityName);
|
||||
_reports.Add(reportKey, reportId);
|
||||
return reportId;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Reports.Services {
|
||||
public class ReportsManager : IReportsManager {
|
||||
private readonly IReportsPersister _reportsPersister;
|
||||
private List<Report> _reports;
|
||||
private static readonly object _synLock = new object();
|
||||
private bool _isDirty;
|
||||
|
||||
public ReportsManager(IReportsPersister reportsPersister) {
|
||||
_reportsPersister = reportsPersister;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public void Add(int reportId, ReportEntryType type, string message) {
|
||||
lock ( _synLock ) {
|
||||
LoadReports();
|
||||
_isDirty = true;
|
||||
var report = Get(reportId);
|
||||
if(report == null) {
|
||||
return;
|
||||
}
|
||||
report.Entries.Add(new ReportEntry {Message = message, Type = type, Utc = DateTime.UtcNow});
|
||||
}
|
||||
}
|
||||
|
||||
public int CreateReport(string title, string activityName) {
|
||||
lock ( _synLock ) {
|
||||
LoadReports();
|
||||
_isDirty = true;
|
||||
var reportId = _reports.Count == 0 ? 1 : _reports.Max(r => r.ReportId) + 1;
|
||||
var report = new Report {ActivityName = activityName, ReportId = reportId, Title = title, Utc = DateTime.UtcNow};
|
||||
_reports.Add(report);
|
||||
return reportId;
|
||||
}
|
||||
}
|
||||
|
||||
public Report Get(int reportId) {
|
||||
lock(_synLock) {
|
||||
LoadReports();
|
||||
return _reports.Where(r => r.ReportId == reportId).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Report> GetReports() {
|
||||
lock ( _synLock ) {
|
||||
LoadReports();
|
||||
return _reports.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void Flush() {
|
||||
if ( _reports == null || !_isDirty) {
|
||||
return;
|
||||
}
|
||||
|
||||
lock ( _synLock ) {
|
||||
_reportsPersister.Save(_reports);
|
||||
_isDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadReports() {
|
||||
if(_reports == null) {
|
||||
_reports = _reportsPersister.Fetch().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using System.IO;
|
||||
|
||||
namespace Orchard.Reports.Services {
|
||||
public class ReportsPersister : IReportsPersister {
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
private readonly string _reportsFileName;
|
||||
private readonly DataContractSerializer _dataContractSerializer;
|
||||
private readonly object _synLock = new object();
|
||||
|
||||
public ReportsPersister(IAppDataFolder appDataFolder, ShellSettings shellSettings) {
|
||||
_appDataFolder = appDataFolder;
|
||||
_shellSettings = shellSettings;
|
||||
_dataContractSerializer = new DataContractSerializer(typeof(Report), new [] { typeof(ReportEntry) });
|
||||
_reportsFileName = Path.Combine(Path.Combine("Sites", _shellSettings.Name), "reports.dat");
|
||||
}
|
||||
|
||||
public IEnumerable<Report> Fetch() {
|
||||
lock ( _synLock ) {
|
||||
if ( !_appDataFolder.FileExists(_reportsFileName) ) {
|
||||
yield break;
|
||||
}
|
||||
|
||||
var text = _appDataFolder.ReadFile(_reportsFileName);
|
||||
var xmlDocument = XDocument.Parse(text);
|
||||
var rootNode = xmlDocument.Root;
|
||||
if (rootNode == null) {
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var reportNode in rootNode.Elements()) {
|
||||
var reader = new StringReader(reportNode.Value);
|
||||
using (var xmlReader = XmlReader.Create(reader)) {
|
||||
yield return (Report) _dataContractSerializer.ReadObject(xmlReader, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(IEnumerable<Report> reports) {
|
||||
lock ( _synLock ) {
|
||||
var xmlDocument = new XDocument();
|
||||
xmlDocument.Add(new XElement("Reports"));
|
||||
foreach (var report in reports) {
|
||||
var reportNode = new XElement("Report");
|
||||
var writer = new StringWriter();
|
||||
using (var xmlWriter = XmlWriter.Create(writer)) {
|
||||
_dataContractSerializer.WriteObject(xmlWriter, report);
|
||||
}
|
||||
reportNode.Value = writer.ToString();
|
||||
xmlDocument.Root.Add(reportNode);
|
||||
}
|
||||
|
||||
var saveWriter = new StringWriter();
|
||||
xmlDocument.Save(saveWriter);
|
||||
_appDataFolder.CreateFile(_reportsFileName, saveWriter.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user