Beispiel #1
0
        private void RenderTask(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                try
                {
                    var points = _reader.Get(unit.it);
                    if (points.HasValue)
                    {
                        var bitmap = new Bitmap(1280, 1024);

                        bitmap = Heatmap.CreateIntensityMask(bitmap, points.Value.Points);

                        var heatmap = Heatmap.Colorize(bitmap, 255);

                        _mapWriter.AddOrUpdate(unit.it, () => new HeatMapView(),
                                               v =>
                        {
                            v.Heatmap   = heatmap;
                            v.Thumbnail = new Bitmap(heatmap, 320, 256);
                        });
                    }


                    token.WaitHandle.WaitOne(5000);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    token.WaitHandle.WaitOne(2000);
                }
            }
        }
Beispiel #2
0
        public IEnumerable <RecipeView> GetByName(int pagesize, int skip = 0)
        {
            var index = indexReader.Get(unit.it).Value.Index;
            var keys  = index.Keys.OrderBy(x => x).Skip(skip).Take(pagesize);
            var ids   = keys.SelectMany(k => index[k]);
            var views = ids.Select(id =>
            {
                RecipeView view;
                reader.TryGet(new RecipeId(id), out view);
                return(view);
            });

            return(views);
        }
        public override void Handle(IHttpContext context)
        {
            var view = _reader.Get(unit.it);

            if (view.HasValue)
            {
                if (context.GetRequestUrl().Contains("thumb"))
                {
                    view.Value.Thumbnail.Save(context.Response.OutputStream, ImageFormat.Jpeg);
                }
                else
                {
                    view.Value.Heatmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);
                }
            }
            else
            {
                ReturnEmptyImage(context);
            }

            context.SetStatusTo(HttpStatusCode.OK);
        }