示例#1
0
        public async Task <IActionResult> Index()
        {
            var context      = CreateDomainContext();
            var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >();
            IEntityEditModel <Thread> threadResult;

            try
            {
                threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Detail");

                ViewBag.Thread = threadResult.Item;
            }
            catch (ArgumentException ex)
            {
                return(NotFound());
            }
            catch (EntityNotFoundException ex)
            {
                return(NotFound());
            }
            var postDomain = DomainProvider.GetService <EntityDomainService <Post> >();
            IEntityViewModel <Post> postResult = await postDomain.ExecuteAsync <IEntityViewModel <Post> >(context, "List");

            return(View(postResult));
        }
示例#2
0
        private async void performMove(IEntityViewModel entity, IDirectoryViewModel targetDirectory)
        {
            var targetVirtualDirectory = targetDirectory.VirtualFileSystem.GetDirectory(targetDirectory.DirectoryPath);

            switch (entity.Type)
            {
            case EntityType.Directory:
                var virtualDirectory = entity.VirtualFileSystem.GetDirectory(entity.FullName);
                try
                {
                    await _longOperationsManager.StartLongOperation(targetDirectory.VirtualFileSystem,
                                                                    operation => virtualDirectory.MoveTo(targetVirtualDirectory, operation.SetState,
                                                                                                         operation.CancellationTokenSource.Token));
                }
                catch (Exception e)
                {
                    _windowsManager.ReportError("Directory move error", e);
                }
                break;

            case EntityType.File:
                var virtualFile = entity.VirtualFileSystem.GetFile(entity.FullName);
                try
                {
                    await _longOperationsManager.StartLongOperation(targetDirectory.VirtualFileSystem,
                                                                    operation => virtualFile.MoveTo(targetVirtualDirectory, operation.SetState,
                                                                                                    operation.CancellationTokenSource.Token));
                }
                catch (Exception e)
                {
                    _windowsManager.ReportError("File move error", e);
                }
                break;
            }
        }
示例#3
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            IEntityViewModel model = (IEntityViewModel)value;

            writer.WriteStartObject();

            writer.WritePropertyName("PageSizeOption");
            serializer.Serialize(writer, model.PageSizeOption);
            writer.WritePropertyName("TotalPage");
            writer.WriteValue(model.TotalPage);
            writer.WritePropertyName("CurrentPage");
            writer.WriteValue(model.CurrentPage);
            writer.WritePropertyName("CurrentSize");
            writer.WriteValue(model.CurrentSize);

            writer.WritePropertyName("ViewButtons");
            serializer.Serialize(writer, model.ViewButtons);
            writer.WritePropertyName("ItemButtons");
            serializer.Serialize(writer, model.ItemButtons);

            writer.WritePropertyName("Items");
            serializer.Serialize(writer, model.Items);

            writer.WritePropertyName("Properties");
            serializer.Serialize(writer, model.Properties);

            writer.WritePropertyName("SearchItem");
            serializer.Serialize(writer, model.SearchItem);

            writer.WritePropertyName("Metadata");
            serializer.Serialize(writer, model.Metadata);

            writer.WriteEndObject();
        }
示例#4
0
        public async Task <IActionResult> Index()
        {
            var context     = CreateDomainContext();
            var forumDomain = DomainProvider.GetService <EntityDomainService <Entity.Forum> >();
            IEntityEditModel <Entity.Forum> forumResult;

            try
            {
                forumResult = await forumDomain.ExecuteAsync <IEntityEditModel <Entity.Forum> >(context, "Detail");

                ViewBag.Forum = forumResult.Item;
            }
            catch (DomainServiceException ex)
            {
                if (ex.InnerException is ArgumentException)
                {
                    return(StatusCode(400, ex.InnerException.Message));
                }
                else if (ex.InnerException is EntityNotFoundException)
                {
                    return(NotFound());
                }
                else
                {
                    ExceptionDispatchInfo.Capture(ex).Throw();
                    throw;
                }
            }
            var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >();
            IEntityViewModel <Thread> threadResult = await threadDomain.ExecuteAsync <IEntityViewModel <Thread> >(context, "List");

            return(View(threadResult));
        }
示例#5
0
        private void performPaste(IEntityViewModel entity, IDirectoryViewModel targetDirectory, bool isCutOperation)
        {
            if (isCutOperation)
            {
                performMove(entity, targetDirectory);
                return;
            }

            performCopy(entity, targetDirectory);
        }
示例#6
0
        private void performOperation(IEntityViewModel entity, IDirectoryViewModel targetDirectory, bool isCutOperation)
        {
            if (entity.VirtualFileSystem == targetDirectory.VirtualFileSystem)
            {
                performPaste(entity, targetDirectory, isCutOperation);
                return;
            }

            performImport(entity, targetDirectory);
        }
示例#7
0
        private static void ModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            EntityViewer viewer = (EntityViewer)d;

            if (e.NewValue == null)
            {
                viewer.NavigatePageCommand   = null;
                viewer.ChangePageSizeCommand = null;
                viewer.EntityViewCommand     = null;
                viewer.EntityItemCommand     = null;
            }
            else
            {
                IEntityViewModel model = (IEntityViewModel)e.NewValue;
                viewer.NavigatePageCommand   = new ViewerNavigatePageCommand(viewer.ServiceProvider);
                viewer.ChangePageSizeCommand = new ViewerChangePageSizeCommand(viewer.ServiceProvider);
                viewer.EntityViewCommand     = new ViewerEntityViewCommand(viewer.ServiceProvider);
                viewer.EntityItemCommand     = new ViewerEntityItemCommand(viewer.ServiceProvider);
                viewer.Title = "列表 " + model.Metadata.Name;
            }
        }
        public ICollection <Field> Resolve(IEntityViewModel source, IEntity <TCategory> destination, ICollection <Field> destMember, ResolutionContext context)
        {
            var newOneIds = source.Fields.Select(x => x.Id);

            destMember.Where(x => !newOneIds.Contains(x.Id)).ToList().ForEach(x =>
            {
                _unitOfWork.Delete(x);
                destMember.Remove(x);
            });
            source.Fields.Where(x => x.Id == Guid.Empty).ToList().MapToModel().ForEach(x =>
            {
                _unitOfWork.Add(x);
                destMember.Add(x);
            });
            source.Fields.Where(x => x.Id != Guid.Empty).ToList().ForEach(x =>
            {
                var old = destMember.First(o => o.Id == x.Id);
                x.MapToExisting(old);
                _unitOfWork.Update(old);
            });
            return(destMember.ToList());
        }
 public static void UpdateEntity(IEntityViewModel e)
 {
     Instance._model.UpdateEntity(e.Entity);
 }
 public static void DeleteEntity(IEntityViewModel e)
 {
     Instance._model.DeleteEntity(e.Entity);
 }
示例#11
0
 public static void UpdateEntity(IEntityViewModel e)
 {
     Instance._model.UpdateEntity(e.Entity);
 }
示例#12
0
 public static void DeleteEntity(IEntityViewModel e)
 {
     Instance._model.DeleteEntity(e.Entity);
 }
 public void Unregister(IEntityViewModel vm)
 {
     Unregister(vm.Entity);
 }
 public void Register(IEntityViewModel vm)
 {
     _cache[vm.Entity] = vm;
 }
示例#15
0
 public LoadEntityDataCommand(ILoadEntityService <T> loadEntityService, IEntityViewModel <T> viewModel, string entityId)
 {
     _viewModel         = viewModel;
     _entityId          = entityId;
     _loadEntityService = loadEntityService;
 }