Пример #1
0
        public ActionResult ContentList(string org, ModelForWebDav model, string pathPart = "")
        {
            try
            {
                if (Request.Browser.IsMobileDevice == false && model.UserSettings.WebDavViewType == FolderViewTypes.Table)
                {
                    return PartialView("_ShowContentTable", model);
                }

                IEnumerable<IHierarchyItem> children;

                if (string.IsNullOrEmpty(model.SearchValue))
                {
                    children = _webdavManager.OpenFolder(pathPart);
                }
                else
                {
                    children = _webdavManager.SearchFiles(WspContext.User.ItemId, pathPart, model.SearchValue, WspContext.User.Login, true);
                }

                model.Items = children.Take(WebDavAppConfigManager.Instance.ElementsRendering.DefaultCount);

                return PartialView("_ShowContentBigIcons", model);
            }
            catch (UnauthorizedException e)
            {
                throw new HttpException(404, "Not Found");
            }
        }
        public ActionResult ShowContent(string org, string pathPart = "", string searchValue = "")
        {
            if (org != WspContext.User.OrganizationId)
            {
                return new HttpStatusCodeResult(HttpStatusCode.NoContent);
            }

            if (_webdavManager.IsFile(pathPart))
            {
                var resource = _webdavManager.GetResource(pathPart);

                var mimeType = _openerManager.GetMimeType(Path.GetExtension(pathPart));

                return new FileStreamResult(resource.GetReadStream(), mimeType);
            }

            try
            {
                var model = new ModelForWebDav
                {
                    UrlSuffix = pathPart, 
                    Permissions =_webDavAuthorizationService.GetPermissions(WspContext.User, pathPart),
                    UserSettings = _userSettingsManager.GetUserSettings(WspContext.User.AccountId),
                    SearchValue = searchValue
                };

                if (Request.Browser.IsMobileDevice)
                {
                    model.UserSettings.WebDavViewType = FolderViewTypes.BigIcons;
                }

                return View(model);
            }
            catch (UnauthorizedException e)
            {
                throw new HttpException(404, "Not Found");
            }
        }
        public ActionResult UploadFiles(string org, string pathPart)
        {
            var model = new ModelForWebDav
            {
                UrlSuffix = pathPart
            };

            return View(model);
        }
        public ActionResult SearchFiles(string org, string pathPart, string searchValue)
        {
            if (string.IsNullOrEmpty(searchValue))
            {
                return RedirectToRoute(FileSystemRouteNames.ShowContentPath);
            }

            var model = new ModelForWebDav
            {
                UrlSuffix = pathPart,
                Permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart),
                UserSettings = _userSettingsManager.GetUserSettings(WspContext.User.AccountId),
                SearchValue = searchValue
            };

            return View("ShowContentSearchResultTable", model);
        }