Esempio n. 1
0
 private void GetInvolvedPlayers(Kill kill, StringReader reader)
 {
     kill.Killers.Add(GetInvolved(reader));
         MoveReader(reader, 1);
         while (HasMoreInvolved(reader))
         {
             kill.Killers.Add(GetInvolved(reader));
         }
 }
Esempio n. 2
0
        private Player GetVictim(StringReader reader, Kill k)
        {
            Player P = new Player();
                List<string> victim = ReadLines(reader, 8);
                P.Name = victim[0].Replace("Victim: ", "");
                P.Corp = victim[1].Replace("Corp: ", "");
                P.Alliance = victim[2].Replace("Alliance: ", "");
                P.Faction = victim[3].Replace("Faction: ", "");
                P.Ship = new Ship {Name = victim[4].Replace("Destroyed: ", "")};
                k.System = victim[5].Replace("System: ", "");

                return P;
        }
Esempio n. 3
0
        public Kill ParseKillMail(string killMail)
        {
            StringReader reader = new StringReader(killMail);
                Kill kill = new Kill();

                try
                {
                    kill.Time = GetIncidentTime(reader);
                    MoveReader(reader, 1);
                    kill.Victim = GetVictim(reader, kill);
                    MoveReader(reader, 3);
                    GetInvolvedPlayers(kill, reader);
                }
                catch (Exception)
                {
                    kill.IsComplete = false;
                }
                return kill;
        }
Esempio n. 4
0
        private void InsertKill(Kill kill, SQLiteConnection conn)
        {
            // Make sure that we haven't stored this
            // kill already
            bool found = false;
            using (SQLiteCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = "SELECT * " +
                                  "FROM Seen LEFT OUTER JOIN " +
                                  "Kill ON Seen.KillID = Kill.ID " +
                                  "WHERE (Seen.Player = @NAME) AND (Seen.Ship = @SHIP) AND " +
                                  "(Seen.isKiller = 0) AND (Kill.System = @SYSTEM) AND (Kill.[Time] = @TIME)";
                cmd.Parameters.AddWithValue("@NAME", kill.Victim.Name);
                cmd.Parameters.AddWithValue("@SHIP", kill.Victim.Ship.Name);
                cmd.Parameters.AddWithValue("@SYSTEM", kill.System);
                cmd.Parameters.AddWithValue("@TIME", kill.Time);

                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    found = reader.HasRows;
                }
            }

            if (found)
                return;

            Int64 id;
            using (SQLiteCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = "insert into Kill(System, Time) values(@SYSTEM, @TIME);";
                cmd.Parameters.AddWithValue("@SYSTEM", kill.System);
                cmd.Parameters.AddWithValue("@TIME", kill.Time);
                cmd.ExecuteNonQuery();

                cmd.Parameters.Clear();

                cmd.CommandText = "SELECT last_insert_rowid()";
                object ret = cmd.ExecuteScalar();
                id = (Int64) ret;
            }

            InsertSeen(kill.Victim, false, id, conn);
            foreach (var killer in kill.Killers)
                InsertSeen(killer, true, id, conn);
        }
Esempio n. 5
0
        private List<Kill> ParseKillMails(List<KillTime> Kills)
        {
            var ret = new List<Kill>();

            ReportProgress("Downloading killmails");
            Log.Info(String.Format("Got {0} killmails to parse", Kills.Count));

            foreach (KillTime Kill in Kills)
            {
                if(Worker.CancellationPending)
                {
                    WorkEventArgs.Cancel = true;
                    return ret;
                }

                var kill = new Kill();

                if(ret.Count % 20 == 0)
                {
                    ReportProgress(String.Format("{0} of {1} killmails downloaded", ret.Count, Kills.Count));
                }

                Document = DownloadDocument("http://www.battleclinic.com/eve_online/pk/" + Kill.Url);

                #region Victim Regex
                // Killmail Details[\W\w]+Victim:</td>[\W]+<td>(.*?">)?(?<MATCH>.+?)<
                // Killmail Details[\W\w]+Corporation:</td>[\W]+<td>(.*?">)?(?<MATCH>.+?)<
                // Killmail Details[\W\w]+Alliance</td>[\W]+<td>(.*?">)?(?<MATCH>.+?)<
                // Killmail Details[\W\w]*?Ship:</td>[\W]+<td>(?<MATCH>.+?)[\W]
                // Killmail Details[\W\w]*?Location:</td>\W+(.+?)">(?<MATCH>.+?)<
                #endregion
                string Name = GetCustomRegexContent(@"Killmail Details[\W\w]+Victim:</td>[\W]+<td>(.*?"">)?(?<MATCH>.+?)<");
                string Corp =
                    GetCustomRegexContent("Killmail Details[\\W\\w]+Corporation:</td>[\\W]+<td>(.*?\">)?(?<MATCH>.+?)<");
                string Alliance =
                    GetCustomRegexContent("Killmail Details[\\W\\w]+Alliance</td>[\\W]+<td>(.*?\">)?(?<MATCH>.+?)<");
                string Ship = GetCustomRegexContent("Killmail Details[\\W\\w]*?Ship:</td>[\\W]+<td>(?<MATCH>.+?)[\\W]");
                string Loc = GetCustomRegexContent("Killmail Details[\\W\\w]*?Location:</td>\\W+(.+?)\">(?<MATCH>.+?)<");

                var victim = new Player {Alliance = Alliance, Corp = Corp, Name = Name, Ship = new Ship{ Name = Ship}};

                kill.Victim = victim;
                kill.System = Loc;
                kill.Time = Kill.Time;

                #region Killer Regex
                // >Name:</td>[\W]+<td\sc(.*">)(?<MATCH>.+?)</a>
                // >Corp:</td>[\W]+<td\sc(.*">)(?<MATCH>.+?)</a>
                // >Alliance</td>[\W]+<td\sc(.*">)(?<MATCH>.+?)</a>
                // >Ship:</td>[\W]+<td\scolspan="2">[\W]+(.+?)[\W]+[(</td>)|(Damage)]
                #endregion
                var Names = GetMatchList(">Name:</td>[\\W]+<td\\sc(.*\">)(?<MATCH>.+?)</a>");
                var Corps = GetMatchList(">Corp:</td>[\\W]+<td\\sc(.*\">)(?<MATCH>.+?)</a>");
                var Alliances = GetMatchList(">Alliance</td>[\\W]+<td\\sc(.*\">)(?<MATCH>.+?)</a>");
                var Ships = GetMatchList(">Ship:</td>[\\W]+<td\\ colspan=\"2\">[\\W]+(?<MATCH>.+?)[\\W]+[(</td>)|(Damage)]");
                for(int i = 0; i < Names.Count; i++)
                {
                    var Killer = new Player
                                     {
                                         Name = Names[i],
                                         Alliance = Alliances[i],
                                         Ship = new Ship {Name = Ships[i]},
                                         Corp = Corps[i]
                                     };

                    kill.Killers.Add(Killer);
                }

                ret.Add(kill);
            }

            return ret;
        }