public async Task <IActionResult> GetStreamMaster(int?skip, int?top, string columns, string FCTY_CODE, string STREAM_CODE, DateTime?STREAM_V_START_DATE, string DBSOURCE_ID) { int s = (skip == null) ? 0 : skip.GetValueOrDefault(); int t = (top == null) ? 1000 : top.GetValueOrDefault(); if (s < 0) { return(BadRequest("Skip can't be a negative number")); } if (t < 1) { return(BadRequest("Top can't be less then 1")); } if (columns != null) { columns = columns.Replace(" ", ""); } /* This section is used to check the existence of columns suplied in the request, * and in the event of no columns being supplied finds a list of each column of the given model. */ StreamMaster obj = new StreamMaster(); var cols = obj.GetType().GetProperties().Select(e => e.Name.ToUpper()).ToArray(); if (columns == null) { columns = string.Join(",", cols); } else { string[] colSplit = columns.Split(','); foreach (string col in colSplit) { if (!cols.Contains(col.Trim().ToUpper())) { return(BadRequest(col + " is not a valid column")); } } } /* This section takes care of the db request. * Here Linq.Dynamic.Core is used to dynamically select specific columns. */ var result = _db.StreamMaster .Where(e => (e.FCTY_CODE == FCTY_CODE || FCTY_CODE == null) && (e.STREAM_CODE == STREAM_CODE || STREAM_CODE == null) && (e.STREAM_V_START_DATE >= STREAM_V_START_DATE || STREAM_V_START_DATE == null) && (e.DBSOURCE_ID == DBSOURCE_ID || DBSOURCE_ID == null) ) .Skip(s) .Take(t) .Select("new(" + columns + ")"); return(Ok(await result.ToDynamicListAsync())); }
/// <summary> /// A streamed source that uses a <see cref="StreamMaster"/> to fetch new samples from. /// </summary> /// <param name="master">The supplier of samples</param> /// <param name="source">Source ID used by the <see cref="master"/></param> public StreamMasterSource(StreamMaster master, int source) { this.master = master; this.source = source; }
/// <summary> /// Renders a decoded stream with Cavern. /// </summary> public Renderer(Decoder stream) { this.stream = stream; reader = new StreamMaster(GetNextObjectSamples); }