General data governance and services for HTML-only applications

Source: Internet
Author: User
Common data governance and services for pure HTML applications. However, to collect data, you need a data repository. To avoid many titles from the application database server, you can collect the data in XML. Below is the basic structure of our project goals

Common data governance and services for pure HTML applications. However, to collect data, you need a data repository. To avoid many titles from the application database server, you can collect the data in XML. Below is the basic structure of our project goals:





I initially restricted the data to first name, last name, and middle. The basic idea behind this page is that user information is obtained on this page. After the user information requirements are met, the process must be transferred to the next logical collection step. To make things simple, I will package user functions into an ASP class.

Function Coalesce (vVar, vAlt)
If vVal = "" Or VarType (vVal) = 1 Or VarType (vVal) = 0 Then
Coalesce = vAlt
Else
Coalesce = vVal
End If
End Function

Class CUser
Private m_ SQL, m_DOM

Public Property Get DOM ()
Set DOM = m_DOM
End Property

Public Sub saveUser ()
M_ SQL .save "save_user", m_DOM
End Sub

Public Function validate ()
M_DOM.loadXML" "& M_ SQL .validateUser (m_DOM )&" "
If Not m_DOM.selectSingleNode ("// error") Is Nothing Then
Validate = False
Else
Validate = True
End If
End Function

Private Sub collectData (dom, oCollection)
Dim nItem, node, parent_node, n, sKey
For nItem = 1 To oCollection. Count
SKey = oCollection. Key (nItem)
Set parent_node = dom. selectSingleNode ("//" & sKey & "s ")
If Not parent_node Is Nothing Then
For n = 1 To oCollection (sKey). Count
Set node = parent_node.selectSingleNode (sKey &_
"[String (.) = '"&
OCollection (sKey) (n) & "']")
If node Is Nothing Then
Set node = dom. createNode (1, sKey ,"")
Set node = parent_node.appendChild (node)
End If
Node. text = Coalesce (oCollection (sKey) (n ),"")
Next
Else
Set node = dom. selectSingleNode ("//" & sKey)
If Not node Is Nothing Then _
Node. text = Coalesce (oCollection (sKey ),"")
End If
Next
End Sub

Private Sub Class_Initialize ()
Set m_ SQL = New CSQL
Set m_DOM = Server. CreateObject ("MSXML2.DOMDocument ")
M_DOM.async = False
If VarType (Request ("txtUserXML") = 0 Or Request ("txtUserXML") = "" Then
M_DOM.loadXML Request ("txtUserXML ")
Else
M_DOM.load" "& Server. MapPath (" user. xml ")&" "
End If
CollectData m_DOM, Request. Form
CollectData m_DOM, Request. QueryString
End Sub

Private Sub Class_Terminate ()
Set m_ SQL = Nothing
Set m_DOM = Nothing
End Sub

End Class

Class CSQL
Private m_DAL, m_Stream

Public Function save (sStoredProc, oDOM)
'Advarchar = 200
M_DAL.RunSP Array (m_DAL.mp ("@ xml_param", 200,800 0, oDOM. xml ))
End Function

Public Function validateUser (oDOM)
Set m_Stream = m_DAL.RunSPReturnStream ("validate_user", Array (_
M_DAL.mp ("@ xml_param", 200,800 0, oDOM. xml )))
ValidateUser = m_Stream.ReadText (-1)
M_Stream.Close
End Function

Private Sub Class_Initialize ()
Set m_DAL = Server. CreateObject ("MyPkg. MyDAL ")
M_DAL.GetConnection "some connection string"
Set m_Stream = Server. CreateObject ("ADODB. Stream ")
End Sub

Private Sub Class_Terminate ()
Set m_DAL = Nothing
Set m_Stream = Nothing
End Sub

End Class
The CSQL class is built based on MyPkg. MyDAL, a data access layer (m_DAL) component. This component is built based on the Fitch and Mather DAL components, which can be found in MSDN. In this way, we can build a bridge between SQL Server and your code.


After the CUser object is initialized, it collects Request data and uses the collectData () Subfunction to store the collected data to a corresponding node in UserDOM. (I will not explain the code because it is quite easy to understand .) After the data is collected (or not collected), we apply XSL to transform the data content into a layout.


Version = "1.0">



* Information in red is required





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.