/// <summary> /// Return a list of channels for the GUI to display /// </summary> /// <param name="reload"></param> /// <param name="progressCallback"></param> /// <param name="feedbackCallback"></param> /// <returns></returns> public List <ImportGuideChannel> GetAllImportChannels( bool reload, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { List <ImportGuideChannel> ligc = new List <ImportGuideChannel>(); if (reload) { try { GiveFeedback(feedbackCallback, "Calling SchedulesDirect JSON WebService ..."); WebClient wc = WebClient.getInstance(); TokenRequest tr = new TokenRequest(ConfigInstance.Current.SDUserName, ConfigInstance.Current.SDPassword); List <AssignedLineupsResponse.Lineup> lineups = wc.getAssignedLineups(tr); GiveFeedback(feedbackCallback, "Got the lineups.... " + lineups.Count + " lineup assigned"); foreach (AssignedLineupsResponse.Lineup lu in lineups) { GiveFeedback(feedbackCallback, "Get channels for " + lu.name); LineupInfoResponse liur = wc.getLineupInfo(tr, lu.uri); GiveFeedback(feedbackCallback, "Got a bunch of channels: " + liur.stations.Count); List <ImportGuideChannel> localLigc = ChannelFactory.makeImportChannels(liur, ConfigInstance.Current.ChannelNameFormat); ligc.AddRange(localLigc); } GuideChannelStore.Save(AvailableChannelsConfigFile, ligc); } catch (Exception ex) { Logger.Error("Had a problem importing channels: {0}\n{1}", ex.Message, ex.StackTrace); throw; } } else { // read from file List <ImportGuideChannel> availableGuideChannels = GuideChannelStore.Load(AvailableChannelsConfigFile); ligc.AddRange(availableGuideChannels); } return(ligc); }
private List <string> getStationIdList(List <ImportGuideChannel> skipChannels) { List <ImportGuideChannel> allChannels = GuideChannelStore.Load(AvailableChannelsConfigFile); Dictionary <string, ImportGuideChannel> allChannelsMap = new Dictionary <string, ImportGuideChannel>(); foreach (ImportGuideChannel igc in allChannels) { allChannelsMap.Add(igc.ExternalId, igc); } // remove skipped channels foreach (ImportGuideChannel igc in skipChannels) { allChannelsMap.Remove(igc.ExternalId); } List <string> channelsToImport = new List <string>(); channelsToImport.AddRange(allChannelsMap.Keys); return(channelsToImport); }