Ejemplo n.º 1
0
    //  ProduceAttachFileListMode
    //  功能:   將附加檔案的資料建構成列表模式
    //  回傳:   單一筆附加檔案在table內的格式
    private string ProduceAttachFileListMode(
        AttachmentThumbnailInfo attachmentInfo,
        bool previewAvailable,
        bool showPreview,
        bool canDownload,
        string linkUrl,
        string sourceUri,
        string attachmentVer)
    {
        StringBuilder sb = new StringBuilder();

        sb.Append("<tr>");
        sb.Append("<td>");

        string downloadLinkStart = "<a href=\"" +
            String.Format(linkUrl, HttpUtility.UrlEncode(attachmentInfo.DisplayName)) +
            "\" target=\"_self\"  title='" +
            attachmentInfo.DisplayName + "'>";

        string viewDocArg = "'" + doc.DocumentId.ToString() + "','" + attachmentVer + "','" +
            HttpUtility.UrlEncode(attachmentInfo.DisplayName) + "'";

        if (attachmentInfo.Type == AttachmentThumbnailInfo.FileType.FLV)
        {
            viewDocArg += ",'flv'";
        }
        else
        {
            viewDocArg += ",'file'";
        }
        string previewLinkStart = "<a href='javascript:void(0)' title='" + attachmentInfo.DisplayName + "' onclick=\"PreviewAttachFile(" + viewDocArg + ");\" >";

        string disabledDownloadLinkStart = "<a href='javascript:void(0)' style='cursor:text; color:#ccc;' target=\"_self\"  title='" + attachmentInfo.DisplayName + "'>";

        string disabledPreviewLinkStart = "<a href='javascript:void(0)' style='cursor:text; color:#ccc;' title='" + i18n.GetMessage("m913") + "'>";

        if (showPreview)
        {
            if (previewAvailable)
            {
                sb.Append(previewLinkStart);
            }
            else
            {
                sb.Append(disabledPreviewLinkStart);
            }
            sb.Append(i18n.GetMessage("m907"));
            sb.Append("</a>");
            sb.Append("&nbsp;");

            if (canDownload)
            {
                sb.Append(downloadLinkStart);
            }
            else
            {
                sb.Append(disabledDownloadLinkStart);
            }
            sb.Append(i18n.GetMessage("m906"));
            sb.Append("</a>");
        }

        sb.Append("&nbsp;<img src='" + attachmentInfo.Icon + "' width='16' height='16' style=\"vertical-align: middle;\"/>");
        sb.Append("</td>");
        sb.Append("<td>");
        int displayNameLengthLimit = 35;
        if (!showPreview && canDownload)
        {
            sb.Append(downloadLinkStart + StringLimitEditor(attachmentInfo.DisplayName, displayNameLengthLimit) + "</a>");
        }
        else
        {
            sb.Append(StringLimitEditor(attachmentInfo.DisplayName, displayNameLengthLimit));
        }

        if (sourceUri.Contains("http://"))
        {
            sb.Append("  [<a href=\"" + sourceUri + "\" target=\"_blank\">" + i18n.GetMessage("m483") +
                "</a>&nbsp;<img src=\"images\\arrow_105.gif\" Title=" +
                i18n.GetMessage("m483") + " onclick=\"javascipt:window.open('" + sourceUri +
                "')\" style='cursor:pointer' align='absmiddle' />]");
        }

        if (attachmentInfo.Type == AttachmentThumbnailInfo.FileType.Image)
        {
            sb.Append("<a herf='#' class='ShowThumbnail'> <img src='images\\view.gif' width='16' height='16' /> <div>");
            sb.Append("<div><img src='" + attachmentInfo.Link + "' /></div>");
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></a>");
        }
        sb.Append("</td>");
        sb.Append("</tr>");
        return sb.ToString();
    }
Ejemplo n.º 2
0
    private void buildFileList()
    {
        string linkUrl = "download.aspx?documentId=" + doc.DocumentId.ToString() + "&fileName={0}&ver=" + ver.ToString();
        StringBuilder sb = new StringBuilder();
        StringBuilder FileListMode = new StringBuilder();
        StringBuilder FileDocMode = new StringBuilder();

        SourceFileInfo[] allFiles = WebUtility.Repository.GetDocumentService().GetFiles(currentUser, doc.DocumentId, ver);
        ThumbnailAgent thumbUtl = new ThumbnailAgent();
        AttachmentThumbnailInfo attachmentInfo = new AttachmentThumbnailInfo();
        bool previewOn = Convert.ToBoolean(ConfigurationManager.AppSettings["ShowPreview"] != null ? ConfigurationManager.AppSettings["ShowPreview"].ToString() : "false");
        string hideList = string.Empty;
        string hideDoc = string.Empty;
        string btnMode = string.Empty;

        if (attachMode == "list")
        {
            hideDoc = " style='display:none;'";
            btnMode =
                "<img id='ListModeImg' src='images\\ListModeOn.png' title='" + i18n.GetMessage("m868") + "' style='cursor:normal' />&nbsp;" +
                "<img id='DocumentModeImg' src='images\\DocumentModeOff.png' title='" + i18n.GetMessage("m867") + "' style='cursor:pointer'/>";
        }
        else
        {
            hideList = " style='display:none;'";
            btnMode =
                "<img id='ListModeImg' src='images\\ListModeOff.png' title='" + i18n.GetMessage("m868") + "' style='cursor:pointer' />&nbsp;" +
                "<img id='DocumentModeImg' src='images\\DocumentModeOn.png' title='" + i18n.GetMessage("m867") + "' style='cursor:normal'/>";
        }

        if (allFiles.Length > 0)
        {
            bool canPreview = WebUtility.HasPreviewPrivilege(docId, currentUser);
            bool canDownload = WebUtility.HasDownloadPrivilege(docId, currentUser);
            bool previewAvaliable = false;
            string attachmentVer = string.Empty;

            foreach (SourceFileInfo sfi in allFiles)
            {
                attachmentInfo = thumbUtl.GetThumbnail(doc.DocumentId, ver, sfi.CurrentPath);
                attachmentVer = GetAttachmentVer(sfi.CurrentPath);
                previewAvaliable = WebUtility.IsOnlinePreviewAvailable(doc.DocumentId, ver, canPreview, sfi.CurrentPath, sfi);
                FileListMode.Append(ProduceAttachFileListMode(
                    attachmentInfo,
                    previewAvaliable,
                    previewOn,
                    canDownload,
                    linkUrl,
                    sfi.SourceUri,
                    attachmentVer));
                FileDocMode.Append(ProduceAttachFileDocumentMode(
                    attachmentInfo,
                    previewAvaliable,
                    previewOn,
                    canDownload,
                    linkUrl,
                    sfi.SourceUri,
                    attachmentVer));
                hasFiles = true;
            }

            LiteralControl c = new LiteralControl();
            c.Text = "<div id='AttachFormRoot'>" +
               "<div id='SwitchAttachModeButtonLoc'>" + btnMode + "</div>" +
               "<div id='AttachListMode' class='AttachFileTable' " + hideList + "><table>" + FileListMode.ToString() + "</table></div>" +
               "<div id='AttachDocumentMode' class='AttachFileTable' " + hideDoc + "></div>" +
               "<div id='AttachDocumentTemp'>" + FileDocMode.ToString() + "</div> </div>";
            fileList.Controls.Add(c);
        }
        else
        {
            LiteralControl blankLabel = new LiteralControl();
            blankLabel.Text = "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td>" + i18n.GetMessage("m241") + "</td></tr></table>";
            fileList.Controls.Add(blankLabel);
        }
    }
Ejemplo n.º 3
0
    //  ProduceAttachFileDocumentMode
    //  功能:   將附加檔案的資料建構成檔案總管模式
    //  回傳:   單一筆附加檔案在table內的格式
    private string ProduceAttachFileDocumentMode(
        AttachmentThumbnailInfo attachmentInfo,
        bool previewAvailable,
        bool showPreview,
        bool canDownload,
        string linkUrl,
        string sourceUri,
        string attachmentVer)
    {
        StringBuilder sb = new StringBuilder();
        int TitleLimit = 14;
        string viewDocArg = "'" + doc.DocumentId.ToString() + "','" + attachmentVer + "','" +
            HttpUtility.UrlEncode(attachmentInfo.DisplayName) + "'";

        if (attachmentInfo.Type == AttachmentThumbnailInfo.FileType.FLV)
        {
            viewDocArg += ",'flv'";
        }
        else
        {
            viewDocArg += ",'file'";
        }
        string downloadLinkStart = "<a href=\"" +
            String.Format(linkUrl, HttpUtility.UrlEncode(attachmentInfo.DisplayName)) +
            "\" target=\"_self\"  title='" +
            attachmentInfo.DisplayName + "'>";

        string previewLinkStart = "<a href='javascript:void(0)' onclick=\"PreviewAttachFile(" + viewDocArg + ");\" >";

        string disabledDownloadLinkStart = "<a href='javascript:void(0)' style='cursor:text; color:#ccc;' target=\"_self\"  title='" + attachmentInfo.DisplayName + "'>";

        string disabledPreviewLinkStart = "<a href='javascript:void(0)' style='cursor:text; color:#ccc;' title='" + i18n.GetMessage("m913") + "'>";

        string imageLinkStart = "<a href='javascript:void(0)' target=\"_self\"  title='" + attachmentInfo.DisplayName + "'>";

        string LinkStrDummyHead = string.Empty;

        if (showPreview)
        {
            LinkStrDummyHead = imageLinkStart;
        }
        else
        {
            if (canDownload)
            {
                LinkStrDummyHead = downloadLinkStart;
            }
            else
            {
                LinkStrDummyHead = disabledDownloadLinkStart;
            }
        }

        string LinkStrEnd = "</a>";

        sb.Append("<div class='DocInnerFrame'>");
        sb.Append("<div class='DocInnerFramePicture'>" + LinkStrDummyHead);
        sb.Append("<div class='ImageFileLoc'>");
        sb.Append("<img border='0' src='" + attachmentInfo.Link + "' />");
        sb.Append("</div>");
        sb.Append(LinkStrEnd + "</div>");

        sb.Append("<div class='DocInnerFrameBriefTitle'>");
        sb.Append(LinkStrDummyHead + StringLimitEditor(attachmentInfo.DisplayName, TitleLimit) + LinkStrEnd);
        sb.Append("</div>");

        sb.Append("<div class='DocInnerFrameFullTitle'>" + LinkStrDummyHead + attachmentInfo.DisplayName + LinkStrEnd);

        if (showPreview)
        {
            if (previewAvailable)
            {
                sb.Append("<div class='CmdTitle ShowPreview'>");
                sb.Append("<ul>");
                sb.Append("<li>");
                sb.Append(previewLinkStart);
                sb.Append(i18n.GetMessage("m907")).Append("</a>");
                sb.Append("</li>");
            }
            else
            {
                sb.Append("<div class='CmdTitle WithoutPreview'>");
                sb.Append("<ul>");
                sb.Append("<li>");
                sb.Append(disabledPreviewLinkStart);
                sb.Append(i18n.GetMessage("m907")).Append("</a>");
                sb.Append("</li>");
            }
            sb.Append("<li>");
            if (canDownload)
            {
                sb.Append(downloadLinkStart);
            }
            else
            {
                sb.Append(disabledDownloadLinkStart);
            }

            sb.Append(i18n.GetMessage("m906"));
            sb.Append("</a>");
            sb.Append("</li>");
            if (sourceUri.Contains("http://"))
            {
                sb.Append("<li><a href='" + sourceUri + "' target='_blank' >" + i18n.GetMessage("m483") + "</a></li>");
            }
            sb.Append("</ul>");
            sb.Append("</div>");

        }
        sb.Append("</div></div>");

        return sb.ToString();
    }