Bonjour,
Dans le cadre d'importation depuis un logiciel tiers (COMAC) vers le logiciel AutoCAD, je cherche a créer une classe (Etude) à partir d'un fichier .pcm (type xml renommé)
Dans le fichier ci-joint vous trouverez un export de mon code source dans un Windows Form ou je cherche uniquement à générer cette classe
Le programme inclus 3 fichiers sources de type XML pour le test
- Le fichier GLOBAL.xml contient tous les éléments
- Le fichier TEST_01.xml ne contient que les informations Etudes + Hypotheses
- Le fichier TEST_02.xml ne contient que les informations Etudes + Hypotheses + Supports
j'ai fais beaucoup de tests : j'ai essayé importer automatiquement le xml en class via xsd.exe, de copier le code --> Edition/ Collage Spécial / Coller XML sous forme de classe...)
Je n'y suis pas arrivé depuis le fichier complet (GLOBAL.XML)
Du coup j'ai généré manuellement mes classes et j'ai codé l'import en dur depuis un XmlSerilizer
Actuellement, les informations de l'étude se charge bien mais les "hypothèses" ne se chargent pas (voir PNG dans le zip)
Pourriez-vous me dire ce qui ne va pas dans mon code s'il vous plait?
Si jamais vous y arriver, pourriez-vous également regarder pourquoi l'import des supports génére un bug (il faut utiliser TEST_02.xml dans fpXML)
Par avance merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Imports System Imports System.Collections Imports System.Collections.Generic Imports System.ComponentModel Imports System.Xml Imports System.Xml.Schema Imports System.Xml.Serialization <XmlRoot("Etude")> Public Class Etude <XmlElement("Version")> Public Property Version As String <XmlElement("Description")> Public Property Description As String <XmlElement("Operateur")> Public Property Operateur As String <XmlElement("NomCorrespondant")> Public Property NomCorrespondant As String <XmlElement("TelCorrespondant")> Public Property TelCorrespondant As String <XmlElement("DistEnergie")> Public Property DistEnergie As String <XmlElement("DateEnregistrement")> Public Property DateEnregistrement As String <XmlElement("Commune")> Public Property Commune As String <XmlElement("Insee")> Public Property Insee As String <XmlElement("Rue")> Public Property Rue As String <XmlElement("NumEtude")> Public Property NumEtude As String <XmlElement("NumAffaire")> Public Property NumAffaire As String <XmlElement("Commentaire")> Public Property Commentaire As String <XmlElement("optEtudeRaccordement")> Public Property optEtudeRaccordement As String <XmlElement("optOpenStreetMap")> Public Property optOpenStreetMap As String <XmlArray("Hypotheses")> <XmlArrayItem("Hypothese", GetType(Hypothese))> Public Property Hypotheses As Hypothese() <XmlArray("Supports")> <XmlArrayItem("Support", GetType(Support))> Public Property Supports As Support() End Class <Serializable()> Public Class Hypotheses '<XmlArrayItem(GetType(Hypothese))> Public Property Hypothese As Hypothese() End Class <Serializable()> Public Class Hypothese <XmlElement("Hypothese")> Public Property Hypothese As String End Class <Serializable()> Public Class Supports '<XmlArrayItem(GetType(Support))> Public Property Support As Support() End Class <Serializable()> Public Class Support <XmlElement("Nom")> Public Property Nom As String <XmlElement("Facade")> Public Property Facade As Integer <XmlElement("Nature")> Public Property Nature As String <XmlElement("Hauteur")> Public Property Hauteur As Double <XmlElement("Classe")> Public Property Classe As String <XmlElement("Effort")> Public Property Effort As Double <XmlElement("Orientation")> Public Property Orientation As Double <XmlElement("Etat")> Public Property Etat As String <XmlElement("Commentaire")> Public Property Commentaire As String <XmlElement("BranchementsBT")> Public Property BranchementsBT As Integer <XmlElement("optBranchementsTelExistants")> Public Property optBranchementsTelExistants As Integer <XmlElement("optBandeauVertAPoser")> Public Property optBandeauVertAPoser As Integer <XmlElement("optBandeauVertExistant")> Public Property optBandeauVertExistant As Integer '<XmlElement("BranchementsTV")> Public Property BranchementsTV As Integer <XmlElement("ReservationEP")> Public Property ReservationEP As Integer <XmlElement("PresenceEP")> Public Property PresenceEP As Integer <XmlElement("HauteurEP")> Public Property HauteurEP As Integer <XmlElement("APoser")> Public Property APoser As Integer <XmlElement("NonCalcule")> Public Property NonCalcule As Integer <XmlElement("Illisible")> Public Property Illisible As Integer <XmlElement("Surimplantation")> Public Property Surimplantation As Integer <XmlElement("X")> Public Property X As Double <XmlElement("Y")> Public Property Y As Double <XmlElement("Z")> Public Property Z As Double <XmlElement("Annee")> Public Property Annee As String <XmlElement("optMALTBT")> Public Property optMALTBT As Integer <XmlElement("RASBT")> Public Property RASBT As Integer <XmlElement("RASFT")> Public Property RASFT As Integer <XmlElement("RASCO")> Public Property RASCO As Integer <XmlElement("RASFO")> Public Property RASFO As Integer <XmlElement("optMALTCuivre")> Public Property optMALTCuivre As Integer <XmlElement("optMALTCoaxial")> Public Property optMALTCoaxial As Integer <XmlElement("optBoitierCuivre")> Public Property optBoitierCuivre As Integer <XmlElement("optBoitierCoaxial")> Public Property optBoitierCoaxial As Integer <XmlElement("optBoitierFibre")> Public Property optBoitierFibre As Integer <XmlElement("NbRaccordementsCuivre")> Public Property NbRaccordementsCuivre As Integer <XmlElement("NbRaccordementsCoaxial")> Public Property NbRaccordementsCoaxial As Integer <XmlElement("NbRaccordementsFibre")> Public Property NbRaccordementsFibre As Integer <XmlElement("TraverseExistante1")> Public Property TraverseExistante1 As Double <XmlElement("TraverseAPoser2")> Public Property TraverseAPoser2 As Double End Class
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 Imports System Imports System.Collections Imports System.IO Imports System.Text Imports System.Xml.Serialization Public Class Form1 Private Sub BtLoad_Click(sender As Object, e As EventArgs) Handles BtLoad.Click Dim FpXLM As String FpXLM = Directory.GetCurrentDirectory() + "\TEST_01.xml" Try Dim EtudeCOMAC As Etude Dim sr As StreamReader = New StreamReader(FpXLM, Encoding.Default, True) Dim ser As XmlSerializer = New XmlSerializer(GetType(Etude)) EtudeCOMAC = ser.Deserialize(sr) MsgBox("Chargement réussi") Catch ex As System.Exception MsgBox(ex.ToString) End Try End Sub End Class
Partager