Merge branch 'dev' into issue/homepage-alias

Conflicts:
	src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs
	src/Orchard.Web/Modules/Orchard.Autoroute/Handlers/AutoroutePartHandler.cs
	src/Orchard.Web/Modules/Orchard.Autoroute/ImportExport/HomeAliasExportStep.cs
	src/Orchard.Web/Modules/Orchard.Autoroute/Orchard.Autoroute.csproj
	src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs
	src/Orchard.Web/Modules/Orchard.ImportExport/Views/Admin/ImportResult.cshtml
	src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj
	src/Orchard.Web/Modules/Orchard.Localization/Providers/LocalizationDateTimeFormatProvider.cs
	src/Orchard.Web/Modules/Orchard.Pages/Orchard.Pages.csproj
	src/Orchard/Localization/Services/CultureDateTimeFormatProvider.cs
	src/Orchard/Localization/Services/DefaultDateFormatter.cs
	src/Orchard/Localization/Services/IDateTimeFormatProvider.cs
This commit is contained in:
Sipke Schoorstra 2015-07-24 14:11:00 +01:00
commit e8cc0cba6e
31 changed files with 578 additions and 568 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,17 +1,17 @@
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)));
}
}
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)));
}
}
}

View File

@ -1,42 +1,42 @@
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);
}
}
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);
}
}
}

View File

@ -1,9 +1,9 @@
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
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

View File

@ -1,33 +1,33 @@
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())
}
};
}
}
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())
}
};
}
}
}

View File

@ -1,16 +1,16 @@
<?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>
<?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>

View File

@ -1,6 +1,6 @@
.navicon-reports {
background-image:url(images/menu.reports.png) !important;
}
.navicon-reports:hover {
background-position:0 -30px !important;
.navicon-reports {
background-image:url(images/menu.reports.png) !important;
}
.navicon-reports:hover {
background-position:0 -30px !important;
}

View File

@ -1,7 +1,7 @@
using Orchard.Reports;
namespace Orchard.Core.Reports.ViewModels {
public class DisplayReportViewModel {
public Report Report { get; set; }
}
using Orchard.Reports;
namespace Orchard.Core.Reports.ViewModels {
public class DisplayReportViewModel {
public Report Report { get; set; }
}
}

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using Orchard.Reports;
namespace Orchard.Core.Reports.ViewModels {
public class ReportsAdminIndexViewModel {
public IList<Report> Reports { get; set; }
}
using System.Collections.Generic;
using Orchard.Reports;
namespace Orchard.Core.Reports.ViewModels {
public class ReportsAdminIndexViewModel {
public IList<Report> Reports { get; set; }
}
}

View File

@ -1,39 +1,39 @@
@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>
@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>
}

View File

@ -1,39 +1,39 @@
@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>
@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>
}

View File

@ -15,6 +15,12 @@ using Orchard.Localization.Services;
using Orchard.Mvc;
using Orchard.Security;
using Orchard.UI.Notify;
using Orchard.Utility.Extensions;
using Orchard.Localization.Services;
using Orchard.Localization.Models;
using Orchard.Mvc;
using System.Web;
using Orchard.ContentManagement.Aspects;
namespace Orchard.Autoroute.Drivers {
public class AutoroutePartDriver : ContentPartDriver<AutoroutePart> {
@ -56,7 +62,7 @@ namespace Orchard.Autoroute.Drivers {
protected override DriverResult Editor(AutoroutePart part, IUpdateModel updater, dynamic shapeHelper) {
var settings = part.TypePartDefinition.Settings.GetModel<AutorouteSettings>();
var itemCulture = _cultureManager.GetSiteCulture();
// If we are editing an existing content item.
if (part.Record.Id != 0) {
ContentItem contentItem = _contentManager.Get(part.Record.ContentItemRecord.Id);

View File

@ -88,6 +88,30 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\Orchard.Alias\Orchard.Alias.csproj">
<Project>{475B6C45-B27C-438B-8966-908B9D6D1077}</Project>
<Name>Orchard.Alias</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.ContentTypes\Orchard.ContentTypes.csproj">
<Project>{0e7646e8-fe8f-43c1-8799-d97860925ec4}</Project>
<Name>Orchard.ContentTypes</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Tokens\Orchard.Tokens.csproj">
<Project>{6F759635-13D7-4E94-BCC9-80445D63F117}</Project>
<Name>Orchard.Tokens</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\AutorouteCommands.cs" />
<Compile Include="Providers\ContentDefinition\ContentDefinitionEventHandler.cs" />
@ -115,28 +139,7 @@
<Compile Include="Settings\AutorouteSettings.cs" />
<Compile Include="ViewModels\AutoroutePartEditViewModel.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2d1d92bb-4555-4cbe-8d0e-63563d6ce4c6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839c-39fc-4ceb-a5af-89ca7e87119f}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Alias\Orchard.Alias.csproj">
<Project>{475b6c45-b27c-438b-8966-908b9d6d1077}</Project>
<Name>Orchard.Alias</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.ContentTypes\Orchard.ContentTypes.csproj">
<Project>{0e7646e8-fe8f-43c1-8799-d97860925ec4}</Project>
<Name>Orchard.ContentTypes</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Tokens\Orchard.Tokens.csproj">
<Project>{6f759635-13d7-4e94-bcc9-80445d63f117}</Project>
<Name>Orchard.Tokens</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Placement.info">
<SubType>Designer</SubType>
@ -153,20 +156,20 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target> -->
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
<PropertyGroup>
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
</PropertyGroup>
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
-->
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
-->
</Target>
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">

View File

@ -148,8 +148,8 @@ namespace Orchard.Autoroute.Services {
} else {
settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = "0", Culture = culture });
return new RoutePattern { Name = "Title", Description = "my-title", Pattern = "{Content.Slug}", Culture = culture };
}
}
}
// return a default pattern if set
var patternCultureSearch = settings.Patterns.Any(x => String.Equals(x.Culture, culture, StringComparison.OrdinalIgnoreCase)) ? culture : null;
@ -159,11 +159,11 @@ namespace Orchard.Autoroute.Services {
if (settings.Patterns.Where(x => x.Culture == patternCultureSearch).ElementAt(Convert.ToInt32(settings.DefaultPatterns.Where(x => x.Culture == defaultPatternCultureSearch).FirstOrDefault().PatternIndex)) != null) {
return settings.Patterns.Where(x => x.Culture == patternCultureSearch).ElementAt(Convert.ToInt32(settings.DefaultPatterns.Where(x => x.Culture == defaultPatternCultureSearch).FirstOrDefault().PatternIndex));
};
}
}
// return a default pattern if none is defined
return new RoutePattern { Name = "Title", Description = "my-title", Pattern = "{Content.Slug}", Culture = culture };
}
}
public void RemoveAliases(AutoroutePart part) {
_aliasService.Delete(part.Path, AliasSource);

View File

@ -1,6 +1,6 @@
@model Orchard.ImportExport.ViewModels.ImportResultViewModel
@{
Layout.Title = T("Import Result").ToString();
@{
Layout.Title = T("Import Result").ToString();
}
@if (Model.Result.IsSuccessful) {
<div class="message message-Information">
@ -14,14 +14,14 @@ else {
}
<h2>@T("Recipe steps")</h2>
<table class="items" style="width: auto;">
<thead>
<tr>
<thead>
<tr>
<th>@T("Step")</th>
<th>@T("Executed")</th>
<th>@T("Result")</th>
<th>@T("Message")</th>
</tr>
</thead>
</tr>
</thead>
<tbody>
@foreach (var step in Model.Result.Steps) {
<tr>
@ -30,7 +30,7 @@ else {
<td>@if (step.IsSuccessful) { @T("Successful") } else if (step.IsCompleted) { <strong>@T("Failed")</strong> }</td>
<td><strong>@step.ErrorMessage</strong></td>
</tr>
}
}
</tbody>
</table>
</table>

View File

@ -597,20 +597,20 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target> -->
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
<PropertyGroup>
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
</PropertyGroup>
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
-->
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
-->
</Target>
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">

View File

@ -81,6 +81,7 @@
<ProjectReference Include="..\Orchard.Autoroute\Orchard.Autoroute.csproj">
<Project>{66fccd76-2761-47e3-8d11-b45d0001ddaa}</Project>
<Name>Orchard.Autoroute</Name>
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\Orchard.ContentPicker\Orchard.ContentPicker.csproj">
<Project>{f301ef7d-f19c-4d83-aa94-cb64f29c037d}</Project>
@ -120,11 +121,11 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,16 +1,16 @@
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; }
}
}
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; }
}
}

View File

@ -1,15 +1,15 @@
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; }
}
}
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; }
}
}

View File

@ -1,35 +1,35 @@
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);
}
}
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);
}
}

View File

@ -1,30 +1,30 @@
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);
}
}
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);
}
}

View File

@ -1,17 +1,17 @@
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();
}
}
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();
}
}

View File

@ -1,14 +1,14 @@
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);
}
}
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);
}
}

View File

@ -1,36 +1,36 @@
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;
}
}
}
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;
}
}
}

View File

@ -1,74 +1,74 @@
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();
}
}
}
}
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();
}
}
}
}

View File

@ -1,67 +1,67 @@
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());
}
}
}
}
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());
}
}
}
}