public JsonResult GeraCsvReact(Models.Laura param) { List <Models.Quest> rClick = new List <Models.Quest>(); using (var db = new LojaDataContext()) { var idLoja = db.Tables.Where(f => f.NOME_LOJA == param.loja).First().ID_LOJA; var quests = db.Quests.Where(c => c.ID_LOJA == idLoja).ToList(); foreach (var item in quests) { rClick.Add(new Models.Quest { data = item.DATA, id = item.ID_QUEST.ToString(), like = item.LIKE, opt = item.OPTION, react = item.REACT, idFoto = item.ID_FOTO, idLoja = item.ID_LOJA }); } var path = System.IO.Path.GetDirectoryName(System.IO.Path.GetTempFileName()); string pathCsv = path + "\\ArquivoReact.csv"; List <string> output = new List <string>(); foreach (var item in rClick) { output.Add(item.id + ", " + item.data + "," + item.idFoto + "," + item.idLoja + "," + item.like + "," + item.opt + "," + item.react); } System.IO.File.WriteAllLines(pathCsv, output.ToArray()); Process.Start(pathCsv); } return(Json(rClick)); }
public JsonResult GeraCsvClick(Models.Laura param) { List <Models.Click> rClick = new List <Models.Click>(); using (var db = new LojaDataContext()) { var idLoja = db.Tables.Where(f => f.NOME_LOJA == param.loja).First().ID_LOJA; var clicks = db.Clicks.Where(c => c.ID_LOJA == idLoja).ToList(); foreach (var item in clicks) { rClick.Add(new Models.Click { data = item.DATA, idClick = item.ID_CLICK, idFoto = item.ID_FOTO, idLoja = item.ID_LOJA }); } var path = System.IO.Path.GetDirectoryName(System.IO.Path.GetTempFileName()); string pathCsv = path + "\\ArquivoClick.csv"; List <string> output = new List <string>(); foreach (var item in rClick) { output.Add(item.idClick.ToString() + ", " + item.idFoto + "," + item.idLoja + "," + item.data.ToString()); } System.IO.File.WriteAllLines(pathCsv, output.ToArray()); Process.Start(pathCsv); } return(Json(rClick)); }
public JsonResult VerificaDash(Models.Laura laura) { Models.Relatorio relatorio = new Models.Relatorio(); string idLoja = ""; using (var db = new LojaDataContext()) { try { idLoja = db.Tables.Where(d => d.NOME_LOJA == laura.loja).First().ID_LOJA; } catch (Exception) { idLoja = ""; } if (idLoja != "") { var clicks = db.Clicks.Where(c => c.ID_LOJA == idLoja).ToList(); var likes = db.Quests.Where(l => l.ID_LOJA == idLoja && l.LIKE == "2").ToList(); var reacts = db.Quests.Where(l => l.ID_LOJA == idLoja && l.REACT == "love").ToList(); var options = db.Quests.Where(l => l.ID_LOJA == idLoja && l.OPTION == "1").ToList(); relatorio.clicks = clicks.Count(); relatorio.like = likes.Count(); relatorio.react = reacts.Count(); relatorio.option = options.Count(); } else { } } return(Json(relatorio)); }