Пример #1
0
        public void WriteStatus(string nick, string host, string place, item.Action action, string newnick = "", string reason = "")
        {
            item user = null;

            lock (GlobalList)
            {
                foreach (item xx in GlobalList)
                {
                    if (nick.ToUpper() == xx.nick.ToUpper())
                    {
                        user = xx;
                        break;
                    }
                }
                if (user == null)
                {
                    user = new item(nick, host, place, action, null, newnick, reason);
                    GlobalList.Add(user);
                }
                else
                {
                    user.nick      = nick;
                    user.LastAc    = action;
                    user.LastSeen  = DateTime.Now;
                    user.hostname  = host;
                    user.lastplace = place;
                    user.quit      = reason;
                    user.newnick   = newnick;
                }
            }
            save = true;
        }
Пример #2
0
        public void LoadData()
        {
            SearchHostThread = new Thread(StartRegex)
            {
                Name = "Module:Seen/SearchHostThread"
            };
            Core.ThreadManager.RegisterThread(SearchHostThread);
            SearchHostThread.Start();
            try
            {
                Core.RecoverFile(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "seen.db");
                if (File.Exists(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "seen.db"))
                {
                    GlobalList = new List <item>();
                    lock (GlobalList)
                    {
                        XmlDocument stat = new XmlDocument();
                        stat.Load(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "seen.db");
                        if (stat.ChildNodes[0].ChildNodes.Count > 0)
                        {
                            foreach (XmlNode curr in stat.ChildNodes[0].ChildNodes)
                            {
                                try
                                {
                                    string      user   = curr.Attributes[0].Value;
                                    item.Action action = item.Action.Exit;
                                    switch (curr.Attributes[3].Value)
                                    {
                                    case "Join":
                                        action = item.Action.Join;
                                        break;

                                    case "Part":
                                        action = item.Action.Part;
                                        break;

                                    case "Talk":
                                        action = item.Action.Talk;
                                        break;

                                    case "Kick":
                                        action = item.Action.Kick;
                                        break;

                                    case "Nick":
                                        action = item.Action.Nick;
                                        break;
                                    }
                                    string Newnick = "";
                                    string Reason  = "";
                                    if (curr.Attributes.Count > 4)
                                    {
                                        if (curr.Attributes[4].Name == "newnick")
                                        {
                                            Newnick = curr.Attributes[4].Value;
                                        }
                                        else if (curr.Attributes[4].Name == "reason")
                                        {
                                            Reason = curr.Attributes[5].Value;
                                        }
                                    }
                                    if (curr.Attributes.Count > 5)
                                    {
                                        if (curr.Attributes[5].Name == "reason")
                                        {
                                            Reason = curr.Attributes[5].Value;
                                        }
                                    }
                                    item User = new item(user, curr.Attributes[1].Value, curr.Attributes[2].Value, action, curr.Attributes[4].Value, Newnick, Reason);
                                    GlobalList.Add(User);
                                }
                                catch (Exception fail)
                                {
                                    HandleException(fail);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception f)
            {
                HandleException(f);
            }
        }
Пример #3
0
        public void LoadData()
        {
            SearchHostThread = new Thread(StartRegex);
            SearchHostThread.Start();
            try
            {
                core.recoverFile(variables.config + System.IO.Path.DirectorySeparatorChar + "seen.db");
                if (System.IO.File.Exists(variables.config + System.IO.Path.DirectorySeparatorChar + "seen.db"))
                {
                    lock (global)
                    {
                        global = new List <item>();
                        XmlDocument stat = new XmlDocument();
                        stat.Load(variables.config + System.IO.Path.DirectorySeparatorChar + "seen.db");
                        if (stat.ChildNodes[0].ChildNodes.Count > 0)
                        {
                            foreach (XmlNode curr in stat.ChildNodes[0].ChildNodes)
                            {
                                try
                                {
                                    string      user   = curr.Attributes[0].Value;
                                    item.Action action = item.Action.Exit;
                                    switch (curr.Attributes[3].Value)
                                    {
                                    case "Join":
                                        action = item.Action.Join;
                                        break;

                                    case "Part":
                                        action = item.Action.Part;
                                        break;

                                    case "Talk":
                                        action = item.Action.Talk;
                                        break;

                                    case "Kick":
                                        action = item.Action.Kick;
                                        break;

                                    case "Nick":
                                        action = item.Action.Nick;
                                        break;
                                    }
                                    string Newnick = "";
                                    string Reason  = "";
                                    if (curr.Attributes.Count > 4)
                                    {
                                        if (curr.Attributes[4].Name == "newnick")
                                        {
                                            Newnick = curr.Attributes[4].Value;
                                        }
                                        else if (curr.Attributes[4].Name == "reason")
                                        {
                                            Reason = curr.Attributes[5].Value;
                                        }
                                    }
                                    if (curr.Attributes.Count > 5)
                                    {
                                        if (curr.Attributes[5].Name == "reason")
                                        {
                                            Reason = curr.Attributes[5].Value;
                                        }
                                    }
                                    item User = new item(user, curr.Attributes[1].Value, curr.Attributes[2].Value, action, curr.Attributes[4].Value, Newnick, Reason);
                                    global.Add(User);
                                }
                                catch (Exception fail)
                                {
                                    handleException(fail);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception f)
            {
                handleException(f);
            }
        }