P
poolieweb
I have created a custom user control which creates a ASPxMenu ( Same
fucntion as standard menu control) from data retreved from a webservice
(Reporting Services) which deals with user access. This process is
slow. And as the menu object will not change in a session I am trying
to cache the menu with the session user as the key. The problem is that
I can not retreve the menu object after the first request. The menu
items are resident in the cahce but can not display the menu. Can any
one help? problibly be a simple ansewer , syntax maybe.
sudo code:
if cache is emtpy then
populate menu
else
menu = cache
Full Code: custom control ascx file
Imports DevExpress.Web.ASPxMenu
Imports System.Web.UI
Partial Class WebUserControl
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If
Cache(System.Net.CredentialCache.DefaultNetworkCredentials.ToString) Is
Nothing Then
'Dim ASPxMenu1 As ASPxMenu = MENU
Dim service As aureports.ReportingService = New
aureports.ReportingService
service.Url =
"http://localhost/reportserver/reportservice.asmx"
'Me.service.Credentials =
System.Net.CredentialCache.DefaultNetworkCredentials
service.Credentials = New
System.Net.NetworkCredential("test", "test")
ASPxMenu1.Items.Clear()
ASPxMenu1.Items.Add("Reports")
ASPxMenu1.Items.Add("Services")
ASPxMenu1.Items.Add("Links")
ASPxMenu1.Items.Add("Help")
Dim items() As aureports.CatalogItem =
service.ListChildren("/", False)
'Ask how to sort the catalogitem list
For Each item As aureports.CatalogItem In items
If item.Type = aureports.ItemTypeEnum.Folder And Not
(item.Name Like "*_aspx") Then
Dim mitem As New
DevExpress.Web.ASPxMenu.MenuItem(item.Name, item.Path)
ASPxMenu1.Items.Item(ASPxMenu1.Items.IndexOfText("Reports")).Items.Add(mitem)
folder(item, mitem, service)
ElseIf item.Type = aureports.ItemTypeEnum.Report And
Not (item.Name Like "*_aspx") And item.Hidden = False Then
Dim mitem As New
DevExpress.Web.ASPxMenu.MenuItem(item.Name)
ASPxMenu1.Items.Item(ASPxMenu1.Items.IndexOfText("Reports")).Items.Add(mitem)
ElseIf item.Type = aureports.ItemTypeEnum.Folder And
item.Name Like "*_aspx" Then
Dim words() As String = Split(item.Name, "_aspx")
Dim mitem As New
DevExpress.Web.ASPxMenu.MenuItem(words(0))
ASPxMenu1.Items.Item(ASPxMenu1.Items.IndexOfText("Services")).Items.Add(mitem)
folder(item, mitem, service)
End If
Next
Cache.Insert(System.Net.CredentialCache.DefaultNetworkCredentials.ToString,
ASPxMenu1)
Else
ASPxMenu1 =
(CType(Cache.Get(System.Net.CredentialCache.DefaultNetworkCredentials.ToString),
ASPxMenu))
End If
End Sub
Public Shared Sub folder(ByVal item As aureports.CatalogItem, ByVal
menu As DevExpress.Web.ASPxMenu.MenuItem, ByVal service As
aureports.ReportingService)
Dim items() As aureports.CatalogItem =
service.ListChildren(item.Path, False)
For Each item2 As aureports.CatalogItem In items
Dim words() As String
words = Split(item2.Name, "_aspx")
Dim itmMenuItem2 As New
DevExpress.Web.ASPxMenu.MenuItem(words(0), "", "", item2.Description)
If item2.Type = aureports.ItemTypeEnum.Folder Then
menu.Items.Add(itmMenuItem2)
folder(item2, itmMenuItem2, service)
ElseIf item2.Type = aureports.ItemTypeEnum.Report And
item2.Hidden = False Then
menu.Items.Add(itmMenuItem2)
ElseIf words.Length > 1 Then
menu.Items.Add(itmMenuItem2)
End If
Next
End Sub
End Class
fucntion as standard menu control) from data retreved from a webservice
(Reporting Services) which deals with user access. This process is
slow. And as the menu object will not change in a session I am trying
to cache the menu with the session user as the key. The problem is that
I can not retreve the menu object after the first request. The menu
items are resident in the cahce but can not display the menu. Can any
one help? problibly be a simple ansewer , syntax maybe.
sudo code:
if cache is emtpy then
populate menu
else
menu = cache
Full Code: custom control ascx file
Imports DevExpress.Web.ASPxMenu
Imports System.Web.UI
Partial Class WebUserControl
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If
Cache(System.Net.CredentialCache.DefaultNetworkCredentials.ToString) Is
Nothing Then
'Dim ASPxMenu1 As ASPxMenu = MENU
Dim service As aureports.ReportingService = New
aureports.ReportingService
service.Url =
"http://localhost/reportserver/reportservice.asmx"
'Me.service.Credentials =
System.Net.CredentialCache.DefaultNetworkCredentials
service.Credentials = New
System.Net.NetworkCredential("test", "test")
ASPxMenu1.Items.Clear()
ASPxMenu1.Items.Add("Reports")
ASPxMenu1.Items.Add("Services")
ASPxMenu1.Items.Add("Links")
ASPxMenu1.Items.Add("Help")
Dim items() As aureports.CatalogItem =
service.ListChildren("/", False)
'Ask how to sort the catalogitem list
For Each item As aureports.CatalogItem In items
If item.Type = aureports.ItemTypeEnum.Folder And Not
(item.Name Like "*_aspx") Then
Dim mitem As New
DevExpress.Web.ASPxMenu.MenuItem(item.Name, item.Path)
ASPxMenu1.Items.Item(ASPxMenu1.Items.IndexOfText("Reports")).Items.Add(mitem)
folder(item, mitem, service)
ElseIf item.Type = aureports.ItemTypeEnum.Report And
Not (item.Name Like "*_aspx") And item.Hidden = False Then
Dim mitem As New
DevExpress.Web.ASPxMenu.MenuItem(item.Name)
ASPxMenu1.Items.Item(ASPxMenu1.Items.IndexOfText("Reports")).Items.Add(mitem)
ElseIf item.Type = aureports.ItemTypeEnum.Folder And
item.Name Like "*_aspx" Then
Dim words() As String = Split(item.Name, "_aspx")
Dim mitem As New
DevExpress.Web.ASPxMenu.MenuItem(words(0))
ASPxMenu1.Items.Item(ASPxMenu1.Items.IndexOfText("Services")).Items.Add(mitem)
folder(item, mitem, service)
End If
Next
Cache.Insert(System.Net.CredentialCache.DefaultNetworkCredentials.ToString,
ASPxMenu1)
Else
ASPxMenu1 =
(CType(Cache.Get(System.Net.CredentialCache.DefaultNetworkCredentials.ToString),
ASPxMenu))
End If
End Sub
Public Shared Sub folder(ByVal item As aureports.CatalogItem, ByVal
menu As DevExpress.Web.ASPxMenu.MenuItem, ByVal service As
aureports.ReportingService)
Dim items() As aureports.CatalogItem =
service.ListChildren(item.Path, False)
For Each item2 As aureports.CatalogItem In items
Dim words() As String
words = Split(item2.Name, "_aspx")
Dim itmMenuItem2 As New
DevExpress.Web.ASPxMenu.MenuItem(words(0), "", "", item2.Description)
If item2.Type = aureports.ItemTypeEnum.Folder Then
menu.Items.Add(itmMenuItem2)
folder(item2, itmMenuItem2, service)
ElseIf item2.Type = aureports.ItemTypeEnum.Report And
item2.Hidden = False Then
menu.Items.Add(itmMenuItem2)
ElseIf words.Length > 1 Then
menu.Items.Add(itmMenuItem2)
End If
Next
End Sub
End Class