Exploring the depths and potentials of ASP.NET RSS 2.0 or Subscribe to .BenRush by Email
 Tuesday, February 14, 2006

I give no guarantees, I give nothing - so don't bug me, I slapped it together last night on my third or fourth Guinness...

Imports System.Web
Imports System.Configuration

' TODO: Add thread safety.
' TODO: Optimize open/closure of data connections per routine call.
Public Class Provider
    Inherits System.Web.SiteMapProvider

    Public Overrides Function FindSiteMapNode(ByVal rawUrl As String) As SiteMapNode
        Try
            ' TODO: clean up this code by taking out the redundant snippets.
            Me.OpenConnection()
            Dim command As Oracle.DataAccess.Client.OracleCommand = Me.m_Connection.CreateCommand()
            command.CommandText = "select * from BEN.SITEMAPNODES WHERE URL = '" + rawUrl + "'"
            Dim adapter As New Oracle.DataAccess.Client.OracleDataAdapter(command)
            Dim node As New SiteMapNodeDS()
            adapter.Fill(node.SITEMAPNODES)
            If node.SITEMAPNODES.Count = 1 Then
                ' we have a single result, which is what we want.
                Dim sn As New SiteMapNode(Me, node.SITEMAPNODES(0).ID.ToString(), node.SITEMAPNODES(0).URL, node.SITEMAPNODES(0).TITLE, node.SITEMAPNODES(0).DESCRIPTION)
                Return sn
            Else
                If node.SITEMAPNODES.Count > 1 Then
                    Throw New System.ApplicationException("Too many rows returned; this violates the restraint.")
                End If ' otherwise error.
            End If
            Return Nothing
        Finally
            Me.CloseConnection()
        End Try
    End Function 'FindSiteMapNode

    Public Overrides Function GetChildNodes(ByVal node As SiteMapNode) As SiteMapNodeCollection
        Try
            Me.OpenConnection()
            Dim command As Oracle.DataAccess.Client.OracleCommand = Me.m_Connection.CreateCommand()
            command.CommandText = "select * from BEN.SITEMAPNODES where ROOTNODE = " + node.Key
            Dim adapter As New Oracle.DataAccess.Client.OracleDataAdapter(command)
            Dim nodeDS As New SiteMapNodeDS()
            adapter.Fill(nodeDS.SITEMAPNODES)
            If nodeDS.SITEMAPNODES.Count > 0 Then
                Dim coll As New SiteMapNodeCollection()
                Dim row As SiteMapNodeDS.SITEMAPNODESRow
                For Each row In nodeDS.SITEMAPNODES.Rows
                    coll.Add(New SiteMapNode(Me, row.ID.ToString(), row.URL, row.TITLE, row.DESCRIPTION))
                Next row
                Return coll
            Else
                Return Nothing
            End If
        Finally
            Me.CloseConnection()
        End Try
    End Function 'GetChildNodes

    Public Overrides Function GetParentNode(ByVal node As SiteMapNode) As SiteMapNode
        ' TODO: implement security trimming.
        Try
            Me.OpenConnection()
            Dim command As Oracle.DataAccess.Client.OracleCommand = Me.m_Connection.CreateCommand()
            command.CommandText = "SELECT * FROM BEN.SITEMAPNODES WHERE ID = (SELECT ROOTNODE from BEN.SITEMAPNODES where ID = " + node.Key + ")"
            Dim adapter As New Oracle.DataAccess.Client.OracleDataAdapter(command)
            Dim ds As New SiteMapNodeDS()
            adapter.Fill(ds.SITEMAPNODES)
            If ds.SITEMAPNODES.Count = 1 Then
                Return New SiteMapNode(Me, ds.SITEMAPNODES(0).ID.ToString(), ds.SITEMAPNODES(0).URL, ds.SITEMAPNODES(0).TITLE, ds.SITEMAPNODES(0).DESCRIPTION)
            Else
                If ds.SITEMAPNODES.Count > 1 Then
                    Throw New System.ApplicationException("Too many parent nodes found, this violates the constraint rules.")
                Else
                    Return Nothing
                End If
            End If
        Finally
            Me.CloseConnection()
        End Try
    End Function 'GetParentNode

    Protected Overrides Function GetRootNodeCore() As SiteMapNode
        Try
            Me.OpenConnection()
            Dim command As Oracle.DataAccess.Client.OracleCommand = Me.m_Connection.CreateCommand()
            command.CommandText = "SELECT * FROM BEN.SITEMAPNODES WHERE ROOTNODE = -1"
            Dim adapter As New Oracle.DataAccess.Client.OracleDataAdapter(command)
            Dim node As New SiteMapNodeDS()
            adapter.Fill(node.SITEMAPNODES)
            If node.SITEMAPNODES.Count = 1 Then
                Return New SiteMapNode(Me, node.SITEMAPNODES(0).ID.ToString(), node.SITEMAPNODES(0).URL, node.SITEMAPNODES(0).TITLE, node.SITEMAPNODES(0).DESCRIPTION)
            Else
                If node.SITEMAPNODES.Count > 1 Then
                    Throw New System.ApplicationException("More than one root node discovered, this violates the parent restraint.")
                Else
                    Return Nothing
                End If
            End If
        Finally
            Me.CloseConnection()
        End Try
    End Function 'GetRootNodeCore

    Private Function OpenConnection() As Oracle.DataAccess.Client.OracleConnection
        If Me.m_Connection Is Nothing Or Me.m_Connection.State <> System.Data.ConnectionState.Open Then
            Me.m_Connection = New Oracle.DataAccess.Client.OracleConnection()
            Try
                Me.m_Connection.ConnectionString = "Data Source=DEV1_BEN;User Id=ben;Password=xxx;"
                Me.m_Connection.Open()
            Catch
            End Try
        End If
        Return Me.m_Connection
    End Function 'OpenConnection

    Private Sub CloseConnection()
        If Not (Me.m_Connection Is Nothing) Then
            Me.m_Connection.Close()
            Me.m_Connection.Dispose()
            Me.m_Connection = Nothing
        End If
        Return
    End Sub 'CloseConnection
    Private m_Connection As Oracle.DataAccess.Client.OracleConnection
End Class 'Provider

 


kick it on DotNetKicks.com
Tuesday, February 14, 2006 11:31:38 AM (Central Standard Time, UTC-06:00)  #    Comments [1] - Trackback
Computing

http://authors.aspalliance.com/aldotnet/examples/translate.aspx


kick it on DotNetKicks.com
Tuesday, February 14, 2006 11:16:01 AM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Computing
 Monday, February 13, 2006

I've seen some interesting solutions for browser-based progress bars in the past, but this one is the first one that seems right.


kick it on DotNetKicks.com
Monday, February 13, 2006 11:14:59 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Computing

I found this via the link I posted on my last entry, but you MUST check this out if you do regex development of any kind.


kick it on DotNetKicks.com
Monday, February 13, 2006 11:09:48 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Computing

A link I found courtesy of Steve for VS hackers.


kick it on DotNetKicks.com
Monday, February 13, 2006 11:05:09 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Computing

I was recently contracted to discover how some hackers had reversed engineered a particular product, and re-remembered the very cool, snazzy and hip WinDBG command: 's'. Basically this little command equates to, in laymen's terms, "Search memory for ANYTHING" :

s (Search Memory)

The s command searches though memory to find a specific byte pattern.

This command should not be confused with the ~s (Change Current Processor), ~s (Set Current Thread), |s (Set Current Process), or ||s (Set Current System) commands.

Syntax

s [-[[Flags]]TypeRange Pattern 
s -[[Flags]]v Range Object 
s -[[Flags]]sa Range 
s -[[Flags]]su Range 


kick it on DotNetKicks.com
Monday, February 13, 2006 11:01:04 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Computing

....so I could read stuff like this and also get the work done that I needed...


kick it on DotNetKicks.com
Monday, February 13, 2006 10:57:12 PM (Central Standard Time, UTC-06:00)  #    Comments [1] - Trackback
Computing

If you have to do .Net and Oracle, I would bookmark this site.


kick it on DotNetKicks.com
Monday, February 13, 2006 3:46:42 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback

Computers Blogs - Blog Top Sites

Archive
<February 2006>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
2627281234
567891011
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009
Benjamin Rush
Sign In
Statistics
Total Posts: 444
This Year: 0
This Month: 0
This Week: 0
Comments: 128
Themes
Pick a theme:
All Content © 2009, Benjamin Rush
DasBlog theme 'Business' created by Christoph De Baene (delarou)