From 67aab39780c3b93df4d5fd7f6049d4d43bd32503 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Fri, 16 Jan 2015 06:22:46 -0800 Subject: [PATCH] webdav protal bugs fixe --- .../Managers/WebDavManager.cs | 18 ++++++++++++++---- .../App_Start/RouteConfig.cs | 6 ++++++ .../Controllers/FileSystemController.cs | 17 +++++------------ .../Scripts/appScripts/uploadingData2.js | 4 ++-- .../UI/Routes/FileSystemRouteNames.cs | 1 + 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs index 9815be79..0f76a99e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs @@ -48,7 +48,7 @@ namespace WebsitePanel.WebDav.Core.Managers _cryptography.Decrypt(WspContext.User.EncryptedPassword), WebDavAppConfigManager.Instance.UserDomain); - _currentFolder = _webDavSession.OpenFolder(string.Format("{0}{1}/{2}",WebDavAppConfigManager.Instance.WebdavRoot, WspContext.User.OrganizationId , pathPart)); + _currentFolder = _webDavSession.OpenFolder(string.Format("{0}{1}/{2}", WebDavAppConfigManager.Instance.WebdavRoot, WspContext.User.OrganizationId, pathPart)); } children = _currentFolder.GetChildren(); @@ -73,9 +73,15 @@ namespace WebsitePanel.WebDav.Core.Managers OpenFolder(folder); - IResource resource = _currentFolder.GetResource(resourceName); + try + { + IResource resource = _currentFolder.GetResource(resourceName); - return resource.ItemType == ItemType.Resource; + return true; + } + catch (Exception e){} + + return false; } @@ -180,6 +186,8 @@ namespace WebsitePanel.WebDav.Core.Managers private string GetFileFolder(string path) { + path = path.TrimEnd('/'); + if (string.IsNullOrEmpty(path) || !path.Contains('/')) { return string.Empty; @@ -187,13 +195,15 @@ namespace WebsitePanel.WebDav.Core.Managers string fileName = path.Split('/').Last(); int index = path.LastIndexOf(fileName, StringComparison.InvariantCultureIgnoreCase); - string folder = path.Remove(index - 1, fileName.Length + 1); + string folder = string.IsNullOrEmpty(fileName)? path : path.Remove(index - 1, fileName.Length + 1); return folder; } private string GetResourceName(string path) { + path = path.TrimEnd('/'); + if (string.IsNullOrEmpty(path) || !path.Contains('/')) { return string.Empty; diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs index c8afc1e8..8a6a2d90 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/RouteConfig.cs @@ -48,6 +48,12 @@ namespace WebsitePanel.WebDavPortal defaults: new { controller = "FileSystem", action = "ShowOfficeDocument", pathPart = UrlParameter.Optional } ); + routes.MapRoute( + name: FileSystemRouteNames.ShowAdditionalContent, + url: "show-additional-content/{*path}", + defaults: new { controller = "FileSystem", action = "ShowAdditionalContent", path = UrlParameter.Optional } + ); + routes.MapRoute( name: FileSystemRouteNames.FilePath, url: "{org}/{*pathPart}", diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs index a5f0ce87..70bdfe36 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs @@ -85,22 +85,15 @@ namespace WebsitePanel.WebDavPortal.Controllers } [HttpPost] - public ActionResult ShowAdditionalContent(string path) + public ActionResult ShowAdditionalContent(string path = "", int resourseRenderCount = 0) { - if (Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] != null) - { - var renderedElementsCount = (int)Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount]; + path = path.Replace(WspContext.User.OrganizationId, "").Trim('/'); - IEnumerable children = _webdavManager.OpenFolder(path); + IEnumerable children = _webdavManager.OpenFolder(path); - var result = children.Skip(renderedElementsCount).Take(WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount); + var result = children.Skip(resourseRenderCount).Take(WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount); - Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] = renderedElementsCount + WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount; - - return PartialView("_ResourseCollectionPartial", result); - } - - return new HttpStatusCodeResult(HttpStatusCode.NoContent); + return PartialView("_ResourseCollectionPartial", result); } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/uploadingData2.js b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/uploadingData2.js index cd9dd1d2..f9c7ef4f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/uploadingData2.js +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/uploadingData2.js @@ -14,8 +14,8 @@ var oldResourcesDivHeight = $('#resourcesDiv').height(); function GetResources() { $.ajax({ type: 'POST', - url: '/FileSystem/ShowAdditionalContent', - data: { path: window.location.pathname }, + url: '/show-additional-content', + data: { path: window.location.pathname, resourseRenderCount: $(".element-container").length }, dataType: "html", success: function (result) { var domElement = $(result); diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Routes/FileSystemRouteNames.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Routes/FileSystemRouteNames.cs index 80d0d67d..f011561a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Routes/FileSystemRouteNames.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Routes/FileSystemRouteNames.cs @@ -8,5 +8,6 @@ namespace WebsitePanel.WebDavPortal.UI.Routes public class FileSystemRouteNames { public const string FilePath = "FilePathRoute"; + public const string ShowAdditionalContent = "ShowAdditionalContentRoute"; } } \ No newline at end of file