Imports System.Web.Script.Serialization
Imports System.Web
Public Class clsTag
    Public Sub GetTagClass()
        Dim mJson As New JavaScriptSerializer
        Dim mSiteID As Integer = CType(BaseFunction.PublicMethod.GetApplication("SiteID"), Integer)
        Dim mClasses = (From c In DB_Tag.clsTagClass.GetLinq(mSiteID) _
                       Select c.ID, c.ClassName).ToList
        HttpContext.Current.Response.Write(mJson.Serialize(mClasses))
    End Sub
    Public Sub GetTagList()
        Dim mClassID As Integer
        If Integer.TryParse(HttpContext.Current.Request("ClassID"), mClassID) Then
            Dim mTags As List(Of DB_Tag.TagData)
            If mClassID > 0 Then
                mTags = DB_Tag.clsTagData.GetClassLinq(mClassID).ToList
            Else
                Dim mSiteID As Integer = CType(BaseFunction.PublicMethod.GetApplication("SiteID"), Integer)
                mTags = DB_Tag.clsTagData.GetLinq(mSiteID).ToList
            End If
            Dim mJson As New JavaScriptSerializer
            Dim mList = (From t In mTags _
                         Select t.ID, t.TagName).ToList
            HttpContext.Current.Response.Write(mJson.Serialize(mList))
        End If
    End Sub
    Public Sub GetJsList()
        Dim mJsList = (From t In DB_Tag.clsTagJscript.GetLinq _
                       Select t.ID, t.JsName).ToList
        Dim mJson As New JavaScriptSerializer
        HttpContext.Current.Response.Write(mJson.Serialize(mJsList))
    End Sub
    Public Sub GetJs()
        Dim mJsID As Integer = 0
        Dim mSQLID As Integer =0
        If Integer.TryParse(HttpContext.Current.Request("JSID"), mJsID) Then
            Integer.TryParse(HttpContext.Current.Request("SQLID"), mSQLID)
            Dim mJS As New DB_Tag.clsTagJscript
            Dim mJsContent As String = ""
            If mSQLID > 0 Then
                mJsContent = (BaseFunction.PublicMethod.Base64DecryptData(mJS.GetSingle(mJsID).JsContent).Replace("@SQLID", mSQLID.ToString))
            Else
                mJsContent = BaseFunction.PublicMethod.Base64DecryptData(mJS.GetSingle(mJsID).JsContent)
            End If
            HttpContext.Current.Response.Write(mJsContent)
        End If
    End Sub
End Class
