Пример #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 string RedirectURL()
 {
     return(ModalFileView.GetRedirectUrl(PublishmentSystemId, Body.GetQueryString("rootPath"),
                                         Body.GetQueryString("FileName"), FileName.Text, Body.GetQueryString("HiddenClientID")));
 }
Пример #3
0
 private string RedirectUrl()
 {
     return(ModalFileView.GetRedirectUrl(SiteId, Body.GetQueryString("rootPath"),
                                         Body.GetQueryString("FileName"), TbFileName.Text, Body.GetQueryString("HiddenClientID")));
 }
Пример #4
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();
        }
Пример #5
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "RelatedPath", "FileName", "IsCreate");
            _relatedPath = AuthRequest.GetQueryString("RelatedPath").Trim('/');
            if (!_relatedPath.StartsWith("@"))
            {
                _relatedPath = "@/" + _relatedPath;
            }
            _theFileName = AuthRequest.GetQueryString("FileName");
            _isCreate    = AuthRequest.GetQueryBool("IsCreate");
            _fileCharset = ECharset.utf_8;
            if (SiteInfo != null)
            {
                _fileCharset = ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset);
            }

            if (_isCreate == false)
            {
                var filePath = SiteInfo != null
                    ? PathUtility.MapPath(SiteInfo, PathUtils.Combine(_relatedPath, _theFileName))
                    : PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName));

                if (!FileUtils.IsFileExists(filePath))
                {
                    PageUtils.RedirectToErrorPage("此文件不存在!");
                    return;
                }
            }

            if (IsPostBack)
            {
                return;
            }

            DdlCharset.Items.Add(new ListItem("默认", string.Empty));
            ECharsetUtils.AddListItems(DdlCharset);

            if (_isCreate == false)
            {
                var filePath = SiteInfo != null?PathUtility.MapPath(SiteInfo, PathUtils.Combine(_relatedPath, _theFileName)) : PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName));

                TbFileName.Text    = _theFileName;
                TbFileName.Enabled = false;
                TbFileContent.Text = FileUtils.ReadText(filePath, _fileCharset);
            }

            if (_isCreate)
            {
                return;
            }

            if (SiteInfo != null)
            {
                LtlOpen.Text =
                    $@"<a class=""btn btn-default m-l-10"" href=""{PageUtility.ParseNavigationUrl(SiteInfo,
                        PageUtils.Combine(_relatedPath, _theFileName), true)}"" target=""_blank"">浏 览</a>";
            }
            else
            {
                LtlOpen.Text =
                    $@"<a class=""btn btn-default m-l-10"" href=""{PageUtils.ParseConfigRootUrl(PageUtils.Combine(_relatedPath, _theFileName))}"" target=""_blank"">浏 览</a>";
            }
            LtlView.Text = $@"<a class=""btn btn-default m-l-10"" href=""{ModalFileView.GetRedirectUrl(SiteId, _relatedPath, _theFileName)}"">查 看</a>";
        }
Пример #6
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID", "RelatedPath", "FileName", "IsCreate");
            _relatedPath = Body.GetQueryString("RelatedPath").Trim('/');
            if (!_relatedPath.StartsWith("@"))
            {
                _relatedPath = "@/" + _relatedPath;
            }
            _theFileName = Body.GetQueryString("FileName");
            _isCreate    = Body.GetQueryBool("IsCreate");
            _fileCharset = ECharset.utf_8;
            if (PublishmentSystemInfo != null)
            {
                _fileCharset = ECharsetUtils.GetEnumType(PublishmentSystemInfo.Additional.Charset);
            }

            if (_isCreate == false)
            {
                string filePath;
                if (PublishmentSystemInfo != null)
                {
                    filePath = PathUtility.MapPath(PublishmentSystemInfo, PathUtils.Combine(_relatedPath, _theFileName));
                }
                else
                {
                    filePath = PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName));
                }
                if (!FileUtils.IsFileExists(filePath))
                {
                    PageUtils.RedirectToErrorPage("此文件不存在!");
                    return;
                }
            }

            if (!IsPostBack)
            {
                Charset.Items.Add(new ListItem("默认", string.Empty));
                ECharsetUtils.AddListItems(Charset);

                if (_isCreate == false)
                {
                    var filePath = string.Empty;
                    if (PublishmentSystemInfo != null)
                    {
                        filePath = PathUtility.MapPath(PublishmentSystemInfo, PathUtils.Combine(_relatedPath, _theFileName));
                    }
                    else
                    {
                        filePath = PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName));
                    }
                    FileName.Text           = _theFileName;
                    FileName.Enabled        = false;
                    FileContentTextBox.Text = FileUtils.ReadText(filePath, _fileCharset);
                }

                if (!_isCreate)
                {
                    if (PublishmentSystemInfo != null)
                    {
                        ltlOpen.Text =
                            $@"<a href=""{PageUtility.ParseNavigationUrl(PublishmentSystemInfo,
                                PageUtils.Combine(_relatedPath, _theFileName))}"" target=""_blank"">浏 览</a>&nbsp;&nbsp;";
                    }
                    else
                    {
                        ltlOpen.Text =
                            $@"<a href=""{PageUtils.ParseConfigRootUrl(PageUtils.Combine(_relatedPath, _theFileName))}"" target=""_blank"">浏 览</a>&nbsp;&nbsp;";
                    }
                    ltlView.Text = $@"<a href=""{ModalFileView.GetRedirectUrl(PublishmentSystemId, _relatedPath, _theFileName)}"">属 性</a>";
                }
            }
        }
Пример #7
0
        private void FillFileSystemsToImage(bool isReload)
        {
            var builder = new StringBuilder();

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

            var directoryUrl = PageUtility.GetPublishmentSystemUrl(PublishmentSystemInfo, _relatedPath);

            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 (string.IsNullOrEmpty(_relatedPath))
                {
                    if (StringUtils.EqualsIgnoreCase(subDirectoryInfo.Name, "api"))
                    {
                        continue;
                    }
                }
                if (mod % 5 == 0)
                {
                    builder.Append("<tr>");
                }
                var linkUrl = GetRedirectUrl(PublishmentSystemId, PageUtils.Combine(_relatedPath, 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, 7)}</a> <input type=""checkbox"" name=""DirectoryNameCollection"" value=""{subDirectoryInfo
				    .Name}"" /></td>
			</tr>
		</table>
	</td>
");

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

            foreach (FileSystemInfoExtend fileInfo in fileSystemInfoExtendCollection.Files)
            {
                if (mod % 5 == 0)
                {
                    builder.Append("<tr>");
                }
                var fileSystemType       = EFileSystemTypeUtils.GetEnumType(fileInfo.Type);
                var showPopWinString     = ModalFileView.GetOpenWindowString(PublishmentSystemId, _relatedPath, fileInfo.Name);
                var linkUrl              = PageUtils.Combine(directoryUrl, fileInfo.Name);
                var fileImageUrl         = string.Empty;
                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 = SiteServerAssets.GetFileSystemIconUrl(fileSystemType, true);
                }

                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=""{showPopWinString}"" target=""_blank""><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}"" target=""_blank"">{StringUtils
                    .MaxLengthText(fileInfo.Name, 7)}</a> <input type=""checkbox"" name=""FileNameCollection"" value=""{fileInfo
                    .Name}"" /></td>
			</tr>
		</table>
	</td>
");

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

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