<%@ Page Language="VB" smartnavigation="false" Trace="False" Debug="True" Explicit="true" %>
<%@ Import Namespace="Microsoft.VisualBasic" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.UI.WebControls.Xml" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="da" lang="da">
<head>
<title>Konfigurator</title>
<link rel="stylesheet" type="text/css" href="/msm/css/style.css" />
<script type="text/javaScript" src="/msm/script/utils.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script Language="VB" runat=server>
Public Sub Page_Load(Source As Object, E As EventArgs)
lblScript.Text = ""
lblMessage.Text = ""
pnStatus.Visible = False
If Not Page.IsPostBack() Then
NameFile.Text = "Skriv filnavn her (Ex.: navn.type)"
ListMinuteFiles()
End If
End Sub
Sub OnClick_Upload(Sender as Object, E as EventArgs)
' PostedFile gets access to the uploaded file specified by a client
If Not (loFile.PostedFile Is Nothing) Then
Try
Dim strFileName, strFileNameChange, strFileNamePath, strFileFolder As String
strFileFolder = Context.Server.MapPath("UploadedFiles/")
strFileName = loFile.PostedFile.FileName
strFileName = Path.GetFileName(strFileName)
If (NameFile.Text = "Skriv filnavn her (Ex.: navn.type)")
strFileNamePath = strFileFolder + strFileName
loFile.PostedFile.SaveAs(strFileNamePath)
lblFileName.Text = strFileName
Else
strFileNameChange = NameFile.Text
strFileNamePath = strFileFolder + strFileNameChange
loFile.PostedFile.SaveAs(strFileNamePath)
lblFileName.Text = strFileNameChange
End If
'strFileNamePath = strFileFolder + strFileNameChange
'loFile.PostedFile.SaveAs(strFileNamePath)
'lblFileName.Text = strFileNameChange
lblFileLength.Text = loFile.PostedFile.ContentLength.ToString()
lblFileType.Text = loFile.PostedFile.ContentType
pnStatus.Visible = True
'NameFile.Text = ""
Catch ex As Exception
Dim lblError As Label
lblError = New Label()
lblError.ForeColor = Color.Red
lblError.Text = "Exception occurred: " + ex.Message
lblError.Visible = True
Page.Controls.Add(lblError)
End Try
End If
ListMinuteFiles()
NameFile.Text = "Skriv filnavn her (Ex.: navn.type)"
End Sub
Public Sub ListMinuteFilesRec(ByRef dtaData As DataTable, strPath As String, strLocation As String)
Dim objDirInfo As DirectoryInfo = New DirectoryInfo(strPath)
If (objDirInfo.Exists = True) Then
Dim arrFileInfo As FileInfo() = objDirInfo.GetFiles()
Dim arrFolderInfo As DirectoryInfo() = objDirInfo.GetDirectories()
Dim objFile As FileInfo
Dim objFolder As DirectoryInfo
For Each objFile In arrFileInfo
Dim strName As String = Left(objDirInfo.Name, objDirInfo.Name.Length)
Dim dr As DataRow = dtaData.NewRow()
dr(0) = objFile.Name
dr(1) = objFile.DirectoryName
dtaData.Rows.Add(dr)
Next
For Each objFolder In arrFolderInfo
If strLocation <> "" Then
ListMinuteFilesRec(dtaData, objFolder.FullName, strLocation & " - " & objFolder.Name)
Else
ListMinuteFilesRec(dtaData, objFolder.FullName, objFolder.Name)
End If
Next
End If
End Sub
Public Sub ListMinuteFiles()
Dim strContentFolderName As String = "UploadedFiles\"
Dim objDirInfo As DirectoryInfo = New DirectoryInfo(Server.MapPath(strContentFolderName))
Dim dt As New DataTable()
dt.Columns.Add(New DataColumn("doctitle", GetType(String)))
dt.Columns.Add(New DataColumn("path", GetType(String)))
ListMinuteFilesRec(dt, objDirInfo.FullName, "")
grdDocumentList.DataSource = dt
grdDocumentList.DataBind
End Sub
Sub grdDocumentList_ItemCommand(source As Object, e As System.Web.UI.WebControls.DataGridCommandEventArgs)
If (e.CommandName="ViewDocument") Then
Dim strDocPath As String = CType(e.Item.Cells(1).Text,String)
strDocPath = "UploadedFiles/" & strDocPath
lblScript.Text = "<" & "script>var w = window.open(""" & strDocPath & """,""viewwindow"");" & "<" & "/script>"
End if
If (e.CommandName="DeleteDocument") Then
System.IO.File.Delete(Server.MapPath("UploadedFiles/" & CType(e.Item.Cells(1).Text,String)))
ListMinuteFiles()
End If
End Sub
</script>
<script language="JavaScript">
firstTime = true;
function selectText(textBox)
{
if(firstTime)
{
firstTime = false;
textBox.select();
}
}
</script>
</head>
<body MS_POSITIONING="FlowLayout">
<form enctype="multipart/form-data" align="center" runat="server">
<div id="content">
<h1 align="center">[Konfigurator]</h1>
<div id="pane" align="center">
<a href="control.html">Historik</a><a href="konfigs.aspx">Konfig-filer</a><a href="textfiles.html">Text-filer</a>
</div>
<br><br>
<div id="Upload" align="left" style="margin-left:20px;">
<asp:label runat="server" id="FileLabel" text="Find den ønsket fil:" />
<input id="loFile" name="loFile" type="file" length="100px" runat="server" style="Width: 400px;" /><br><br>
<asp:label runat="server" id="NamingFileLabel" text="Ændre filnavn til:" />
<ASP:TextBox id="NameFile" onclick="java script:selectText(this);" name="NameFile" type="Text" Font-Italic="True" runat="server" style="Width:325px;"></ASP:TextBox>
<br><br>
<pre> <asp:button runat="server" id="UploadButton" length="100px" OnClick="OnClick_Upload" text="Upload" BackColor="WhiteSmoke" Width="100px" BorderColor="LightGray" BorderStyle="Ridge" ForeColor="Black"/></pre>
<P>
<asp:panel align="center" id="pnStatus" runat="server" Visible="False">
<asp:Label id="lblFileName" Runat="server" Font-Bold="True"></asp:Label> uploaded<BR>File Length:
<asp:Label id="lblFileLength" Runat="server"></asp:Label>bytes<BR>File Type:
<asp:Label id="lblFileType" Runat="server"></asp:Label>
</asp:panel>
</P>
</div>
<asp:DataGrid align="center" id="grdDocumentList" CellPadding="2" AllowPaging="False" AllowCustomPaging="False" OnItemCommand="grdDocumentList_ItemCommand" runat="server">
<HeaderStyle BackColor="#99EEBB" ForeColor="Black" Font-Bold="True" />
<columns>
<asp:TemplateColumn HeaderText="View">
<HeaderStyle HorizontalAlign="Left" Width="0px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="0px"></ItemStyle>
<itemtemplate>
<asp:ImageButton ToolTip="View document" width="10" length="10" ImageUrl="View.gif" CommandName="ViewDocument" runat="server" />
</itemtemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="DocTitle" DataField="doctitle" SortExpression="doctitle" Visible="False" />
<asp:BoundColumn HeaderText="DocPath" DataField="path" SortExpression="path" Visible="False" />
<asp:TemplateColumn HeaderText="Delete">
<HeaderStyle HorizontalAlign="Left" Width="0px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="0px"></ItemStyle>
<itemtemplate>
<asp:ImageButton ToolTip="Delete document" width="10" length="10" ImageUrl="delete.gif" CommandName="DeleteDocument" runat="server" />
</itemtemplate>
</asp:TemplateColumn>
</columns>
</asp:DataGrid>
<br>
<asp:Label id="lblMessage" runat="server" />
<asp:Label id="lblScript" runat="server" />
<address>Copyright © Software Innovation</address>
</div>
</form>
</body>
</html>