Esempio n. 1
0
File: Raid.cs Progetto: esdkp/esdkp
        public void ParseAttendance(string logFile, string zo)
        {
            debugLogger.WriteDebug_3("Begin Method: Raid.ParseAttendance(string,string) (" + logFile.ToString() + "," + zo.ToString() + ")");

            string[] zones = zo.Split(new char[] { ' ' });
            string line;
            FileStream input;
            StreamReader sr;
            Regex regex = new Regex(@"\[.*\] \[.*\] (?<name>\S+).*<(?<guild>.*)> ZONE: (?<zone>.*)$");
            Match m;
            ArrayList people = new ArrayList();

            foreach (DataRow z in dbRaid.Rows)	people.Add(z.ItemArray[0]);

            try
            {
                input = new FileStream(logFile,FileMode.Open,FileAccess.Read);
                sr = new StreamReader(input);
            }
            catch (Exception ex)
            {
                debugLogger.WriteDebug_1("Failed to open log to parse: " + ex.Message);
                MessageBox.Show("File IO Error.\n(" + ex.Message + ")");
                return;
            }

            do
            {
                line = sr.ReadLine();

                if (line!=null)
                {
                    m = regex.Match(line);
                    if (m.Success)
                    {
                        string _guild = m.Groups["guild"].ToString();
                        string _zone = m.Groups["zone"].ToString();
                        string _name = m.Groups["name"].ToString();

                        if (owner.GuildNames.Contains(_guild) && zo.Contains(_zone) && !people.Contains(_name))
                        {
                            debugLogger.WriteDebug_2(_name + " <" + _guild + "> is in zone " + _zone + ", adding to people array.");
                            people.Add(_name);
                        }
                    }
                }
            } while (line!=null);

            sr.Close();
            input.Close();

            people.Sort();

            foreach (string s in people)
            {
                DataRow[] rows = dbPeople.Select("Name='" + s + "'");

                if (rows.Length > 0)
                {
                    DataRow[] rs = dbRaid.Select("Name='" + s + "' AND PTS>=0");
                    if (rs.Length == 0)
                    {
                        dbRaid.Rows.Add(new object[] { s, RaidDate, RaidName, 0, null, null });
                        debugLogger.WriteDebug_3("Added attendance row for " + s);
                    }
                }
                else
                {
                    string t = GetAlt(s);
                    if ((t != null && t.Length != 0))
                    {
                        if (!people.Contains(t))
                        {
                            DataRow[] rs = dbRaid.Select("Name='" + t + "' AND PTS>=0");
                            if (rs.Length == 0)
                            {
                                dbRaid.Rows.Add(new object[] { t, RaidDate, RaidName, 0, null, null });
                                debugLogger.WriteDebug_3("Added attendance row for " + t + " (Alt: " + s + ")");
                            }
                        }

                    }
                    else
                    {
                        AppAltDialog alt = new AppAltDialog(owner,s,dbPeople);
                        t = alt.GetName();
                        if ((t != null && t.Length != 0))
                        {
                            DataRow[] rs = dbRaid.Select("Name='" + t + "' AND PTS>=0");
                            if (rs.Length==0)
                            {
                                dbRaid.Rows.Add(new object[] {t,RaidDate,RaidName,0,null,null});
                                debugLogger.WriteDebug_3("Added attendance row for " + t);
                            }
                            if (t!=s) dbAlts.Rows.Add(new object[] {s,t});
                            altDA.Update(dbAlts);
                        }
                    }
                }

            }
            debugLogger.WriteDebug_3("Begin Method: Raid.ParseAttendance()");
        }
Esempio n. 2
0
File: Raid.cs Progetto: esdkp/esdkp
        public void ParseRaidDump(string logFile)
        {
            debugLogger.WriteDebug_3("Begin Method: Raid.ParseRaidDump(string) (" + logFile.ToString() + ")");

            FileStream input;
            StreamReader sr;
            string line;
            char[] delimiters = new char[] { '\t' };
            ArrayList people = new ArrayList();

            try
            {
                input = new FileStream(logFile, FileMode.Open, FileAccess.Read);
                sr = new StreamReader(input);
            }
            catch (Exception ex)
            {
                debugLogger.WriteDebug_1("Failed to open raid dump file to parse: " + ex.Message);
                MessageBox.Show("File IO Error.\n(" + ex.Message + ")");
                return;
            }

            do
            {
                line = sr.ReadLine();

                if (line == null)
                {
                    debugLogger.WriteDebug_3("Line in file empty, skipping");
                    break;
                }

                string[] parts = line.Split(delimiters);

                people.Add(parts[1]);
            } while (line != null);

            if (people.Count > 0)
            {
                MessageBox.Show("Found " + people.Count + " raiders including " + people[0] + ".");
            }

            foreach (string s in people)
            {
                DataRow[] rows = dbPeople.Select("Name='" + s + "'");

                if (rows.Length > 0)
                {
                    DataRow[] rs = dbRaid.Select("Name='" + s + "' AND PTS>=0");
                    if (rs.Length == 0)
                    {
                        dbRaid.Rows.Add(new object[] { s, RaidDate, RaidName, 0, null, null });
                        debugLogger.WriteDebug_3("Added attendance row for " + s);
                    }
                }
                else
                {
                    string t = GetAlt(s);
                    if ((t != null && t.Length != 0))
                    {
                        if (!people.Contains(t))
                        {
                            DataRow[] rs = dbRaid.Select("Name='" + t + "' AND PTS>=0");
                            if (rs.Length == 0)
                            {
                                dbRaid.Rows.Add(new object[] { t, RaidDate, RaidName, 0, null, null });
                                debugLogger.WriteDebug_3("Added attendance row for " + t + " (Alt: " + s + ")");
                            }
                        }

                    }
                    else
                    {
                        AppAltDialog alt = new AppAltDialog(owner, s, dbPeople);
                        t = alt.GetName();
                        if ((t != null && t.Length != 0))
                        {
                            DataRow[] rs = dbRaid.Select("Name='" + t + "' AND PTS>=0");
                            if (rs.Length == 0)
                            {
                                dbRaid.Rows.Add(new object[] { t, RaidDate, RaidName, 0, null, null });
                                debugLogger.WriteDebug_3("Added attendance row for " + t);
                            }
                            if (t != s) dbAlts.Rows.Add(new object[] { s, t });
                            altDA.Update(dbAlts);
                        }
                    }
                }

            }

            debugLogger.WriteDebug_3("End Method: Raid.ParseRaidDump()");
        }
Esempio n. 3
0
File: Raid.cs Progetto: esdkp/esdkp
        public void InputPerson(string s)
        {
            debugLogger.WriteDebug_3("Begin Method: Raid.InputPerson(string) (" + s.ToString() + ")");

            DataRow[] rows = dbPeople.Select("Name='" + s + "'");

            if (rows.Length > 0)
            {
                DataRow[] rs = dbRaid.Select("Name='" + s + "' AND PTS>=0");
                if (rs.Length == 0)
                {
                    dbRaid.Rows.Add(new object[] { s, RaidDate, RaidName, 0, null, null });
                    debugLogger.WriteDebug_3("Added person: " + s);
                }
            }
            else
            {
                string t = GetAlt(s);
                if ((t != null && t.Length != 0))
                {
                    if (dbRaid.Select("Name='" + t + "' AND PTS>=0").Length==0)
                    {
                        DataRow[] rs = dbRaid.Select("Name='" + t + "' AND PTS>=0");
                        if (rs.Length == 0)
                        {
                            dbRaid.Rows.Add(new object[] { t, RaidDate, RaidName, 0, null, null });
                            debugLogger.WriteDebug_3("Added person: " + t);
                        }

                    }

                }
                else
                {
                    if (!ignore.Contains(t))
                    {
                        AppAltDialog alt = new AppAltDialog(owner,s,dbPeople);
                        t = alt.GetName();
                        if ((t != null && t.Length != 0))
                        {
                            DataRow[] rs = dbRaid.Select("Name='" + t + "' AND PTS>=0");
                            if (rs.Length==0)
                            {
                                dbRaid.Rows.Add(new object[] {t,RaidDate,RaidName,0,null,null});
                                debugLogger.WriteDebug_3("Added person: " + t);
                            }
                            if (t!=s) dbAlts.Rows.Add(new object[] {s,t});
                            altDA.Update(dbAlts);
                        }
                        else { ignore.Add(t); }
                    }
                }
            }
        }