Beispiel #1
0
 public void LoadXml(XmlNode xml, WarFilter warFilter)
 {
     this.xml = xml;
     XmlNode planidata = xml.SelectSingleNode("scann/plani_data");
     XmlNode coords = planidata.SelectSingleNode("koordinaten");
     gal = uint.Parse(coords["gal"].InnerText);
     sol = uint.Parse(coords["sol"].InnerText);
     pla = uint.Parse(coords["pla"].InnerText);
     pla_typ = planidata.SelectSingleNode("planeten_typ/name").InnerText;
     obj_typ = planidata.SelectSingleNode("objekt_typ/name").InnerText;
     owner_name = planidata.SelectSingleNode("user/name").InnerText;
     owner_ally = planidata.SelectSingleNode("user/allianz_tag").InnerText;
     timestamp = uint.Parse(xml.SelectSingleNode("scann/timestamp").InnerText);
     ress = new ResourceSet();
     ress.ParseXml(xml.SelectSingleNode("scann/ressourcen"));
     WarFilter.War war = warFilter.getWar(owner_ally, timestamp);
     warID = war != null ? war.id : 0;
 }
Beispiel #2
0
 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     String str = IWCache.WebQuery(matches[0].Value);
     System.Xml.XmlDocument d = new System.Xml.XmlDocument();
     d.LoadXml(str);
     foreach(XmlNode sch in d["struktur"].SelectNodes("schiff")) {
         MySqlCommand insertItem = new MySqlCommand("INSERT IGNORE INTO " + DBPrefix + "techtree_items (name, type) VALUES (?name, 'schiff')", con);
         insertItem.Parameters.Add("?name", MySqlDbType.String).Value = sch["name"].InnerText;
         insertItem.ExecuteNonQuery();
         long itemID = insertItem.LastInsertedId;
         if(itemID == 0) {
             MySqlCommand sel = new MySqlCommand("SELECT ID FROM " + DBPrefix + "techtree_items WHERE name=?name AND type='schiff'", con);
             sel.Parameters.Add("?name", MySqlDbType.String).Value = sch["name"].InnerText;
             Object obj = sel.ExecuteScalar();
             itemID = (uint)obj;
         }
         ResourceSet kosten = new ResourceSet();
         kosten.ParseXml(sch["kosten"]);
         kosten.Zeit = TimeSpan.FromSeconds(int.Parse(sch["dauer"].InnerText));
         MySqlCommand insertStufe = new MySqlCommand("INSERT INTO " + DBPrefix + @"techtree_stufen (ItemID, Stufe, Dauer, bauE,bauS,bauC,bauV,bauEis,bauW,bauEn,bauCr,bauBev) VALUES (?itemid, 1, ?dauer, ?baue, ?baus, ?bauc, ?bauv, ?baueis, ?bauw, ?bauen, ?baucr, ?baubev)
     ON DUPLICATE KEY UPDATE Dauer=VALUES(Dauer), bauE=VALUES(bauE), bauS=VALUES(bauS), bauC=VALUES(bauC), bauV=VALUES(bauV), bauEis=VALUES(bauEis), bauW=VALUES(bauW), bauEn=VALUES(bauEn), bauCr=VALUES(bauCr), bauBev=VALUES(bauBev)", con);
         insertStufe.Parameters.Add("?itemid", MySqlDbType.UInt32).Value = itemID;
         insertStufe.Parameters.Add("?dauer", MySqlDbType.UInt32).Value = kosten.Zeit.TotalSeconds;
         insertStufe.Parameters.Add("?baue", MySqlDbType.UInt32).Value = kosten.Eisen;
         insertStufe.Parameters.Add("?baus", MySqlDbType.UInt32).Value = kosten.Stahl;
         insertStufe.Parameters.Add("?bauc", MySqlDbType.UInt32).Value = kosten.Chemie;
         insertStufe.Parameters.Add("?bauv", MySqlDbType.UInt32).Value = kosten.VV4A;
         insertStufe.Parameters.Add("?baueis", MySqlDbType.UInt32).Value = kosten.Eis;
         insertStufe.Parameters.Add("?bauw", MySqlDbType.UInt32).Value = kosten.Wasser;
         insertStufe.Parameters.Add("?bauen", MySqlDbType.UInt32).Value = kosten.Energie;
         insertStufe.Parameters.Add("?baucr", MySqlDbType.UInt32).Value = kosten.Credits;
         insertStufe.Parameters.Add("?baubev", MySqlDbType.UInt32).Value = kosten.Bev;
         insertStufe.ExecuteNonQuery();
     }
     resp.Respond("Schiffskosten-XML erfolgreich eingelesen!");
 }