Exemple #1
0
        protected void PageLoad()
        {
            var file = new File();

            try
            {
                ShareLink = Request[UrlConstant.DocUrlKey] ?? "";
                WithLink  = !string.IsNullOrEmpty(ShareLink);

                var fileId = WithLink ? (object)-1 : Request[UrlConstant.FileId];
                FileNew = !string.IsNullOrEmpty(Request[UrlConstant.New]) && Request[UrlConstant.New] == "true";

                file = DocumentUtils.EditIframeSrc(fileId, FileNew, ShareLink, out SrcIframe);

                if (SecurityContext.IsAuthenticated)
                {
                    var parent = Global.DaoFactory.GetFolderDao().GetFolder(file.FolderID);
                    if (file.RootFolderType == FolderType.USER &&
                        file.RootFolderCreator != SecurityContext.CurrentAccount.ID &&
                        !Global.GetFilesSecurity().CanRead(parent))
                    {
                        FolderUrl = PathProvider.GetFolderUrl(Global.FolderShare, false, null);
                    }
                    else
                    {
                        FolderUrl = PathProvider.GetFolderUrl(parent);

                        if (string.IsNullOrEmpty(FolderUrl))
                        {
                            FolderUrl = Request.UrlReferrer == null
                                            ? VirtualPathUtility.ToAbsolute(PathProvider.StartURL)
                                            : Request.UrlReferrer.ToString();
                        }

                        if (Global.EnableShare)
                        {
                            CommonContainerHolder.Controls.Add(LoadControl(AccessRights.Location));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Redirect(PathProvider.BaseVirtualPath + "docviewer.aspx" + "?" + Request.QueryString + "#" + UrlConstant.Error + "/" + HttpUtility.UrlEncode(ex.Message));
            }

            Title       = file.Title;
            FileId      = file.ID;
            FileTitle   = file.Title;
            FileVersion = file.Version;

            DocKeyForTrack = DocumentUtils.GetDocKey(file.ID, -1, DateTime.MinValue);

            using (var tagDao = Global.DaoFactory.GetTagDao())
            {
                tagDao.RemoveTags(Tag.New(SecurityContext.CurrentAccount.ID, file));
            }

            FileLocker.Add(file.ID);
        }