[FogBugz #109] Optimisation creation XML #171

Open
opened 2023-07-03 23:35:27 +02:00 by fbenoist68 · 9 comments

Assigned To: CLOSED
Project: CAISSE
Area: awcaisse
Category: Bogue
Priority: A faire le plus tôt possible

Assigned To: CLOSED Project: CAISSE Area: awcaisse Category: Bogue Priority: A faire le plus tôt possible
Poster
Owner

Event ID: 496
Date: 2013-03-14T17:37:33Z
Person: Frederik Benoist
Description: Fermé par Frederik Benoist

Event ID: 496 Date: 2013-03-14T17:37:33Z Person: Frederik Benoist Description: Fermé par Frederik Benoist
Poster
Owner

Event ID: 495
Date: 2013-03-14T17:37:33Z
Person: Frederik Benoist
Description: Resolved (Fixed) and assigned to Frederik Benoist by Frederik Benoist

Event ID: 495 Date: 2013-03-14T17:37:33Z Person: Frederik Benoist Description: Resolved (Fixed) and assigned to Frederik Benoist by Frederik Benoist
Poster
Owner

Event ID: 494
Date: 2013-03-14T17:36:42Z
Person: Frederik Benoist
Description: Réouvert (attribué à Frederik Benoist) par Frederik Benoist

Mauvaise Optimisation car si des .XML sont contenus dans des Lob cela ne met pas le bon codage.



Après plusieurs tentative d'optimisation infructueuse j'ai remis le code de départ.



Dommage ....

Event ID: 494 Date: 2013-03-14T17:36:42Z Person: Frederik Benoist Description: Réouvert (attribué à Frederik Benoist) par Frederik Benoist Mauvaise Optimisation car si des .XML sont contenus dans des Lob cela ne met pas le bon codage.<br /> <br /> Apr&#232;s plusieurs tentative d&#39;optimisation infructueuse j&#39;ai remis le code de d&#233;part.<br /> <br /> Dommage ....
Poster
Owner

Event ID: 475
Date: 2013-03-11T07:12:58Z
Person: Frederik Benoist
Description: Fermé par Frederik Benoist

Event ID: 475 Date: 2013-03-11T07:12:58Z Person: Frederik Benoist Description: Fermé par Frederik Benoist
Poster
Owner

Event ID: 474
Date: 2013-03-11T07:12:58Z
Person: Frederik Benoist
Description: Resolved (Fixed) and assigned to Frederik Benoist by Frederik Benoist

Event ID: 474 Date: 2013-03-11T07:12:58Z Person: Frederik Benoist Description: Resolved (Fixed) and assigned to Frederik Benoist by Frederik Benoist
Poster
Owner

Event ID: 461
Date: 2013-03-08T15:55:48Z
Person: Frederik Benoist
Description: Resolved (Fixed) and assigned to Frederik Benoist by Frederik Benoist

Remplacé PAR



        Public Shared Function msExecuteXml(ByVal sql As String, Optional ByVal nomTable As String = "Table") As XmlDocument



            Dim xml As New XmlDocument()

            Dim MyString As New System.Text.StringBuilder()



            Const quote As String = """"



            '<root>

            '  <A0A1A0A0>

            '      <row ........... />

            '</A0A1A0A0>

            '</root>

            MyString.Append("<root>")

            MyString.Append("<" & nomTable & ">")



            Using reader As IDataReader = cDatabase.psInstance.mExecuteReader(sql)

                Dim XmlFCount As Integer = reader.FieldCount

                Dim aFieldName(XmlFCount) As String

                Dim aFieldValues(XmlFCount) As Object



                For i As Integer = 0 To XmlFCount - 1

                    aFieldName(i) = reader.GetName(i)

                Next



                While reader.Read()

                    MyString.Append("<row ")



                    reader.GetValues(aFieldValues)



                    For i As Integer = 0 To XmlFCount - 1

                        MyString.Append(aFieldName(i) & "=" & quote & aFieldValues(i).ToString & quote & " ")

                    Next



                    MyString.Append("/>")

                End While



                MyString.Append("</" & nomTable & ">")

                MyString.Append("</root>")



                xml.LoadXml(MyString.ToString)

            End Using



            Return xml



        End Function

Event ID: 461 Date: 2013-03-08T15:55:48Z Person: Frederik Benoist Description: Resolved (Fixed) and assigned to Frederik Benoist by Frederik Benoist Remplac&#233; PAR <br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; Public Shared Function msExecuteXml(ByVal sql As String, Optional ByVal nomTable As String = &quot;Table&quot;) As XmlDocument<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim xml As New XmlDocument()<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim MyString As New System.Text.StringBuilder()<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Const quote As String = &quot;&quot;&quot;&quot;<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&lt;root&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; &lt;A0A1A0A0&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; &nbsp; &nbsp; &lt;row ........... /&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&lt;/A0A1A0A0&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&lt;/root&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyString.Append(&quot;&lt;root&gt;&quot;)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyString.Append(&quot;&lt;&quot; &amp; nomTable &amp; &quot;&gt;&quot;)<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Using reader As IDataReader = cDatabase.psInstance.mExecuteReader(sql)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim XmlFCount As Integer = reader.FieldCount<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim aFieldName(XmlFCount) As String<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim aFieldValues(XmlFCount) As Object<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For i As Integer = 0 To XmlFCount - 1<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aFieldName(i) = reader.GetName(i)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; While reader.Read()<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyString.Append(&quot;&lt;row &quot;)<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.GetValues(aFieldValues)<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For i As Integer = 0 To XmlFCount - 1<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyString.Append(aFieldName(i) &amp; &quot;=&quot; &amp; quote &amp; aFieldValues(i).ToString &amp; quote &amp; &quot; &quot;)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyString.Append(&quot;/&gt;&quot;)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End While<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyString.Append(&quot;&lt;/&quot; &amp; nomTable &amp; &quot;&gt;&quot;)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyString.Append(&quot;&lt;/root&gt;&quot;)<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xml.LoadXml(MyString.ToString)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End Using<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return xml<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; End Function<br />
Poster
Owner

Event ID: 451
Date: 2013-03-07T15:37:28Z
Person: Frederik Benoist
Description: Modifié par Frederik Benoist

Dans cSqlDAO.vb



  Public Shared Function msExecuteXml(ByVal sql As String, Optional ByVal nomTable As String = "Table") As XmlDocument



            Dim xml As New XmlDocument()



            Using reader As IDataReader = cDatabase.psInstance.mExecuteReader(sql)



                Dim XmlRoot As XmlElement = xml.CreateElement("root")

                Dim XmlTable As XmlElement = xml.CreateElement(nomTable)



                Dim XmlRow As XmlElement

                Dim XmlAtr As XmlAttribute



                While reader.Read()

                    XmlRow = xml.CreateElement("row")

                    For i As Integer = 0 To reader.FieldCount - 1

                        XmlAtr = xml.CreateAttribute(reader.GetName(i))

                        Dim value As Object = reader.GetValue(i)

                        XmlAtr.Value = value.ToString()

                        XmlRow.Attributes.Append(XmlAtr)

                    Next

                    XmlTable.AppendChild(XmlRow)

                End While



                XmlRoot.AppendChild(XmlTable)

                xml.AppendChild(XmlRoot)



            End Using



            Return xml



        End Function

Event ID: 451 Date: 2013-03-07T15:37:28Z Person: Frederik Benoist Description: Modifié par Frederik Benoist Dans cSqlDAO.vb<br /> <br /> &nbsp; Public Shared Function msExecuteXml(ByVal sql As String, Optional ByVal nomTable As String = &quot;Table&quot;) As XmlDocument<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim xml As New XmlDocument()<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Using reader As IDataReader = cDatabase.psInstance.mExecuteReader(sql)<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim XmlRoot As XmlElement = xml.CreateElement(&quot;root&quot;)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim XmlTable As XmlElement = xml.CreateElement(nomTable)<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim XmlRow As XmlElement<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim XmlAtr As XmlAttribute<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; While reader.Read()<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XmlRow = xml.CreateElement(&quot;row&quot;)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For i As Integer = 0 To reader.FieldCount - 1<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XmlAtr = xml.CreateAttribute(reader.GetName(i))<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim value As Object = reader.GetValue(i)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XmlAtr.Value = value.ToString()<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XmlRow.Attributes.Append(XmlAtr)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XmlTable.AppendChild(XmlRow)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End While<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XmlRoot.AppendChild(XmlTable)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xml.AppendChild(XmlRoot)<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End Using<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return xml<br /> <br /> &nbsp; &nbsp; &nbsp; &nbsp; End Function<br />
Poster
Owner

Event ID: 450
Date: 2013-03-07T15:36:22Z
Person: Frederik Benoist
Description: Attribué à Frederik Benoist par Frederik Benoist

Event ID: 450 Date: 2013-03-07T15:36:22Z Person: Frederik Benoist Description: Attribué à Frederik Benoist par Frederik Benoist
Poster
Owner

Event ID: 449
Date: 2013-03-07T15:36:22Z
Person: Frederik Benoist
Description: Ouvert par Frederik Benoist

Event ID: 449 Date: 2013-03-07T15:36:22Z Person: Frederik Benoist Description: Ouvert par Frederik Benoist
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fbenoist68/mobileportal#171
There is no content yet.