public static Dictionary <string, string> makeChannelMap(LineupInfoResponse lir) { Dictionary <string, string> channelMap = new Dictionary <string, string>(); foreach (LineupInfoResponse.ChannelMap cm in lir.map) { if (!channelMap.ContainsKey(cm.stationID)) { if (lir.metadata.transport != null && lir.metadata.transport.ToLower().Equals("antenna")) { // Over the air channels have a uhfVhf channel and/or atscMajor/atsc minor // // example: // sometimes, uvfVhf is only present, sometimes just atsc stuff is present //{ // "stationID": "24504", // "uhfVhf": 9, // "atscMajor": 9, // "atscMinor": 9 //}, if (cm.atscMinor != null && cm.atscMajor != null && cm.uhfVhf != null) { // all three options are there if (ConfigInstance.Current.AntennaUseUhfVhfChannel) { channelMap.Add(cm.stationID, cm.uhfVhf); } else { channelMap.Add(cm.stationID, cm.atscMajor + "." + cm.atscMinor); } } else if (cm.uhfVhf != null) { channelMap.Add(cm.stationID, cm.uhfVhf); } else if (cm.atscMinor != null && cm.atscMajor != null) { channelMap.Add(cm.stationID, cm.atscMajor + "." + cm.atscMinor); } else { Logger.Info("There was a problem picking a Logical Channel Number for station ID: {0}", cm.stationID); } } else { channelMap.Add(cm.stationID, cm.channel); } } } return(channelMap); }
public void TestGetLineupInfo() { WebClient wc = WebClient.getInstance(); TokenRequest tr = new TokenRequest(); tr.username = username; tr.password = password; LineupInfoResponse lir = wc.getLineupInfo(tr, "/20141201/lineups/CAN-0005410-X"); Assert.NotNull(lir); }
public static Dictionary <string, ImportGuideChannel> makeImportChannelMap(LineupInfoResponse lir, string channelNameFormat) { Dictionary <string, ImportGuideChannel> digc = new Dictionary <string, ImportGuideChannel>(); List <ImportGuideChannel> ligc = makeImportChannels(lir, channelNameFormat); foreach (ImportGuideChannel igc in ligc) { digc.Add(igc.ExternalId, igc); } return(digc); }
public List <LineupInfoResponse> getAssignedLineupInfoList(TokenRequest tr) { List <LineupInfoResponse> llir = new List <LineupInfoResponse>(); List <AssignedLineupsResponse.Lineup> lineups = getAssignedLineups(tr); foreach (AssignedLineupsResponse.Lineup lu in lineups) { LineupInfoResponse lir = getLineupInfo(tr, lu.uri); llir.Add(lir); } return(llir); }
public LineupInfoResponse getLineupInfo(TokenRequest tr, string lineupRelativeUrl) { LineupInfoResponse lir = new LineupInfoResponse(); string token = getToken(tr); // assuming lineupRelativeUrl starts with / string url = baseUrlWithoutVersion + lineupRelativeUrl; lir = executeHttpRequest <LineupInfoResponse>(token, "GET", url); return(lir); }
/// <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); }
public static List <ImportGuideChannel> makeImportChannels(LineupInfoResponse lir, string channelNameFormat) { List <ImportGuideChannel> ligc = new List <ImportGuideChannel>(); Dictionary <string, ImportGuideChannel> migc = new Dictionary <string, ImportGuideChannel>(); // make a real map from the map "array" // Dictionary<string,string> channelMap = new Dictionary<string, string>(); // foreach (LineupInfoResponse.ChannelMap cm in lir.map) { // if (!channelMap.ContainsKey(cm.stationID)) { // if (lir.metadata.transport != null && lir.metadata.transport.ToLower().Equals("antenna")) { // // Over the air channels have a uhfVhf channel and/or atscMajor/atsc minor // // // // example: // // sometimes, uvfVhf is only present, sometimes just atsc stuff is present // //{ // // "stationID": "24504", // // "uhfVhf": 9, // // "atscMajor": 9, // // "atscMinor": 9 // //}, // // // if (cm.atscMinor != null && cm.atscMajor != null && cm.uhfVhf != null) { // // all three options are there // if (ConfigInstance.Current.AntennaUseUhfVhfChannel) { // channelMap.Add(cm.stationID, cm.uhfVhf); // } else { // channelMap.Add(cm.stationID, cm.atscMajor + "." + cm.atscMinor); // } // } else if (cm.uhfVhf != null) { // channelMap.Add(cm.stationID, cm.uhfVhf); // } else if (cm.atscMinor != null && cm.atscMajor != null) { // channelMap.Add(cm.stationID, cm.atscMajor + "." + cm.atscMinor); // } else { // Logger.Info("There was a problem picking a Logical Channel Number for station ID: {0}", cm.stationID); // // } // } else { // channelMap.Add(cm.stationID, cm.channel); // } // } // } Dictionary <string, string> channelMap = makeChannelMap(lir); foreach (LineupInfoResponse.Station station in lir.stations) { ImportGuideChannel igc = new ImportGuideChannel(); igc.ExternalId = station.stationID; igc.ChannelName = makeChannelName(station, channelMap, channelNameFormat); if (!migc.ContainsKey(station.stationID)) { migc.Add(station.stationID, igc); } string lcn = channelMap[station.stationID]; if (lcn != null && lcn.Contains(".")) { string[] lcnArray = lcn.Split('.'); igc.LogicalChannelNumber = Int32.Parse(lcnArray[0]); } else { igc.LogicalChannelNumber = Int32.Parse(lcn); } } ligc.AddRange(migc.Values); return(ligc); }