Click here to Skip to main content
15,746,883 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: The header and footer contents in master page are refreshing - Need help Pin
jkirkerx1-Dec-11 11:29
professionaljkirkerx1-Dec-11 11:29 
GeneralRe: The header and footer contents in master page are refreshing - Need help Pin
Member 32222641-Dec-11 23:38
Member 32222641-Dec-11 23:38 
GeneralRe: The header and footer contents in master page are refreshing - Need help Pin
jkirkerx2-Dec-11 6:23
professionaljkirkerx2-Dec-11 6:23 
GeneralRe: The header and footer contents in master page are refreshing - Need help Pin
Member 32222645-Dec-11 19:06
Member 32222645-Dec-11 19:06 
QuestionWCF message edit error Pin
arnold0930-Nov-11 19:19
arnold0930-Nov-11 19:19 
AnswerRe: WCF message edit error Pin
jkirkerx1-Dec-11 11:49
professionaljkirkerx1-Dec-11 11:49 
GeneralRe: WCF message edit error Pin
arnold092-Dec-11 0:45
arnold092-Dec-11 0:45 
GeneralRe: WCF message edit error Pin
jkirkerx2-Dec-11 6:36
professionaljkirkerx2-Dec-11 6:36 
This is a xsd template. I write them in Liquid Studio, but now I can write them from scratch. This one is very simple. I don't export the xml as a memory stream, but I do hold the entire xml in server memory, and when done, I write it back to the disk drive. The xsd, xml, program code all matches together. This is the fastest xml in asp.net. It is capable of doing 10 transactions per second, and I have 1 complex file with over 20,000 records in it, that can update really fast. This is how you write xml for DHL Express, UPS, Chase Payment Tech, PayPal, and any other web service that requires XML. It may be very difficult to comprehend at first, but I did all the heavy lifting for you.

You can save this as Sale_Messenger.xsd
XML
<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio - FREE Community Edition 7.1.6.1440 (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Sale_Messenger">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="unbounded" name="Registered_Members">
          <xs:complexType>
            <xs:all>
              <xs:element name="Name" type="xs:string" />
              <xs:element name="EmailAddress" type="xs:string" />
            </xs:all>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="Version" type="xs:string" />
      <xs:attribute name="CreationDate" type="xs:string" />
    </xs:complexType>
  </xs:element>
</xs:schema>


Now I run the xsd using LS, to confirm it makes a valid xml file.
Sale_Messenger.xml

XML
<?xml version="1.0" encoding="utf-8" ?>
- <!--  Created with Liquid XML Studio - FREE Community Edition 7.1.6.1440 (http://www.liquid-technologies.com)
  -->
- <Notification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Sep-WSDLS\TransactionNotifications\TransactionNotifications.xsd" Version="string" CreationDate="string">
- <Registered_Members>
  <Name>string</Name>
  <EmailAddress>string</EmailAddress>
  </Registered_Members>
- <Registered_Members>
  <Name>string</Name>
  <EmailAddress>string</EmailAddress>
  </Registered_Members>
- <Registered_Members>
  <Name>string</Name>
  <EmailAddress>string</EmailAddress>
  </Registered_Members>
- <Registered_Members>
  <Name>string</Name>
  <EmailAddress>string</EmailAddress>
  </Registered_Members>
  </Notification>


So I have 2 files, Sales_Messenger.xsd, and Sales_Messenger.xml

I use xsd.exe on the xsd file - xsd.exe /vb /classes Sales_Messenger.xsd to produce a Sales_Messenger.vb class. Now I import the class into my project. You can find xsd.exe in VS 2005, 09, 10. Make the file and copy it into your project, include it.

Then I wrote a new class, to create a new file, update, and delete.


 Private Sub Add_NewMember()

        Dim FirstRecordFlag As Boolean = False

        Dim Success As Boolean = True
        Dim ContactName As String = False
        Dim SecureContactName As String = Nothing
        Dim Master_ContactName As String = Nothing
        Dim ContactEmailAddress As String = Nothing
        Dim SecureEmailAddress As String = Nothing

        ContactName = txt_Setup_SalesMessenger_SendName_Field.Text.Trim
        ContactEmailAddress = txt_Setup_SalesMessenger_SendEmail_Field.Text.Trim
        SecureContactName = ice5commerce.common.EncryptDecrypt.Encrypt(ContactName)
        SecureEmailAddress = ice5commerce.common.EncryptDecrypt.Encrypt(ContactEmailAddress)

        Dim DataLocation As String = Nothing
        DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")

        'XML Data routines go here
        Dim request_serializer As New XmlSerializer(GetType(Sale_Messenger))
        AddHandler request_serializer.UnknownNode, AddressOf serializer_UnknownNode
        AddHandler request_serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute

        Dim Reader As XmlTextReader = Nothing
        Dim XmlRequest As New Sale_Messenger

        Try
            Reader = New XmlTextReader(DataLocation)
            XmlRequest = CType(request_serializer.Deserialize(Reader), Sale_Messenger)
            Reader.Close()
            Reader = Nothing

        Catch ex As Exception
            FirstRecordFlag = True
        End Try

        Try
            If FirstRecordFlag = True Then
                Dim MyMembers_0 As Sale_MessengerRegistered_Members = New Sale_MessengerRegistered_Members
                MyMembers_0.Name = SecureContactName
                MyMembers_0.EmailAddress = SecureEmailAddress

                Dim MyMembers() As Sale_MessengerRegistered_Members = {MyMembers_0}

                'Now Lets Write out the file as a MemoryStream
                Dim serializer As XmlSerializer
                serializer = New XmlSerializer(GetType(Sale_Messenger))

                Dim XmlResponse As New Sale_Messenger
                XmlResponse.Version = "1.4.2"
                XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
                XmlResponse.Registered_Members = MyMembers

                'Now we have to write out a file for certification
                Dim response_serializer As XmlSerializer = Nothing
                response_serializer = New XmlSerializer(GetType(Sale_Messenger))

                Dim response_writer As StreamWriter = Nothing
                response_writer = New StreamWriter(DataLocation)
                response_serializer.Serialize(response_writer, XmlResponse)

                response_writer.Close()
                response_writer = Nothing

                request_serializer = Nothing
                serializer = Nothing

            Else
                Dim MyMembers() As Sale_MessengerRegistered_Members
                Dim MyMembers_Length As Integer = 0
                MyMembers = XmlRequest.Registered_Members
                MyMembers_Length = MyMembers.Length
                Array.Resize(MyMembers, MyMembers_Length + 1)

                MyMembers(MyMembers_Length) = New Sale_MessengerRegistered_Members
                MyMembers(MyMembers_Length).Name = SecureContactName
                MyMembers(MyMembers_Length).EmailAddress = SecureEmailAddress

                'Now Lets Write out the file as a MemoryStream
                Dim serializer As XmlSerializer
                serializer = New XmlSerializer(GetType(Sale_Messenger))

                Dim XmlResponse As New Sale_Messenger
                XmlResponse.Version = "1.4.2"
                XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
                XmlResponse.Registered_Members = MyMembers

                'Now we have to write out a file for certification
                Dim response_serializer As XmlSerializer = Nothing
                response_serializer = New XmlSerializer(GetType(Sale_Messenger))

                Dim response_writer As StreamWriter = Nothing
                response_writer = New StreamWriter(DataLocation)
                response_serializer.Serialize(response_writer, XmlResponse)

                response_writer.Close()
                response_writer = Nothing

                request_serializer = Nothing
                serializer = Nothing
            End If

        Catch ex As Exception
            Success = False
            Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "ADD", ContactName, False)

        End Try

        If Success = True Then
            txt_Setup_SalesMessenger_SendEmail_Field.Text = ""
            txt_Setup_SalesMessenger_SendName_Field.Text = ""
            txt_Setup_SalesMessenger_SendEmailConfirm_Field.Text = ""
            Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "ADD", ContactName, True)
        End If

    End Sub
    Private Sub Delete_Member()

        Dim Name As String = Nothing
        Dim SecureName As String = Nothing
        Dim DeleteName As String = Nothing
        Dim SecureDeleteName As String = Nothing

        If lb_SalesMessenger_ContactList_Field.SelectedIndex > -1 Then
            Dim idx As Integer = 0
            SecureDeleteName = lb_SalesMessenger_ContactList_Field.SelectedValue
            DeleteName = ice5commerce.common.EncryptDecrypt.Decrypt(SecureDeleteName)

            Dim DataLocation As String = Nothing
            DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")

            'XML Data routines go here
            Dim request_serializer As New XmlSerializer(GetType(Sale_Messenger))
            AddHandler request_serializer.UnknownNode, AddressOf serializer_UnknownNode
            AddHandler request_serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute

            Dim Reader As XmlTextReader = New XmlTextReader(DataLocation)
            Dim XmlRequest As New Sale_Messenger
            XmlRequest = CType(request_serializer.Deserialize(Reader), Sale_Messenger)
            Reader.Close()
            Reader = Nothing

            Dim MyMembers() As Sale_MessengerRegistered_Members
            Dim MyMembers_Length As Integer = 0
            MyMembers = XmlRequest.Registered_Members
            MyMembers_Length = MyMembers.Length

            Dim TestName As String = Nothing
            Dim SecureTestName As String = Nothing
            Dim SecureEmailAddress As String = Nothing
            Dim ResizeArray_Flag As Boolean = False

            Dim New_MyMembers() As Sale_MessengerRegistered_Members = MyMembers
            Array.Resize(New_MyMembers, MyMembers.Length - 1)
            Dim New_MyMembers_Length As Integer = New_MyMembers.Length
            Dim jdx As Integer = 0

            For idx = 0 To MyMembers_Length - 1
                SecureTestName = MyMembers(idx).Name
                SecureEmailAddress = MyMembers(idx).EmailAddress
                TestName = ice5commerce.common.EncryptDecrypt.Decrypt(SecureTestName)
                If Not String.Compare(TestName, DeleteName, True) = 0 Then
                    New_MyMembers(jdx).Name = SecureTestName
                    New_MyMembers(jdx).EmailAddress = SecureEmailAddress
                    jdx += 1
                End If
                idx += 1
            Next

            'Now Lets Write out the file as a MemoryStream
            Dim serializer As XmlSerializer
            serializer = New XmlSerializer(GetType(Sale_Messenger))

            Dim XmlResponse As New Sale_Messenger
            XmlResponse.Version = "1.4.2"
            XmlResponse.CreationDate = DateTime.Now.ToString("yyyy-MM-dd")
            XmlResponse.Registered_Members = New_MyMembers

            'Now we have to write out a file for certification
            Dim response_serializer As XmlSerializer = Nothing
            response_serializer = New XmlSerializer(GetType(Sale_Messenger))

            Dim response_writer As StreamWriter = Nothing
            response_writer = New StreamWriter(DataLocation)
            response_serializer.Serialize(response_writer, XmlResponse)

            response_writer.Close()
            response_writer = Nothing

            request_serializer = Nothing
            serializer = Nothing

            Load_ListBox()
            Admin_Standard.Admin_PCI_Transction.Insert_PCI_Transaction("Display_SU_Sale_Messenger.vb", "MESSENGER", "DELETE", DeleteName, True)
        End If

    End Sub
    Private Function Does_SalesMessenger_XMLExist() As Boolean

        Dim Context As HttpContext = HttpContext.Current

        Try
            Dim FileExist As Boolean = False
            Dim DataLocation As String = Nothing
            DataLocation = Context.Server.MapPath("~/App_Data/CompanyInfo/Messenger.xml")
            Dim f As New IO.FileInfo(DataLocation)
            If f.Exists = True Then
                FileExist = True
            Else
                FileExist = False
            End If

            f = Nothing
            Return FileExist

        Catch ex As Exception
            Record_Admin_Setup_Errors(ex.Message.ToString, ex.StackTrace.ToString)
        End Try

        Context = Nothing

    End Function
Protected Sub serializer_UnknownNode(ByVal sender As Object, ByVal e As XmlNodeEventArgs)

        Dim Context As HttpContext = HttpContext.Current
        'Context.Response.Write("Unknown Node:" & e.Name & ControlChars.Tab & e.Text)

    End Sub
    Protected Sub serializer_UnknownAttribute(ByVal sender As Object, ByVal e As XmlAttributeEventArgs)

        Dim Context As HttpContext = HttpContext.Current
        Dim attr As System.Xml.XmlAttribute = e.Attr
        'Context.Response.Write("Unknown attribute " & attr.Name & "='" & attr.Value & "'")

    End Sub

GeneralRe: WCF message edit error Pin
arnold095-Dec-11 18:55
arnold095-Dec-11 18:55 
GeneralRe: WCF message edit error Pin
jkirkerx6-Dec-11 6:45
professionaljkirkerx6-Dec-11 6:45 
Questionloginstatus control-sessions Pin
MalarGayu30-Nov-11 14:57
MalarGayu30-Nov-11 14:57 
AnswerRe: loginstatus control-sessions Pin
Member 322226430-Nov-11 19:48
Member 322226430-Nov-11 19:48 
AnswerRe: loginstatus control-sessions Pin
uspatel30-Nov-11 23:23
professionaluspatel30-Nov-11 23:23 
AnswerRe: loginstatus control-sessions Pin
coded0071-Dec-11 2:21
professionalcoded0071-Dec-11 2:21 
GeneralRe: loginstatus control-sessions Pin
MalarGayu1-Dec-11 13:09
MalarGayu1-Dec-11 13:09 
AnswerRe: loginstatus control-sessions Pin
thatraja1-Dec-11 21:04
professionalthatraja1-Dec-11 21:04 
QuestionFIXED HEADER AND FOOTER IN MASTER PAGE-WITHOUT REFRESH ON MENU CLICK Pin
Member 322226430-Nov-11 1:39
Member 322226430-Nov-11 1:39 
AnswerRe: FIXED HEADER AND FOOTER IN MASTER PAGE-WITHOUT REFRESH ON MENU CLICK Pin
jkirkerx30-Nov-11 12:03
professionaljkirkerx30-Nov-11 12:03 
QuestionHow to Access VB class from c# class which both Classes in App_code folder Pin
Member 282342130-Nov-11 0:35
Member 282342130-Nov-11 0:35 
AnswerRe: How to Access VB class from c# class which both Classes in App_code folder Pin
AmitGajjar30-Nov-11 1:28
professionalAmitGajjar30-Nov-11 1:28 
GeneralRe: How to Access VB class from c# class which both Classes in App_code folder Pin
Member 282342130-Nov-11 1:31
Member 282342130-Nov-11 1:31 
GeneralRe: How to Access VB class from c# class which both Classes in App_code folder Pin
AmitGajjar30-Nov-11 1:54
professionalAmitGajjar30-Nov-11 1:54 
GeneralRe: How to Access VB class from c# class which both Classes in App_code folder Pin
Member 282342130-Nov-11 1:57
Member 282342130-Nov-11 1:57 
GeneralRe: How to Access VB class from c# class which both Classes in App_code folder Pin
AmitGajjar30-Nov-11 4:59
professionalAmitGajjar30-Nov-11 4:59 
AnswerRe: How to Access VB class from c# class which both Classes in App_code folder Pin
David Asp30-Nov-11 10:31
David Asp30-Nov-11 10:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.