public void ProcessRequest(HttpContext context) { RegistroUsuario cadUsuario = new RegistroUsuario(); if (!string.IsNullOrWhiteSpace(context.Request.QueryString["usuario"])) { context.Response.ContentType = "image/png"; string xml = string.Empty; using (WebClient client = new WebClient()) { var parametros = new System.Collections.Specialized.NameValueCollection(); parametros.Add("modo", "B"); parametros.Add("id", context.Request.QueryString["usuario"]); byte[] resposta = client.UploadValues(context.Request.Url.Scheme + "://localhost:" + context.Request.Url.Port + "/usuario_cadastro.ashx", "POST", parametros); xml = Encoding.UTF8.GetString(resposta); } if (!xml.Contains("<mensagem") && xml.Contains("<imagem>")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); if (!string.IsNullOrWhiteSpace(xmlDoc.SelectSingleNode("/retorno/imagem").InnerText)) { if (xmlDoc.SelectSingleNode("/retorno/imagem").InnerText.StartsWith("JPG_")) { context.Response.ContentType = "image/jpg"; } context.Response.BinaryWrite(Convert.FromBase64String(xmlDoc.SelectSingleNode("/retorno/imagem").InnerText.Substring(4))); } else { context.Response.WriteFile("img/User-Coat-Red-icon.png"); } } else { context.Response.WriteFile("img/User-Coat-Red-icon.png"); } } else { context.Response.RedirectPermanent("inicio.aspx"); } context.Response.End(); }
public void ProcessRequest(HttpContext context) { RegistroPacote cadPacote = new RegistroPacote(); if (context.Request.Form["modo"] == "C") { context.Response.ContentType = "text/xml"; context.Response.Write("<?xml version=\"1.0\"?>" + Environment.NewLine); context.Response.Write("<retorno>" + Environment.NewLine); context.Response.Write("<id>" + cadPacote.CriaRegistro( context.Request.Form["descricao"] ) + "</id>" + Environment.NewLine); if (cadPacote.Mensagem.Length > 5) { context.Response.Write("<mensagem>" + cadPacote.Mensagem.Replace("<", "<").Replace(">", ">").Replace("&", "&") + "</mensagem>" + Environment.NewLine); } context.Response.Write("</retorno>"); } else if (context.Request.Form["modo"] == "B") { context.Response.ContentType = "text/xml"; context.Response.Write("<?xml version=\"1.0\"?>" + Environment.NewLine); context.Response.Write("<retorno>" + Environment.NewLine); context.Response.Write("<descricao>" + cadPacote.BuscaPacote( Convert.ToInt64(context.Request.Form["id"]) ).Replace("<", "<").Replace(">", ">") + "</descricao>" + Environment.NewLine); if (cadPacote.Mensagem.Length > 5) { context.Response.Write("<mensagem>" + cadPacote.Mensagem.Replace("<", "<").Replace(">", ">").Replace("&", "&") + "</mensagem>" + Environment.NewLine); } context.Response.Write("</retorno>"); } else if (context.Request.Form["modo"] == "G") { context.Response.ContentType = "text/html"; bool previsto = context.Request.Form["previsto"] == "S"; string[] estatistica = cadPacote.GeraEstatisticaPacote( Convert.ToInt64(context.Request.Form["id"]), previsto ); string atividadeTarefa = string.Empty; string diferenca = string.Empty; Dictionary <string, string> UsuarioSoma = new Dictionary <string, string>(); Dictionary <string, string> UsuarioCor = new Dictionary <string, string>(); SortedDictionary <string, string> UsuarioRanking = new SortedDictionary <string, string>(); int cor = (previsto ? 0 : 6); string[] cores = { "darksalmon", "darkolivegreen", "darkslateblue", "darkgoldenrod", "darkkhaki", "darkgray", "darkred", "darkgreen", "darkblue", "darkorange", "darkcyan", "darkorchid" }; string estatisticas = string.Empty; string usuarios = string.Empty; for (int i = 11; i < estatistica.Length; i = i + 12) { if (atividadeTarefa != estatistica[i - 11] || diferenca == estatistica[i - (previsto ? 4 : 0)]) { if (atividadeTarefa != estatistica[i - 11] && !string.IsNullOrWhiteSpace(atividadeTarefa)) { estatisticas += "<tr>" + Environment.NewLine + @"<td colspan=""4""> </td>" + Environment.NewLine + "</tr>" + Environment.NewLine; } atividadeTarefa = estatistica[i - 11]; diferenca = estatistica[i - (previsto ? 4 : 0)]; if (!UsuarioSoma.ContainsKey(estatistica[i - 10])) { UsuarioSoma.Add(estatistica[i - 10], "1;" + (i - 9)); } else { UsuarioSoma[estatistica[i - 10]] = (Convert.ToInt32(UsuarioSoma[estatistica[i - 10]].Split(';')[0]) + 1) + ";" + UsuarioSoma[estatistica[i - 10]].Split(';')[1]; } } if (!UsuarioCor.ContainsKey(estatistica[i - 10])) { UsuarioCor.Add(estatistica[i - 10], cores[cor]); cor++; if (cor == 12) { cor = 0; } } estatisticas += "<tr>" + Environment.NewLine + "<td>" + atividadeTarefa + "</td>" + Environment.NewLine + "<td>" + RegistroUsuario.IniciaisNome(estatistica[i - 9]) + "</td>" + Environment.NewLine + @"<td style=""width:66%"">" + Environment.NewLine + @"<div class=""progress"">" + Environment.NewLine + @"<div class=""progress-bar"" style=""background-image:none;background-color:" + UsuarioCor[estatistica[i - 10]] + ";width:" + estatistica[i - (previsto ? 5 : 1)].Replace(",", ".") + @"%""><span>" + estatistica[i - 7] + "</span></div>" + Environment.NewLine + @"<div class=""progress-bar progress-bar-striped"" style=""width:" + estatistica[i - (previsto ? 4 : 0)].Replace(",", ".") + @"%""><span>" + estatistica[i - (previsto ? 6 : 2)] + "</span></div>" + Environment.NewLine + "</div>" + Environment.NewLine + "</td>" + Environment.NewLine + "<td>" + estatistica[i - (previsto ? 8 : 3)] + "</td>" + Environment.NewLine + "</tr>" + Environment.NewLine; } foreach (KeyValuePair <string, string> kvp in UsuarioSoma) { if (!UsuarioRanking.ContainsKey(kvp.Value.Split(';')[0])) { UsuarioRanking.Add(kvp.Value.Split(';')[0], estatistica[Convert.ToInt32(kvp.Value.Split(';')[1])] ); } else { UsuarioRanking[kvp.Value.Split(';')[0]] += " / " + estatistica[Convert.ToInt32(kvp.Value.Split(';')[1])]; } } foreach (KeyValuePair <string, string> kvp in UsuarioRanking) { usuarios = "<tr>" + Environment.NewLine + "<td>" + kvp.Value + "</td>" + Environment.NewLine + "<td>" + kvp.Key + "</td>" + Environment.NewLine + "</tr>" + Environment.NewLine + usuarios; } context.Response.Write("<!-- estatisticas; -->" + Environment.NewLine); context.Response.Write(estatisticas); context.Response.Write("<!-- usuarios; -->" + Environment.NewLine); context.Response.Write(usuarios); } else { context.Response.RedirectPermanent("inicio.aspx"); } context.Response.End(); }
public void ProcessRequest(HttpContext context) { RegistroUsuario cadUsuario = new RegistroUsuario(); if (context.Request.Form["modo"] == "C") { context.Response.ContentType = "text/xml"; context.Response.Write("<?xml version=\"1.0\"?>" + Environment.NewLine); context.Response.Write("<retorno>" + Environment.NewLine); context.Response.Write("<id>" + cadUsuario.CriaRegistro( context.Request.Form["login"], context.Request.Form["senha"], context.Request.Form["nome"], context.Request.Form["email"], context.Request.Form["imagem"] ) + "</id>" + Environment.NewLine); if (cadUsuario.Mensagem.Length > 5) { context.Response.Write("<mensagem>" + cadUsuario.Mensagem.Replace("<", "<").Replace(">", ">").Replace("&", "&") + "</mensagem>" + Environment.NewLine); } context.Response.Write("</retorno>"); } else if (context.Request.Form["modo"] == "M") { context.Response.ContentType = "text/xml"; context.Response.Write("<?xml version=\"1.0\"?>" + Environment.NewLine); context.Response.Write("<retorno>" + Environment.NewLine); context.Response.Write("<id>" + cadUsuario.ModificaRegistro( Convert.ToInt64(context.Request.Form["id"]), context.Request.Form["login"], context.Request.Form["senha"], context.Request.Form["nome"], context.Request.Form["email"], context.Request.Form["imagem"] ) + "</id>" + Environment.NewLine); if (cadUsuario.Mensagem.Length > 5) { context.Response.Write("<mensagem>" + cadUsuario.Mensagem.Replace("<", "<").Replace(">", ">").Replace("&", "&") + "</mensagem>" + Environment.NewLine); } context.Response.Write("</retorno>"); } else if (context.Request.Form["modo"] == "B") { context.Response.ContentType = "text/xml"; context.Response.Write("<?xml version=\"1.0\"?>" + Environment.NewLine); context.Response.Write("<retorno>" + Environment.NewLine); if (string.IsNullOrWhiteSpace(context.Request.Form["id"])) { context.Response.Write("<id>" + cadUsuario.BuscaUsuario( context.Request.Form["login"], context.Request.Form["senha"] ) + "</id>" + Environment.NewLine); } else { string[] usuario = cadUsuario.BuscaUsuario( Convert.ToInt64(context.Request.Form["id"]) ); for (int i = 3; i < usuario.Length; i = i + 4) { context.Response.Write("<nome>" + usuario[i - 3] + "</nome>" + Environment.NewLine); context.Response.Write("<email>" + usuario[i - 2] + "</email>" + Environment.NewLine); context.Response.Write("<imagem>" + usuario[i - 1] + "</imagem>" + Environment.NewLine); context.Response.Write("<pacotes>" + usuario[i] + "</pacotes>" + Environment.NewLine); } } if (cadUsuario.Mensagem.Length > 5) { context.Response.Write("<mensagem>" + cadUsuario.Mensagem.Replace("<", "<").Replace(">", ">").Replace("&", "&") + "</mensagem>" + Environment.NewLine); } context.Response.Write("</retorno>"); } else { context.Response.RedirectPermanent("inicio.aspx"); } context.Response.End(); }