webdav portal owa fixes
This commit is contained in:
parent
2968fbb967
commit
eb8c879605
6 changed files with 48 additions and 24 deletions
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Policy;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
@ -83,12 +84,8 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
public ActionResult ShowOfficeDocument(string org, string pathPart = "", FileAccess? fileAccess = null)
|
||||
public ActionResult ShowOfficeDocument(string org, string pathPart, string owaOpenerUri)
|
||||
{
|
||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
|
||||
|
||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||
|
||||
string fileUrl = WebDavAppConfigManager.Instance.WebdavRoot+ org + "/" + pathPart.TrimStart('/');
|
||||
var accessToken = _tokenManager.CreateToken(WspContext.User, pathPart);
|
||||
|
||||
|
@ -97,22 +94,32 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
string wopiSrc = Server.UrlDecode(url);
|
||||
|
||||
string owaOpenerUri = string.Empty;
|
||||
|
||||
if (fileAccess == null)
|
||||
{
|
||||
owaOpenerUri = permissions.HasFlag(WebDavPermissions.Write) ? owaOpener.OwaEditor : owaOpener.OwaView;
|
||||
}
|
||||
else
|
||||
{
|
||||
owaOpenerUri = permissions.HasFlag(WebDavPermissions.Write) && fileAccess == FileAccess.Write ? owaOpener.OwaEditor : owaOpener.OwaView;
|
||||
}
|
||||
|
||||
var uri = string.Format("{0}/{1}WOPISrc={2}&access_token={3}", WebDavAppConfigManager.Instance.OfficeOnline.Url, owaOpenerUri, Server.UrlEncode(wopiSrc), Server.UrlEncode(accessToken.AccessToken.ToString("N")));
|
||||
|
||||
string fileName = fileUrl.Split('/').Last();
|
||||
|
||||
return View(new OfficeOnlineModel(uri, fileName));
|
||||
return View("ShowOfficeDocument", new OfficeOnlineModel(uri, fileName));
|
||||
}
|
||||
|
||||
public ActionResult ViewOfficeDocument(string org, string pathPart)
|
||||
{
|
||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||
|
||||
return ShowOfficeDocument(org, pathPart, owaOpener.OwaView);
|
||||
}
|
||||
|
||||
public ActionResult EditOfficeDocument(string org, string pathPart)
|
||||
{
|
||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
|
||||
|
||||
if (permissions.HasFlag(WebDavPermissions.Write) == false)
|
||||
{
|
||||
return new RedirectToRouteResult(FileSystemRouteNames.ViewOfficeOnline, null);
|
||||
}
|
||||
|
||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||
|
||||
return ShowOfficeDocument(org, pathPart, owaOpener.OwaEditor);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue