1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
Sub Modif_Xml(ByRef NbChamp As Integer, ByVal Nom As String, ByVal Fich_Xml_Rub As String, ByVal Chemin_Xml As String, ByVal RD1 As String, ByVal Op1 As String, ByVal Val1 As String, ByVal Coor As String, ByVal RD2 As String, ByVal Op2 As String, ByVal Val2 As String, ByVal RubCalcul1 As String, ByVal RubCalcul2 As String, ByVal RubCalcul3 As String, ByVal OpCalcul As String)
Dim d As New XmlDocument()
Dim ProgressionEventArgs As System.EventArgs
Dim RDAtt1 As String
Dim ValAtt1 As String
Dim RubCalculAtt1 As String
Dim RubCalculAtt2 As String
Dim RubCalculAtt3 As String
Dim RDAtt2 As String
Dim ValAtt2 As String
Dim Xml_Read As New XmlTextReader(Fich_Xml_Rub)
d.Load(Chemin_Xml)
Do While Xml_Read.Value <> Nom
Xml_Read.Read()
Loop
Do While Xml_Read.Name <> "Rubrique"
If Xml_Read.Name = "RubriqueDeclencheuse" Then
Xml_Read.MoveToAttribute("Champ")
RD1 = Xml_Read.GetAttribute(0)
Xml_Read.Read()
Xml_Read.Read()
End If
If Xml_Read.Name = "Valeur" Then
Xml_Read.MoveToAttribute("Champ")
If Xml_Read.GetAttribute(0) <> "" Then
Val1 = Xml_Read.GetAttribute(0)
ValAtt1 = Val1
Else
ValAtt1 = ""
End If
Xml_Read.Read()
Xml_Read.Read()
End If
If Xml_Read.Name = "RubriqueCalcul1" Then
Xml_Read.MoveToAttribute("Champ")
If Xml_Read.GetAttribute(0) <> "" Then
RubCalcul1 = Xml_Read.GetAttribute(0)
RubCalculAtt1 = RubCalcul1
Else
RubCalculAtt1 = ""
End If
Xml_Read.Read()
Xml_Read.Read()
End If
If Xml_Read.Name = "RubriqueCalcul2" Then
Xml_Read.MoveToAttribute("Champ")
If Xml_Read.GetAttribute(0) <> "" Then
RubCalcul2 = Xml_Read.GetAttribute(0)
RubCalculAtt2 = RubCalcul2
Else
RubCalculAtt2 = ""
End If
Xml_Read.Read()
Xml_Read.Read()
End If
If Xml_Read.Name = "RubriqueCalcul3" Then
Xml_Read.MoveToAttribute("Champ")
If Xml_Read.GetAttribute(0) <> "" Then
RubCalcul3 = Xml_Read.GetAttribute(0)
RubCalculAtt3 = RubCalcul3
Else
RubCalculAtt3 = ""
End If
Xml_Read.Read()
Xml_Read.Read()
End If
If Xml_Read.Name = "RubriqueDeclencheuseRestriction" Then
Xml_Read.MoveToAttribute("Champ")
If Xml_Read.GetAttribute(0) <> "" Then
RD2 = Xml_Read.GetAttribute(0)
RDAtt2 = RD2
Else
RDAtt2 = ""
End If
Xml_Read.Read()
Xml_Read.Read()
End If
If Xml_Read.Name = "ValeurRestriction" Then
Xml_Read.MoveToAttribute("Champ")
If Xml_Read.GetAttribute(0) <> "" Then
Val2 = Xml_Read.GetAttribute(0)
ValAtt2 = Val2
Else
ValAtt2 = ""
End If
Xml_Read.Read()
Xml_Read.Read()
End If
Xml_Read.Read()
Loop
Xml_Read.Close()
Dim root As XmlNode = d.DocumentElement
Dim i As Integer = 2
Dim n As Integer
Dim format As String
Dim NodeCount As XmlNode = root.SelectSingleNode("//ligne[position () = last()]")
n = NodeCount.Attributes("id").Value
If RubCalcul1.StartsWith("Champ") = False Then
Ajoutchamp(n, Chemin_Xml, d, NbChamp, RubCalcul1, root)
End If
For i = 2 To n
RaiseEvent ProgressionTraitement(Me, New ProgressionEventArgs())
'traitement Compteur(i, n)
Dim NodeRD1 As XmlNode = root.SelectSingleNode("//ligne[@id='" & i & "']//" & RD1)
If RD2 = "Vide" Then
If ValAtt1 = "" Then
Dim firstTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD1), NodeRD1.InnerText), CheckFormat(Verif_Format(Val1), Val1), Op1)
If FirstTest = True Then
Traitement_Xml(NbChamp, i, root, d, RubCalcul1, RubCalcul2, RubCalcul3, OpCalcul, RDAtt1, RDAtt2, RubCalculAtt1, RubCalculAtt2, RubCalculAtt3, ValAtt1, ValAtt2)
End If
Else
Dim NodeVal1 As XmlNode = root.SelectSingleNode("//ligne[@id='" & i & "']//" & Val1)
Dim firstTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD1), NodeRD1.InnerText), CheckFormat(GetFormatNode(NodeVal1), NodeVal1.InnerText), Op1)
If FirstTest = True Then
Traitement_Xml(NbChamp, i, root, d, RubCalcul1, RubCalcul2, RubCalcul3, OpCalcul, RDAtt1, RDAtt2, RubCalculAtt1, RubCalculAtt2, RubCalculAtt3, ValAtt1, ValAtt2)
End If
End If
Else
Dim NodeRD2 As XmlNode = root.SelectSingleNode("//ligne[@id='" & i & "']//" & RD2)
If ValAtt1 = "" And ValAtt2 <> "" Then
Dim NodeVal2 As XmlNode = root.SelectSingleNode("//ligne[@id='" & i & "']//" & Val2)
Dim firstTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD1), NodeRD1.InnerText), CheckFormat(Verif_Format(Val1), Val1), Op1)
Dim secondTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD2), NodeRD2.InnerText), CheckFormat(GetFormatNode(NodeVal2), NodeVal2.InnerText), Op2)
If CheckLogical(firstTest, secondTest, Coor) Then
Traitement_Xml(NbChamp, i, root, d, RubCalcul1, RubCalcul2, RubCalcul3, OpCalcul, RDAtt1, RDAtt2, RubCalculAtt1, RubCalculAtt2, RubCalculAtt3, ValAtt1, ValAtt2)
End If
ElseIf ValAtt1 <> "" And ValAtt2 = "" Then
Dim NodeVal1 As XmlNode = root.SelectSingleNode("//ligne[@id='" & i & "']//" & Val1)
Dim firstTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD1), NodeRD1.InnerText), CheckFormat(GetFormatNode(NodeVal1), NodeVal1.InnerText), Op1)
Dim secondTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD2), NodeRD2.InnerText), CheckFormat(Verif_Format(Val2), Val2), Op2)
If CheckLogical(firstTest, secondTest, Coor) Then
Traitement_Xml(NbChamp, i, root, d, RubCalcul1, RubCalcul2, RubCalcul3, OpCalcul, RDAtt1, RDAtt2, RubCalculAtt1, RubCalculAtt2, RubCalculAtt3, ValAtt1, ValAtt2)
End If
ElseIf ValAtt1 = "" And ValAtt2 = "" Then
Dim firstTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD1), NodeRD1.InnerText), CheckFormat(Verif_Format(Val1), Val1), Op1)
Dim secondTest As Boolean = CheckRelational(CheckFormat(GetFormatNode(NodeRD2), NodeRD2.InnerText), CheckFormat(Verif_Format(Val2), Val2), Op2)
If CheckLogical(firstTest, secondTest, Coor) Then
Traitement_Xml(NbChamp, i, root, d, RubCalcul1, RubCalcul2, RubCalcul3, OpCalcul, RDAtt1, RDAtt2, RubCalculAtt1, RubCalculAtt2, RubCalculAtt3, ValAtt1, ValAtt2)
End If
Else
Dim NodeVal1 As XmlNode = root.SelectSingleNode("//ligne[@id='" & i & "']//" & Val1)
Dim NodeVal2 As XmlNode = root.SelectSingleNode("//ligne[@id='" & i & "']//" & Val2)
format = GetFormatNode(NodeVal1)
format = GetFormatNode(NodeVal2)
Dim firstTest As Boolean = CheckRelational(CheckFormat(format, NodeRD1.InnerText), CheckFormat(format, NodeVal1.InnerText), Op1)
Dim secondTest As Boolean = CheckRelational(CheckFormat(format, NodeRD2.InnerText), CheckFormat(format, NodeVal2.InnerText), Op2)
If CheckLogical(firstTest, secondTest, Coor) Then
Traitement_Xml(NbChamp, i, root, d, RubCalcul1, RubCalcul2, RubCalcul3, OpCalcul, RDAtt1, RDAtt2, RubCalculAtt1, RubCalculAtt2, RubCalculAtt3, ValAtt1, ValAtt2)
End If
End If
End If
Next
d.Save(Chemin_Xml)
End Sub |
Partager