Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Collections.Generic
Imports System.Xml
Imports CharterDotCom.WebSite.Library


Public Class CachedControls


    Public Shared Function getExpireDate() As DateTime
        '#############################################################################
        'MODIFICATION   MAR 6, 2009     ROD COPELAND
        '#############################################################################
        'NORMAL OPERATION: DUMP/EXPIRE CACHE AT 3AM TODAY UNLESS IT'S AFTER 3AM, THEN JUST 
        'DUMP/EXPIRE CACHE 3AM TOMORROW MORNING.
        '#############################################################################
        'THE CONTENT CACHE IS ABLE TO BE DUMPED BASED ON AN ADMIN USER MANUALLY 
        'CLICKING THE RESET CACHE BUTTON IN THE ADMIN UI ON THE APP TIER.  THERE IS 
        'ANOTHER NOT SO WE'LL KNOWN FEATURE OF THE SITE THAT DUMPS THE CACHE 
        'AUTOMATICALLY AT 3AM BY SETTING THE CONTENT EXPIRATION DATE WHEN ADDING TO THE 
        'HTTP CACHE COLLECTION. THE EXPIRATION DATE OF THE CONTENT IS INTENDED TO BE A 
        'CONFIGURABLE VALUE TO BE CHANGED AT RUNTIME FOR NEW ENTRIES TO THE CACHE ONLY.  
        'THIS VALUE SHOULD EXIST IN THE ADMIN.WEBCONFIG TABLE WITH A KEY OF 
        '"NUM_OF_DAYS_TO_CACHE" AND "NUM_OF_HOURS_TO_CACHE".  DETAILS OF THE USE OF 
        'THESE VALUES CAN BE FOUND IN THE 
        'commonEntities.Library.dll\virtualManagers\GenericClient.vb\GenerateContentCacheExpirationDate() 
        'method  ANY EXCEPTION IN THE FUNCTION CALL TO GET THE 
        'EXPIRATION DATE WILL SHOULD RESULT IN A RETURNED DATE OF 2 DAYS FROM NOW AT 3AM.
        '#############################################################################
        Dim lManager As New BLContentManager
        Dim expiredate As DateTime = lManager.GenerateContentCacheExpirationDate()
        '#############################################################################

        Return expiredate

    End Function

    'Public Function GetUserControlList() As List(Of String)
    '    Try
    '        Dim currentcontext As HttpContext = System.Web.HttpContext.Current
    '        Dim cacheInformation As String

    '        If currentcontext.Application(ApplicationKey.CacheInformation) Is Nothing Then
    '            Dim wsConfigProvider As New ConfigProvider.Service
    '            Dim ds As New DataSet
    '            wsConfigProvider.Url = ConfigurationManager.AppSettings("ConfigProvider.service")
    '            ds = wsConfigProvider.GetWebConfig(ConfigurationManager.AppSettings("ConfigLocation"))
    '            For Each row As Data.DataRow In ds.Tables(0).Rows
    '                Select Case row.Item("Key").ToString()
    '                    Case ApplicationKey.CacheInformation
    '                        cacheInformation = CStr(row.Item("XMLData"))
    '                        Exit For
    '                    Case Else
    '                        ' do nothing
    '                End Select
    '            Next
    '            ds = Nothing
    '            wsConfigProvider = Nothing
    '        Else
    '            cacheInformation = currentcontext.Application(ApplicationKey.CacheInformation)
    '            currentcontext.Application.Remove(ApplicationKey.CacheInformation)
    '        End If
    '        If cacheInformation Is Nothing Then
    '            Return Nothing
    '        Else
    '            Return ParseUserControlList(cacheInformation)
    '        End If
    '    Catch ex As Exception
    '        Throw ex
    '    End Try
    'End Function

    'Private Function ParseUserControlList(ByVal data As String) As List(Of String)
    '    Try
    '        Dim xmldoc As New XmlDataDocument
    '        Dim usercontrols As New List(Of String)
    '        xmldoc.LoadXml(data)
    '        For Each node As XmlNode In xmldoc.ChildNodes(0).ChildNodes
    '            If node.Attributes("value").Value = "true" Then
    '                usercontrols.Add(node.Attributes("ID").Value)
    '            End If
    '        Next
    '        Return usercontrols
    '    Catch ex As Exception
    '        Throw ex
    '    End Try

    'End Function
End Class
