Beispiel #1
0
        /// <summary>
        /// Construit le patron
        /// </summary>
        /// <param name="Doc"></param>
        /// <param name="Code"></param>
        private void XmlBuild(ref XmlDocument Doc, XmlCode Code)
        {
            if (Doc == null)
            {
                Doc = new XmlDocument();
            }
            else
            {
                Doc.RemoveAll();
            }
            sVersion Actual = Outils.GetVersion();
            //Déclaration de la norme utilisée
            XmlDeclaration xmlDeclaration = Doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            XmlElement     root           = Doc.DocumentElement;

            Doc.InsertBefore(xmlDeclaration, root);

            //Création de la racine
            XmlElement xmlffs2play = Doc.CreateElement(string.Empty, "ffs2play", string.Empty);

            Doc.AppendChild(xmlffs2play);

            //Création de la version
            XmlElement xmlVersion = Doc.CreateElement(string.Empty, "version", string.Empty);

            xmlVersion.InnerText = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + "_" + Actual.Major.ToString() + "_" + Actual.Minor.ToString() + "_" + Actual.Build.ToString();
            xmlffs2play.AppendChild(xmlVersion);

            //Activation du P2P;
            XmlElement xmlP2P = Doc.CreateElement(string.Empty, "P2P", string.Empty);

            xmlP2P.InnerText = Properties.Settings.Default.P2PEnable.ToString();
            xmlffs2play.AppendChild(xmlP2P);

            //Création du switch
            XmlElement xmlSwitch = Doc.CreateElement(string.Empty, "switch", string.Empty);

            xmlffs2play.AppendChild(xmlSwitch);

            //Création du data
            XmlElement xmlData = Doc.CreateElement(string.Empty, "data", string.Empty);

            xmlData.InnerText = Code.ToString();
            xmlSwitch.AppendChild(xmlData);

            //Création du key
            XmlElement xmlKey = Doc.CreateElement(string.Empty, "key", string.Empty);

            xmlKey.InnerText = Key;
            xmlSwitch.AppendChild(xmlKey);

            switch (Code)
            {
            case XmlCode.hello:
                XmlElement xmlHello = Doc.CreateElement(string.Empty, "hello", string.Empty);
                xmlffs2play.AppendChild(xmlHello);
                //Création de la balise pilotID
                XmlElement xmlLogin = Doc.CreateElement(string.Empty, "pilotID", string.Empty);
                xmlLogin.InnerText = User.Login;
                xmlHello.AppendChild(xmlLogin);
                break;

            case XmlCode.verify:
                //Création de la balise verify
                XmlElement xmlVerify = Doc.CreateElement(string.Empty, "verify", string.Empty);
                xmlffs2play.AppendChild(xmlVerify);

                //Création de la balise AES
                XmlElement xmlAES = Doc.CreateElement(string.Empty, "AES", string.Empty);
                xmlAES.InnerText = Crypted_AESKey;
                xmlVerify.AppendChild(xmlAES);

                //Création de la balise pilotID
                XmlElement xmlPilotID = Doc.CreateElement(string.Empty, "pilotID", string.Empty);
                xmlPilotID.InnerText = User.Login;
                xmlVerify.AppendChild(xmlPilotID);

                //Création de la balise password
                XmlElement xmlPassword = Doc.CreateElement(string.Empty, "password", string.Empty);
                xmlPassword.InnerText = Outils.EncryptMessage(Outils.Decrypt(User.Password), m_sAESKey);
                xmlVerify.AppendChild(xmlPassword);

                //Envoi du port en écoute
                XmlElement xmlPort = Doc.CreateElement(string.Empty, "port", string.Empty);
                xmlPort.InnerText = P2P.Port.ToString();
                xmlVerify.AppendChild(xmlPort);

                //Envoi du port en écoute
                XmlElement xmlLocalIP = Doc.CreateElement(string.Empty, "local_ip", string.Empty);
                xmlLocalIP.InnerText = P2P.LocalIPSerialized;
                xmlVerify.AppendChild(xmlLocalIP);
                break;

            case XmlCode.liveupdate:
                //Création de la balise liveupdate
                XmlElement xmlLiveUpdate2 = Doc.CreateElement(string.Empty, "liveupdate", string.Empty);
                xmlffs2play.AppendChild(xmlLiveUpdate2);
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "registration", string.Empty));                //Création de la balise registration
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "latitude", string.Empty));                    //Création de la balise latitude
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "longitude", string.Empty));                   //Création de la balise longitude
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "heading", string.Empty));                     //Création de la balise heading
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "altitude", string.Empty));                    //Création de la balise altitude
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "groundSpeed", string.Empty));                 //Création de la balise groundSpeed
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "iaspeed", string.Empty));                     //Création de la balise iaspeed
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "squawk", string.Empty));                      //Création de la balise squawk
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "onground", string.Empty));                    //Création de la balise onground
                xmlLiveUpdate2.AppendChild(Doc.CreateElement(string.Empty, "sim", string.Empty));                         //Création de la balise simulateur
                break;

            case XmlCode.atc:
                //Création de la balise liveupdate
                XmlElement xmlAtc = Doc.CreateElement(string.Empty, "atc", string.Empty);
                xmlffs2play.AppendChild(xmlAtc);
                xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "latitude", string.Empty));                       //Création de la balise latitude
                xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "longitude", string.Empty));                      //Création de la balise longitude
                xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "heading", string.Empty));                        //Création de la balise heading
                xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "altitude", string.Empty));                       //Création de la balise altitude
                xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "groundSpeed", string.Empty));                    //Création de la balise groundSpeed
                xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "iaspeed", string.Empty));                        //Création de la balise iaspeed
                xmlAtc.AppendChild(Doc.CreateElement(string.Empty, "squawk", string.Empty));                         //Création de la balise squawk
                break;

            case XmlCode.syncai:
                XmlElement xmlSyncAI = Doc.CreateElement(string.Empty, "syncai", string.Empty);
                xmlffs2play.AppendChild(xmlSyncAI);
                xmlSyncAI.AppendChild(Doc.CreateElement(string.Empty, "md5list", string.Empty));
                break;

            case XmlCode.sendai:
                XmlElement xmlSendAI = Doc.CreateElement(string.Empty, "sendai", string.Empty);
                xmlffs2play.AppendChild(xmlSendAI);
                break;
            }
        }