bugs fix
This commit is contained in:
parent
f2c54df2b0
commit
41a540bd1e
13 changed files with 165 additions and 114 deletions
|
@ -6,6 +6,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||||
public class WebDavExplorerConfigurationSettingsSection : ConfigurationSection
|
public class WebDavExplorerConfigurationSettingsSection : ConfigurationSection
|
||||||
{
|
{
|
||||||
private const string UserDomainKey = "userDomain";
|
private const string UserDomainKey = "userDomain";
|
||||||
|
private const string WebdavRootKey = "webdavRoot";
|
||||||
private const string AuthTimeoutCookieNameKey = "authTimeoutCookieName";
|
private const string AuthTimeoutCookieNameKey = "authTimeoutCookieName";
|
||||||
private const string AppName = "applicationName";
|
private const string AppName = "applicationName";
|
||||||
private const string WebsitePanelConstantUserKey = "websitePanelConstantUser";
|
private const string WebsitePanelConstantUserKey = "websitePanelConstantUser";
|
||||||
|
@ -25,6 +26,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||||
set { this[AuthTimeoutCookieNameKey] = value; }
|
set { this[AuthTimeoutCookieNameKey] = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConfigurationProperty(WebdavRootKey, IsRequired = true)]
|
||||||
|
public WebdavRootElement WebdavRoot
|
||||||
|
{
|
||||||
|
get { return (WebdavRootElement)this[WebdavRootKey]; }
|
||||||
|
set { this[WebdavRootKey] = value; }
|
||||||
|
}
|
||||||
|
|
||||||
[ConfigurationProperty(UserDomainKey, IsRequired = true)]
|
[ConfigurationProperty(UserDomainKey, IsRequired = true)]
|
||||||
public UserDomainElement UserDomain
|
public UserDomainElement UserDomain
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||||
|
{
|
||||||
|
public class WebdavRootElement : ConfigurationElement
|
||||||
|
{
|
||||||
|
private const string ValueKey = "value";
|
||||||
|
|
||||||
|
[ConfigurationProperty(ValueKey, IsKey = true, IsRequired = true)]
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get { return (string)this[ValueKey]; }
|
||||||
|
set { this[ValueKey] = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,11 @@ namespace WebsitePanel.WebDav.Core.Config
|
||||||
get { return _configSection.UserDomain.Value; }
|
get { return _configSection.UserDomain.Value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string WebdavRoot
|
||||||
|
{
|
||||||
|
get { return _configSection.WebdavRoot.Value; }
|
||||||
|
}
|
||||||
|
|
||||||
public string ApplicationName
|
public string ApplicationName
|
||||||
{
|
{
|
||||||
get { return _configSection.ApplicationName.Value; }
|
get { return _configSection.ApplicationName.Value; }
|
||||||
|
|
|
@ -5,13 +5,11 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Managers
|
||||||
{
|
{
|
||||||
public interface IWebDavManager
|
public interface IWebDavManager
|
||||||
{
|
{
|
||||||
string RootPath { get; }
|
IEnumerable<IHierarchyItem> OpenFolder(string path);
|
||||||
void OpenFolder(string pathPart);
|
bool IsFile(string path);
|
||||||
IEnumerable<IHierarchyItem> GetChildren();
|
byte[] GetFileBytes(string path);
|
||||||
bool IsFile(string fileName);
|
IResource GetResource(string path);
|
||||||
byte[] GetFileBytes(string fileName);
|
string GetFileUrl(string path);
|
||||||
IResource GetResource( string fileName);
|
|
||||||
string GetFileUrl(string fileName);
|
|
||||||
|
|
||||||
string CreateFileId(string path);
|
string CreateFileId(string path);
|
||||||
string FilePathFromId(string id);
|
string FilePathFromId(string id);
|
||||||
|
|
|
@ -21,16 +21,8 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
|
|
||||||
private readonly ILog Log;
|
private readonly ILog Log;
|
||||||
|
|
||||||
private IFolder _currentFolder;
|
|
||||||
private bool _isRoot = true;
|
private bool _isRoot = true;
|
||||||
|
private IFolder _currentFolder;
|
||||||
private Lazy<IList<SystemFile>> _rootFolders;
|
|
||||||
private Lazy<string> _webDavRootPath;
|
|
||||||
|
|
||||||
public string RootPath
|
|
||||||
{
|
|
||||||
get { return _webDavRootPath.Value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public WebDavManager(ICryptography cryptography)
|
public WebDavManager(ICryptography cryptography)
|
||||||
{
|
{
|
||||||
|
@ -38,49 +30,29 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
Log = LogManager.GetLogger(this.GetType());
|
Log = LogManager.GetLogger(this.GetType());
|
||||||
|
|
||||||
_webDavSession = new WebDavSession();
|
_webDavSession = new WebDavSession();
|
||||||
|
|
||||||
_rootFolders = new Lazy<IList<SystemFile>>(ConnectToWebDavServer);
|
|
||||||
_webDavRootPath = new Lazy<string>(() =>
|
|
||||||
{
|
|
||||||
if (_rootFolders.Value.Any())
|
|
||||||
{
|
|
||||||
var folder = _rootFolders.Value.First();
|
|
||||||
var uri = new Uri(folder.Url);
|
|
||||||
return uri.Scheme + "://" + uri.Host + uri.Segments[0] + uri.Segments[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenFolder(string pathPart)
|
public IEnumerable<IHierarchyItem> OpenFolder(string pathPart)
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(pathPart))
|
|
||||||
{
|
|
||||||
_isRoot = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_isRoot = false;
|
|
||||||
|
|
||||||
_webDavSession.Credentials = new NetworkCredential(WspContext.User.Login, _cryptography.Decrypt(WspContext.User.EncryptedPassword), WebDavAppConfigManager.Instance.UserDomain);
|
|
||||||
|
|
||||||
_currentFolder = _webDavSession.OpenFolder(_webDavRootPath.Value + pathPart);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<IHierarchyItem> GetChildren()
|
|
||||||
{
|
{
|
||||||
IHierarchyItem[] children;
|
IHierarchyItem[] children;
|
||||||
|
|
||||||
if (_isRoot)
|
if (string.IsNullOrWhiteSpace(pathPart))
|
||||||
{
|
{
|
||||||
children = _rootFolders.Value.Select(x => new WebDavHierarchyItem {Href = new Uri(x.Url), ItemType = ItemType.Folder}).ToArray();
|
children = ConnectToWebDavServer().Select(x => new WebDavHierarchyItem { Href = new Uri(x.Url), ItemType = ItemType.Folder }).ToArray();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (_currentFolder == null || _currentFolder.Path.ToString() != pathPart)
|
||||||
|
{
|
||||||
|
_webDavSession.Credentials = new NetworkCredential(WspContext.User.Login,
|
||||||
|
_cryptography.Decrypt(WspContext.User.EncryptedPassword),
|
||||||
|
WebDavAppConfigManager.Instance.UserDomain);
|
||||||
|
|
||||||
|
_currentFolder = _webDavSession.OpenFolder(string.Format("{0}{1}/{2}",WebDavAppConfigManager.Instance.WebdavRoot, WspContext.User.OrganizationId , pathPart));
|
||||||
|
}
|
||||||
|
|
||||||
children = _currentFolder.GetChildren();
|
children = _currentFolder.GetChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IHierarchyItem> sortedChildren = children.Where(x => x.ItemType == ItemType.Folder).OrderBy(x => x.DisplayName).ToList();
|
List<IHierarchyItem> sortedChildren = children.Where(x => x.ItemType == ItemType.Folder).OrderBy(x => x.DisplayName).ToList();
|
||||||
sortedChildren.AddRange(children.Where(x => x.ItemType != ItemType.Folder).OrderBy(x => x.DisplayName));
|
sortedChildren.AddRange(children.Where(x => x.ItemType != ItemType.Folder).OrderBy(x => x.DisplayName));
|
||||||
|
@ -88,30 +60,40 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
return sortedChildren;
|
return sortedChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFile(string fileName)
|
public bool IsFile(string path)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(fileName) | _currentFolder == null)
|
string folder = GetFileFolder(path);
|
||||||
return false;
|
|
||||||
|
|
||||||
try
|
if (string.IsNullOrWhiteSpace(folder))
|
||||||
{
|
{
|
||||||
IResource resource = _currentFolder.GetResource(fileName);
|
return false;
|
||||||
//Stream stream = resource.GetReadStream();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException)
|
|
||||||
{
|
var resourceName = GetResourceName(path);
|
||||||
}
|
|
||||||
return false;
|
OpenFolder(folder);
|
||||||
|
|
||||||
|
IResource resource = _currentFolder.GetResource(resourceName);
|
||||||
|
|
||||||
|
return resource.ItemType == ItemType.Resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] GetFileBytes(string fileName)
|
|
||||||
|
public byte[] GetFileBytes(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IResource resource = _currentFolder.GetResource(fileName);
|
string folder = GetFileFolder(path);
|
||||||
|
|
||||||
|
var resourceName = GetResourceName(path);
|
||||||
|
|
||||||
|
OpenFolder(folder);
|
||||||
|
|
||||||
|
IResource resource = _currentFolder.GetResource(resourceName);
|
||||||
|
|
||||||
Stream stream = resource.GetReadStream();
|
Stream stream = resource.GetReadStream();
|
||||||
byte[] fileBytes = ReadFully(stream);
|
byte[] fileBytes = ReadFully(stream);
|
||||||
|
|
||||||
return fileBytes;
|
return fileBytes;
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException exception)
|
catch (InvalidOperationException exception)
|
||||||
|
@ -120,12 +102,17 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResource GetResource(string fileName)
|
public IResource GetResource(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IResource resource = _currentFolder.GetResource(fileName);
|
string folder = GetFileFolder(path);
|
||||||
return resource;
|
|
||||||
|
var resourceName = GetResourceName(path);
|
||||||
|
|
||||||
|
OpenFolder(folder);
|
||||||
|
|
||||||
|
return _currentFolder.GetResource(resourceName);
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException exception)
|
catch (InvalidOperationException exception)
|
||||||
{
|
{
|
||||||
|
@ -133,11 +120,17 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFileUrl(string fileName)
|
public string GetFileUrl(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IResource resource = _currentFolder.GetResource(fileName);
|
string folder = GetFileFolder(path);
|
||||||
|
|
||||||
|
var resourceName = GetResourceName(path);
|
||||||
|
|
||||||
|
OpenFolder(folder);
|
||||||
|
|
||||||
|
IResource resource = _currentFolder.GetResource(resourceName);
|
||||||
return resource.Href.ToString();
|
return resource.Href.ToString();
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException exception)
|
catch (InvalidOperationException exception)
|
||||||
|
@ -171,19 +164,6 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
return rootFolders;
|
return rootFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] ReadFully(Stream input)
|
|
||||||
{
|
|
||||||
var buffer = new byte[16*1024];
|
|
||||||
using (var ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
int read;
|
|
||||||
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
|
|
||||||
ms.Write(buffer, 0, read);
|
|
||||||
return ms.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string CreateFileId(string path)
|
public string CreateFileId(string path)
|
||||||
{
|
{
|
||||||
return _cryptography.Encrypt(path).Replace("/", "AAAAA");
|
return _cryptography.Encrypt(path).Replace("/", "AAAAA");
|
||||||
|
@ -193,5 +173,45 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
{
|
{
|
||||||
return _cryptography.Decrypt(id.Replace("AAAAA", "/"));
|
return _cryptography.Decrypt(id.Replace("AAAAA", "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Helpers
|
||||||
|
|
||||||
|
private byte[] ReadFully(Stream input)
|
||||||
|
{
|
||||||
|
var buffer = new byte[16 * 1024];
|
||||||
|
using (var ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
ms.Write(buffer, 0, read);
|
||||||
|
return ms.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetFileFolder(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path) || !path.Contains('/'))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
string fileName = path.Split('/').Last();
|
||||||
|
int index = path.LastIndexOf(fileName, StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
string folder = path.Remove(index - 1, fileName.Length + 1);
|
||||||
|
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetResourceName(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path) || !path.Contains('/'))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Split('/').Last(); ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,13 +23,7 @@ namespace WebsitePanel.WebDav.Core.Owa
|
||||||
|
|
||||||
public CheckFileInfo GetCheckFileInfo(string path)
|
public CheckFileInfo GetCheckFileInfo(string path)
|
||||||
{
|
{
|
||||||
string fileName = path.Split('/').Last();
|
var resource = _webDavManager.GetResource(path);
|
||||||
int index = path.LastIndexOf(fileName, StringComparison.InvariantCultureIgnoreCase);
|
|
||||||
string folder = path.Remove(index - 1, fileName.Length + 1);
|
|
||||||
|
|
||||||
_webDavManager.OpenFolder(folder);
|
|
||||||
|
|
||||||
var resource = _webDavManager.GetResource(fileName);
|
|
||||||
|
|
||||||
var cFileInfo = new CheckFileInfo
|
var cFileInfo = new CheckFileInfo
|
||||||
{
|
{
|
||||||
|
@ -44,13 +38,7 @@ namespace WebsitePanel.WebDav.Core.Owa
|
||||||
|
|
||||||
public FileResult GetFile(string path)
|
public FileResult GetFile(string path)
|
||||||
{
|
{
|
||||||
string fileName = path.Split('/').Last();
|
var fileBytes = _webDavManager.GetFileBytes(path);
|
||||||
int index = path.LastIndexOf(fileName, StringComparison.InvariantCultureIgnoreCase);
|
|
||||||
string folder = path.Remove(index - 1, fileName.Length + 1);
|
|
||||||
|
|
||||||
_webDavManager.OpenFolder(folder);
|
|
||||||
|
|
||||||
var fileBytes = _webDavManager.GetFileBytes(fileName);
|
|
||||||
|
|
||||||
return new FileContentResult(fileBytes, MediaTypeNames.Application.Octet);
|
return new FileContentResult(fileBytes, MediaTypeNames.Application.Octet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,17 @@ namespace WebsitePanel.WebDav.Core.Security.Authentication
|
||||||
|
|
||||||
public WspPrincipal LogIn(string login, string password)
|
public WspPrincipal LogIn(string login, string password)
|
||||||
{
|
{
|
||||||
if (_principalContext.ValidateCredentials(login, password) == false)
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//var user = UserPrincipal.FindByIdentity(_principalContext, IdentityType.UserPrincipalName, login);
|
var user = UserPrincipal.FindByIdentity(_principalContext, IdentityType.UserPrincipalName, login);
|
||||||
|
|
||||||
|
if (_principalContext.ValidateCredentials(login, password) == false && user != null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var principal = new WspPrincipal(login);
|
var principal = new WspPrincipal(login);
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.DirectoryServices.AccountManagement" />
|
<Reference Include="System.DirectoryServices.AccountManagement" />
|
||||||
|
@ -83,9 +84,8 @@
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="WebsitePanel.EnterpriseServer.Base, Version=2.1.0.1, Culture=neutral, PublicKeyToken=da8782a6fc4d0081, processorArchitecture=MSIL">
|
<Reference Include="WebsitePanel.EnterpriseServer.Base">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Base.dll</HintPath>
|
||||||
<HintPath>..\..\..\..\Scheduler Domains\WebsitePanel\Bin\WebsitePanel.EnterpriseServer.Base.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="WebsitePanel.EnterpriseServer.Client">
|
<Reference Include="WebsitePanel.EnterpriseServer.Client">
|
||||||
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
|
<HintPath>..\WebsitePanel.WebPortal\Bin\WebsitePanel.EnterpriseServer.Client.dll</HintPath>
|
||||||
|
@ -114,6 +114,7 @@
|
||||||
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
|
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
|
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
|
<Compile Include="Config\WebConfigSections\WebDavExplorerConfigurationSettingsSection.cs" />
|
||||||
|
<Compile Include="Config\WebConfigSections\WebdavRootElement.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
||||||
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
||||||
<Compile Include="Entities\Owa\CheckFileInfo.cs" />
|
<Compile Include="Entities\Owa\CheckFileInfo.cs" />
|
||||||
|
@ -155,6 +156,7 @@
|
||||||
<Folder Include="Interfaces\ActiveDirectory\" />
|
<Folder Include="Interfaces\ActiveDirectory\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -40,9 +40,9 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
{
|
{
|
||||||
var user = _authenticationService.LogIn(model.Login, model.Password);
|
var user = _authenticationService.LogIn(model.Login, model.Password);
|
||||||
|
|
||||||
ViewBag.LdapIsAuthentication = user.Identity.IsAuthenticated;
|
ViewBag.LdapIsAuthentication = user != null;
|
||||||
|
|
||||||
if (user.Identity.IsAuthenticated)
|
if (user != null && user.Identity.IsAuthenticated)
|
||||||
{
|
{
|
||||||
_authenticationService.CreateAuthenticationTicket(user);
|
_authenticationService.CreateAuthenticationTicket(user);
|
||||||
|
|
||||||
|
|
|
@ -41,19 +41,21 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
public ActionResult ShowContent(string org, string pathPart = "")
|
public ActionResult ShowContent(string org, string pathPart = "")
|
||||||
{
|
{
|
||||||
if (org != WspContext.User.OrganizationId)
|
if (org != WspContext.User.OrganizationId)
|
||||||
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
|
||||||
|
|
||||||
string fileName = pathPart.Split('/').Last();
|
|
||||||
if (_webdavManager.IsFile(fileName))
|
|
||||||
{
|
{
|
||||||
var fileBytes = _webdavManager.GetFileBytes(fileName);
|
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
string fileName = pathPart.Split('/').Last();
|
||||||
|
|
||||||
|
if (_webdavManager.IsFile(pathPart))
|
||||||
|
{
|
||||||
|
var fileBytes = _webdavManager.GetFileBytes(pathPart);
|
||||||
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
|
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_webdavManager.OpenFolder(pathPart);
|
IEnumerable<IHierarchyItem> children = _webdavManager.OpenFolder(pathPart).Where(x => !WebDavAppConfigManager.Instance.ElementsRendering.ElementsToIgnore.Contains(x.DisplayName.Trim('/')));
|
||||||
IEnumerable<IHierarchyItem> children = _webdavManager.GetChildren().Where(x => !WebDavAppConfigManager.Instance.ElementsRendering.ElementsToIgnore.Contains(x.DisplayName.Trim('/')));
|
|
||||||
|
|
||||||
var model = new ModelForWebDav { Items = children.Take(WebDavAppConfigManager.Instance.ElementsRendering.DefaultCount), UrlSuffix = pathPart };
|
var model = new ModelForWebDav { Items = children.Take(WebDavAppConfigManager.Instance.ElementsRendering.DefaultCount), UrlSuffix = pathPart };
|
||||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] = WebDavAppConfigManager.Instance.ElementsRendering.DefaultCount;
|
Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] = WebDavAppConfigManager.Instance.ElementsRendering.DefaultCount;
|
||||||
|
@ -70,7 +72,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
{
|
{
|
||||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||||
|
|
||||||
string fileUrl = _webdavManager.RootPath.TrimEnd('/') + "/" + pathPart.TrimStart('/');
|
string fileUrl = WebDavAppConfigManager.Instance.WebdavRoot+ org + "/" + pathPart.TrimStart('/');
|
||||||
string accessToken = _authenticationService.CreateAccessToken(WspContext.User);
|
string accessToken = _authenticationService.CreateAccessToken(WspContext.User);
|
||||||
|
|
||||||
string wopiSrc = Server.UrlDecode(Url.RouteUrl(OwaRouteNames.CheckFileInfo, new { encodedPath = _webdavManager.CreateFileId(pathPart) }, Request.Url.Scheme));
|
string wopiSrc = Server.UrlDecode(Url.RouteUrl(OwaRouteNames.CheckFileInfo, new { encodedPath = _webdavManager.CreateFileId(pathPart) }, Request.Url.Scheme));
|
||||||
|
@ -81,13 +83,13 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult ShowAdditionalContent()
|
public ActionResult ShowAdditionalContent(string path)
|
||||||
{
|
{
|
||||||
if (Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] != null)
|
if (Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount] != null)
|
||||||
{
|
{
|
||||||
var renderedElementsCount = (int)Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount];
|
var renderedElementsCount = (int)Session[WebDavAppConfigManager.Instance.SessionKeys.ResourseRenderCount];
|
||||||
|
|
||||||
IEnumerable<IHierarchyItem> children = _webdavManager.GetChildren();
|
IEnumerable<IHierarchyItem> children = _webdavManager.OpenFolder(path);
|
||||||
|
|
||||||
var result = children.Skip(renderedElementsCount).Take(WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount);
|
var result = children.Skip(renderedElementsCount).Take(WebDavAppConfigManager.Instance.ElementsRendering.AddElementsCount);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Web.SessionState;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
|
using WebsitePanel.WebDav.Core.Managers;
|
||||||
using WebsitePanel.WebDav.Core.Owa;
|
using WebsitePanel.WebDav.Core.Owa;
|
||||||
using WebsitePanel.WebDav.Core.Security;
|
using WebsitePanel.WebDav.Core.Security;
|
||||||
using WebsitePanel.WebDav.Core.Security.Authentication;
|
using WebsitePanel.WebDav.Core.Security.Authentication;
|
||||||
|
@ -23,7 +24,7 @@ namespace WebsitePanel.WebDavPortal.DependencyInjection
|
||||||
kernel.Bind<HttpSessionState>().ToProvider<HttpSessionStateProvider>();
|
kernel.Bind<HttpSessionState>().ToProvider<HttpSessionStateProvider>();
|
||||||
kernel.Bind<ICryptography>().To<CryptoUtils>();
|
kernel.Bind<ICryptography>().To<CryptoUtils>();
|
||||||
kernel.Bind<IAuthenticationService>().To<FormsAuthenticationService>();
|
kernel.Bind<IAuthenticationService>().To<FormsAuthenticationService>();
|
||||||
kernel.Bind<IWebDavManager>().ToProvider<WebDavManagerProvider>();
|
kernel.Bind<IWebDavManager>().To<WebDavManager>();
|
||||||
kernel.Bind<IWopiServer>().To<WopiServer>();
|
kernel.Bind<IWopiServer>().To<WopiServer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ function GetResources() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '/FileSystem/ShowAdditionalContent',
|
url: '/FileSystem/ShowAdditionalContent',
|
||||||
data: '',
|
data: { path: window.location.pathname },
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
var domElement = $(result);
|
var domElement = $(result);
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<webDavExplorerConfigurationSettings>
|
<webDavExplorerConfigurationSettings>
|
||||||
<userDomain value="websitepanel.net" />
|
<userDomain value="websitepanel.net" />
|
||||||
|
<webdavRoot value="https://webdav.websitepanel.net/" />
|
||||||
<applicationName value="WebDAV Explorer" />
|
<applicationName value="WebDAV Explorer" />
|
||||||
<authTimeoutCookieName value=".auth-logout-timeout" />
|
<authTimeoutCookieName value=".auth-logout-timeout" />
|
||||||
<elementsRendering defaultCount="20" addElementsCount="20" elementsToIgnoreKey="web.config" />
|
<elementsRendering defaultCount="20" addElementsCount="20" elementsToIgnoreKey="web.config" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue