Ejemplo n.º 1
0
 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     List<XmlNode> xmls = new List<XmlNode>();
     foreach(Match linkMatch in matches) {
         XmlNode xml = IWCache.Query(linkMatch.Value, con, DBPrefix);
         xmls.Add(xml);
     }
     resp.Respond(matches.Count + "x Unixml-Links erkannt!");
     base.Parse(xmls, posterID, victimID, con, handler, resp);
 }
Ejemplo n.º 2
0
 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySql.Data.MySqlClient.MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     foreach (Match forschungsInfo in matches) {
         try {
             TechtreeItem item = TechtreeForschung.Parse(forschungsInfo.Value, DBPrefix);
             if (item == null) {
                 resp.RespondError("Eine Forschung konnte nicht richtig erkannt werden! Bitte als Bug melden!");
                 continue;
             }
             item.WriteToDB(con);
             resp.Respond("Forschung " + item.Name + " eingelesen.\n");
         } catch (FormatException) {
             resp.RespondError("Ein Formatfehler ist beim Einlesen einer Forschung aufgetreten! Sind die Tausendertrennzeichen richtig eingestellt?");
             continue;
         }
     }
 }
Ejemplo n.º 3
0
 public void Parse(List<XmlNode> xmls, uint posterID, uint victimID, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     MySqlCommand checkQuery = new MySqlCommand(@"SELECT ownername, inserttime FROM " + DBPrefix + "universum WHERE gala=?gal AND sys=?sys AND pla=?pla", con);
     checkQuery.Parameters.Add("?gal", MySqlDbType.UInt32);
     checkQuery.Parameters.Add("?sys", MySqlDbType.UInt32);
     checkQuery.Parameters.Add("?pla", MySqlDbType.UInt32);
     checkQuery.Parameters.Add("?time", MySqlDbType.UInt32);
     checkQuery.Prepare();
     MySqlCommand allyTagInsert = new MySqlCommand("INSERT INTO " + DBPrefix + "uni_userdata (name, allytag, updatetime) VALUES (?name, ?tag, ?time) ON DUPLICATE KEY UPDATE allytag=IF(VALUES(updatetime) > updatetime, VALUES(allytag), allytag), updatetime=IF(VALUES(updatetime) > updatetime, VALUES(updatetime), updatetime)", con);
     allyTagInsert.Parameters.Add("?name", MySqlDbType.String);
     allyTagInsert.Parameters.Add("?tag", MySqlDbType.String);
     allyTagInsert.Parameters.Add("?time", MySqlDbType.UInt32);
     allyTagInsert.Prepare();
     MySqlCommand insertQry = new MySqlCommand("INSERT INTO " + DBPrefix + "universum (iwid, gala, sys, pla, inserttime, planityp, objekttyp, ownername, planiname) VALUES (?iwid, ?gala, ?sys, ?pla, ?time, ?ptyp, ?otyp, ?oname, ?pname)", con);
     insertQry.Parameters.Add("?iwid", MySqlDbType.UInt32);
     insertQry.Parameters.Add("?gala", MySqlDbType.UInt32);
     insertQry.Parameters.Add("?sys", MySqlDbType.UInt32);
     insertQry.Parameters.Add("?pla", MySqlDbType.UInt32);
     insertQry.Parameters.Add("?time", MySqlDbType.UInt32);
     insertQry.Parameters.Add("?ptyp", MySqlDbType.Enum);
     insertQry.Parameters.Add("?otyp", MySqlDbType.Enum);
     insertQry.Parameters.Add("?oname", MySqlDbType.String);
     insertQry.Parameters.Add("?pname", MySqlDbType.String);
     insertQry.Prepare();
     MySqlCommand updateQry = new MySqlCommand("UPDATE " + DBPrefix + "universum SET iwid=?iwid, planityp=?ptyp, objekttyp=?otyp, ownername=?oname, planiname=?pname, inserttime=?time WHERE gala=?gala AND sys=?sys AND pla=?pla", con);
     updateQry.Parameters.Add("?iwid", MySqlDbType.UInt32);
     updateQry.Parameters.Add("?gala", MySqlDbType.UInt32);
     updateQry.Parameters.Add("?sys", MySqlDbType.UInt32);
     updateQry.Parameters.Add("?pla", MySqlDbType.UInt32);
     updateQry.Parameters.Add("?ptyp", MySqlDbType.Enum);
     updateQry.Parameters.Add("?otyp", MySqlDbType.Enum);
     updateQry.Parameters.Add("?oname", MySqlDbType.String);
     updateQry.Parameters.Add("?pname", MySqlDbType.String);
     updateQry.Parameters.Add("?time", MySqlDbType.UInt32);
     updateQry.Prepare();
     uint insert = 0;
     uint update = 0;
     uint skipped = 0;
     foreach (XmlNode xml in xmls) {
         uint age = uint.Parse(xml.SelectSingleNode("planeten_data/informationen/aktualisierungszeit").InnerText);
         List<UniXmlPlani> planis = new List<UniXmlPlani>();
         foreach (XmlNode n in xml.SelectNodes("planeten_data/planet")) {
             UniXmlPlani plani = new UniXmlPlani(n);
             if (plani.planiTyp == "Sonne")
                 continue;
             checkQuery.Parameters["?gal"].Value = plani.gala;
             checkQuery.Parameters["?sys"].Value = plani.sys;
             checkQuery.Parameters["?pla"].Value = plani.pla;
             if (plani.ownerName.Length > 0) {
                 allyTagInsert.Parameters["?name"].Value = plani.ownerName;
                 allyTagInsert.Parameters["?tag"].Value = plani.allyTag;
                 allyTagInsert.Parameters["?time"].Value = age;
                 allyTagInsert.ExecuteNonQuery();
             }
             MySqlDataReader checkReader = checkQuery.ExecuteReader();
             String oldOwner = null;
             bool alreadyExists;
             try {
                 alreadyExists = checkReader.Read();
                 if(alreadyExists) {
                     if(checkReader.GetUInt32(1) >= age) {
                         ++skipped;
                         continue;
                     }
                     oldOwner = checkReader.GetString(0);
                 }
             } finally {
                 checkReader.Close();
             }
             if(alreadyExists) {
                 if(oldOwner != plani.ownerName && plani.objektTyp == "Kampfbasis")
                     parser.NeueKbGesichtet(plani.gala, plani.sys, plani.pla, plani.ownerName, plani.allyTag);
                 updateQry.Parameters["?iwid"].Value = plani.iwid;
                 updateQry.Parameters["?gala"].Value = plani.gala;
                 updateQry.Parameters["?sys"].Value = plani.sys;
                 updateQry.Parameters["?pla"].Value = plani.pla;
                 updateQry.Parameters["?time"].Value = age;
                 updateQry.Parameters["?ptyp"].Value = plani.planiTyp;
                 updateQry.Parameters["?otyp"].Value = plani.objektTyp;
                 updateQry.Parameters["?oname"].Value = plani.ownerName;
                 updateQry.Parameters["?pname"].Value = plani.planiName;
                 updateQry.ExecuteNonQuery();
                 ++update;
             } else {
                 if(plani.objektTyp == "Kampfbasis")
                     parser.NeueKbGesichtet(plani.gala, plani.sys, plani.pla, plani.ownerName, plani.allyTag);
                 insertQry.Parameters["?iwid"].Value = plani.iwid;
                 insertQry.Parameters["?gala"].Value = plani.gala;
                 insertQry.Parameters["?sys"].Value = plani.sys;
                 insertQry.Parameters["?pla"].Value = plani.pla;
                 insertQry.Parameters["?time"].Value = age;
                 insertQry.Parameters["?ptyp"].Value = plani.planiTyp;
                 insertQry.Parameters["?otyp"].Value = plani.objektTyp;
                 insertQry.Parameters["?oname"].Value = plani.ownerName;
                 insertQry.Parameters["?pname"].Value = plani.planiName;
                 insertQry.ExecuteNonQuery();
                 ++insert;
             }
         }
     }
     resp.Respond(insert + " neue Planeten eingelesen, " + update + " aktualisiert und "+skipped+" übersprungen!");
 }
Ejemplo n.º 4
0
 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     List<XmlNode> xmls = new List<XmlNode>();
     foreach (Match m in matches) {
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(m.Groups[0].Value);
         xmls.Add(doc);
     }
     resp.Respond(matches.Count + "x Uni-XML-Daten erkannt!");
     Parse(xmls, posterID, victimID, con, handler, resp);
 }
Ejemplo n.º 5
0
 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     foreach (Match m in matches) {
         String url = m.Value+"&typ=xml";
         XmlNode xml = IWCache.Query(url, con, DBPrefix);
         if (xml.SelectSingleNode("scann/informationen/vollstaendig").InnerText != "1") {
             resp.Respond("Ein Scan war nicht vollständig!");
             continue;
         }
         switch (xml.SelectSingleNode("scann/scann_typ/id").InnerText) {
             case "1": //Sondierung (Geologie)
                 GeoScan scan = GeoScan.Parse(xml, DBPrefix, handler.BesData);
                 if (scan == null) {
                     resp.RespondError("Beim Einlesen eines Geoscans ist ein Fehler aufgetreten!\n");
                     continue;
                 }
                 scan.ToDB(con);
                 resp.Respond("Geoscan eingelesen!\n");
                 break;
             case "2": //Sondierung (Gebäude/Ress)
                 GebScan s = new GebScan(uint.Parse(m.Groups[1].Value), m.Groups[2].Value);
                 s.LoadXml(xml, warFilter);
                 if (s.ToDB(con, DBPrefix, warFilter.TechKostenCache)) {
                     resp.Respond("Gebäudescan eingelesen!\n");
                 } else {
                     resp.Respond("Gebäudescan übersprungen!\n");
                 }
                 break;
             case "3": //Sondierung (Schiffe/Def/Ress)
                 SchiffScan schiffScan = new SchiffScan(uint.Parse(m.Groups[1].Value), m.Groups[2].Value);
                 schiffScan.LoadXml(xml, warFilter);
                 if(schiffScan.ToDB(con, DBPrefix, warFilter.TechKostenCache)) {
                     resp.Respond("Schiffscan eingelesen!\n");
                 } else {
                     resp.Respond("Schiffscan übersprungen!\n");
                 }
                 break;
         }
     }
 }
Ejemplo n.º 6
0
 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     uint unixnow = IWDBUtils.toUnixTimestamp(now);
     String dot = Regex.Escape(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator);
     String comma = Regex.Escape(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
     foreach (Match outerMatch in matches) {
         MatchCollection innerMatches = Regex.Matches(outerMatch.Value, "\n" + KolonieName + @"\s+(\d+):(\d+):(\d+)\s+
     \((?:Kolonie|Kampfbasis|Sammelbasis)\)\s+((?:[\d" + dot + @"]+\s+
     \([-\d" + dot + comma + @"]+\)\s+
     (?:---|[\d" + dot + @"]+)\s+
     [\d" + dot + @"]+\s){7})+", RegexOptions.IgnorePatternWhitespace);
         uint uid = 0;
         if (innerMatches.Count == 0)
             return;
         foreach (Match innerMatch in innerMatches) {
             ResourceSet aktRess = new ResourceSet();
             ResourceSet vRess = new ResourceSet();
             ResourceSet lager = new ResourceSet();
             MatchCollection ressMatches = Regex.Matches(innerMatch.Groups[4].Value, @"([\d" + dot + @"]+)\s+
     \(([-\d" + dot + comma + @"]+)\)\s+
     (---|[\d" + dot + @"]+)\s+
     [\d" + dot + @"]+\s", RegexOptions.IgnorePatternWhitespace);
             int i = 0;
             foreach (Match m in ressMatches) {
                 aktRess.Set(i, m.Groups[1].Value);
                 vRess.Set(i, m.Groups[2].Value);
                 String str = m.Groups[3].Value;
                 if (str != "---")
                     lager.Set(i, str);
                 ++i;
             }
             uint gala = uint.Parse(innerMatch.Groups[1].Value);
             uint sys = uint.Parse(innerMatch.Groups[2].Value);
             uint pla = uint.Parse(innerMatch.Groups[3].Value);
             uint planid;
             if (uid == 0) {
                 MySqlCommand uidPlanidQry = new MySqlCommand(@"SELECT universum.id , igm_data.id
                     FROM " + DBPrefix + "universum AS universum LEFT JOIN " + DBPrefix + @"igm_data AS igm_data ON universum.ownername=igm_data.igmname
                     WHERE universum.sys=?sys AND universum.gala=?gala AND universum.pla=?pla", con);
                 uidPlanidQry.Parameters.Add("?sys", MySqlDbType.UInt32).Value = sys;
                 uidPlanidQry.Parameters.Add("?gala", MySqlDbType.UInt32).Value = gala;
                 uidPlanidQry.Parameters.Add("?pla", MySqlDbType.UInt32).Value = pla;
                 MySqlDataReader r = uidPlanidQry.ExecuteReader();
                 if (!r.Read() || r.IsDBNull(1)) {
                     resp.RespondError("Universumsdaten fehlerhaft oder unvollständig!\n");
                     r.Close();
                     continue;
                 }
                 planid = r.GetUInt32(0);
                 uid = r.GetUInt32(1);
                 r.Close();
                 MySqlCommand cleanupQry = new MySqlCommand(@"DELETE FROM " + DBPrefix + "ressuebersicht WHERE uid=?uid", con);
                 cleanupQry.Parameters.Add("?uid", MySqlDbType.UInt32).Value = uid;
                 cleanupQry.ExecuteNonQuery();
             } else {
                 MySqlCommand planIdQry = new MySqlCommand("SELECT id from " + DBPrefix + "universum WHERE sys=?sys AND gala=?gala AND pla=?pla", con);
                 planIdQry.Parameters.Add("?sys", MySqlDbType.UInt32).Value = sys;
                 planIdQry.Parameters.Add("?gala", MySqlDbType.UInt32).Value = gala;
                 planIdQry.Parameters.Add("?pla", MySqlDbType.UInt32).Value = pla;
                 object res = planIdQry.ExecuteScalar();
                 if (res == null || Convert.IsDBNull(res)) {
                     resp.RespondError("Universumsdaten fehlerhaft oder unvollständig!\n");
                     continue;
                 }
                 planid = (uint)res;
             }
             MySqlCommand insertQry = new MySqlCommand("INSERT INTO " + DBPrefix + @"ressuebersicht (uid, planid, fe, st, vv, ch, ei, wa, en, vFe, vSt, vVv, vCh, vEi, vWa, vEn, lCh, lEi, lWa, lEn, time) VALUES (
                                                                                             ?uid, ?planid, ?fe, ?st, ?vv, ?ch, ?ei, ?wa, ?en, ?vFe, ?vSt, ?vVv, ?vCh, ?vEi, ?vWa, ?vEn, ?lCh, ?lEi, ?lWa, ?lEn, ?time)
                                                             on duplicate key update uid=VALUES(uid), fe=VALUES(fe), st=VALUES(st), vv=VALUES(vv), ch=VALUES(ch), ei=VALUES(ei), wa=VALUES(wa), en=VALUES(en), vFe=VALUES(vFe), vSt=VALUES(vSt), vVv=VALUES(vVv), vCh=VALUES(vCh), vEi=VALUES(vEi), vWa=VALUES(vWa), vEn=VALUES(vEn), lCh=VALUES(lCh), lEi=VALUES(lEi), lWa=VALUES(lWa), lEn=VALUES(lEn), time=VALUES(time)", con);
             insertQry.Parameters.Add("?uid", MySqlDbType.UInt32).Value = uid;
             insertQry.Parameters.Add("?planid", MySqlDbType.UInt32).Value = planid;
             insertQry.Parameters.Add("?fe", MySqlDbType.UInt32).Value = aktRess.Eisen;
             insertQry.Parameters.Add("?st", MySqlDbType.UInt32).Value = aktRess.Stahl;
             insertQry.Parameters.Add("?vv", MySqlDbType.UInt32).Value = aktRess.VV4A;
             insertQry.Parameters.Add("?ch", MySqlDbType.UInt32).Value = aktRess.Chemie;
             insertQry.Parameters.Add("?ei", MySqlDbType.UInt32).Value = aktRess.Eis;
             insertQry.Parameters.Add("?wa", MySqlDbType.UInt32).Value = aktRess.Wasser;
             insertQry.Parameters.Add("?en", MySqlDbType.UInt32).Value = aktRess.Energie;
             insertQry.Parameters.Add("?vFe", MySqlDbType.Int32).Value = vRess.Eisen * 100;
             insertQry.Parameters.Add("?vSt", MySqlDbType.Int32).Value = vRess.Stahl * 100;
             insertQry.Parameters.Add("?vVv", MySqlDbType.Int32).Value = vRess.VV4A * 100;
             insertQry.Parameters.Add("?vCh", MySqlDbType.Int32).Value = vRess.Chemie * 100;
             insertQry.Parameters.Add("?vEi", MySqlDbType.Int32).Value = vRess.Eis * 100;
             insertQry.Parameters.Add("?vWa", MySqlDbType.Int32).Value = vRess.Wasser * 100;
             insertQry.Parameters.Add("?vEn", MySqlDbType.Int32).Value = vRess.Energie * 100;
             insertQry.Parameters.Add("?lCh", MySqlDbType.UInt32).Value = lager.Chemie;
             insertQry.Parameters.Add("?lEi", MySqlDbType.UInt32).Value = lager.Eis;
             insertQry.Parameters.Add("?lWa", MySqlDbType.UInt32).Value = lager.Wasser;
             insertQry.Parameters.Add("?lEn", MySqlDbType.UInt32).Value = lager.Energie;
             insertQry.Parameters.Add("?time", MySqlDbType.UInt32).Value = unixnow;
             insertQry.ExecuteNonQuery();
         }
         resp.Respond("Ressourcenkoloübersicht eingelesen!\n");
     }
 }
Ejemplo n.º 7
0
        public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
        {
            foreach (Match outerMatch in matches) {
                uint creditsGes = (uint)Math.Round(float.Parse(outerMatch.Groups[4].Value));
                float globalFpMod = float.Parse(outerMatch.Groups[2].Value)+float.Parse(outerMatch.Groups[3].Value);
                String dot = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator;
                String comma = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
                MatchCollection c = Regex.Matches(outerMatch.Groups[1].Value, KolonieName + @"\s+(\d+):(\d+):(\d+)\s+([\d"+dot+comma+@"]+)\s+
            \([^)]+\)\)\s+(\S+)\s+\d+%\s+\S+\s+/\s+(\S+)\s+/\s+\S+\s+
            \(([^)]+)\)\s+(?:(\S+)\s+
            \(([^)]+)\))?", RegexOptions.IgnorePatternWhitespace);
                if (c.Count == 0)
                    return;
                int planiCnt = c.Count;
                float creditsAllysteuer = float.Parse(outerMatch.Groups[5].Value) / planiCnt;
                foreach (Match innerMatch in c) {
                    uint gala = uint.Parse(innerMatch.Groups[1].Value);
                    uint sys = uint.Parse(innerMatch.Groups[2].Value);
                    uint pla = uint.Parse(innerMatch.Groups[3].Value);
                    float fp = globalFpMod*float.Parse(innerMatch.Groups[4].Value);
                    float creds = float.Parse(innerMatch.Groups[5].Value);
                    uint bev = uint.Parse(innerMatch.Groups[6].Value, System.Globalization.NumberStyles.Integer|System.Globalization.NumberStyles.AllowThousands);
                    int vBev = int.Parse(innerMatch.Groups[7].Value, System.Globalization.NumberStyles.Integer | System.Globalization.NumberStyles.AllowThousands);
                    float zu, vZu;
                    if (innerMatch.Groups[8].Length > 0) {
                        zu = float.Parse(innerMatch.Groups[8].Value);
                        vZu = float.Parse(innerMatch.Groups[9].Value);
                    } else {
                        zu = 100;
                        vZu = 0;
                    }

                    uint insertFP = (uint)Math.Round(fp * 100);
                    int realCreds = (int)Math.Round((creds + creditsAllysteuer) * 100);
                    uint realZu = (uint)Math.Round(zu * 100);
                    int realVZu = (int)Math.Round(vZu * 100);

                    MySqlCommand planIdQry = new MySqlCommand("SELECT id from " + DBPrefix + "universum WHERE sys=?sys AND gala=?gala AND pla=?pla", con);
                    planIdQry.Parameters.Add("?sys", MySqlDbType.UInt32).Value = sys;
                    planIdQry.Parameters.Add("?gala", MySqlDbType.UInt32).Value = gala;
                    planIdQry.Parameters.Add("?pla", MySqlDbType.UInt32).Value = pla;
                    object res = planIdQry.ExecuteScalar();
                    if (res == null || Convert.IsDBNull(res)) {
                        resp.RespondError("Universumsdaten fehlerhaft oder unvollständig!\n");
                        continue;
                    }
                    uint planid = (uint)res;
                    MySqlCommand updateQry = new MySqlCommand("UPDATE " + DBPrefix + @"ressuebersicht
            SET fp=?fp, cr=?cr, bev=?bev, zu=?zu, vCr=?vCr, vBev=?vBev, vZu=?vZu
            WHERE planid=?planid", con);
                    updateQry.Parameters.Add("?fp", MySqlDbType.UInt32).Value = insertFP;
                    updateQry.Parameters.Add("?cr", MySqlDbType.UInt32).Value = creditsGes;
                    updateQry.Parameters.Add("?bev", MySqlDbType.UInt32).Value = bev;
                    updateQry.Parameters.Add("?zu", MySqlDbType.UInt32).Value = realZu;
                    updateQry.Parameters.Add("?vCr", MySqlDbType.Int32).Value = realCreds;
                    updateQry.Parameters.Add("?vBev", MySqlDbType.Int32).Value = vBev;
                    updateQry.Parameters.Add("?vZu", MySqlDbType.Int32).Value = realVZu;
                    updateQry.Parameters.Add("?planid", MySqlDbType.UInt32).Value = planid;
                    updateQry.ExecuteNonQuery();
                }
                resp.Respond("RessourcenKoloÜbersicht Teil 2 eingelesen!\n");
            }
        }
Ejemplo n.º 8
0
        public override void Matched(System.Text.RegularExpressions.MatchCollection matches, uint posterID, uint victimID, DateTime now, MySql.Data.MySqlClient.MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
        {
            foreach (Match outerMatch in matches) {
                uint time = IWDBUtils.parseIWTime(outerMatch.Groups[1].Value);
                MatchCollection c = Regex.Matches(outerMatch.Groups[2].Value, @"(\d+)\s+("+SpielerName+@")\s+("+AllyTag+@")?\s+("+Number+")\\s+("+Number+")\\s+("+Number+")\\s+("+DecimalNumber+@")\s+(-?"+Number+")\\s+("+Datum+")");
                MySqlCommand ins = new MySqlCommand("INSERT IGNORE INTO "+DBPrefix+"highscore (time, pos, name, ally, gebp, forp, gesp, ppd, diff, dabei) VALUES (?time, ?pos, ?name, ?ally, ?gebp, ?forp, ?gesp, ?ppd, ?diff, ?dabei)", con);
                ins.Parameters.Add("?time", MySqlDbType.UInt32).Value = time;
                MySqlParameter pPos = ins.Parameters.Add("?pos", MySqlDbType.UInt32);
                MySqlParameter pName = ins.Parameters.Add("?name", MySqlDbType.String);
                MySqlParameter pAlly = ins.Parameters.Add("?ally", MySqlDbType.String);
                MySqlParameter pGebp = ins.Parameters.Add("?gebp", MySqlDbType.UInt32);
                MySqlParameter pForp = ins.Parameters.Add("?forp", MySqlDbType.UInt32);
                MySqlParameter pGesp = ins.Parameters.Add("?gesp", MySqlDbType.UInt32);
                MySqlParameter pPpd = ins.Parameters.Add("?ppd", MySqlDbType.Double);
                MySqlParameter pDiff = ins.Parameters.Add("?diff", MySqlDbType.Int32);
                MySqlParameter pDabei = ins.Parameters.Add("?dabei", MySqlDbType.UInt32);
                ins.Prepare();

                MySqlCommand insInactive = new MySqlCommand("INSERT INTO " + DBPrefix + @"highscore_inactive (name, since, until, gebp) VALUES (?name, ?since, ?until, ?gebp)
                    ON DUPLICATE KEY UPDATE
                        since = IF(gebp=VALUES(gebp),IF(since<VALUES(since),since,VALUES(since)), IF(since>VALUES(since),since,VALUES(since))),
                        until = IF(VALUES(until)>until,VALUES(until),until),
                        gebp  = IF(until < VALUES(until), VALUES(gebp), gebp)", con);
                MySqlParameter pInsName = insInactive.Parameters.Add("?name", MySqlDbType.String);
                insInactive.Parameters.Add("?since", MySqlDbType.UInt32).Value = time;
                insInactive.Parameters.Add("?until", MySqlDbType.UInt32).Value = time;
                MySqlParameter pInsGebp = insInactive.Parameters.Add("?gebp", MySqlDbType.UInt32);
                insInactive.Prepare();

                MySqlCommand unidataUpdate = new MySqlCommand("INSERT INTO " + DBPrefix + @"uni_userdata (name, allytag, updatetime) VALUES (?name, ?tag, ?time)
                    ON DUPLICATE KEY UPDATE
                        allytag = IF(updatetime<=VALUES(updatetime), VALUES(allytag), allytag),
                        updatetime = IF(updatetime<=VALUES(updatetime), VALUES(updatetime), updatetime)", con);
                MySqlParameter pUniName = unidataUpdate.Parameters.Add("?name", MySqlDbType.String);
                MySqlParameter pUniTag = unidataUpdate.Parameters.Add("?tag", MySqlDbType.String);
                unidataUpdate.Parameters.Add("?time", MySqlDbType.UInt32).Value = time;
                unidataUpdate.Prepare();

                foreach (Match m in c) {
                    pPos.Value = uint.Parse(m.Groups[1].Value);
                    pName.Value = m.Groups[2].Value;
                    pAlly.Value = m.Groups[3].Value;
                    pGebp.Value = uint.Parse(m.Groups[4].Value, System.Globalization.NumberStyles.Any);
                    pForp.Value = uint.Parse(m.Groups[5].Value, System.Globalization.NumberStyles.Any);
                    pGesp.Value = uint.Parse(m.Groups[6].Value, System.Globalization.NumberStyles.Any);
                    pPpd.Value = double.Parse(m.Groups[7].Value, System.Globalization.NumberStyles.Any);
                    pDiff.Value = int.Parse(m.Groups[8].Value, System.Globalization.NumberStyles.Any);
                    pDabei.Value = IWDBUtils.toUnixTimestamp(DateTime.ParseExact(m.Groups[9].Value, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.AssumeLocal|System.Globalization.DateTimeStyles.AdjustToUniversal));
                    if (ins.ExecuteNonQuery() == 0) {
                        resp.Respond("HS übersprungen!");
                        continue;
                    }

                    pInsName.Value = m.Groups[2].Value;
                    pInsGebp.Value = uint.Parse(m.Groups[4].Value, System.Globalization.NumberStyles.Any);
                    insInactive.ExecuteNonQuery();

                    pUniName.Value = m.Groups[2].Value;
                    String tag = m.Groups[3].Value;
                    pUniTag.Value = tag.Length < 2 ? tag : tag.Substring(1,tag.Length-2);
                    unidataUpdate.ExecuteNonQuery();

                    resp.Respond("HS eingelesen!");
                }
            }
        }
Ejemplo n.º 9
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!");
 }
Ejemplo n.º 10
0
        public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
        {
            foreach (Match m in matches) {

                MySqlCommand cleanup = new MySqlCommand(@"DELETE FROM techtree_useritems
            USING (" + DBPrefix + @"techtree_useritems AS techtree_useritems) INNER JOIN (" + DBPrefix + @"techtree_items AS techtree_items) ON techtree_items.ID=techtree_useritems.itemid
            WHERE techtree_useritems.uid=?uid AND techtree_items.type = 'for'", con);
                cleanup.Parameters.Add("?uid", MySqlDbType.UInt32).Value = victimID;
                cleanup.Prepare();
                cleanup.ExecuteNonQuery();

                String[] parts = m.Groups[1].Value.Split('\n');
                MySqlCommand idQry = new MySqlCommand(@"SELECT ID FROM " + DBPrefix + @"techtree_items WHERE Name=?name", con);
                idQry.Parameters.Add("?name", MySqlDbType.String);
                idQry.Prepare();

                MySqlCommand idInsert = new MySqlCommand(@"INSERT IGNORE INTO " + DBPrefix + @"techtree_useritems (uid, itemid, count) VALUES (?uid, ?itemid, 1)", con);
                idInsert.Parameters.Add("?uid", MySqlDbType.UInt32).Value = victimID;
                idInsert.Parameters.Add("?itemid", MySqlDbType.UInt32);
                idInsert.Prepare();

                foreach (String forschung in parts) {
                    idQry.Parameters["?name"].Value = forschung;
                    object res = idQry.ExecuteScalar();
                    if (res == null)
                        continue;
                    uint id = (uint)res;
                    idInsert.Parameters["?itemid"].Value = id;
                    idInsert.ExecuteNonQuery();
                }
            }
            resp.Respond("Forschungsübersicht eingelesen!");
        }
Ejemplo n.º 11
0
 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     foreach (Match m in matches) {
         TechtreeItem item = new TechtreeSchiff(m, DBPrefix);
         item.WriteToDB(con);
         resp.Respond("Schiffsinfo eingelesen!\n");
     }
 }
Ejemplo n.º 12
0
        public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
        {
            foreach (Match outerMatch in matches) {
                MySqlCommand cleanup = new MySqlCommand("DELETE FROM "+DBPrefix+"techtree_useritems WHERE uid=?uid AND coords <> ''", con);
                cleanup.Parameters.Add("?uid", MySqlDbType.UInt32).Value=victimID;
                cleanup.Prepare();
                cleanup.ExecuteNonQuery();

                MySqlCommand idQry = new MySqlCommand(@"SELECT ID FROM " + DBPrefix + "techtree_items WHERE Name=?name", con);
                idQry.Parameters.Add("?name", MySqlDbType.String);
                idQry.Prepare();

                MySqlCommand insert = new MySqlCommand(@"INSERT INTO "+DBPrefix+"techtree_useritems (uid, itemid, count, coords) VALUES (?uid, ?itemid, ?count, ?coords)", con);
                insert.Parameters.Add("?uid", MySqlDbType.UInt32).Value = victimID;
                insert.Parameters.Add("?itemid", MySqlDbType.UInt32);
                insert.Parameters.Add("?count", MySqlDbType.UInt32);
                insert.Parameters.Add("?coords", MySqlDbType.Enum);
                insert.Prepare();

                MatchCollection mc = Regex.Matches(outerMatch.Groups[1].Value, @"([a-zA-ZäöüÄÖÜ& ]+)\n
            ((?:\s+\d+:\d+:\d+\n\(.+\))+)\n
            ((?:.+?(?:\s\d*)+\n)+)", RegexOptions.IgnorePatternWhitespace);

                foreach (Match m in mc) {
                    MatchCollection koloMatches = Regex.Matches(m.Groups[2].Value, @"(\d+):(\d+):(\d+)\s+\((.+)\)");
                    List<Kolo> kolos = new List<Kolo>();
                    foreach (Match koloMatch in koloMatches) {
                        kolos.Add(new Kolo(koloMatch));
                    }
                    MatchCollection itemMatches = Regex.Matches(m.Groups[3].Value, @"(.+?)((?:\s\d*)+)\n");
                    foreach (Match itemMatch in itemMatches) {
                        String item = itemMatch.Groups[1].Value;
                        idQry.Parameters["?name"].Value = item;
                        object ItemID = idQry.ExecuteScalar();
                        if (ItemID == null)
                            continue;

                        insert.Parameters["?itemid"].Value = (uint)ItemID;
                        MatchCollection anzMatches = Regex.Matches(itemMatch.Groups[2].Value, @"\s(\d*)");
                        int i = 0;
                        foreach (Match anzahlMatch in anzMatches) {
                            if (anzahlMatch.Groups[1].Length == 0)
                                continue;
                            uint anz = uint.Parse(anzahlMatch.Groups[1].Value);
                            insert.Parameters["?count"].Value = anz;
                            insert.Parameters["?coords"].Value = kolos[i].Coords;
                            insert.ExecuteNonQuery();
                            ++i;
                        }
                    }
                }

            }
            resp.Respond("Gebäudeübersicht eingelesen!");
        }
Ejemplo n.º 13
0
        public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySql.Data.MySqlClient.MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
        {
            foreach (Match gebinfo in matches) {
                try {
                    TechtreeItem item = TechtreeGebäude.Parse(gebinfo.Value, DBPrefix);
                    if (item == null) {
                        resp.RespondError("Bei einem Gebäude ist das Einlesen fehlgeschlagen!");
                        continue;
                    }
                    item.WriteToDB(con);
                    resp.Respond("Gebäude " + item.Name + " eingelesen.\n");
                } catch (FormatException) {
                    resp.RespondError("Ein Formatfehler ist beim Einlesen eines Gebäudes aufgetreten! Sind die Tausendertrennzeichen richtig eingestellt?");
                    continue;
                }

            }
        }
Ejemplo n.º 14
0
 public bool ToDB(MySqlConnection con, String DBPrefix, BesonderheitenData dta, ParserResponse resp, String desc)
 {
     PlaniFetcher f = new PlaniFetcher(dta, con, DBPrefix) {Gala = zielGala, Sys=zielSys, Pla=zielPla};
     List<PlaniInfo> ids = f.FetchMatching(PlaniDataFlags.ID);
     if (ids.Count == 0) {
         resp.RespondError(desc+" übersprungen, Unidaten fehlerhaft bei " + zielGala + ":" + zielSys);
         return false;
     }
     uint planid = ids[0].ID;
     MySqlCommand cmd = new MySqlCommand("INSERT IGNORE INTO " + DBPrefix + "bilanz (planid, empfaenger, absender, zeit, eisen, stahl, chemie, vv4a, eis, wasser, energie, bev) VALUES (?planid, ?empf, ?abs, ?zeit, ?fe, ?st, ?ch, ?vv, ?ei, ?wa, ?en, ?bev)", con);
     cmd.Parameters.Add("?planid", MySqlDbType.UInt32).Value = planid;
     cmd.Parameters.Add("?empf", MySqlDbType.String).Value = empfänger;
     cmd.Parameters.Add("?abs", MySqlDbType.String).Value = absender;
     cmd.Parameters.Add("?zeit", MySqlDbType.UInt32).Value = ankunftszeit;
     cmd.Parameters.Add("?fe", MySqlDbType.UInt32).Value = eisen;
     cmd.Parameters.Add("?st", MySqlDbType.UInt32).Value = stahl;
     cmd.Parameters.Add("?ch", MySqlDbType.UInt32).Value = chem;
     cmd.Parameters.Add("?vv", MySqlDbType.UInt32).Value = vv4a;
     cmd.Parameters.Add("?ei", MySqlDbType.UInt32).Value = eis;
     cmd.Parameters.Add("?wa", MySqlDbType.UInt32).Value = wasser;
     cmd.Parameters.Add("?en", MySqlDbType.UInt32).Value = energie;
     cmd.Parameters.Add("?bev", MySqlDbType.UInt32).Value = bev;
     if (cmd.ExecuteNonQuery() == 0)
         resp.Respond("Bereits bekannten "+desc+" übersprungen!");
     else
         resp.Respond(desc+" eingelesen!");
     return true;
 }