Re: Retrive User Control from Cache



If the object is serializable, you should be able to store it in Cache,
Session, Application state, etc.

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"poolieweb@xxxxxxxxxxx" wrote:

Thanks Peter I'll use the session id.

Going to have to think about the menu a little more. as the datasource
is more complicated than just dataset. Ideally I would store an items
collection for the menu but have not found the methods to do this.
Would this not be working due the complexity of the object ?



Peter wrote:
You have a couple of issues that could be improved:

1) use a simpler key for the Cache item - say, the SessionId, which should
not change during the user's session.
2) instead of caching the entire MenuControl, cache only the datasource, and
use that to rebuild your menu.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"poolieweb@xxxxxxxxxxx" wrote:

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




.



Relevant Pages

  • RE: Retrive User Control from Cache
    ... use a simpler key for the Cache item - say, the SessionId, which should ... And as the menu object will not change in a session I am trying ... Dim service As aureports.ReportingService = New ... Dim mitem As New ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Retrive User Control from Cache
    ... use a simpler key for the Cache item - say, the SessionId, which should ... Dim service As aureports.ReportingService = New ... Dim mitem As New ... ElseIf item.Type = aureports.ItemTypeEnum.Report And ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Thread takes up 100% CPU
    ... Each client connection is a thread (session class). ... Dim Thread As Threading.Thread ... Private ClientAs SessionInfo ... Private Sub TestButton_Click(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to clean the Outlook forms cache in outlook 2002?
    ... We simply don't know all the causes of forms cache corruption. ... > Set myItem = myItems.Add ... > Dim objFolder ...
    (microsoft.public.office.developer.outlook.forms)
  • Re: populating Crystal Reports from DataGrid data
    ... Session belongs to Asp.Net, not CR. ... Bind the model to the DataGrid you have on the page already. ... Dim emps As Employees ... Dim Employee As Employee ...
    (microsoft.public.dotnet.framework.aspnet)