Exemplo n.º 1
0
        public static MemoryStream ParseAttendance(string toon, string server)
        {
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms, Encoding.ASCII);

            string lastdumpfile = GetLastFile(FuEQ.GetEQFolderForToon(toon, server), String.Format("RaidRoster_{0}-*.txt", server));

            if (String.IsNullOrEmpty(lastdumpfile))
            {
                System.Windows.Forms.MessageBox.Show(String.Format("There were no files matching {0} in the {1} folder", "RaidRoster-*.txt", FuEQ.GetEQFolderForToon(toon, server)));
                return(ms);
            }

            try
            {
                string dump = File.ReadAllText(lastdumpfile);
                if (dump.Length > 0)
                {
                    sw.Write(dump);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show(String.Format("The file {0} was empty", lastdumpfile));
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(String.Format("An exception occurred - {0}", e.Message));
                return(ms); // failure reading file
            }
            sw.Flush();
            ms.Position = 0;
            return(ms);
        }
Exemplo n.º 2
0
        public static MemoryStream ParseRoster(string toon, string server)
        {
            // get the guild dump
            // looking for last file of format fu world order-<datetime>.txt in eq\Fu World Order-20161226-090424.txt

            MemoryStream ms           = new MemoryStream();
            StreamWriter sw           = new StreamWriter(ms, Encoding.ASCII);
            string       lastdumpfile = GetLastFile(FuEQ.GetEQFolderForToon(toon, server), String.Format("{0}_{1}-*.txt", Cfg.get("EqGuildName"), server));

            if (String.IsNullOrEmpty(lastdumpfile))
            {
                return(ms);
            }

            try
            {
                sw.Write(File.ReadAllText(lastdumpfile));
            }
            catch (Exception e)
            {
                return(ms); // failure reading file
            }
            sw.Flush();

            ms.Position = 0;
            return(ms);
        }
Exemplo n.º 3
0
        public static string ParseLootLookup(string toon, string server, float minutes, DateTime when, float megs)
        {
            // load the log file
            string logPath = Path.Combine(FuEQ.GetEQFolderForToon(toon, server), "Logs", String.Format("eqlog_{0}_{1}.txt", toon, server));

            // datetime format that EQ uses in log file
            string dateFormat = "ddd MMM dd HH:mm:ss yyyy";

            // "before" is a datetime after which we start caring about the log entries.
            DateTime before = when.AddMinutes(-minutes);

            string[] partFile = ReadLog(logPath, megs);

            // list of names
            List <string> names = new List <string>();

            DateTime d;

            foreach (string l in partFile)
            {
                // if the line doesnt contain at least the length of the date, ignore it
                if (l.Length < dateFormat.Length + 1)
                {
                    continue;
                }

                // get a DateTime out of the log for this line, ignore the line if it didnt work
                if (DateTime.TryParseExact(l.Substring(1, dateFormat.Length), dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out d) != false)
                {
                    // if the line is after the "before" date and contains a tell
                    if (
                        d >= before &&
                        (l.Contains("tells you") || l.Contains("told you"))
                        )
                    {
                        // extract the name and add it to the list
                        Regex re = new Regex(@"(\w+)\s+((tells)|(told))\s+you", RegexOptions.IgnoreCase);
                        Match m  = re.Match(l);
                        if (m.Success && !names.Contains(m.Groups[1].Value))
                        {
                            names.Add(m.Groups[1].Value);
                        }
                    }
                }
            }
            // stick list together with commas
            return(String.Join(",", names));
        }
Exemplo n.º 4
0
        public static MemoryStream ParseLoot(string toon, string server, float minutes, DateTime when, float megs)
        {
            // rather than writing the output to a file we'll use a memory stream
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms, Encoding.ASCII);

            // load the log file
            string logPath = Path.Combine(FuEQ.GetEQFolderForToon(toon, server), "Logs", String.Format("eqlog_{0}_{1}.txt", toon, server));

            // datetime format that EQ uses in log file
            string dateFormat = "ddd MMM dd HH:mm:ss yyyy";

            // "before" is a datetime after which we start caring about the log entries.  RaidHours is configurable in config file
            DateTime before = when.AddMinutes(-minutes);

            string[] partFile = ReadLog(logPath, megs);

            DateTime d;

            foreach (string l in partFile)
            {
                // if the line doesnt contain at least the length of the date, ignore it
                if (l.Length < dateFormat.Length + 1)
                {
                    continue;
                }

                // get a DateTime out of the log for this line, ignore the line if it didnt work
                if (DateTime.TryParseExact(l.Substring(1, dateFormat.Length), dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out d) != false)
                {
                    // if the line is after the "before" date and contains stuff we want, write it to the stream
                    if (
                        d >= before &&
                        (
                            l.Contains("You say to your guild") || // potential grats message from me
                            l.Contains("tells the guild") || // potential grats message from other
                            l.Contains("] --")    // potential looted message
                        )
                        )
                    {
                        sw.WriteLine(l);
                    }
                }
            }
            sw.Flush();
            ms.Position = 0;
            return(ms);
        }
Exemplo n.º 5
0
        private void LoadConfig()
        {
            cmbToons.Items.Clear();
            cmbToons.Items.AddRange(FuEQ.GetToons().ToArray());

            if (cmbToons.Items.Count > 0)
            {
                cmbToons.Enabled = true;
                if (m_currentToon.Length > 0 && m_currentServer.Length > 0)
                {
                    int i = cmbToons.Items.IndexOf(String.Format("{0} - {1}", m_currentServer, m_currentToon));
                    if (i > -1)
                    {
                        cmbToons.SelectedIndex = i;
                    }
                }
                else if (cmbToons.Items.Count > 0)
                {
                    cmbToons.SelectedIndex = 0;
                }
                string[] toonBits = cmbToons.Items[cmbToons.SelectedIndex].ToString().Split(new string[] { " - " }, StringSplitOptions.None);
                if (toonBits.Length == 2)
                {
                    m_currentToon   = toonBits[1];
                    m_currentServer = toonBits[0];
                    EnableRestOfUI();
                }
            }
            else
            {
                cmbToons.Enabled = false;
                // force them to add a toon
                DisableRestOfUI();
            }

            txtEqFolder.Text = FuEQ.GetEQFolderForToon(m_currentToon, m_currentServer);
//            txtEqFolder.Text = Cfg.get("EqFolder");
            txtLootMinutes.Text       = Cfg.get("LootMinutes");
            txtLootLookupMinutes.Text = Cfg.get("LootLookupMinutes");
            txtEqCharacter.Text       = "";
            txtEqServer.Text          = "bristle";
            txtFuUsername.Text        = Cfg.getEncrypted("HttpUsername");
            txtFuPassword.Text        = Cfg.getEncrypted("HttpPassword");
        }