Example #1
0
        internal bool LoadMail()
        {
            XmlDocument file = new XmlDocument();
            string filename = Path.Combine(Path.Combine(_baseDirectory, GlobalConstants.LIB_ETC), "Mail.xml");

            try
            {
                file.Load(filename);
            }
            catch
            {
                SaveMail();

                file.Load(filename);
            }

            XmlNodeList list = file.GetElementsByTagName("MailData");
            int count = 0;

            foreach (XmlNode node in list)
            {
                MailData mail = new MailData();
                mail.To = long.Parse(node.Attributes["To"].Value);
                mail.From = long.Parse(node.Attributes["From"].Value);
                mail.MailTime = DateTime.Parse(node.Attributes["MailTime"].Value);
                mail.Content = node.InnerText;

                if (!_mail.ContainsKey(mail.To))
                    _mail.Add(mail.To, new List<MailData>());

                _mail[mail.To].Add(mail);
                count++;
            }

            Log("  "+count+" messages loaded.");

            return true;
        }
Example #2
0
        internal void StoreMail(long from, long to, string content)
        {
            MailData mail = new MailData();
            mail.To = to;
            mail.From = from;
            mail.Content = content;
            mail.MailTime = DateTime.Now;

            if (!_mail.ContainsKey(to))
                _mail.Add(to, new List<MailData>());

            _mail[to].Add(mail);
        }