public ActionResult ValidarPedido(string idcartao, string estado) { TrelloConector trello = HttpContext.RequestServices.GetService(typeof(TrelloConector)) as TrelloConector; FT_ManagementContext context = HttpContext.RequestServices.GetService(typeof(FT_ManagementContext)) as FT_ManagementContext; TrelloCartoes cartao = trello.ObterCartao(idcartao); foreach (var folhaObra in context.ObterListaFolhasObraCartao(idcartao)) { //if (folhaObra.RelatorioServico != String.Empty && folhaObra.RelatorioServico != null) { trello.NovoComentario(folhaObra.IdCartao, folhaObra.RelatorioServico); } TrelloAnexos Anexo = new TrelloAnexos { Id = folhaObra.IdCartao, Name = "FolhaObra_" + folhaObra.IdFolhaObra + ".pdf", File = context.PreencherFormularioFolhaObra(folhaObra).ToArray(), }; Anexo.dict.TryGetValue(Anexo.Name.Split('.').Last(), out string mimeType); Anexo.MimeType = mimeType; trello.NovoAnexo(Anexo); } trello.NovaLabel(idcartao, estado == "1" ? "green" : estado == "2" ? "yellow" : "red"); return(RedirectToAction("ListaPedidos", new { idQuadro = cartao.IdQuadro, idlista = cartao.IdLista })); }
public void NovoAnexo(TrelloAnexos Anexo) { if (ObterAnexos(Anexo.Id).Where(a => a.Name == Anexo.Name).Count() > 0) { ApagarAnexo(ObterAnexos(Anexo.Id).Where(a => a.Name == Anexo.Name).First().Id, Anexo.Id); } NameValueCollection nvc = new NameValueCollection(); nvc.Add("id", Anexo.Id); nvc.Add("name", Anexo.Name); HttpUploadFile("https://api.trello.com/1/cards/" + Anexo.Id + "/attachments?key=" + API_KEY + "&token=" + TOKEN + "", Anexo.File, "file", Anexo.MimeType, nvc, Anexo.Name); }
public TrelloAnexos ObterAnexo(string IdAnexo, string IdCartao) { TrelloAnexos trelloAnexo; var anexo = GetTrelloJson("https://api.trello.com/1/cards/" + IdCartao + "/attachments/" + IdAnexo + "?key=" + API_KEY + "&token=" + TOKEN + ""); WebClient myWebClient = new WebClient(); trelloAnexo = new TrelloAnexos { Id = anexo.id, Name = anexo.name, File = myWebClient.DownloadData(anexo.url.ToString()), MimeType = anexo.mimeType, Date = anexo.date, IdCartao = IdCartao }; return(trelloAnexo); }