Imports System.IO
Imports System.Collections.Generic
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Data
Imports System.Data.SqlClient
Public Class Site
Inherits System.Web.UI.MasterPage
Dim PathMSDS As String = "C:\Users\TiP-ToP\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\REPORT"
Dim myDirInfo As DirectoryInfo
Dim myFolderInfo As DirectoryInfo
Dim arrFolderInfo As Array
Dim _dirFile As String
Dim RootMaster = New Menu
Dim RootMenu = New MenuItem
Dim RootTmp = New MenuItem
Dim SubTmp = New MenuItem
Dim arrMenu() As String
Dim tarray As New ArrayList()
Dim SearchPath As String = "C:\MSDS\"
Sub BuildTree(ByVal s As String)
Dim strName As String = HttpContext.Current.User.Identity.Name.ToString
Dim rootdir = New DirectoryInfo("C:\Users\TiP-ToP\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\REPORT\" & s)
Dim rootnode = New TreeNode(rootdir.Name, rootdir.FullName)
Dim rootSub = New MenuItem(rootdir.Name, rootdir.FullName)
'DocumentMenu.Items.Add(rootSub)
NavigationMenu.Items.Add(rootSub)
'RecursiveSearch(rootdir, rootSub)
RecursiveSearch2(rootdir, rootSub)
'TreeView1.Nodes.Add(rootnode)
'traversetree(rootdir, rootnode)
End Sub
'Private Sub RecursiveSearch(ByRef CurrentMenu, ByRef CurrentSubMenu)
' Dim dir As DirectoryInfo
' For Each dir In CurrentMenu.GetDirectories
' Dim SubMenu As New MenuItem(dir.Name, dir.FullName)
' 'Dim LstFiles() As String
' 'LstFiles = Directory.GetFiles("path ")
' 'For i As Int32 = 0 To LstFiles.Length - 1
' ' nuItem(Days.name, )
' 'Next
' CurrentSubMenu.Childitems.add(SubMenu)
' RecursiveSearch(dir, SubMenu)
' Next
' Dim myFile As FileInfo
' For Each myFile In CurrentMenu.GetFiles
' Dim MenuFile As New MenuItem(Mid(myFile.Name, 1, Len(myFile.Name) - 4), myFile.FullName)
' 'MsgBox(Menu1.Items.Count)
' 'MenuFile.NavigateUrl = myFile.FullName
' CurrentSubMenu.Childitems.Add(MenuFile)
' Next
'End Sub
Private Sub RecursiveSearch2(ByRef CurrentMenu, ByRef CurrentSubMenu)
'Dim dir As DirectoryInfo
'For Each dir In CurrentMenu.GetDirectories
' Dim SubMenu As New MenuItem(dir.Name, dir.FullName)
' CurrentSubMenu.Childitems.add(SubMenu)
' RecursiveSearch(dir, SubMenu)
'Next
Dim myFile As FileInfo
For Each myFile In CurrentMenu.GetFiles
Dim MenuFile As New MenuItem(Mid(myFile.Name, 1, Len(myFile.Name) - 4), myFile.FullName)
'MsgBox(Menu1.Items.Count)
MenuFile.NavigateUrl = "viewreport.aspx"
CurrentSubMenu.Childitems.Add(MenuFile)
Next
End Sub
'Private Sub traversetree(ByRef CurrentDir, ByRef CurrentNode)
' Dim dir As DirectoryInfo
' For Each dir In CurrentDir.GetDirectories
' Dim node As New TreeNode(dir.Name, dir.FullName)
' CurrentNode.ChildNodes.Add(node)
' traversetree(dir, node)
' Next
' Dim myFile As FileInfo
' For Each myFile In CurrentDir.GetFiles
' Dim newNode As TreeNode = New TreeNode(myFile.Name, myFile.FullName)
' newNode.NavigateUrl = "viewreport.aspx"
' 'myFile.FullName
' CurrentNode.ChildNodes.Add(newNode)
' Next
'End Sub
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = False Then
BuildTree("Account")
BuildTree("Bill Collector")
BuildTree("Finance")
BuildTree("IT")
BuildTree("Marketing")
BuildTree("Purchase")
BuildTree("Terminal")
End If
End Sub
Private Sub DocumentMenu_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs)
MsgBox(sender.ToString & " " & e.Item.Value)
'Select Case UCase(Right(e.Item.Value, 4))
' Case ".PDF"
' Response.ContentType = "Application/pdf"
' Case ".DOC"
' Case Else
'End Select
'frame1.Attributes.Add("src", e.Item.Value)
'Me.frame1.InnerHtml = e.Item.Value
End Sub
'Protected Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu1.MenuItemClick
' 'If UCase(Right(e.Item.Value)) = ".PDF" Then
' ' MultiView1.ActiveViewIndex = 1
' ' frame1.Attributes.Add("src", e.Item.Value)
' 'Else
' ' "")
' 'End If
' 'frame1.Attributes.Add("src", ViewReport)
'End Sub
'Protected Sub lkButtonBack_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lkButtonBack.Click
' 'MultiView1.ActiveViewIndex = 0
'End Sub
Protected Sub NavigationMenu_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles NavigationMenu.MenuItemClick
End Sub
End Class