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); } }
private void ArchiveChat(object state) { try { List <ChatType> working = null; DateUtil dateUtil = new DateUtil(); DateUtil dateUtilSavedLines = new DateUtil(); lock (LockObject) { working = ChatTypes; ChatTypes = new List <ChatType>(); } for (int i = 0; i < working.Count; i++) { var chatType = working[i]; var chatLine = CreateLine(dateUtil, chatType.Line); DateTime dateTime = DateTime.MinValue.AddSeconds(chatLine.BeginTime); string year = dateTime.ToString("yyyy", CultureInfo.CurrentCulture); string month = dateTime.ToString("MM", CultureInfo.CurrentCulture); string day = dateTime.ToString("dd", CultureInfo.CurrentCulture); AddToArchive(year, month, day, chatLine, chatType, dateUtilSavedLines); } lock (LockObject) { if (ChatTypes.Count > 0) { ArchiveTimer?.Dispose(); ArchiveTimer = new Timer(new TimerCallback(ArchiveChat)); ArchiveTimer.Change(0, Timeout.Infinite); } else { SaveCurrent(true); if (ChannelCacheUpdated) { var current = ChannelCache.Keys.ToList(); ConfigUtil.SaveList(PLAYER_DIR + @"\channels.txt", current); ChannelCacheUpdated = false; EventsNewChannels?.Invoke(this, current); } if (PlayerCacheUpdated) { ConfigUtil.SaveList(PLAYER_DIR + @"\players.txt", PlayerCache.Keys.OrderBy(player => player) .Where(player => !PlayerManager.Instance.IsVerifiedPet(player)).ToList()); PlayerCacheUpdated = false; } EventsUpdatePlayer?.Invoke(this, CurrentPlayer); Running = false; } } } catch (ObjectDisposedException ex) { LOG.Error(ex); } }