Ejemplo n.º 1
0
        public CheckFileInfo GetCheckFileInfo(WebDavAccessToken token)
        {
            var resource = _webDavManager.GetResource(token.FilePath);

            var permissions = _webDavAuthorizationService.GetPermissions(ScpContext.User, token.FilePath);

            var readOnly = permissions.HasFlag(WebDavPermissions.Write) == false || permissions.HasFlag(WebDavPermissions.OwaEdit) == false;

            var cFileInfo = new CheckFileInfo
            {
                BaseFileName = resource == null?token.FilePath.Split('/').Last() : resource.DisplayName.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault(),
                                   OwnerId                 = ScpContext.User.Login,
                                   Size                    = resource == null ? 0 : resource.ContentLength,
                                   Version                 = DateTime.Now.ToString("s"),
                                   SupportsCoauth          = true,
                                   SupportsCobalt          = true,
                                   SupportsFolders         = true,
                                   SupportsLocks           = true,
                                   SupportsScenarioLinks   = false,
                                   SupportsSecureStore     = false,
                                   SupportsUpdate          = true,
                                   UserCanWrite            = !readOnly,
                                   ReadOnly                = readOnly,
                                   RestrictedWebViewOnly   = false,
                                   CloseButtonClosesWindow = true
            };

            if (resource != null)
            {
                cFileInfo.ClientUrl = _webDavManager.GetFileUrl(token.FilePath);
            }

            return(cFileInfo);
        }
Ejemplo n.º 2
0
        public ActionResult ShowContent(string org, string pathPart = "", string searchValue = "")
        {
            if (org != ScpContext.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(ScpContext.User, pathPart),
                    UserSettings = _userSettingsManager.GetUserSettings(ScpContext.User.AccountId),
                    SearchValue  = searchValue
                };

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

                return(View(model));
            }
#pragma warning disable 0168
            catch (UnauthorizedException e)
#pragma warning restore 0168
            {
                throw new HttpException(404, "Not Found");
            }
        }