1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeShow.aspx.cs" Inherits="WebApplication1.TreeShow" %>
2
3 <!DOCTYPE html>
4 <%@ Register Src="~/UserControls/AspNetPager.ascx" TagName="AspNetPager"
5 TagPrefix="uc3" %>
6 <%@ Register Assembly="ASTreeView" Namespace="Geekees.Common.Controls" TagPrefix="ct" %>
7 <html xmlns="http://www.w3.org/1999/xhtml">
8 <head runat="server">
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10 <title></title>
11 <script type="text/javascript">
12 function WenJian(obj) {
13 document.getElementById("hidfgbh").value = obj;
14 document.getElementById("btnOpenFile").click();
15 }
16 </script>
17 </head>
18 <body>
19
20 <link href="<%=ResolveUrl("Scripts/astreeview/astreeview.css")%>" type="text/css"
21 rel="stylesheet" />
22 <link href="<%=ResolveUrl("Scripts/contextmenu/contextmenu.css")%>" type="text/css"
23 rel="stylesheet" />
24 <script src="<%=ResolveUrl("Scripts/astreeview/astreeview_packed.js")%>?ver=<%=ASTreeViewVersion %>"
25 type="text/javascript"></script>
26 <script src="<%=ResolveUrl("Scripts/contextmenu/contextmenu_packed.js")%>?ver=<%=ASTreeViewVersion %>"
27 type="text/javascript"></script>
28 <form id="form1" runat="server">
29 <div style="display: none;">
30 <asp:HiddenField ID="hidnodevalue" runat="server" />
31 <asp:Button ID="btnOpenFile" runat="server" OnClick="btnOpenFile_Click" />
32 <asp:HiddenField ID="hidfgbh" runat="server" />
33 </div>
34
35 <div>
36 <div id="divLeftTree" runat="server" style="width: 19%; border: 1px solid #365d86; border-right-width: 0px; border-right: 0px; float: left; height: 400px; overflow-y: auto;"
37 valign="top">
38 <div>
39 <a onclick="openall()" style="cursor: pointer;">文件目录</a>
40 </div>
41 <div>
42 <ct:ASTreeView ID="astvMyTree" runat="server" AutoPostBack="true" BasePath="Scripts/astreeview/themes/macOS"
43 DataTableRootNodeValue="0" EnableRoot="false" EnableNodeSelection="true" EnableCheckbox="false"
44 EnableDragDrop="false" EnableTreeLines="true" EnableNodeIcon="true" EnableCustomizedNodeIcon="false"
45 EnableParentNodeExpand="false" EnableDebugMode="false" EnableContextMenu="false"
46 ExpandDepth="0" OnOnSelectedNodeChanged="astvMyTree_OnSelectedNodeChanged" />
47 </div>
48 </div>
49 <div style="width: 80%; border: 1px solid #365d86; border-right: 0px; float: left; height: auto; height: 400px; border-right-width: 1px;"
50 valign="top">
51 <div>
52 <div class="tab">
53 <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
54 <HeaderTemplate>
55 <table width="100%" class="mytable newTable">
56 <thead>
57 <tr style="font-weight: bold; line-height: 25px; height: 25px;">
58 <td class="brs" width="5%" nowrap="" align="center">
59 <strong>序号</strong>
60 </td>
61 <td class="brs" width="5%" nowrap="" align="center">
62 <div style="margin-left: -1px;">
63 <asp:CheckBox ID="CheckBox1" runat="server" ToolTip="全选" onclick="checkss(this);" />
64 </div>
65 </td>
66 <td class="brs" width="35%" nowrap="" align="center">
67 <strong>文件名称</strong>
68 </td>
69 <td class="brs" width="10%" nowrap="" align="center">
70 <strong>更改名称</strong>
71 </td>
72 <td class="brs" width="10%" nowrap="" align="center">
73 <strong>文件大小</strong>
74 </td>
75 <td class="brs" width="10%" nowrap="" align="center">
76 <strong>上传人</strong>
77 </td>
78 <td class="brs" width="15%" nowrap="" align="center">
79 <strong>创建时间</strong>
80 </td>
81 <td class="brs" width="10%" nowrap="" align="center">
82 <strong>排序号</strong>
83 </td>
84 </tr>
85 </thead>
86 <tbody>
87 </HeaderTemplate>
88 <ItemTemplate>
89 <tr id='tr_<%# DataBinder.Eval(Container.DataItem, "FGBH")%>'>
90 <td style="text-align: center; color: Blue;">
91 <%#Container.ItemIndex + 1 + AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1) %>
92 </td>
93 <td style="color: Blue;">
94 <input type="checkbox" id="CheckBox11" class="checkBox" guid='<%# DataBinder.Eval(Container.DataItem, "FGBH") %>' />
95 </td>
96 <td>
97 <div runat="server" id="divpp" style="cursor: pointer; color: #6300FF;">
98 <asp:Literal ID="ltDown" runat="server"></asp:Literal>
99 </div>
100 </td>
101 <td></td>
102 <td></td>
103 <td>
104 <%# Eval("XGR")%>
105 </td>
106 <td>
107 <%# Eval("CJSJ")%>
108 </td>
109 <td>
110 <%# Eval("PXM")%>
111 </td>
112 </tr>
113 </ItemTemplate>
114 <FooterTemplate>
115 </tbody> </table>
116 </FooterTemplate>
117 </asp:Repeater>
118 </div>
119 <div style="text-align: right;">
120 <uc3:AspNetPager ID="AspNetPager1" runat="server" PageSize="10" OnPageChanged="AspNetPager1_PageChanged" />
121 </div>
122 </div>
123 </div>
124 </div>
125 </form>
126 </body>
127 </html>
using Geekees.Common.Controls;
using Oceansoft.Net;
using SubSonic;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class TreeShow : System.Web.UI.Page
{
protected string ASTreeViewVersion
{
get
{
return typeof(ASTreeView).Assembly.GetName().Version.ToString();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadTree();
}
}
public void LoadInfo(string nodevalue,string notetext,int pageindex)
{
string sql = " SELECT * FROM T_YDZF_FLFG WHERE FIDH=@fidh ";
DataTable dt = new DataTable();
QueryCommand qc = new InlineQuery("Test1").GetCommand(sql,new object[]{nodevalue});
dt = DataService.GetDataSet(qc).Tables[0];//将查询出来的数据集放到List中去(查询数据的方法,有很多,这边我用的是Subsonic类自带的查询方法)
this.AspNetPager1.CurrentPageIndex =pageindex;
this.AspNetPager1.PageSize = 10;
this.Repeater1.DataSource = dt;
this.AspNetPager1.RecordCount = dt.Rows.Count;
this.Repeater1.DataBind();
}
public void LoadTree()
{
try
{
this.astvMyTree.RootNode.Clear();
TYdzfFlfgController asset = new TYdzfFlfgController();
var Menus = asset.FetchAll();
var top = from c in Menus where c.Fidh=="ROOT" && c.Sfml=="1" orderby c.Pxm select c;
foreach (var item in top)
{
var Node = new ASTreeViewNode(item.Fgmc, item.Fgbh);
this.astvMyTree.RootNode.AppendChild(Node);
this.appendChildNode(Node, Menus);
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 加载子节点
/// </summary>
/// <param name="node"></param>
/// <param name="Collection"></param>
private void appendChildNode(ASTreeViewNode node, TYdzfFlfgCollection Collection)
{
try
{
var childNodes = from c in Collection where c.Fidh == node.NodeValue && c.Sfml == "1" orderby c.Pxm select c;
if (childNodes.Count() > 0)
{
foreach (var item in childNodes)
{
var ChildNode = new ASTreeViewNode(item.Fgmc, item.Fgbh);
node.AppendChild(ChildNode);
if (item.Sfml == "1")
{
this.appendChildNode(ChildNode, Collection);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
protected void astvMyTree_OnSelectedNodeChanged(object src, ASTreeViewNodeSelectedEventArgs e)
{
LoadInfo(e.NodeValue, e.NodeText,1);
this.hidnodevalue.Value = e.NodeValue;
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
LoadInfo(this.hidnodevalue.Value, string.Empty, AspNetPager1.CurrentPageIndex);
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
HtmlGenericControl divpp = (HtmlGenericControl)e.Item.FindControl("divpp");
Literal ltdown = (Literal)e.Item.FindControl("ltdown");
DataRowView drv = e.Item.DataItem as DataRowView;
if (drv["FGMC"] != null)
{
if (string.IsNullOrEmpty(Path.GetExtension(drv["FGMC"].ToString())))//说明是文件夹
{
ltdown.Text = drv["FGMC"].ToString();
divpp.Attributes.Add("onclick", "javascript:WenJian('" + drv["FGBH"] + "');");
}
else//说明是文件 xxxx.jpg
{
if (getIsFile(drv["FGBH"].ToString()))//判断文件是否存在
{
ltdown.Text = string.Format("<a id='divhrefa' style='color:#6300FF;' href='../../../../UserControls/CommAttShow.aspx?AttachmentId={0}&AttachType={2}'>{1}</a> ", drv["FGBH"], drv["FGMC"], "EnvironAttachment");
}
else
{
ltdown.Text = string.Format("<a onclick=" + "javascript:alert('附件不存在')" + ">{0}</a>", drv["FGMC"].ToString());
}
}
}
}
}
//判断文件是否存在
public bool getIsFile(string attId)
{
bool Istrue = false;
TYdzfFlfgController asset = new TYdzfFlfgController();
var Menus = asset.FetchAll().Where("Fgbh", attId);
string guid = "";
string fileName = "";
string extName = "";
string PanAddress = "";
foreach (var item in Menus)
{
guid = item.Fgbh;
fileName = item.Fgmc;
extName = Path.GetExtension(item.Fgmc);
}
PanAddress = ConfigurationManager.AppSettings["EnvironAttachment"].ToString();//@ConfigurationSettings.AppSettings["EnvironAttachment"].ToString();
string filePath = PanAddress + guid.Replace("/", @"\") + extName;
if (File.Exists(filePath))
{
// fullName = filePath;
// break;
Istrue = true;
}
return Istrue;
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CommAttShow.aspx.cs" Inherits="EBCM_NET.UserControls.CommAttShow" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function showAttachmentPage()
{
alert("附件不存在");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="display:none;">
<asp:HiddenField ID="hidAttachType" runat="server" />
</div>
<div>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using PowerDataNet.Model;
using System.Configuration;
namespace EBCM_NET.UserControls
{
public partial class CommAttShow : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (!string.IsNullOrEmpty(Request["AttachType"]))
{
this.hidAttachType.Value = Request["AttachType"].ToString();//获取 保存的是什么附件 在web.config 中
}
InitPage();
}
}
private void InitPage()
{
try
{
//附件Id
string attId = "";
//文件名
string fileName = "";
//文件后缀名
string extName = "";
//物理文件全名
string fullNamePath = "";
if (!string.IsNullOrEmpty(Request.QueryString["AttachmentId"]))
{
attId = Request.QueryString["AttachmentId"];
string file = GetCommAttFileName(attId, this.hidAttachType.Value);
fileName = file.Split('|')[0];
fullNamePath = file.Split('|')[1];
if (!string.IsNullOrEmpty(fullNamePath))
{
System.IO.FileInfo fileInfo = new System.IO.FileInfo(fullNamePath);
if (fileInfo.Exists == true)
{
try
{
FileInfo info = new FileInfo(fullNamePath);
long fileSize = info.Length;
Response.Clear();
Response.ContentType = "application/x-zip-compressed";
string flname = Server.UrlEncode(fileName);
Response.AddHeader("Content-Disposition", "attachment;filename=" + flname);
//不指明Content-Length用Flush的话不会显示下载进度
Response.AddHeader("Content-Length", fileSize.ToString());
Response.TransmitFile(fullNamePath, 0, fileSize);
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
throw ex;
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 取附件
/// </summary>
/// <param name="pFullPath">完全路径,有正确的扩展名</param>
/// <returns>数据流</returns>
public Stream GetFileStream(string pFullPath)
{
Stream pStream = null;
try
{
FileStream pFileStream = null;
FileInfo pFileObject = new FileInfo(pFullPath);
pFileStream = pFileObject.Open(System.IO.FileMode.Open);
pStream = (Stream)pFileStream;
return pStream;
}
catch (Exception)
{
throw;
}
}
public byte[] GetFileByte(Stream fileStream)
{
//Stream fileStream = GetFileStream(fullName);
int fileLength = (int)fileStream.Length;
byte[] imgdata = new byte[fileLength];
int n = fileStream.Read(imgdata, 0, fileLength);
return imgdata;
}
public string GetCommAttFileName(string attId, string stringAttachType)
{
string fullName = "";
string fileName = "";
string extName = "";
string guid = "";
string PanAddress = "";
if (!string.IsNullOrEmpty(stringAttachType))
{
if (this.hidAttachType.Value.Equals("EnvironAttachment"))//这是环保手册附件 地址
{
T_YDZF_FLFGBLL bllhbsc = new T_YDZF_FLFGBLL();
var Menus = bllhbsc.GetList(attId);
foreach (var item in Menus)
{
guid = item.FGBH;
fileName = item.FGMC;
extName = Path.GetExtension(item.FGMC);
}
}
else if (this.hidAttachType.Value.Equals("ZFQZCL")) //执法取证材料
{
U_YDZF_T_YDZF_FJBBLL bllxcqz = new U_YDZF_T_YDZF_FJBBLL();
var Menus = bllxcqz.GetList(attId);
foreach (var item in Menus)
{
guid = item.BH;
fileName = item.FJMC;
extName = Path.GetExtension(item.FJDZ);
}
}
}
if (!string.IsNullOrEmpty(this.hidAttachType.Value))
{
if (this.hidAttachType.Value.Equals("EnvironAttachment"))//这是环保手册附件 地址
{
PanAddress = ConfigurationManager.AppSettings["EnvironAttachment"].ToString();// @ConfigurationSettings.AppSettings["EnvironAttachment"].ToString();
}
else if (this.hidAttachType.Value.Equals("ZFQZCL"))
{
PanAddress = ConfigurationManager.AppSettings["ZFQZCL"].ToString();// @ConfigurationSettings.AppSettings["ZFQZCL"].ToString();
}
}
//E:\hbwj\hbwj\flfg
string filePath = PanAddress + guid.Replace("/", @"\") + extName;
if (File.Exists(filePath))
{
fullName = filePath;
// break;
}
return fileName + "|" + fullName;
}
}
}