Exemplo n.º 1
0
        public ActionResult TreeLabel(long id)
        {
            var tree = TreeService.Get(id);
            var data = TreeTagPainter.Paint(tree, HttpContext.Request.Url.Host);

            return(File(data, "image/jpeg"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(Tree model)
        {
            if (ModelState.IsValid)
            {
                var user = GetUser();
                model.UserID = user.ID;
                TreeService.Update(model);

                var path  = Server.MapPath("/label");
                var bytes = TreeTagPainter.Paint(model, HttpContext.Request.Url.Host);
                System.IO.File.WriteAllBytes(path + "/" + model.ID + ".png", bytes);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Exemplo n.º 3
0
        public ActionResult DownloadLabel(string ids)
        {
            var          id     = ids.Split(',').Select(c => long.Parse(c));
            MemoryStream memory = new MemoryStream();

            using (var output = new ZipOutputStream(memory))
            {
                foreach (var i in id)
                {
                    var tree = TreeService.Get(i);
                    var data = TreeTagPainter.Paint(tree, HttpContext.Request.Url.Host);

                    ZipEntry entry = new ZipEntry(tree.Name + "-" + tree.ID + ".png");
                    entry.DateTime = DateTime.Now;
                    output.PutNextEntry(entry);
                    output.Write(data, 0, data.Length);
                }
                output.Finish();
                output.Close();
            }

            return(File(memory.ToArray(), "application/x-zip-compressed", "tree-label.zip"));
        }