protected void ButtonExportarPdf_Click(object sender, EventArgs e) { AcuseFolio objAcuseOpinionFolio; strTipoArrendamiento = Request.QueryString["TipoArrto"]; int intFolio; bool ConversionOK; //esta nos dice si es un número válido try { StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter htw = new HtmlTextWriter(sw); Page page = new Page(); HtmlForm form = new HtmlForm(); page.EnableEventValidation = false; page.DesignerInitialize(); form = this.form1; form.FindControl("ButtonExportarPdf").Visible = false; page.Controls.Add(form); page.RenderControl(htw); //string strCabecero ="<!DOCTYPE html> <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/><title></title><meta charset='utf-8' /></head><body>"; string strCabecero = "<!DOCTYPE html> <html xmlns='http://www.w3.org/1999/xhtml'> <head runat='server'> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <title></title> <link href='https://framework-gb.cdn.gob.mx/assets/styles/main.css' rel='stylesheet'/> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300' rel='stylesheet' type='text/css'/> <link href='https://framework-gb.cdn.gob.mx/favicon.ico' rel='shortcut icon'/> <style> @media print { #ZonaNoImrpimible {display:none;} } nav,aside { display: none; } .auto-style1 { height: 119px; } </style> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'></script> </head> <body>"; string strPie = "</body> </html>"; string strBotonExportar = "<asp:Button ID=\"ButtonExportarPdf\" runat=\"server\" CssClass=\"btn btn-default\" OnClick=\"ButtonExportarPdf_Click\" Text=\"Exportar a PDF\" ToolTip=\"Exportar a PDF.\" />"; string strBotonImprimir = "<input type=\"button\" id=\"ButtonImprimir\" value=\"Imprimir\" onclick=\"javascript: window.print()\" class=\"btn\" />"; string strBrakePage = "page-break-before: always;"; string strCuerpoOriginal = sb.ToString(); string strPaginaConCuerpo = strCabecero + strCuerpoOriginal + strPie; //string strCuerpoFormateado = especialesHTML(strPaginaConCuerpo).Replace(strImagenLogoIndaabinHtml, strImagenLogoIndaabinFisica).Replace(strImagenEscudoNacionalHtml, strImagenEscudoNacionalFisica).Replace(strBotonImprimir, "").Replace(strBotonExportar, "").Replace(strBrakePage, ""); string strCuerpoFormateado = especialesHTML(strPaginaConCuerpo); //poner la url del nuevo logo si pasa del 1 de diciembre de 2018 ConversionOK = int.TryParse(Request.QueryString["IdFolio"].ToString(), out intFolio); if (ConversionOK) { objAcuseOpinionFolio = new NGConceptoRespValor().ObtenerAcuseSolicitudOpinionConInmueble(intFolio, strTipoArrendamiento); string fecha = objAcuseOpinionFolio.FechaAutorizacion.ToString(); string[] nuevafecha = fecha.Split('/'); string[] ano = nuevafecha[2].Split(' '); string dia = nuevafecha[0]; string mes = nuevafecha[1]; string year = ano[0]; strCuerpoFormateado = strCuerpoFormateado.Replace("src=\"http://sistemas.indaabin.gob.mx/ImagenesComunes/INDAABIN_01.jpg\"", "src=\"https://sistemas.indaabin.gob.mx/ImagenesComunes/SHCP-INDAABINREDUCIDO.PNG"); strCuerpoFormateado = strCuerpoFormateado.Replace("url(http://sistemas.indaabin.gob.mx/ImagenesComunes/aguila.png);", "url(https://sistemas.indaabin.gob.mx/ImagenesComunes/nuevoescudo.png);"); strCuerpoFormateado = strCuerpoFormateado.Replace("background-position: center;", "background-position: left;"); strCuerpoFormateado = strCuerpoFormateado.Replace("##font##", "font-family: Montserrat;"); strCuerpoFormateado = strCuerpoFormateado.Replace("##Viejo##", "display:none;"); //if (Convert.ToInt32(year) >= 2018) //{ // if (Convert.ToInt32(mes) >= 12) // { // if (Convert.ToInt32(dia) >= 1) // { // strCuerpoFormateado = strCuerpoFormateado.Replace("src=\"http://sistemas.indaabin.gob.mx/ImagenesComunes/INDAABIN_01.jpg\"", "src=\"https://sistemas.indaabin.gob.mx/ImagenesComunes/SHCP-INDAABINREDUCIDO.PNG"); // strCuerpoFormateado = strCuerpoFormateado.Replace("url(http://sistemas.indaabin.gob.mx/ImagenesComunes/aguila.png);", "url(https://sistemas.indaabin.gob.mx/ImagenesComunes/nuevoescudo.png);"); // strCuerpoFormateado = strCuerpoFormateado.Replace("background-position: center;", "background-position: left;"); // strCuerpoFormateado = strCuerpoFormateado.Replace("##font##", "font-family: Montserrat;"); // strCuerpoFormateado = strCuerpoFormateado.Replace("##Viejo##", "display:none;"); // } // else // { // strCuerpoFormateado = strCuerpoFormateado.Replace("##Nuevo##", "display:none;"); // } // } // else // { // strCuerpoFormateado = strCuerpoFormateado.Replace("##Nuevo##", "display:none;"); // } //} //else //{ // strCuerpoFormateado = strCuerpoFormateado.Replace("##Nuevo##", "display:none;"); //} } ExportHTML exportar = new ExportHTML(); exportar.CanPrint = true; //RCA 10/18/2017 exportar.GenerarPDF(strCuerpoFormateado); //exportar.GenerarPDF(strCuerpoFormateado, Server.MapPath("~")); } catch (Exception ex) { Msj = "Ha ocurrido un error al exportar a PDF. Contacta al área de sistemas."; this.LabelInfo.Text = "<div class='alert alert-danger'><strong> Error </strong>" + Msj + "</div>"; MostrarMensajeJavaScript(Msj); BitacoraExcepcion BitacoraExcepcionAplictivo = new BitacoraExcepcion { CadenaconexionBD = System.Configuration.ConfigurationManager.ConnectionStrings["cnArrendamientoInmueble"].ConnectionString, Aplicacion = "ContratosArrto", Modulo = MethodInfo.GetCurrentMethod().DeclaringType.ToString() + ".aspx", Funcion = MethodBase.GetCurrentMethod().Name + "()", DescExcepcion = ex.InnerException == null ? ex.Message : ex.InnerException.Message, Usr = ((SSO)Session["Contexto"]).UserName.ToString() }; BitacoraExcepcionAplictivo.RegistrarBitacoraExcepcion(); BitacoraExcepcionAplictivo = null; } }
public async void webSock(string errorMessageLog, ConcurrentDictionary <string, clientMachine.userPreference> userPreference, int iteration, string outputFolder, byte csvReadSeparator, char csvWriteSeparator, Dictionary <int, string> forwardMessage, ConcurrentDictionary <decimal, clientMachine.request> requestDict, ConcurrentDictionary <decimal, clientMachine.response> responseDict, ConcurrentDictionary <string, clientMachine.clientSession> clientSessionVariable, string sourceFolder, string db1Folder, string dbBackupFolder) { resetDimensionOrder[0] = false; processAcceptList.Add(1, new Dictionary <string, string>()); processAcceptList.Add(2, new Dictionary <string, string>()); processAcceptList[2].Add("dataSorting", "interimEvent"); processAcceptList[2].Add("moveToCrosstab", "interimEvent"); processAcceptList[2].Add("removeFromCrosstab", "interimEvent"); processAcceptList[2].Add("rotateDimension", "interimEvent"); processAcceptList[2].Add("rotateDimensionCrosstab", "interimEvent"); processAcceptList[2].Add("rotateDimensionDrillDown", "interimEvent"); processAcceptList[2].Add("displayPrecision", "finalEvent"); processAcceptList[2].Add("nextPrecision", "finalEvent"); processAcceptList[2].Add("changeDrillDownEvent", "finalEvent"); processAcceptList[2].Add("drillDown", "finalEvent"); processAcceptList[2].Add("pageMove", "finalEvent"); processAcceptList[2].Add("downloadReport", "finalEvent"); processAcceptList[2].Add("openReportByWindows", "finalEvent"); int serialID = 0; // to force uniqueness of html ID for adding filter control bool isRemove = false; DateTime currentDateTime = DateTime.Now; Random random = new Random(); string myHost = System.Net.Dns.GetHostName(); string myIP = null; int IP4v = 0; Dictionary <int, string> myIP4V_List = new Dictionary <int, string>(); if (userPreference["system"].os == "Linux") { foreach (var netInterface in NetworkInterface.GetAllNetworkInterfaces()) { if (netInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || netInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet) { foreach (var addrInfo in netInterface.GetIPProperties().UnicastAddresses) { if (addrInfo.Address.AddressFamily == AddressFamily.InterNetwork) { IP4v++; var ipAddress = addrInfo.Address; myIP4V_List.Add(IP4v, ipAddress.ToString()); } } } } } if (userPreference["system"].os == "Windows Client" || userPreference["system"].os == "Windows Server") { for (int i = 0; i < System.Net.Dns.GetHostEntry(myHost).AddressList.Length; i++) { if (System.Net.Dns.GetHostEntry(myHost).AddressList[i].IsIPv6LinkLocal == false) { IP4v++; myIP = System.Net.Dns.GetHostEntry(myHost).AddressList[i].ToString(); myIP4V_List.Add(IP4v, myIP); } } } var countIP = myIP4V_List.Count; if (userPreference["system"].os == "Windows Client") { userPreference["system"].serverIP = "127.0.0.1"; } else if (countIP > 1) { foreach (KeyValuePair <int, string> item in myIP4V_List) { Console.WriteLine("Option {0} IP:{1}", item.Key, item.Value); } Console.Write("Please select your option: "); var select = Console.ReadLine(); int selected = Int32.Parse(select); userPreference["system"].serverIP = myIP4V_List[selected]; } else { userPreference["system"].serverIP = myIP4V_List[1]; } Console.WriteLine("youFast websocket server is starting at " + userPreference["system"].serverIP + ":" + userPreference["system"].websocketPort); Console.WriteLine("Please open web browser with URL http://desktop.youfast.net"); string dotNetVersion = Environment.Version.ToString(); Console.WriteLine(dotNetVersion); if (userPreference["system"].os == "Windows Client") { if (dotNetVersion.Substring(0, 1) == "4") { System.Diagnostics.Process.Start("http://desktop.youfast.net"); } } StringBuilder html = new StringBuilder(); byte[] contentByte = Encoding.ASCII.GetBytes(html.ToString()); string htmlHeader = "HTTP/1.0 200 OK" + "\r\n" + "Server: WebServer 1.0" + "\r\n" + "Content-Length: " + contentByte.Length + "\r\n" + "Content-Type: text/html" + "\r\n" + "\r\n"; byte[] headerByte = Encoding.ASCII.GetBytes(htmlHeader); WebSocketServer wsServer = new WebSocketServer("ws://" + userPreference["system"].serverIP + ":" + userPreference["system"].websocketPort); queueThread.TryAdd(1, new Thread(() => requestQueue2Thread(requestID2SessionIDsending, requestID2SessionIDsent, isResponse, requestID2SessionID, wsServerSessionID, errorMessageLog, ramMapping, copyMemDetailRandomly, userPreference, tableFact, currentRequestID, sourceFolder, csvReadSeparator, db1Folder, iteration, outputFolder, csvWriteSeparator, clientSessionVariable, requestDict, responseDict, forwardMessage, htmlTable, ramDetail, ramK2V, incomingRequestQueue, request2Response, cancelRequestID, isRemove, currentDateTime, screenControl))); queueThread[1].Start(); decimal userRequestCount = 0; wsServer.Start(socket => { socket.OnOpen = () => { wsServerSessionID.Add(socket); Console.WriteLine(string.Format("youFast websocket client " + socket.ConnectionInfo.Id + " connected at " + socket.ConnectionInfo.ClientIpAddress + ":" + socket.ConnectionInfo.ClientPort + " Current connecton count is " + wsServerSessionID.Count)); }; socket.OnClose = () => { wsServerSessionID.Remove(socket); }; socket.OnMessage = async message => { forwardMessage[0] = message; // Console.WriteLine(message + " "); if (message.Contains("{") == true) // message may be JSON { decimal requestID = 0; DateTime dt = DateTime.Now; userRequestCount++; requestID = (userRequestCount * 1000 + dt.Millisecond) / 1000; if (!responseDict.ContainsKey(requestID)) { responseDict.TryAdd(requestID, new clientMachine.response()); } if (!requestID2SessionID.ContainsKey(requestID)) { requestID2SessionID.TryAdd(requestID, socket); } responseDict[requestID].serverSession = socket.ConnectionInfo.Id.ToString(); responseDict[requestID].startTime = DateTime.Now; if (responseDict[requestID].serverSession != null) { clientSessionVariable.TryAdd(responseDict[requestID].serverSession, new clientMachine.clientSession()); // new a clientSession } if (!isResponse.ContainsKey(responseDict[requestID].serverSession)) { isResponse.TryAdd(responseDict[requestID].serverSession, true); } if (isResponse[responseDict[requestID].serverSession] == true) { Json convert = new Json(); await Task.Run(() => convert.Json2VariableArray(message)); await Task.Run(() => convert.Json2VariableList(message, requestID, requestDict)); if (processAcceptList[2].ContainsKey(requestDict[requestID].processID) == true) { isResponse[responseDict[requestID].serverSession] = false; await Task.Run(() => convert.Json2VariableList(message, 2, requestDict)); } else if (requestDict[requestID].processID == "css") // next process is "function displayFilterDropDownList()", where processID = "selectFile" { CSS currentExport = new CSS(); await Task.Run(() => currentExport.css(isResponse, requestID2SessionID, wsServerSessionID, requestID, responseDict)); } else if (requestDict[requestID].processID == "addFilter") { serialID++; ExportHTML currentExport = new ExportHTML(); await Task.Run(() => currentExport.ramdistinct2AddFilter(isResponse, requestID2SessionID, wsServerSessionID, userPreference, outputFolder, requestID, clientSessionVariable, requestDict, responseDict, serialID, ramK2V[requestDict[requestID].importFile])); } else if (requestDict[requestID].processID == "addDisplayColumn") { ExportHTML currentExport = new ExportHTML(); serialID++; if (requestDict[requestID].addColumnType == "AddAllDistinctDimension") { await Task.Run(() => currentExport.ramdistint2DisplayAllColumn(isResponse, requestID2SessionID, wsServerSessionID, userPreference, outputFolder, requestID, clientSessionVariable, requestDict, responseDict, ramK2V[requestDict[requestID].importFile])); } if (requestDict[requestID].addColumnType == "AddCrosstabDimension") { await Task.Run(() => currentExport.ramdistint2Crosstab(isResponse, requestID2SessionID, wsServerSessionID, userPreference, tableFact, outputFolder, requestID, clientSessionVariable, requestDict, responseDict, ramK2V[requestDict[requestID].importFile])); } if (requestDict[requestID].addColumnType == "AddAllMeasurement") { await Task.Run(() => currentExport.ramdistint2AllMeasurement(isResponse, requestID2SessionID, wsServerSessionID, userPreference, outputFolder, requestID, clientSessionVariable, requestDict, responseDict, ramK2V[requestDict[requestID].importFile])); } } else if (requestDict[requestID].processID == "importSelectedFile" || requestDict[requestID].processID == "runReport") { isResponse[responseDict[requestID].serverSession] = false; currentRequestID[0] = requestID; requestDict[requestID].processID = ""; if (incomingRequest.TryAdd(requestID, message) == true) { incomingRequestQueue.Enqueue(requestID); } } } } }; socket.OnBinary = message => { }; }); }
protected void ButtonExportarPdf_Click(object sender, EventArgs e) { ModeloNegocios.AcuseContrato objAcuseContrato; int intFolio; bool ConversionOK; //esta nos dice si es un número válido ConversionOK = int.TryParse(Request.QueryString["IdFolio"], out intFolio); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter htw = new HtmlTextWriter(sw); Page page = new Page(); HtmlForm form = new HtmlForm(); page.EnableEventValidation = false; page.DesignerInitialize(); form = this.form1; form.FindControl("ButtonExportarPdf").Visible = false; page.Controls.Add(form); page.RenderControl(htw); string strCabecero = "<!DOCTYPE html> <html xmlns='http://www.w3.org/1999/xhtml'> <head runat='server'> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <title></title> <link href='https://framework-gb.cdn.gob.mx/assets/styles/main.css' rel='stylesheet'/> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300' rel='stylesheet' type='text/css'/> <link href='https://framework-gb.cdn.gob.mx/favicon.ico' rel='shortcut icon'/> <style> @media print { #ZonaNoImrpimible {display:none;} } nav,aside { display: none; } .auto-style1 { height: 119px; } </style> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'></script> </head> <body>"; string strPie = "</body> </html>"; string strBotonExportar = "<asp:Button ID=\"ButtonExportarPdf\" runat=\"server\" CssClass=\"btn btn-default\" OnClick=\"ButtonExportarPdf_Click\" Text=\"Exportar a PDF\" ToolTip=\"Exportar a PDF.\" />"; string strBotonImprimir = "<input type=\"button\" id=\"ButtonImprimir\" value=\"Imprimir\" onclick=\"javascript: window.print()\" class=\"btn\" />"; //RCA 10/08/2017 string strImagenLogoIndaabinHtml = "url('http://sistemas.indaabin.gob.mx/ImagenesComunes/INDAABIN_01.jpg')"; string strImagenLogoIndaabinFisica = "../Imagenes/logoindaabin.jpg"; string strBrakePage = "page-break-before: always;"; //RCA 10/08/2017 //cambio de ruta a rutas relativas string strImagenEscudoNacionalHtml = "url('http://sistemas.indaabin.gob.mx/ImagenesComunes/aguila.png')"; string strImagenEscudoNacionalFisica = "../Imagenes/EscudoNacional.png"; string strCuerpoOriginal = sb.ToString(); string strPaginaConCuerpo = strCabecero + strCuerpoOriginal + strPie; string strCuerpoFormateado = especialesHTML(strPaginaConCuerpo).Replace(strImagenLogoIndaabinHtml, strImagenLogoIndaabinFisica).Replace(strImagenEscudoNacionalHtml, strImagenEscudoNacionalFisica).Replace(strBotonImprimir, "").Replace(strBotonExportar, "").Replace(strBrakePage, ""); //cambiamos formato si pasa del 1/12/2018 //poner la url del nuevo logo si pasa del 1 de diciembre de 2018 if (ConversionOK) { objAcuseContrato = new NG_ContratoArrto().ObtenerAcuseContrato(intFolio); string fecha = objAcuseContrato.FechaAutorizacion.ToString(); string[] nuevafecha = fecha.Split('/'); string[] ano = nuevafecha[2].Split(' '); string dia = nuevafecha[0]; string mes = nuevafecha[1]; string year = ano[0]; if (Convert.ToInt32(year) >= 2018) { if (Convert.ToInt32(mes) >= 12) { if (Convert.ToInt32(dia) >= 1) { strCuerpoFormateado = strCuerpoFormateado.Replace("src=\"http://sistemas.indaabin.gob.mx/ImagenesComunes/INDAABIN_01.jpg\"", "src=\"https://sistemas.indaabin.gob.mx/ImagenesComunes/SHCP-INDAABINREDUCIDO.PNG\""); strCuerpoFormateado = strCuerpoFormateado.Replace("url(http://sistemas.indaabin.gob.mx/ImagenesComunes/aguila.png);", "url(https://sistemas.indaabin.gob.mx/ImagenesComunes/nuevoescudo.png);"); strCuerpoFormateado = strCuerpoFormateado.Replace("background-position: center;", "background-position: left;"); strCuerpoFormateado = strCuerpoFormateado.Replace("##font##", "font-family: Montserrat;"); strCuerpoFormateado = strCuerpoFormateado.Replace("##Viejo##", "display:none;"); } else { strCuerpoFormateado = strCuerpoFormateado.Replace("##Nuevo##", "display:none;"); } } else { strCuerpoFormateado = strCuerpoFormateado.Replace("##Nuevo##", "display:none;"); } } else { strCuerpoFormateado = strCuerpoFormateado.Replace("##Nuevo##", "display:none;"); } } ExportHTML exportar = new ExportHTML(); exportar.CanPrint = true; //RCA 10/18/2017 exportar.GenerarPDF(strCuerpoFormateado); }