public IActionResult Index(Guid?id, bool isSource = false)
        {
            _contextHolder.GetContext(HttpContext).Build(HttpContext);
            var  versionInput = HttpContext.Request.Query["version"].ToString();
            long version;

            long.TryParse(versionInput, out version);

            var model = new UserPositionViewModel();

            id = id ?? DObject.RootId;
            FilesPanelType type = HttpContext.Session.GetSessionValues <FilesPanelType>(SessionKeys.FilesPanelType);

            model.CurrentFolderId = id.Value;
            model.FilesPanelType  = type;
            SetViewBagParams(isSource, type);

            var context = _contextHolder.GetContext(HttpContext);
            var repo    = context.Repository;
            var node    = repo.GetObjects(new[] { id.Value }).FirstOrDefault();

            if (node != null)
            {
                var nodeType = repo.GetType(node.TypeId);
                if (nodeType.HasFiles)
                {
                    model.Version = version;
                    model.IsFile  = true;
                }
            }

            return(View(model));
        }
示例#2
0
        /// <summary>
        /// Представление Types
        /// </summary>
        /// <returns>представление Types</returns>
        public IActionResult Types()
        {
            var context = _contextHolder.GetContext(HttpContext);
            var types   = context.Repository.GetTypes();

            return(View(types));
        }
示例#3
0
        public IViewComponentResult Invoke(Guid id)
        {
            Queue <KeyValuePair <string, string> > result = new Queue <KeyValuePair <string, string> >();

            try
            {
                var context    = _contextHolder.GetContext(HttpContext);
                var types      = context.Repository.GetTypes().ToDictionary(x => x.Id, y => y);
                var repository = _contextHolder.GetContext(HttpContext).Repository;

                Guid parentId = id;
                bool isSource = ViewBag.IsSource ?? false;
                while (parentId != DObject.RootId)
                {
                    var obj   = repository.GetObjects(new[] { parentId })[0];
                    var mType = types[obj.TypeId];
                    result.Enqueue(new KeyValuePair <string, string>(Url.Action("Index", "Files", new { id = obj.Id, isSource }), obj.GetTitle(mType)));
                    if (mType.IsMountable)
                    {
                        isSource = false;
                    }
                    parentId = obj.ParentId;
                }
                result.Enqueue(new KeyValuePair <string, string>(Url.Action("Index", "Files", new { id = DObject.RootId }), "Начало"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(View(result));
        }
示例#4
0
 public async Task <ActionResult> GetTaskDetails(string taskId)
 {
     return(await Task <ActionResult> .Factory.StartNew(() =>
     {
         var id = Guid.Parse(taskId);
         var model = new TaskDetailsViewModel(id, _contextHolder.GetContext(HttpContext).Repository);
         return PartialView("TaskDetails", model);
     }));
 }
        protected static void CheckGet(IContextHolder holder)
        {
            var container = GetMock <IInternalContainer>();

            container.Expect(c => c.CreateNewLog()).Return(null);
            var context = holder.GetContext(container);

            Assert.That(context, Is.InstanceOf <InjectionContext>());
            Assert.That(((InjectionContext)context).ThreadId, Is.EqualTo(Thread.CurrentThread.ManagedThreadId));
        }
        protected void CheckGet(IContextHolder holder)
        {
            var internalContainerMock = GetMock <IInternalContainer>();

            internalContainerMock.Setup(c => c.CreateNewLog()).Returns((IGroboContainerLog)null);
            var context = holder.GetContext(internalContainerMock.Object);

            Assert.That(context, Is.InstanceOf <InjectionContext>());
            Assert.That(((InjectionContext)context).ThreadId, Is.EqualTo(Thread.CurrentThread.ManagedThreadId));
        }
示例#7
0
        /// <summary>
        /// Вызвать компонент панели файлов
        /// </summary>
        /// <param name="folderId">Идентификатор текущего каталога</param>
        /// <param name="panelType">Тип отображения панели</param>
        /// <param name="onlySource">Отображать только исходные файлы</param>
        /// <returns>Представление панели управения файлом для каталога с идентификатором Id и итпом отбражения Type.</returns>
        public async Task <IViewComponentResult> InvokeAsync(Guid folderId, FilesPanelType panelType, bool onlySource)
        {
            return(await Task.Run(() =>
            {
                {
                    List <FileViewModel> model = new List <FileViewModel>();
                    try
                    {
                        var context = _contextHolder.GetContext(HttpContext);
                        var repository = context.Repository;
                        var types = repository.GetTypes().ToDictionary(x => x.Id, y => y);
                        var folder = repository.GetObjects(new[] { folderId }).First();

                        if (folder.Children?.Any() != true)
                        {
                            return View(panelType == FilesPanelType.List ? "List" : "Grid", new FileViewModel[] { });
                        }

                        var childrenIds = folder.Children.Select(x => x.ObjectId).ToArray();
                        var childrens = repository.GetObjects(childrenIds);

                        var folderType = types[folder.TypeId];
                        if (folderType.IsMountable && !(ViewBag.IsSource ?? false))
                        {
                            model.Add(new FileViewModel
                            {
                                IsFolder = true,
                                Id = folder.Id,
                                ObjectId = folder.Id,
                                ObjectName = "Исходные файлы",
                                ObjectTypeName = "Папка с исходными файлами",
                                ObjectTypeId = ApplicationConst.SourcefolderTypeid,
                                LastModifiedDate = folder.Created,
                                ChildrenCount = folder.Children.Count(x => types[x.TypeId].IsProjectFileOrFolder())
                            });
                        }

                        if (onlySource)
                        {
                            FillModelWithSource(childrens, types, model);
                        }
                        else
                        {
                            FillModel(childrens, types, model);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                    return View(panelType == FilesPanelType.List ? "List" : "Grid", model);
                }
            }));
        }
        /// <summary>
        /// Отображение боковой панели.
        /// </summary>
        /// <param name="id">Уникальный Id папки, для которой запрашивается представление.</param>
        /// <returns>Представление боковой панели для папки с идентификатором Id.</returns>
        public IViewComponentResult GetSidePanel(Guid?id)
        {
            id = id ?? DObject.RootId;

            var context     = _contextHolder.GetContext(HttpContext);
            var repo        = context.Repository;
            var rootObject  = repo.GetObjects(new[] { id.Value }).First();
            var bRootObject = repo.GetObjects(new[] { DObject.RootId }).First();
            var mTypes      = repo.GetTypes().ToDictionary(x => x.Id, y => y);
            var model       = new SidePanelViewModel
            {
                ObjectId = id.Value,
                Types    = mTypes,
                Items    = new List <SidePanelItem>()
            };

            var prevId   = rootObject.Id;
            var parentId = rootObject.Id;

            do
            {
                var parentObject    = repo.GetObjects(new[] { parentId }).First();
                var parentChildsIds = parentObject.Children
                                      .Where(x => mTypes[x.TypeId].IsService == false)
                                      .Select(x => x.ObjectId).ToArray();
                if (parentChildsIds.Length != 0)
                {
                    var parentChilds    = repo.GetObjects(parentChildsIds);
                    var visibleChildren = parentChilds.Where(x => x.IsVisible()).ToList();
                    var subtree         = model.Items;
                    model.Items = new List <SidePanelItem>();
                    foreach (var parentChild in visibleChildren)
                    {
                        if (parentChild.IsForbidden())
                        {
                            continue;
                        }

                        model.Items.Add(new SidePanelItem
                        {
                            Type     = mTypes[parentChild.TypeId],
                            DObject  = parentChild,
                            SubItems = parentChild.Id == prevId ? subtree : null,
                            Selected = parentChild.Id == id
                        });
                    }
                }

                prevId   = parentId;
                parentId = parentObject.ParentId;
            } while (parentId != bRootObject.ParentId);
            return(View(model));
        }
        /// <summary>
        /// Вызвать компонент панели файлов
        /// </summary>
        /// <param name="docId">Идентификатор текущего документа</param>
        /// <param name="panelType">Тип отображения панели</param>
        /// <param name="version">Время версии</param>
        /// <returns>Представление панели управения файлом для каталога с идентификатором Id и итпом отбражения Type.</returns>
        public async Task <IViewComponentResult> InvokeAsync(Guid docId, FilesPanelType panelType, long version)
        {
            return(await Task.Run(() =>
            {
                {
                    try
                    {
                        ViewBag.Repository = _contextHolder.GetContext(HttpContext).Repository;
                        ViewBag.DocumentRender = _render;
                        ViewBag.Store = _store;

                        var model = new FilesDetailsViewModel(docId, version, _contextHolder.GetContext(HttpContext).Repository, panelType);
                        return View("FileDetails", model);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex);
                        throw new Exception(ex.Message);
                    }
                }
            }));
        }
        public async Task <IActionResult> Index()
        {
            return(await Task <ActionResult> .Factory.StartNew(() =>
            {
                var taskId = HttpContext.Request.Query["id"].ToString();
                if (string.IsNullOrEmpty(taskId))
                {
                    return View("TaskDetails");
                }

                var id = Guid.Parse(taskId);
                var model = new TaskDetailsViewModel(id, _contextHolder.GetContext(HttpContext).Repository);
                return View("TaskDetails", model);
            }));
        }
 /// <summary>
 /// Вызвать компонент панели файлов
 /// </summary>
 /// <param name="docId">Идентификатор текущего документа</param>
 /// <param name="panelType">Тип отображения панели</param>
 /// <param name="version">Время версии</param>
 /// <returns>Представление панели управения файлом для каталога с идентификатором Id и итпом отбражения Type.</returns>
 public async Task <IViewComponentResult> InvokeAsync(Guid docId, FilesPanelType panelType, long version)
 {
     return(await Task.Run(() =>
     {
         {
             try
             {
                 var model = new FilesDetailsViewModel(docId, version, _contextHolder.GetContext(HttpContext).Repository, panelType);
                 return View("FileDetails", model);
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }));
 }
示例#12
0
        public IActionResult Index(Guid?id, bool isSource = false)
        {
            _contextHolder.GetContext(HttpContext).Build(HttpContext);

            var model = new UserPositionViewModel();

            id = id ?? DObject.RootId;
            FilesPanelType type = HttpContext.Session.GetSessionValues <FilesPanelType>(SessionKeys.FilesPanelType);

            model.CurrentFolderId  = id.Value;
            model.FilesPanelType   = type;
            ViewBag.FilesPanelType = type;
            ViewBag.IsSource       = isSource;

            return(View(model));
        }
示例#13
0
        public void Dispose()
        {
            var context = holder.GetContext(internalContainer);

            context.InternalContainer.CallDispose();
        }