I need to retrieve a binary image from the database and dispaly it in my orgchart.
i use Entity framework, I recovered my data, but I got my binary image like urls and of course it gives me an error as you see in the image. error URl 414
It takes the binary image as a url and of course gives me the error 414 My queries are as below:
public JsonResult Read()
{
var nodes = (from s in entities.AGENT
from u in entities.UNITE_ORG
from f in entities.PHOTO
where s.MATRICULE == u.RESPONSABLE && f.MATRICULE==s.MATRICULE
select new NodeModel() {
id= u.UO,
pid= u.UO_RATTACHEMENT,
responsable = u.RESPONSABLE,
matricule = s.MATRICULE,
nom= s.NOM,
prenom= s.PRENOM,
img= f.PHOTO1,
poste=u.POSTE,
});
return Json(new { nodes = nodes }, JsonRequestBehavior.AllowGet);
}
public class NodeModel
{
public string id { get; set; }
public string pid { get; set; }
public string responsable { get; set; }
public byte[] img { get; set; }
public string nom { get; set; }
public string prenom { get; set; }
public string poste { get; set; }
public string matricule{ get; set; }
}
this is my script :
<script>
$.get("@Url.Action("Read")").done(function (response) {
var chart = new OrgChart(document.getElementById("tree"), {
template: "diva",
layout: OrgChart.mixed,
menu: {
pdf: { text: "Export PDF" },
png: { text: "Export PNG" },
svg: { text: "Export SVG" },
csv: { text: "Export CSV" }
},
nodeBinding: {
field_0: "nom",
field_1: "prenom",
field_2:"poste",
img_0: "img"
},
nodeMenu: {
details: { text: "Details" },
edit: { text: "Edit" },
add: { text: "Add" },
remove: { text: "Remove" }
},
nodes: response.nodes
});
document.getElementById("selectTemplate").addEventListener("change", function () {
chart.config.template = this.value;
chart.draw();
});
});
</script>
Now i need to read the pictures the right way, maybe i need to convert binary to other things but i don't know which one.
thank you !