public Attempt <OperationResult <MoveOperationStatusType>?> Move(TItem moving, int containerId) { EventMessages eventMessages = EventMessagesFactory.Get(); var moveInfo = new List <MoveEventInfo <TItem> >(); using (ICoreScope scope = ScopeProvider.CreateCoreScope()) { var moveEventInfo = new MoveEventInfo <TItem>(moving, moving.Path, containerId); MovingNotification <TItem> movingNotification = GetMovingNotification(moveEventInfo, eventMessages); if (scope.Notifications.PublishCancelable(movingNotification)) { scope.Complete(); return(OperationResult.Attempt.Fail(MoveOperationStatusType.FailedCancelledByEvent, eventMessages)); } scope.WriteLock(WriteLockIds); // also for containers try { EntityContainer?container = null; if (containerId > 0) { container = _containerRepository?.Get(containerId); if (container == null) { throw new DataOperationException <MoveOperationStatusType>(MoveOperationStatusType.FailedParentNotFound); // causes rollback } } moveInfo.AddRange(Repository.Move(moving, container !)); scope.Complete(); } catch (DataOperationException <MoveOperationStatusType> ex) { scope.Complete(); return(OperationResult.Attempt.Fail(ex.Operation, eventMessages)); } // note: not raising any Changed event here because moving a content type under another container // has no impact on the published content types - would be entirely different if we were to support // moving a content type under another content type. MovedNotification <TItem> movedNotification = GetMovedNotification(moveInfo, eventMessages); movedNotification.WithStateFrom(movingNotification); scope.Notifications.Publish(movedNotification); } return(OperationResult.Attempt.Succeed(MoveOperationStatusType.Success, eventMessages)); }
public Attempt <OperationStatus <MoveOperationStatusType> > Move(IDataTypeDefinition toMove, int parentId) { var evtMsgs = EventMessagesFactory.Get(); var moveInfo = new List <MoveEventInfo <IDataTypeDefinition> >(); using (var uow = UowProvider.GetUnitOfWork()) { var moveEventInfo = new MoveEventInfo <IDataTypeDefinition>(toMove, toMove.Path, parentId); var moveEventArgs = new MoveEventArgs <IDataTypeDefinition>(evtMsgs, moveEventInfo); if (uow.Events.DispatchCancelable(Moving, this, moveEventArgs)) { uow.Commit(); return(Attempt.Fail(new OperationStatus <MoveOperationStatusType>(MoveOperationStatusType.FailedCancelledByEvent, evtMsgs))); } var containerRepository = RepositoryFactory.CreateEntityContainerRepository(uow, Constants.ObjectTypes.DataTypeContainerGuid); var repository = RepositoryFactory.CreateDataTypeDefinitionRepository(uow); try { EntityContainer container = null; if (parentId > 0) { container = containerRepository.Get(parentId); if (container == null) { throw new DataOperationException <MoveOperationStatusType>(MoveOperationStatusType.FailedParentNotFound); } } moveInfo.AddRange(repository.Move(toMove, container)); } catch (DataOperationException <MoveOperationStatusType> ex) { return(Attempt.Fail( new OperationStatus <MoveOperationStatusType>(ex.Operation, evtMsgs))); } uow.Commit(); moveEventArgs.MoveInfoCollection = moveInfo; moveEventArgs.CanCancel = false; uow.Events.Dispatch(Moved, this, moveEventArgs); } return(Attempt.Succeed( new OperationStatus <MoveOperationStatusType>(MoveOperationStatusType.Success, evtMsgs))); }
public Attempt <OperationResult <MoveOperationStatusType> > Move(IDataType toMove, int parentId) { var evtMsgs = EventMessagesFactory.Get(); var moveInfo = new List <MoveEventInfo <IDataType> >(); using (var scope = ScopeProvider.CreateScope()) { var moveEventInfo = new MoveEventInfo <IDataType>(toMove, toMove.Path, parentId); var movingDataTypeNotification = new DataTypeMovingNotification(moveEventInfo, evtMsgs); if (scope.Notifications.PublishCancelable(movingDataTypeNotification)) { scope.Complete(); return(OperationResult.Attempt.Fail(MoveOperationStatusType.FailedCancelledByEvent, evtMsgs)); } try { EntityContainer container = null; if (parentId > 0) { container = _dataTypeContainerRepository.Get(parentId); if (container == null) { throw new DataOperationException <MoveOperationStatusType>(MoveOperationStatusType.FailedParentNotFound); // causes rollback } } moveInfo.AddRange(_dataTypeRepository.Move(toMove, container)); scope.Notifications.Publish(new DataTypeMovedNotification(moveEventInfo, evtMsgs).WithStateFrom(movingDataTypeNotification)); scope.Complete(); } catch (DataOperationException <MoveOperationStatusType> ex) { scope.Complete(); // TODO: what are we doing here exactly? return(OperationResult.Attempt.Fail(ex.Operation, evtMsgs)); } } return(OperationResult.Attempt.Succeed(MoveOperationStatusType.Success, evtMsgs)); }
public Attempt <OperationResult <MoveOperationStatusType> > Move(IDataType toMove, int parentId) { var evtMsgs = EventMessagesFactory.Get(); var moveInfo = new List <MoveEventInfo <IDataType> >(); using (var scope = ScopeProvider.CreateScope()) { var moveEventInfo = new MoveEventInfo <IDataType>(toMove, toMove.Path, parentId); var moveEventArgs = new MoveEventArgs <IDataType>(evtMsgs, moveEventInfo); if (scope.Events.DispatchCancelable(Moving, this, moveEventArgs)) { scope.Complete(); return(OperationResult.Attempt.Fail(MoveOperationStatusType.FailedCancelledByEvent, evtMsgs)); } try { EntityContainer container = null; if (parentId > 0) { container = _dataTypeContainerRepository.Get(parentId); if (container == null) { throw new DataOperationException <MoveOperationStatusType>(MoveOperationStatusType.FailedParentNotFound); // causes rollback } } moveInfo.AddRange(_dataTypeRepository.Move(toMove, container)); moveEventArgs.MoveInfoCollection = moveInfo; moveEventArgs.CanCancel = false; scope.Events.Dispatch(Moved, this, moveEventArgs); scope.Complete(); } catch (DataOperationException <MoveOperationStatusType> ex) { scope.Complete(); // fixme what are we doing here exactly? return(OperationResult.Attempt.Fail(ex.Operation, evtMsgs)); } } return(OperationResult.Attempt.Succeed(MoveOperationStatusType.Success, evtMsgs)); }
public ContentTypeMovingNotification(MoveEventInfo <IContentType> target, EventMessages messages) : base( target, messages) { }
protected MovedToRecycleBinNotification(MoveEventInfo <T> target, EventMessages messages) : base(new[] { target }, messages) { }
protected abstract MovingNotification <TItem> GetMovingNotification(MoveEventInfo <TItem> moveInfo, EventMessages eventMessages);
protected MovingNotification(MoveEventInfo <T> target, EventMessages messages) : base(new[] { target }, messages) { }
private bool IsUserTag(MoveEventInfo <IContent> arg) => arg.Entity.ContentType.Alias == _documentTypeAliasProvider.GetUserTag();
protected override MovingNotification <IMediaType> GetMovingNotification(MoveEventInfo <IMediaType> moveInfo, EventMessages eventMessages) => new MediaTypeMovingNotification(moveInfo, eventMessages);
public DataTypeMovedNotification(MoveEventInfo <IDataType> target, EventMessages messages) : base(target, messages) { }
public ContentMovedToRecycleBinNotification(MoveEventInfo <IContent> target, EventMessages messages) : base( target, messages) { }
public MediaMovingToRecycleBinNotification(MoveEventInfo <IMedia> target, EventMessages messages) : base(target, messages) { }
public MemberTypeMovedNotification(MoveEventInfo <IMemberType> target, EventMessages messages) : base(target, messages) { }
public MediaMovedNotification(MoveEventInfo <IMedia> target, EventMessages messages) : base(target, messages) { }
public MediaTypeMovingNotification(MoveEventInfo <IMediaType> target, EventMessages messages) : base(target, messages) { }