Fix build after merge

This commit is contained in:
Stephan
2016-07-08 17:58:01 +02:00
parent 3c7245f9ba
commit be056869f0
42 changed files with 221 additions and 297 deletions

View File

@@ -614,7 +614,7 @@ namespace Umbraco.Core.Services
// all descendants are going to be deleted
var allDescendantsAndSelf = itemsA.SelectMany(xx => xx.DescendantsAndSelf(this))
.Distinct()
.DistinctBy(x => x.Id)
.ToArray();
// delete content

View File

@@ -281,21 +281,6 @@ namespace Umbraco.Core.Services
IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalRecords,
string orderBy, Direction orderDirection, bool orderBySystemField, IQuery<IContent> filter);
/// <summary>
/// Gets a collection of <see cref="IContent"/> objects by Parent Id
/// </summary>
/// <param name="id">Id of the Parent to retrieve Descendants from</param>
/// <param name="pageIndex">Page number</param>
/// <param name="pageSize">Page size</param>
/// <param name="totalRecords">Total records query would return without paging</param>
/// <param name="orderBy">Field to order by</param>
/// <param name="orderDirection">Direction to order by</param>
/// <param name="orderBySystemField">Flag to indicate when ordering by system field</param>
/// <param name="filter"></param>
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalRecords,
string orderBy, Direction orderDirection, bool orderBySystemField, IQuery<IContent> filter);
/// <summary>
/// Gets a collection of an <see cref="IContent"/> objects versions by its Id
/// </summary>

View File

@@ -25,20 +25,17 @@ namespace Umbraco.Core.Services
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
private readonly IUserService _userService;
private readonly IContentService _contentService;
private readonly RepositoryFactory _repositoryFactory;
private readonly ILogger _logger;
public NotificationService(IDatabaseUnitOfWorkProvider provider, IUserService userService, IContentService contentService, RepositoryFactory repositoryFactory, ILogger logger)
public NotificationService(IDatabaseUnitOfWorkProvider provider, IUserService userService, IContentService contentService, ILogger logger)
{
if (provider == null) throw new ArgumentNullException("provider");
if (userService == null) throw new ArgumentNullException("userService");
if (contentService == null) throw new ArgumentNullException("contentService");
if (repositoryFactory == null) throw new ArgumentNullException("repositoryFactory");
if (logger == null) throw new ArgumentNullException("logger");
if (provider == null) throw new ArgumentNullException(nameof(provider));
if (userService == null) throw new ArgumentNullException(nameof(userService));
if (contentService == null) throw new ArgumentNullException(nameof(contentService));
if (logger == null) throw new ArgumentNullException(nameof(logger));
_uowProvider = provider;
_userService = userService;
_contentService = contentService;
_repositoryFactory = repositoryFactory;
_logger = logger;
}
@@ -83,8 +80,7 @@ namespace Umbraco.Core.Services
SendNotification(operatingUser, u, content, allVersions,
actionName, http, createSubject, createBody);
_logger.Debug<NotificationService>(string.Format("Notification type: {0} sent to {1} ({2})",
action, u.Name, u.Email));
_logger.Debug<NotificationService>($"Notification type: {action} sent to {u.Name} ({u.Email})");
}
catch (Exception ex)
{
@@ -119,7 +115,7 @@ namespace Umbraco.Core.Services
// lazily get versions - into lists to ensure we can enumerate multiple times
var allVersionsDictionary = new Dictionary<int, List<IContent>>();
int totalUsers;
long totalUsers;
var allUsers = _userService.GetAll(0, int.MaxValue, out totalUsers);
foreach (var u in allUsers.Where(x => x.IsApproved))
{
@@ -140,8 +136,7 @@ namespace Umbraco.Core.Services
SendNotification(operatingUser, u, content, allVersions,
actionName, http, createSubject, createBody);
_logger.Debug<NotificationService>(string.Format("Notification type: {0} sent to {1} ({2})",
action, u.Name, u.Email));
_logger.Debug<NotificationService>($"Notification type: {action} sent to {u.Name} ({u.Email})");
}
catch (Exception ex)
{
@@ -496,9 +491,9 @@ namespace Umbraco.Core.Services
var diffs = Diff.DiffText1(oldText, newText);
int pos = 0;
for (int n = 0; n < diffs.Length; n++)
for (var n = 0; n < diffs.Length; n++)
{
Diff.Item it = diffs[n];
var it = diffs[n];
// write unchanged chars
while ((pos < it.StartB) && (pos < newText.Length))
@@ -511,7 +506,7 @@ namespace Umbraco.Core.Services
if (displayDeletedText && it.DeletedA > 0)
{
sb.Append(deletedStyle);
for (int m = 0; m < it.DeletedA; m++)
for (var m = 0; m < it.DeletedA; m++)
{
sb.Append(oldText[it.StartA + m]);
} // for

View File

@@ -3,112 +3,112 @@ using System.Collections.Generic;
using Umbraco.Core.Events;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
namespace Umbraco.Core.Services
{
internal class RedirectUrlService : RepositoryService, IRedirectUrlService
{
public RedirectUrlService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, ILogger logger, IEventMessagesFactory eventMessagesFactory)
: base(provider, repositoryFactory, logger, eventMessagesFactory)
public RedirectUrlService(IDatabaseUnitOfWorkProvider provider, ILogger logger, IEventMessagesFactory eventMessagesFactory)
: base(provider, logger, eventMessagesFactory)
{ }
public void Register(string url, Guid contentKey)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
var redir = repo.Get(url, contentKey);
if (redir != null)
redir.CreateDateUtc = DateTime.UtcNow;
else
redir = new RedirectUrl { Url = url, ContentKey = contentKey };
repo.AddOrUpdate(redir);
uow.Commit();
uow.Complete();
}
}
public void Delete(IRedirectUrl redirectUrl)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
repo.Delete(redirectUrl);
uow.Commit();
uow.Complete();
}
}
public void Delete(int id)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
repo.Delete(id);
uow.Commit();
uow.Complete();
}
}
public void DeleteContentRedirectUrls(Guid contentKey)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
repo.DeleteContentUrls(contentKey);
uow.Commit();
uow.Complete();
}
}
public void DeleteAll()
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
repo.DeleteAll();
uow.Commit();
uow.Complete();
}
}
public IRedirectUrl GetMostRecentRedirectUrl(string url)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
var rule = repo.GetMostRecentUrl(url);
uow.Commit();
uow.Complete();
return rule;
}
}
public IEnumerable<IRedirectUrl> GetContentRedirectUrls(Guid contentKey)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
var rules = repo.GetContentUrls(contentKey);
uow.Commit();
uow.Complete();
return rules;
}
}
public IEnumerable<IRedirectUrl> GetAllRedirectUrls(long pageIndex, int pageSize, out long total)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
var rules = repo.GetAllUrls(pageIndex, pageSize, out total);
uow.Commit();
uow.Complete();
return rules;
}
}
public IEnumerable<IRedirectUrl> GetAllRedirectUrls(int rootContentId, long pageIndex, int pageSize, out long total)
{
using (var uow = UowProvider.GetUnitOfWork())
using (var repo = RepositoryFactory.CreateRedirectUrlRepository(uow))
using (var uow = UowProvider.CreateUnitOfWork())
{
var repo = uow.CreateRepository<IRedirectUrlRepository>();
var rules = repo.GetAllUrls(rootContentId, pageIndex, pageSize, out total);
uow.Commit();
uow.Complete();
return rules;
}
}

View File

@@ -34,12 +34,13 @@ namespace Umbraco.Core.Services
private readonly Lazy<IMemberGroupService> _memberGroupService;
private readonly Lazy<INotificationService> _notificationService;
private readonly Lazy<IExternalLoginService> _externalLoginService;
private readonly Lazy<IRedirectUrlService> _redirectUrlService;
/// <summary>
/// Initializes a new instance of the <see cref="ServiceContext"/> class with lazy services.
/// </summary>
/// <remarks>Used by IoC. Note that LightInject will favor lazy args when picking a constructor.</remarks>
public ServiceContext(Lazy<IMigrationEntryService> migrationEntryService, Lazy<IPublicAccessService> publicAccessService, Lazy<ITaskService> taskService, Lazy<IDomainService> domainService, Lazy<IAuditService> auditService, Lazy<ILocalizedTextService> localizedTextService, Lazy<ITagService> tagService, Lazy<IContentService> contentService, Lazy<IUserService> userService, Lazy<IMemberService> memberService, Lazy<IMediaService> mediaService, Lazy<IContentTypeService> contentTypeService, Lazy<IMediaTypeService> mediaTypeService, Lazy<IDataTypeService> dataTypeService, Lazy<IFileService> fileService, Lazy<ILocalizationService> localizationService, Lazy<IPackagingService> packagingService, Lazy<IServerRegistrationService> serverRegistrationService, Lazy<IEntityService> entityService, Lazy<IRelationService> relationService, Lazy<IApplicationTreeService> treeService, Lazy<ISectionService> sectionService, Lazy<IMacroService> macroService, Lazy<IMemberTypeService> memberTypeService, Lazy<IMemberGroupService> memberGroupService, Lazy<INotificationService> notificationService, Lazy<IExternalLoginService> externalLoginService)
public ServiceContext(Lazy<IMigrationEntryService> migrationEntryService, Lazy<IPublicAccessService> publicAccessService, Lazy<ITaskService> taskService, Lazy<IDomainService> domainService, Lazy<IAuditService> auditService, Lazy<ILocalizedTextService> localizedTextService, Lazy<ITagService> tagService, Lazy<IContentService> contentService, Lazy<IUserService> userService, Lazy<IMemberService> memberService, Lazy<IMediaService> mediaService, Lazy<IContentTypeService> contentTypeService, Lazy<IMediaTypeService> mediaTypeService, Lazy<IDataTypeService> dataTypeService, Lazy<IFileService> fileService, Lazy<ILocalizationService> localizationService, Lazy<IPackagingService> packagingService, Lazy<IServerRegistrationService> serverRegistrationService, Lazy<IEntityService> entityService, Lazy<IRelationService> relationService, Lazy<IApplicationTreeService> treeService, Lazy<ISectionService> sectionService, Lazy<IMacroService> macroService, Lazy<IMemberTypeService> memberTypeService, Lazy<IMemberGroupService> memberGroupService, Lazy<INotificationService> notificationService, Lazy<IExternalLoginService> externalLoginService, Lazy<IRedirectUrlService> redirectUrlService)
{
_migrationEntryService = migrationEntryService;
_publicAccessService = publicAccessService;
@@ -68,6 +69,7 @@ namespace Umbraco.Core.Services
_memberGroupService = memberGroupService;
_notificationService = notificationService;
_externalLoginService = externalLoginService;
_redirectUrlService = redirectUrlService;
}
/// <summary>
@@ -101,7 +103,8 @@ namespace Umbraco.Core.Services
IPublicAccessService publicAccessService = null,
IExternalLoginService externalLoginService = null,
IMigrationEntryService migrationEntryService = null,
IServerRegistrationService serverRegistrationService = null)
IServerRegistrationService serverRegistrationService = null,
IRedirectUrlService redirectUrlService = null)
{
if (serverRegistrationService != null) _serverRegistrationService = new Lazy<IServerRegistrationService>(() => serverRegistrationService);
if (migrationEntryService != null) _migrationEntryService = new Lazy<IMigrationEntryService>(() => migrationEntryService);