private IEnumerable <mwc.Incumbent> GetIncumbentsFromTable(string tableName, string partitionKey, IncumbentType incumbentType) { // Todo: this is a temporary method provided until the backend supports retriving incumbents of type "tv_us" Microsoft.WhiteSpaces.AzureTableAccess.AzureTableOperation azureTableOperations = new Microsoft.WhiteSpaces.AzureTableAccess.AzureTableOperation(); string tableQuery = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey); if (incumbentType != IncumbentType.None) { tableQuery = TableQuery.CombineFilters(tableQuery, TableOperators.And, TableQuery.GenerateFilterConditionForInt("Type", QueryComparisons.Equal, (int)incumbentType)); } IEnumerable <mwc.Incumbent> tvEngDataList = azureTableOperations.GetAllEntities <CDBSTvEngData>(tableName, tableQuery) .Select(cdbsTvEndData => { List <Position> contourPoints = WhitespacesManager.GetContourPointsSpaceSeperator(cdbsTvEndData.Contour); mwc.Incumbent incumbent = new mwc.Incumbent( cdbsTvEndData.CallSign, cdbsTvEndData.Channel, contourPoints, null, incumbentType, null, new Location(cdbsTvEndData.Latitude, cdbsTvEndData.Longitude)); return(incumbent); }); return(tvEngDataList); }
public List <mwc.Incumbent> GetIncumbents(string incumbentType, string regionName, IEnumerable <int> channels) { Check.IsNotEmptyOrWhiteSpace(incumbentType, "incumbentType"); Check.IsNotEmptyOrWhiteSpace(regionName, "regionName"); IncumbentType enumType = (IncumbentType)Enum.Parse(typeof(IncumbentType), incumbentType, true); // Todo: This is temporary code until backend supports returning TV_US via the GetIncumbents call. if (enumType == IncumbentType.TV_US || enumType == IncumbentType.MVPD || enumType == IncumbentType.TV_TRANSLATOR) { return(this.GetIncumbentsFromTable(channels, enumType)); } mwc.IRequestParameters requestParams = this.GetRequestParams( req => { req.RegionName = regionName; req.Params = new Parameters { IncumbentType = incumbentType }; }); object[] rawIncumbents = this.whitespacesClient.GetIncumbents(requestParams).IncumbentList; return(WhitespacesManager.ParseRawIncumbents(enumType, rawIncumbents, channels)); }
private static List <mwc.Incumbent> ParseRawIncumbents(IncumbentType incumbentType, object[] rawIncumbents, IEnumerable <int> channels) { dynamic incumbentList = null; List <mwc.Incumbent> incumbents = new List <mwc.Incumbent>(); if (rawIncumbents != null) { switch (incumbentType) { case IncumbentType.MVPD: incumbentList = WhitespacesManager.GetDeserializedIncumbents <MVPDRegistration>(rawIncumbents); break; case IncumbentType.LPAux: case IncumbentType.UnlicensedLPAux: incumbentList = WhitespacesManager.GetDeserializedIncumbents <LPAuxRegistration>(rawIncumbents); break; case IncumbentType.TBAS: incumbentList = WhitespacesManager.GetDeserializedIncumbents <TempBASRegistration>(rawIncumbents); break; case IncumbentType.TV_US: // TODO: Logic to de-serialize TV_US incumbents type. [Need to wait until back-end supports this] break; } if (incumbentList != null) { foreach (object incumbent in incumbentList) { mwc.Incumbent incumbentModel = WhitespacesManager.GetIncumbent(incumbent, incumbentType); incumbents.Add(incumbentModel); } } if (channels != null) { IEnumerable <mwc.Incumbent> filteredIncumbents = WhitespacesManager.FilterIncumbentsByChannel(incumbents, channels); incumbents = filteredIncumbents != null?filteredIncumbents.ToList() : incumbents; } } return(incumbents); }
public List <mwc.Incumbent> GetIncumbents(string incumbentType, double latitude, double longitude, string regionName, IEnumerable <int> channels) { Check.IsNotEmptyOrWhiteSpace(incumbentType, "incumbentType"); Check.IsNotEmptyOrWhiteSpace(regionName, "regionName"); IncumbentType enumType = (IncumbentType)Enum.Parse(typeof(IncumbentType), incumbentType, true); // Todo: This is temporary code until backend supports returning TV_US via the GetIncumbents call. if (enumType == IncumbentType.TV_US || enumType == IncumbentType.TV_TRANSLATOR || enumType == IncumbentType.MVPD) { return(this.GetIncumbentsFromTable(channels, enumType, latitude, longitude)); } // [Note:] As of now, it doesn't make any sense passing latitude and longitude values to filter the incumbents // based on the search region, but if it is enabled in back-end in future we can use following request. mwc.IRequestParameters requestParams = this.GetRequestParams( req => { req.RegionName = regionName; req.Params = new Parameters { IncumbentType = incumbentType, Location = new GeoLocation { Point = new Ellipse { Center = new Point { Latitude = latitude.ToString(), Longitude = longitude.ToString() } } } }; }); object[] rawIncumbents = this.whitespacesClient.GetIncumbents(requestParams).IncumbentList; return(WhitespacesManager.ParseRawIncumbents(enumType, rawIncumbents, channels)); }