예제 #1
0
        private void FillFileSystemsToList(bool isReload)
        {
            var builder = new StringBuilder();

            builder.Append(@"<table class=""table table-bordered table-hover""><tr class=""info thead""><td>名称</td><td width=""80"">大小</td><td width=""120"">类型</td><td width=""120"">修改日期</td></tr>");
            var directoryUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, _directoryPath, true);

            var fileSystemInfoExtendCollection = FileManager.GetFileSystemInfoExtendCollection(_directoryPath, isReload);

            foreach (FileSystemInfoExtend subDirectoryInfo in fileSystemInfoExtendCollection.Folders)
            {
                string fileNameString =
                    $"<img src={SiteServerAssets.GetFileSystemIconUrl(EFileSystemType.Directory, false)} border=0 /> {subDirectoryInfo.Name}";
                var    fileSystemTypeString = "文件夹";
                var    fileModifyDateTime   = subDirectoryInfo.LastWriteTime;
                var    linkUrl = GetRedirectUrl(PageUtils.Combine(_currentRootPath, subDirectoryInfo.Name));
                string trHtml  =
                    $"<tr><td><nobr><a href=\"{linkUrl}\">{fileNameString}</a></nobr></td><td align=\"right\">&nbsp;</td><td align=\"center\">{fileSystemTypeString}</td><td align=\"center\">{DateUtils.GetDateString(fileModifyDateTime, EDateFormatType.Day)}</td></tr>";
                builder.Append(trHtml);
            }

            foreach (FileSystemInfoExtend fileInfo in fileSystemInfoExtendCollection.Files)
            {
                string fileNameString =
                    $"<img src={GetFileSystemIconUrl(SiteInfo, fileInfo, false)} border=0 /> {fileInfo.Name}";
                var fileSystemType       = EFileSystemTypeUtils.GetEnumType(fileInfo.Type);
                var fileSystemTypeString = (fileSystemType == EFileSystemType.Unknown) ?
                                           $"{fileInfo.Type.TrimStart('.').ToUpper()} 文件"
                    : EFileSystemTypeUtils.GetText(fileSystemType);
                var fileKbSize = fileInfo.Size / 1024;
                if (fileKbSize == 0)
                {
                    fileKbSize = 1;
                }
                var fileModifyDateTime = fileInfo.LastWriteTime;
                var linkUrl            = PageUtils.Combine(directoryUrl, fileInfo.Name);
                var attachmentUrl      = linkUrl.Replace(SiteInfo.Additional.WebUrl, "@");
                //string fileViewUrl = Modal.FileView.GetOpenWindowString(base.SiteId, attachmentUrl);
                var    fileViewUrl = ModalFileView.GetOpenWindowStringHidden(SiteId, attachmentUrl, _hiddenClientId);
                string trHtml      =
                    $"<tr><td><a href=\"javascript:;\" onClick=\"window.parent.SelectAttachment('{_hiddenClientId}', '{attachmentUrl.Replace("'", "\\'")}', '{fileViewUrl.Replace("'", "\\'")}');{LayerUtils.CloseScript}\" title=\"点击此项选择此附件\">{fileNameString}</a></td><td align=\"right\">{fileKbSize} KB</td><td align=\"center\">{fileSystemTypeString}</td><td align=\"center\">{DateUtils.GetDateString(fileModifyDateTime, EDateFormatType.Day)}</td></tr>";
                builder.Append(trHtml);
            }

            builder.Append("</table>");
            LtlFileSystems.Text = builder.ToString();
        }
예제 #2
0
        private void FillFileSystemsToImage(bool isReload)
        {
            var builder = new StringBuilder();

            builder.Append(@"<table class=""table table-noborder table-hover"">");

            var directoryUrl       = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, _directoryPath, true);
            var backgroundImageUrl = SiteServerAssets.GetIconUrl("filesystem/management/background.gif");
            var directoryImageUrl  = SiteServerAssets.GetFileSystemIconUrl(EFileSystemType.Directory, true);

            var fileSystemInfoExtendCollection = FileManager.GetFileSystemInfoExtendCollection(_directoryPath, isReload);

            var mod = 0;

            foreach (FileSystemInfoExtend subDirectoryInfo in fileSystemInfoExtendCollection.Folders)
            {
                if (mod % 4 == 0)
                {
                    builder.Append("<tr>");
                }
                var linkUrl = GetRedirectUrl(PageUtils.Combine(_currentRootPath, subDirectoryInfo.Name));

                builder.Append($@"
<td>
		<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
			<tr>
				<td style=""height:100px; width:100px; text-align:center; vertical-align:middle;"">
					<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
						<tr>
							<td background=""{backgroundImageUrl}"" style=""background-repeat:no-repeat; background-position:center;height:96px; width:96px; text-align:center; vertical-align:middle;"" align=""center""><a href=""{linkUrl}""><img src=""{directoryImageUrl}"" border=0 /></a></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style=""height:20px; width:100%; text-align:center; vertical-align:middle;""><a href=""{linkUrl}"">{StringUtils
				    .MaxLengthText(subDirectoryInfo.Name, 8)}</a></td>
			</tr>
		</table>
	</td>
");

                if (mod % 4 == 3)
                {
                    builder.Append("</tr>");
                }
                mod++;
            }

            foreach (FileSystemInfoExtend fileInfo in fileSystemInfoExtendCollection.Files)
            {
                if (mod % 4 == 0)
                {
                    builder.Append("<tr>");
                }
                var    fileSystemType = EFileSystemTypeUtils.GetEnumType(fileInfo.Type);
                var    linkUrl        = PageUtils.Combine(directoryUrl, fileInfo.Name);
                string fileImageUrl;
                var    imageStyleAttributes = string.Empty;
                if (EFileSystemTypeUtils.IsImage(fileInfo.Type))
                {
                    var imagePath = PathUtils.Combine(_directoryPath, fileInfo.Name);
                    try
                    {
                        var image = ImageUtils.GetImage(imagePath);
                        if (image.Height > image.Width)
                        {
                            if (image.Height > 94)
                            {
                                imageStyleAttributes = @"style=""height:94px;""";
                            }
                        }
                        else
                        {
                            if (image.Width > 94)
                            {
                                imageStyleAttributes = @"style=""width:94px;""";
                            }
                        }
                        fileImageUrl = PageUtils.Combine(directoryUrl, fileInfo.Name);
                        image.Dispose();
                    }
                    catch
                    {
                        fileImageUrl = SiteServerAssets.GetFileSystemIconUrl(fileSystemType, true);
                    }
                }
                else
                {
                    fileImageUrl = GetFileSystemIconUrl(SiteInfo, fileInfo, true);
                }

                var attachmentUrl = PageUtility.GetVirtualUrl(SiteInfo, linkUrl);
                //string fileViewUrl = Modal.FileView.GetOpenWindowString(base.SiteId, attachmentUrl);
                var fileViewUrl = ModalFileView.GetOpenWindowStringHidden(SiteId, attachmentUrl, _hiddenClientId);

                builder.Append($@"
<td>
		<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
			<tr>
				<td style=""height:100px; width:100px; text-align:center; vertical-align:middle;"">
					<table cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"">
						<tr>
							<td background=""{backgroundImageUrl}"" style=""background-repeat:no-repeat; background-position:center;height:96px; width:96px; text-align:center; vertical-align:middle;"" align=""center""><a href=""javascript:;"" onClick=""window.parent.SelectAttachment('{_hiddenClientId}', '{attachmentUrl
				    .Replace("'", "\\'")}', '{fileViewUrl.Replace("'", "\\'")}');{LayerUtils.CloseScript}"" title=""{fileInfo.Name}""><img src=""{fileImageUrl}"" {imageStyleAttributes} border=0 /></a></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style=""height:20px; width:100%; text-align:center; vertical-align:middle;""><a href=""{linkUrl}"" title=""点击此项浏览此附件"" target=""_blank"">{StringUtils
				    .MaxLengthText(fileInfo.Name, 8)}</a></td>
			</tr>
		</table>
	</td>
");

                if (mod % 4 == 3)
                {
                    builder.Append("</tr>");
                }
                mod++;
            }

            builder.Append("</table>");
            LtlFileSystems.Text = builder.ToString();
        }