public Dictionary <string, ChanFav> GetFavoriteList(string server) { if (_ChannelFavorites == null) { _ChannelFavorites = new Dictionary <string, ChanFav>(); } _ChannelFavorites.Clear(); curServer = server; SavedSet.ChannelFavoritesDataTable dtFavs = GetFavorites(); DataView dv = new DataView(dtFavs); dv.RowFilter = "servername = '" + server + "'"; foreach (DataRowView drv in dv) { ChanFav cf = new ChanFav(); cf.channel = drv["channel"].ToString(); if (drv["NotifyMinute"] != DBNull.Value) { cf.NotifyMinute = Convert.ToInt32(drv["NotifyMinute"]); } if (drv["phonetic"] != DBNull.Value) { cf.Phonetic = drv["phonetic"].ToString(); } if (drv["last"] != DBNull.Value) { cf.Last = Convert.ToDateTime(drv["last"]); } _ChannelFavorites.Add(cf.channel, cf); } return(_ChannelFavorites); }
public void AddChannels(string server, string[] channellist) { if (_ChannelFavorites == null) { _ChannelFavorites = new Dictionary <string, ChanFav>(); } _ChannelFavorites.Clear(); SavedSet.ChannelFavoritesDataTable dtFavs = GetFavorites(); DataView dv = new DataView(dtFavs); dv.RowFilter = "servername = '" + server + "'"; foreach (DataRowView drv in dv) { ChanFav cf = new ChanFav(); cf.channel = drv["channel"].ToString(); _ChannelFavorites.Add(cf.channel, cf); } foreach (string fav in channellist) { if (!_ChannelFavorites.ContainsKey(fav)) { //Add favorite to list ChanFav cf = new ChanFav(fav); _ChannelFavorites.Add(cf.channel, cf); SavedSet.ChannelFavoritesRow cfr = dtFavs.NewChannelFavoritesRow(); cfr.Channel = fav; cfr.servername = server; dtFavs.AddChannelFavoritesRow(cfr); } } data.WriteXml(Application.UserAppDataPath + "\\IRCAL.xml"); }
internal void UpdateChanFavLast() { SavedSet.ChannelFavoritesDataTable dtFavs = GetFavorites(); foreach (SavedSet.ChannelFavoritesRow cfr in dtFavs) { if (cfr["Channel"] == DBNull.Value) { continue; } if (cfr.Channel == _CurChannel && cfr.servername == curServer) { cfr.Last = DateTime.Now; break; } } }
public void RemoveChannels(string server, string[] channellist) { if (_ChannelFavorites == null) { _ChannelFavorites = new Dictionary <string, ChanFav>(); } _ChannelFavorites.Clear(); SavedSet.ChannelFavoritesDataTable dtFavs = GetFavorites(); DataView dv = new DataView(dtFavs); dv.RowFilter = "servername = '" + server + "'"; foreach (DataRowView drv in dv) { ChanFav cf = new ChanFav(); cf.channel = drv["channel"].ToString(); _ChannelFavorites.Add(cf.channel, cf); } SavedSet.ChannelFavoritesRow cfr; foreach (string fav in channellist) { if (_ChannelFavorites.ContainsKey(fav)) { //Add favorite to list _ChannelFavorites.Remove(fav); for (int i = 0; i < data.ChannelFavorites.Count; i++) { cfr = data.ChannelFavorites[i]; if (cfr["Channel"] != DBNull.Value && cfr.Channel == fav) { data.ChannelFavorites.RemoveChannelFavoritesRow(cfr); } } } } data.WriteXml(Application.UserAppDataPath + "\\IRCAL.xml"); }
internal void UpdateChanFav(string server, string chan, Int32 Notify, string Phonetic) { SavedSet.ChannelFavoritesDataTable dtFavs = GetFavorites(); SavedSet.ChannelFavoritesRow cfr; for (int i = 0; i < dtFavs.Count; i++) { cfr = dtFavs[i]; if (cfr["Channel"] == DBNull.Value) { dtFavs.RemoveChannelFavoritesRow(cfr); i--; continue; } if (cfr.Channel == chan && cfr.servername == server) { cfr.Phonetic = Phonetic; cfr.NotifyMinute = Notify; break; } } Save(); }