webdav protal office 365 fix
This commit is contained in:
parent
92befdea38
commit
f2c54df2b0
27 changed files with 466 additions and 80 deletions
|
@ -1,17 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using WebsitePanel.WebDav.Core;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Exceptions;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||
using WebsitePanel.WebDavPortal.CustomAttributes;
|
||||
using WebsitePanel.WebDavPortal.Extensions;
|
||||
using WebsitePanel.WebDavPortal.Models;
|
||||
using System.Net;
|
||||
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Controllers
|
||||
|
||||
|
@ -20,11 +26,15 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
[LdapAuthorization]
|
||||
public class FileSystemController : Controller
|
||||
{
|
||||
private readonly ICryptography _cryptography;
|
||||
private readonly IWebDavManager _webdavManager;
|
||||
private readonly IAuthenticationService _authenticationService;
|
||||
|
||||
public FileSystemController(IWebDavManager webdavManager)
|
||||
public FileSystemController(ICryptography cryptography, IWebDavManager webdavManager, IAuthenticationService authenticationService)
|
||||
{
|
||||
_cryptography = cryptography;
|
||||
_webdavManager = webdavManager;
|
||||
_authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
@ -58,8 +68,14 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
public ActionResult ShowOfficeDocument(string org, string pathPart = "")
|
||||
{
|
||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||
|
||||
string fileUrl = _webdavManager.RootPath.TrimEnd('/') + "/" + pathPart.TrimStart('/');
|
||||
var uri = new Uri(WebDavAppConfigManager.Instance.OfficeOnline.Url).AddParameter("src", fileUrl).ToString();
|
||||
string accessToken = _authenticationService.CreateAccessToken(WspContext.User);
|
||||
|
||||
string wopiSrc = Server.UrlDecode(Url.RouteUrl(OwaRouteNames.CheckFileInfo, new { encodedPath = _webdavManager.CreateFileId(pathPart) }, Request.Url.Scheme));
|
||||
|
||||
var uri = string.Format("{0}/{1}?WOPISrc={2}&access_token={3}", WebDavAppConfigManager.Instance.OfficeOnline.Url, owaOpener.OwaOpener, Server.UrlEncode(wopiSrc), Server.UrlEncode(accessToken));
|
||||
|
||||
return View(new OfficeOnlineModel(uri, new Uri(fileUrl).Segments.Last()));
|
||||
}
|
||||
|
@ -80,7 +96,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
return PartialView("_ResourseCollectionPartial", result);
|
||||
}
|
||||
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NoContent); ;
|
||||
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue