コード例 #1
0
        internal static bool DeleteArchivedPlayer(string player)
        {
            bool deleted = false;

            var dir = ConfigUtil.GetArchiveDir() + @"/" + player;

            if (Directory.Exists(dir))
            {
                try
                {
                    Directory.Delete(dir, true);
                    deleted = true;
                }
                catch (IOException ex)
                {
                    LOG.Error(ex);
                }
                catch (UnauthorizedAccessException uax)
                {
                    LOG.Error(uax);
                }
            }

            return(deleted);
        }
コード例 #2
0
        internal ChatManager()
        {
            try
            {
                CurrentPlayer = ConfigUtil.PlayerName + "." + ConfigUtil.ServerName;
                PLAYER_DIR    = ConfigUtil.GetArchiveDir() + CurrentPlayer;

                if (!Directory.Exists(PLAYER_DIR))
                {
                    // create config dir if it doesn't exist
                    Directory.CreateDirectory(PLAYER_DIR);
                }

                GetSavedChannels(CurrentPlayer).ForEach(channel => ChannelCache[channel] = 1);
                GetPlayers(CurrentPlayer).ForEach(channel => PlayerCache[channel]        = 1);
            }
            catch (IOException ex)
            {
                LOG.Error(ex);
            }
            catch (UnauthorizedAccessException uax)
            {
                LOG.Error(uax);
            }
        }
コード例 #3
0
        private static List <string> GetSavedChannels(string playerAndServer)
        {
            string playerDir = ConfigUtil.GetArchiveDir() + playerAndServer;
            var    file      = playerDir + @"\channels.txt";

            return(ConfigUtil.ReadList(file));
        }
コード例 #4
0
        internal static List <string> GetPlayers(string playerAndServer)
        {
            string playerDir = ConfigUtil.GetArchiveDir() + playerAndServer;
            var    file      = playerDir + @"\players.txt";

            return(ConfigUtil.ReadList(file));
        }
コード例 #5
0
        internal static List <string> GetArchivedPlayers()
        {
            var result = new List <string>();

            if (Directory.Exists(ConfigUtil.GetArchiveDir()))
            {
                foreach (var dir in Directory.GetDirectories(ConfigUtil.GetArchiveDir()))
                {
                    string name  = Path.GetFileName(dir);
                    var    split = name.Split('.');

                    if (split.Length > 1 && split[1].Length > 3)
                    {
                        bool found = false;
                        foreach (var sub in Directory.GetDirectories(dir))
                        {
                            if (int.TryParse(Path.GetFileName(sub), out int year))
                            {
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            result.Add(name);
                        }
                    }
                }
            }

            return(result.OrderBy(name => name).ToList());
        }
コード例 #6
0
        private static List <string> GetSelectedChannels(string playerAndServer)
        {
            List <string> result    = null; // throw null to check case where file has never existed vs empty content
            var           playerDir = ConfigUtil.GetArchiveDir() + playerAndServer;
            string        fileName  = playerDir + @"\" + SELECTED_CHANNELS_FILE;

            if (File.Exists(fileName))
            {
                result = ConfigUtil.ReadList(fileName);
            }
            return(result);
        }
コード例 #7
0
        internal ChatIterator(string playerAndServer, ChatFilter ChatFilter)
        {
            Home = ConfigUtil.GetArchiveDir() + playerAndServer;
            CurrentChatFilter = ChatFilter;

            if (Directory.Exists(Home))
            {
                var years = Directory.GetDirectories(Home);
                if (years.Length > 0)
                {
                    Directories = years.ToList().OrderByDescending(year => year).ToList();
                    GetNextYear();
                }
            }
        }
コード例 #8
0
 internal static void SaveSelectedChannels(string playerAndServer, List <string> channels)
 {
     try
     {
         // create config dir if it doesn't exist
         Directory.CreateDirectory(ConfigUtil.GetArchiveDir() + playerAndServer);
         ConfigUtil.SaveList(ConfigUtil.GetArchiveDir() + playerAndServer + @"\" + SELECTED_CHANNELS_FILE, channels);
     }
     catch (IOException ex)
     {
         LOG.Error(ex);
     }
     catch (UnauthorizedAccessException uax)
     {
         LOG.Error(uax);
     }
 }