2021-01-22 14:59:35 +00:00
/ * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* Instituto Costarricense de Acueductos y Alcantarillados . - 2015
* Administración de la Seguridad
* Nombre de la Pantalla : frwBusquedaSolicitud . aspx
*
* Explicación de los contenidos del archivo
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* HISTORIAL
*
* PERSONA DIA – MES - AÑO DESCRIPCIÓN
* Esteban Gutierrez Rapso 20 – 04 - 2015 Se inicia con el diseño de la pagina
* … … … … … … … … … … … … … … … … … … … … … …
* … … … … … … … … … … … … … … … … … … … … … …
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* Derechos Reservados ( C ) 2015 AyA .
* ESTE CÓDIGO ES PROVEÍDO “ TAL CUAL ES ” SIN GARANTÍA ALGUNA
* DE NINGÚN TIPO , SEA IMPLICITA O EXPLICITA .
* NO SE PERMITE SU REPRODUCCIÓN PARCIAL O TOTAL , NI SU COMERCIALIZACIÓN
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* /
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Web ;
using System.Web.UI ;
using System.Web.UI.WebControls ;
using System.Web.UI.HtmlControls ;
using AyABL ;
using AyABL.AUT.Autenticacion ;
using AyABL.APL ;
using AyADAL ;
using System.Configuration ;
using AyABL.RCS ;
using AyABL.Tran ;
using AyABL.Usuario ;
using System.Globalization ;
using System.Text ;
using System.Security.Cryptography ;
using System.IO ;
using AyABL.TRA ;
using iTextSharp.text ;
using iTextSharp.text.pdf ;
2021-02-23 19:07:27 +00:00
using Ionic.Zip ;
2021-01-22 14:59:35 +00:00
public partial class Forms_Trans_frwCartaSolicitud : General
{
#region Inicializar Formulario ( R0 )
override protected void OnInit ( EventArgs e ) //M0
{
try
{
base . OnInit ( e ) ;
InicializarFormulario ( ) ;
}
catch ( Exception ex )
{
MensajeError ( "Error en R0M0" , ex ) ;
}
}
private void InicializarFormulario ( ) //M1
{
try
{
Response . Cache . SetCacheability ( HttpCacheability . NoCache ) ;
Javascript . CheckAllGridViewItems ( Page ) ;
grvListaCartaSolicitud . Columns [ 1 ] . ItemStyle . Width = 150 ;
//cuwVentanaEmergenteDevolucion.AbrirVentanaEmergenteDevolucion += new ControlUsuario_cuwVentanaEmergenteDevolucion.SearchEvent(AbrirVentanaEmergenteDevolucion);
}
catch ( Exception ex )
{
MensajeError ( "Error en R0M1" , ex ) ;
}
}
#endregion
#region Variables ( R1 )
estadoCartaBL objEstadoCargaBL ;
tipoCartaBL objTipoCartaBL ;
//solicitudBL objSolicitudBL;
usuarioBL objUsuarioBL ;
UsuarioBL objUsuarioAyABL ;
cartaBL objCartaBL ;
DropDownList ddlTemporal , ddlTemporal2 ;
string strNumSolicitudTMP = string . Empty ;
2021-02-23 19:07:27 +00:00
int nNumeroSolicitudCFIA = 0 ;
2021-01-22 14:59:35 +00:00
#region variable firma digital
int nNumSolicitudTMP = 0 ;
int nPKReutilizaTMP = 0 ;
/// <summary>
/// Código del sistema cliente del servicio de firma digital. Cada sistema cliente debe usar un código diferente.
/// </summary>
private const string CodigoSistema = "SIGPC" ;
/// <summary>
/// Identificador del usuario definido para el sistema cliente
/// </summary>
private long IdUsuarioSistemaCliente
{
get
{
return long . Parse ( ConfigurationManager . AppSettings [ "IdUsuarioSistemaCliente" ] ) ;
}
}
#endregion
#region variables del estandar
string strPagina = string . Empty ;
string strScript = string . Empty ;
#endregion
#endregion
#region Eventos Formulario ( R2 )
protected void Page_Load ( object sender , EventArgs e ) //M0
{
try
{
2021-02-16 23:18:53 +00:00
strPKSolicitudTMP = Session [ "PKSOLICITUD" ] . ToString ( ) ;
2021-01-22 14:59:35 +00:00
ScriptManager . GetCurrent ( Page ) . RegisterPostBackControl ( btnNuevoCarta ) ;
ScriptManager . GetCurrent ( Page ) . RegisterPostBackControl ( grvListaCartaSolicitud ) ;
if ( Session [ "SOLICITUD" ] ! = null & & ! Session [ "SOLICITUD" ] . ToString ( ) . Contains ( "-TMP" ) )
{
nNumSolicitudTMP = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
nPKReutilizaTMP = int . Parse ( Session [ "FKREUTILIZA" ] . ToString ( ) ) ;
lblNumSolicitud . Text = Session [ "SOLICITUD" ] . ToString ( ) ;
strNumSolicitudTMP = Session [ "SOLICITUD" ] . ToString ( ) ;
if ( Request [ "d" ] ! = null )
{
if ( Request [ "d" ] . ToString ( ) = = "deshabilitar" | | Request [ "d" ] . ToString ( ) = = "finalizado" ) // || Request["d"].ToString() == "constancia") probar esto
{
mostrarFilaTabla ( 1 ) ;
ddlJefatura1 . Enabled = false ;
ddlJefatura2 . Enabled = false ;
btnGuardar . Enabled = false ;
btnNuevoCarta . Enabled = false ;
//cuwVentanaEmergenteDevolucion.Visible = false;
}
if ( Request [ "d" ] . ToString ( ) = = "finalizado" )
{
btnFinalizar . Enabled = false ;
}
if ( Request [ "d" ] . ToString ( ) = = "firmar" )
chkFirmado . Visible = true ;
2021-02-16 23:18:53 +00:00
chkNotificacion . Visible = true ;
2021-01-22 14:59:35 +00:00
}
if ( ( ! IsPostBack ) & & ( Session . Count > 0 ) )
{
Session [ "Pagina" ] = "" ;
mostrarFilaTabla ( 2 ) ;
//solicitudBL objSolicitudBL = new solicitudBL();
//objSolicitudBL.objSolicitudEL.PK = int.Parse(Session["PKPROGRAMACION"].ToString());
////objSolicitudBL.objSolicitudEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
//DataSet ds = objSolicitudBL.dsListaActividadesEncargado(null);
//if (ds.Tables[0].Rows[0]["CLASIFICACIONSOLICITUD"].ToString() == "Crecimiento vegetativo")
//{
// ddlJefatura2.Enabled = false;
//}
verificarCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
llenarDDLtipoformulario ( ) ;
ddlTemporal = ( DropDownList ) tdLista . FindControl ( "ddlJefatura1" ) ;
llenarDDLjefatura ( ddlTemporal ) ;
ddlTemporal2 = ( DropDownList ) tdLista . FindControl ( "ddlJefatura2" ) ;
llenarDDLjefatura ( ddlTemporal2 ) ;
}
}
else
{ ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript:parent.closeIFrameConstancia();</script>" ) ; }
if ( ViewState [ "MODO" ] ! = null )
{
if ( ViewState [ "MODO" ] . ToString ( ) = = "Firmador" )
{
obtenerDocumentoFirmado ( ) ;
}
}
}
catch ( Exception ex )
{
MensajeError ( "Error en R2M0" , ex ) ;
}
}
2021-02-16 23:18:53 +00:00
protected void btnSalirNotificacionCliente_Click ( object sender , EventArgs e )
{
try
{
//string pdfPathDocumentos = ConfigurationManager.AppSettings["RutaPdfAdjuntosSql"].ToString() + @"\" + Session["SOLICITUD"].ToString().Trim();
//if (Directory.Exists(pdfPathDocumentos))
// Directory.Delete(pdfPathDocumentos, true);
EjecutarScript ( "VentanaCerrarNotificacionCliente();VentanaAbrirActividades();" ) ;
//CargarImagenesSeguimientoActividades(int.Parse(Session["PKPROGRAMACION"].ToString()));
}
catch ( Exception ex )
{
EjecutarScript ( "window.parent.VentanaCerrarNotificacionClienteSesion();" ) ;
}
}
public void limpiarCampos ( ) //M2
{
txtDestinatario . Text = string . Empty ;
txtObservaciones . Text = string . Empty ;
}
protected void ddlTipoRevision_SelectedIndexChanged ( object sender , EventArgs e ) //M3
{
try
{
limpiarCampos ( ) ;
if ( ddlTipoRevision . SelectedValue = = "3" )
dvExaminar . Visible = true ;
else
dvExaminar . Visible = false ;
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M3" , ex ) ;
}
}
private bool SubirDocumentos ( string strAccion )
{
bool bRespuesta = true ;
string rutaAdjuntos = string . Empty ;
try
{
String path = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + lblNumSolicitud . Text . Trim ( ) + @"\DocumentosREQ\" ;
DirectoryInfo di = new DirectoryInfo ( path ) ;
foreach ( var fi in di . GetFiles ( ) )
{
string ext = Path . GetExtension ( fi . Name ) ;
if ( ext = = ".pdf" | | ext = = ".PDF" )
{
//string targetUrl = "'../../../DocumentosPDF/" + lblNumSolicitud.Text.Trim() + @"/";
string fname = Path . GetFileName ( fi . Name ) ;
//subir documentos a vision 2020
Documento oDoc = new Documento ( ) ;
string fileDirectory = path + fi . Name . Replace ( " " , "_" ) ;
//se transaforma el archivo a un arreglo de bytes
byte [ ] bDoc = System . IO . File . ReadAllBytes ( fileDirectory ) ;
string nombreAdjunto = fi . Name . Replace ( ".pdf" , "" ) ;
//se carga el archivo y el registro a vision 2020
string strResultado = oDoc . Archivar_Documento ( lblNumSolicitud . Text . Trim ( ) + "|" + "Otros" , fi . Name . Replace ( " " , "_" ) , bDoc ) ;
if ( strResultado ! = string . Empty )
bRespuesta = false ;
else
{
bRespuesta = true ;
File . Delete ( fileDirectory ) ;
}
}
}
}
catch ( Exception ex )
{
bRespuesta = false ;
MensajeError ( "Se dio un error al subir los documentos...." , ex ) ;
}
return bRespuesta ;
}
string strPKSolicitudTMP = "0" ;
private DataSet obtenerAdjuntos ( )
{
DataSet dsResult = new DataSet ( ) ;
try
{
adjuntoBL objAdjuntoBL = new adjuntoBL ( ) ;
objAdjuntoBL . objadjuntoEL . FKSOLICITUD = int . Parse ( strPKSolicitudTMP ) ;
//objAdjuntoBL.objadjuntoEL.FKREUTILIZA = int.Parse(strPKReutiliza);
char [ ] separadorColumna = { '-' } ;
string [ ] arrSolicitud = Session [ "SOLICITUD" ] . ToString ( ) . Split ( separadorColumna ) ;
objAdjuntoBL . objadjuntoEL . NUMEROSOLICITUD = arrSolicitud [ 1 ] . ToString ( ) ;
dsResult = objAdjuntoBL . listarAdjuntos ( null , false ) ;
}
catch ( Exception ex )
{
throw ex ;
}
return dsResult ;
}
private void llenarAdjuntos ( )
{
try
{
DataSet ds = obtenerAdjuntos ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
//if (ds.Tables[0].Rows[0]["DESCRIPCIONDOCUMENTO"].ToString() != string.Empty)
{
grvListaAdjuntos . DataSource = ds ;
grvListaAdjuntos . DataBind ( ) ;
General . detalleGridView ( ds , grvListaAdjuntos , null ) ;
//mostrarFilaTabla(1);
// llenarRequisitos();
}
}
}
catch ( Exception ex )
{
throw ex ;
}
}
protected void grvListaAdjuntos_PageIndexChanging ( object sender , GridViewPageEventArgs e )
{
try
{
grvListaAdjuntos . PageIndex = e . NewPageIndex ;
llenarAdjuntos ( ) ;
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M3" , ex ) ;
}
}
protected void grvListaAdjuntos_RowCommand ( object sender , GridViewCommandEventArgs e )
{
try
{
int i = Convert . ToInt32 ( e . CommandArgument ) ;
GridViewRow selectedRow = grvListaAdjuntos . Rows [ i ] ;
int nPk = int . Parse ( selectedRow . Cells [ 1 ] . Text ) ;
//int nFKAdjunto = int.Parse(selectedRow.Cells[4].Text);
string strNombreAdjunto = selectedRow . Cells [ 2 ] . Text . Replace ( " " , "_" ) ;
if ( e . CommandName = = "ver" )
{
string pdfPath = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + selectedRow . Cells [ 5 ] . Text + @"\DocumentosREQ\" + strNombreAdjunto ;
string targetURL = "'../../DocumentosPDF/" + selectedRow . Cells [ 5 ] . Text . Trim ( ) + "/DocumentosREQ/" + strNombreAdjunto + "'" ;
if ( System . IO . File . Exists ( pdfPath ) )
{
EjecutarScript ( "abrirPDF(" + targetURL + ");" ) ;
}
else
{
string strResultado = "" ;
Documento oDoc = new Documento ( ) ;
//consulta la ruta en la que se encuentra ubicado la copia del archivo a consultar
strResultado = oDoc . Consultar_Documento ( selectedRow . Cells [ 5 ] . Text . Trim ( ) + "|Otros" , selectedRow . Cells [ 5 ] . Text . Trim ( ) , strNombreAdjunto ) ;
int nTop = 400 ;
if ( strResultado ! = "" & & strResultado ! = "No existe" )
{
EjecutarScript ( "window.open('" + strResultado + "','','width=500,height=245,left=350,top=" + ( nTop . ToString ( ) ) + "');" ) ;
}
else
{
EjecutarScript ( "MensajeInformativoCompleto('No se encontró el documento." + strNombreAdjunto + "');" ) ;
}
}
}
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M15" , ex ) ;
}
}
protected void grvListaAdjuntos_RowDataBound ( object sender , GridViewRowEventArgs e )
{
try
{
e . Row . Cells [ 5 ] . Visible = false ; //OCULTAR NUMERO DE SOLICITUD
if ( e . Row . RowType = = DataControlRowType . DataRow )
{
bool bEnvioCorreo = false ;
if ( e . Row . Cells [ 6 ] . Text ! = " " )
bEnvioCorreo = bool . Parse ( e . Row . Cells [ 6 ] . Text ) ;
HtmlInputCheckBox chkTemp = ( HtmlInputCheckBox ) e . Row . Controls [ 0 ] . Controls [ 1 ] ;
chkTemp . Checked = bEnvioCorreo ;
}
e . Row . Cells [ 6 ] . Visible = false ; //OCULTAR ENVIOCORREO
}
catch ( Exception )
{ }
}
protected void btnSubirarchivo_Click ( object sender , EventArgs e )
{
try
{
string strRequisito = string . Empty ;
//if(txtdescripcion.Text != string.Empty)
//{
bool bSubirDocs = SubirDocumentos ( " " ) ;
if ( bSubirDocs )
{
llenarAdjuntos ( ) ;
EjecutarScript ( "MensajeInformativo();" ) ;
}
//}
//else
//{
// MensajeAlerta("Debe agregar la descripción del requisito...");
//}
}
catch ( Exception ex )
{
MensajeError ( "Se produjo un error en la operación" , ex ) ;
}
}
2021-01-22 14:59:35 +00:00
#endregion
#region Eventos Controles Web ( R3 )
2021-02-23 19:07:27 +00:00
protected void btnEnviarRevision_Click ( object sender , EventArgs e ) //M0
{
try
{
//if (ddlTipoRevision.SelectedValue != "3" || (ddlTipoRevision.SelectedValue == "3" && File.Exists(ConfigurationManager.AppSettings["RutaPdfAdjuntosSql"].ToString() + @"\" + lblNumSolicitud.Text.Trim() + @"\DocumentosREQ\" + lblNumSolicitud.Text.Trim() + "_DF" + ".pdf")))
//{
string strRutaArchivosAdjuntos = string . Empty ;
int nNumSolicitudTMP = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
strRutaArchivosAdjuntos = obtenerCartaSolicitud ( nNumSolicitudTMP ) ;
//MensajeInformativo("llego7");
if ( validarTamañoArchivos ( strRutaArchivosAdjuntos ) )
{
if ( txtDestinatario . Text ! = string . Empty )
{
notificacionClienteBL objNotificacionCliente = new notificacionClienteBL ( ) ;
objNotificacionCliente . objnotificacionClienteEL . DESTINATARIO = txtDestinatario . Text ;
objNotificacionCliente . objnotificacionClienteEL . OBSERVACIONES = txtObservaciones . Text ;
objNotificacionCliente . objnotificacionClienteEL . FECHAENVIO = DateTime . Now ;
objNotificacionCliente . objnotificacionClienteEL . FKTIPONOTIFICACION = int . Parse ( ddlTipoRevision . SelectedValue . ToString ( ) ) ;
objNotificacionCliente . objnotificacionClienteEL . FKUSUARIOXDEPENDENCIA = int . Parse ( Session [ "PKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) ;
objNotificacionCliente . objnotificacionClienteEL . FKSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
objNotificacionCliente . objnotificacionClienteEL . ASTATE = true ;
int nPKNotificacion = objNotificacionCliente . insertarNotificacionCliente ( ) ;
if ( nPKNotificacion > 0 )
{
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": Se ha registrado la notificacion al cliente en la solicitud " + strNumSolicitudTMP ,
"frwNotificacionCliente.aspx" ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
if ( ddlTipoRevision . SelectedValue = = "1" | | ddlTipoRevision . SelectedValue = = "3" )
{
#region Envio de correo externo
//System.Drawing.Image img = System.Drawing.Image.FromFile(ConfigurationManager.AppSettings["Imagenes"].ToString());
//string imgStr = imageToByteArray(img);
string p_strDocHtml = "<img alt='' src='cid:logoAyA.png' style='width: 100px; height: 82px;' />" ;
//string strImage64Bits = "data:image/jpg;base64," + imgStr;
//p_strDocHtml = p_strDocHtml.Replace("/logoAyA.png", strImage64Bits);
string strCuerpo = "El Instituto Costarricense de Acueductos y Alcantarillados le comunica que su trámite de Disponibilidad de Servicios ha sido concluido el " + DateTime . Now . ToLongDateString ( ) + ".</BR>Estamos para servirle, en nuestro horario de atención de 7:00 AM a 3:00 PM en las oficinas de AyA, si tiene alguna duda por favor contáctenos al teléfono " + Session [ "TELEFONODEPENDENCIA" ] . ToString ( ) + " o al 800-737-6783.</BR></BR>" + p_strDocHtml + "</BR></BR>Este es un mensaje generado de forma automática a la dirección de correo electrónico que usted ha suministrado por la cual NO DEBE SER RESPONDIDO. Base legal para esta alerta: Artículo Artículo 239 y siguientes de la Ley General de la Administración Pública." ;
string strPiePagina = "</BR> </BR></BR>AVISO DE CONFIDENCIALIDAD: este mensaje y la información incluida en él es confidencial y está dirigida únicamente al destinatario. Puede contener información privilegiada, confidencial, amparada por el secreto profesional o que no debe ser revelada. Si usted ha recibido este correo por error, por favor comunicarlo inmediatamente vía correo y tener la amabilidad de eliminarlo de su sistema. Queda notificado que no deberá copiar este mensaje, ni utilizar, divulgar, publicar o distribuir su contenido de modo alguno. Todo mensaje enviado a esta dirección de correo electrónico puede ser sujeto a inspección por alguien distinto de su receptor originario. La transmisión de correos no garantiza que el correo electrónico sea seguro o libre de error. Por consiguiente, se advierte que esta información pueda estar incompleta o ser poco precisa ya que toda información está sujeta a alterarse sin previo aviso.”" ;
string strAsunto = "Resolución de Trámite de Disponibilidad de Servicios" ;
AyABL . TRA . correoExternoBL objcorreoExternoBL = new AyABL . TRA . correoExternoBL ( ) ;
objcorreoExternoBL . objcorreoExternoEL . p_recipients = txtDestinatario . Text ;
objcorreoExternoBL . objcorreoExternoEL . p_copy = "" ;
objcorreoExternoBL . objcorreoExternoEL . p_subject = strAsunto ;
objcorreoExternoBL . objcorreoExternoEL . p_body = strCuerpo + strPiePagina ;
objcorreoExternoBL . objcorreoExternoEL . P_PRIORIDAD = "High" ;
objcorreoExternoBL . objcorreoExternoEL . p_format = "html" ;
#region adjuntar constancias
objcorreoExternoBL . objcorreoExternoEL . p_file_attachments = strRutaArchivosAdjuntos ; //obtenerCartaSolicitud(nNumSolicitudTMP);
#endregion
int nValorRetornado = objcorreoExternoBL . EnviarCorreoExterno ( ) ;
objcorreoExternoBL . objcorreoExternoEL . p_recipients = Session [ "LOGIN" ] . ToString ( ) + "@aya.go.cr" ;
nValorRetornado = objcorreoExternoBL . EnviarCorreoExterno ( ) ;
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": Se envió el correo de notificación a la dirección " + txtDestinatario . Text ,
"frwNotificacionCliente.aspx" ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
#endregion
}
//llenarGridNotificacionClientes();
limpiarCampos ( ) ;
btnFinalizar . Enabled = true ;
chkNotificacion . Enabled = false ;
MensajeInformativo ( "Se ha enviado la notificación al cliente." ) ;
}
}
else
{
MensajeAlerta ( "Debe digitar el teléfono o correo del destinatario." ) ;
}
//}
//else
//{
// MensajeAlerta("Debe adjuntar el documento fisico de respuesta al cliente.");
//}
}
}
catch ( Exception ex )
{
//Trace.Write(ex.Message.ToString());
MensajeError ( "Error en R3M0 Error al registrar la notificación al cliente" , ex ) ;
}
}
private string obtenerCartaSolicitud ( int nNumSolicitud ) //M2
{
string strResultado = string . Empty ;
string pdfPathConstancia = string . Empty ;
string pdfPathCriterioAP = string . Empty ;
string pdfPathCriterioAS = string . Empty ;
string pdfPathAdjuntos = string . Empty ;
string strNombreCarta = string . Empty ;
string targetURL = string . Empty ;
string ruta = string . Empty ;
try
{
#region constancias
//Instancia el objeto
cartaBL objCartaBL = new cartaBL ( ) ;
//Trace.Write("Paso 0");
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitud ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = string . Empty ;
//objCartaBL.objCartaEL.FKREUTILIZA = nPKReutiliza;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
string pdfPath = "" ;
//ViewState["MODO"] = "Modificar";
foreach ( DataRow row in ds . Tables [ 0 ] . Rows )
{
try
{
if ( row [ "DESCRIPCIONESTADOCARTA" ] . ToString ( ) = = "Activo" )
{
char delimitador = '-' ;
string [ ] arrayNombre = row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) . Split ( delimitador ) ;
pdfPath = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) + @"\" + row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + ".pdf" ;
ruta = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) ;
if ( ! File . Exists ( pdfPath ) )
{
//MensajeInformativo("llego5");no entro
//obtener la constancia y ponerla en la carpeta compartida para el envio de correo
//se el registro de vision 2020
Documento oDoc = new Documento ( ) ;
string strAlmacenado = oDoc . Visor_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Constancia" , strNumSolicitudTMP . ToString ( ) . Trim ( ) , pdfPath , row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + ".pdf" ) ;
if ( strAlmacenado ! = string . Empty & & strAlmacenado ! = "No existe" )
strResultado + = pdfPath + ";" ;
}
else
{
strResultado + = pdfPath + ";" ;
}
}
}
catch ( Exception exp )
{
MensajeError ( exp . ToString ( ) , exp ) ;
}
}
strResultado + = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\logoAyA.png;" ;
}
#endregion
//Trace.Write("Paso 1");
#region formulario agua potable
//limpiarCampos();
strNombreCarta = strNumSolicitudTMP ;
pdfPathCriterioAP = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + strNumSolicitudTMP + @"\" + strNombreCarta + "-AP.pdf" ;
ruta = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + strNumSolicitudTMP ;
if ( ! File . Exists ( pdfPathCriterioAP ) )
{
//se carga el archivo y el registro a vision 2020
Documento oDoc = new Documento ( ) ;
string strAlmacenado = oDoc . Visor_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Criterio técnico AP" , strNumSolicitudTMP . ToString ( ) . Trim ( ) , pdfPathCriterioAP , strNombreCarta + "-AP.pdf" ) ;
if ( strAlmacenado ! = string . Empty & & strAlmacenado ! = "No existe" )
strResultado + = pdfPathCriterioAP + ";" ; ;
}
else
{
//EjecutarScript("alert('" + pdfPathCriterioAP + "-" + ruta + @"\" + strNombreCarta + "-AP.pdf" + "');");
// File.Copy(pdfPathCriterioAP, ruta + @"\" + strNombreCarta + "-AP.pdf", true);
strResultado + = ( ruta + @"\" + strNombreCarta + "-AP.pdf" + ";" ) ;
}
#endregion
//Trace.Write("Paso 2");
#region formulario alcantarillado sanitario
//limpiarCampos();
strNombreCarta = strNumSolicitudTMP ;
pdfPathCriterioAS = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + strNumSolicitudTMP + @"\" + strNombreCarta + "-AS.pdf" ;
ruta = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + strNumSolicitudTMP ;
targetURL = "'../../DocumentosPDF/" + strNumSolicitudTMP + "/" + strNombreCarta + "-AS.pdf'" ;
if ( ! File . Exists ( pdfPathCriterioAS ) )
{
//se carga el archivo y el registro a vision 2020
Documento oDoc = new Documento ( ) ;
string strAlmacenado = oDoc . Visor_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Criterio técnico AS" , strNumSolicitudTMP . ToString ( ) . Trim ( ) , pdfPathCriterioAS , strNombreCarta + "-AS.pdf" ) ;
if ( strAlmacenado ! = string . Empty & & strAlmacenado ! = "No existe" )
strResultado + = pdfPathCriterioAS + ";" ; ;
}
else
{
//File.Copy(pdfPathCriterioAS, ruta + @"\" + strNombreCarta + "-AS.pdf", true);
strResultado + = ( ruta + @"\" + strNombreCarta + "-AS.pdf" + ";" ) ;
}
#endregion
//Trace.Write("Paso 3");
#region adjuntos
// recorro el grid
foreach ( GridViewRow row in grvListaAdjuntos . Rows )
{
HtmlInputCheckBox chkTemp = ( HtmlInputCheckBox ) row . Controls [ 0 ] . Controls [ 1 ] ;
if ( chkTemp ! = null )
{
// si el registro esta marcado
if ( chkTemp . Checked )
{
string strNombreDocumento = row . Cells [ 2 ] . Text ;
ruta = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + lblNumSolicitud . Text . Trim ( ) + @"\DocumentosREQ\" ;
pdfPathAdjuntos = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + lblNumSolicitud . Text . Trim ( ) + @"\DocumentosREQ\" + strNombreDocumento ;
if ( ! File . Exists ( pdfPathAdjuntos ) )
{
//obtener la constancia y ponerla en la carpeta compartida para el envio de correo
//se el registro de vision 2020
Documento oDoc = new Documento ( ) ;
string strAlmacenado = oDoc . Visor_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Otros" , strNumSolicitudTMP . ToString ( ) . Trim ( ) , pdfPathAdjuntos , strNombreDocumento ) ;
if ( strAlmacenado ! = string . Empty & & strAlmacenado ! = "No existe" ) //si el documento es adjuntado al correo desde vision 2020
{
strResultado + = pdfPathAdjuntos + ";" ; ;
AyABL . Tran . adjuntoBL objdocumentoBL = new AyABL . Tran . adjuntoBL ( ) ;
objdocumentoBL . objadjuntoEL . PK = int . Parse ( row . Cells [ 1 ] . Text ) ;
int nPKDocumento = objdocumentoBL . modificarEnvioCorreoAdjunto ( ) ; //pone el adjunto como enviado en el correo
}
}
else
{
if ( File . Exists ( pdfPathAdjuntos ) ) //si el documento es adjuntado al correo desde la ruta fisica
{
strResultado + = pdfPathAdjuntos + ";" ; ;
AyABL . Tran . adjuntoBL objdocumentoBL = new AyABL . Tran . adjuntoBL ( ) ;
objdocumentoBL . objadjuntoEL . PK = int . Parse ( row . Cells [ 1 ] . Text ) ;
int nPKDocumento = objdocumentoBL . modificarEnvioCorreoAdjunto ( ) ; //pone el adjunto como enviado en el correo
}
}
}
}
}
//Trace.Write("Paso 4");
#endregion
}
catch ( Exception ex )
{
//EjecutarScript("alert('" + ex.Message.ToString() + "');");
throw ex ;
}
return strResultado ;
}
public bool validarTamañoArchivos ( string strRutaArchivos )
{
bool bResultado = false ;
int nMaximoTamañoCorreo = int . Parse ( ConfigurationManager . AppSettings [ "TamañoArchivosBytes" ] . ToString ( ) ) ;
long nSumTamañoAdjuntos = 0 ;
string strInfoArchivos = string . Empty ;
try
{
char [ ] separadorAdjuntos = { ';' } ;
string [ ] strArrayAdjuntos = strRutaArchivos . Split ( separadorAdjuntos ) ;
for ( int i = 0 ; i < = ( strArrayAdjuntos . Length - 1 ) ; i + + )
{
if ( strArrayAdjuntos [ i ] ! = string . Empty )
{
if ( File . Exists ( strArrayAdjuntos [ i ] . ToString ( ) ) )
{
FileInfo file = new FileInfo ( strArrayAdjuntos [ i ] . ToString ( ) ) ;
nSumTamañoAdjuntos + = file . Length ;
if ( nSumTamañoAdjuntos < nMaximoTamañoCorreo )
bResultado = true ;
else
bResultado = false ;
decimal dResultado = decimal . Divide ( decimal . Parse ( file . Length . ToString ( ) ) , decimal . Parse ( "1048576" ) ) ;
strInfoArchivos + = file . Name + " - " + dResultado . ToString ( "N2" ) + " MB</BR>" ;
}
}
}
if ( bResultado = = false )
{
MensajeAlerta ( "El tamaño de los archivos excede el limite permitido " + ( int . Parse ( ConfigurationManager . AppSettings [ "TamañoArchivosBytes" ] . ToString ( ) ) / 1048576 ) . ToString ( ) + " MB.</BR>" + strInfoArchivos ) ; //conversion a megabytes
}
}
catch ( Exception ex )
{
throw ex ;
}
return bResultado ;
}
2021-02-17 20:08:24 +00:00
protected void chkNotificacion_CheckedChanged ( object sender , EventArgs e )
{
try
{
if ( chkNotificacion . Checked )
{
divNotificacion . Visible = true ;
2021-02-23 19:07:27 +00:00
btnFinalizar . Enabled = false ;
2021-02-17 20:08:24 +00:00
}
else
{
divNotificacion . Visible = false ;
txtDestinatario . Text = "" ;
txtObservaciones . Text = "" ;
chkCFIA . Checked = false ;
2021-02-23 19:07:27 +00:00
btnFinalizar . Enabled = true ;
2021-02-17 20:08:24 +00:00
}
}
catch ( Exception ex )
{
MensajeError ( "Se dio un error." , ex ) ;
}
finally
{
EjecutarScript ( "inicializaTab('formulario');" ) ;
}
}
2021-01-22 14:59:35 +00:00
protected void btnNuevaCarta_Click ( object sender , EventArgs e ) //M1
{
try
{
//limpiarCampos();
ViewState [ "MODO" ] = "Nuevo" ;
mostrarFilaTabla ( 3 ) ;
//Limpia el grid de Active Directory
ddlTipoFormulario . Focus ( ) ;
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M6" , ex ) ;
}
}
/// <summary>
/// Metodo que se utiliza para borrar clientes
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grvListaCartaSolicitud_RowCommand ( object sender , GridViewCommandEventArgs e ) //M2
{
PdfReader reader = null ;
FileStream fs = null ;
PdfStamper stamp = null ;
Document document = null ;
try
{
int i = Convert . ToInt32 ( e . CommandArgument ) ;
GridViewRow selectedRow = grvListaCartaSolicitud . Rows [ i ] ;
int nPk = int . Parse ( selectedRow . Cells [ 0 ] . Text ) ;
Char delimiter = '-' ;
string [ ] arrayDoc = selectedRow . Cells [ 1 ] . Text . Split ( delimiter ) ; //SIGDD - AÑO - CONTADOR - CONTADOR DOCUMENTO - CONTADOR VERSION
string strNombreCarta = arrayDoc [ 0 ] . ToString ( ) + "-" + arrayDoc [ 1 ] . ToString ( ) + "-" + arrayDoc [ 2 ] . ToString ( ) + "-" + arrayDoc [ 3 ] . ToString ( ) + "-" + arrayDoc [ 4 ] . ToString ( ) + "-" + arrayDoc [ 5 ] . ToString ( ) ;
if ( e . CommandName = = "eliminar" )
{
if ( eliminarCartaSolicitud ( nPk ) )
obtenerCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . EliminarRegistro + ": Se ha eliminado la carta " + strNombreCarta + " de la solicitud " + selectedRow . Cells [ 1 ] . Text ,
"frwCartaSolicitud.aspx" ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
}
if ( e . CommandName = = "renovar" )
{
if ( RenovarDocumento ( nNumSolicitudTMP , selectedRow . Cells [ 1 ] . Text , nPk ) )
obtenerCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": Se ha renovado el documento " + selectedRow . Cells [ 1 ] . Text + " para la solicitud " + Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) ,
"frwCartaSolicitud.aspx" ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
}
if ( e . CommandName = = "reconsiderar" )
{
//Instancia el objeto
objCartaBL = new cartaBL ( ) ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitudTMP ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = selectedRow . Cells [ 1 ] . Text ;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
if ( int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "FKESTADO" ] . ToString ( ) ) = = 1 )
{
//limpiarCampos();
eliminarCartaSolicitud ( nPk ) ;
ViewState [ "MODO" ] = "Reconsiderar" ;
ViewState [ "RECONSIDERAR" ] = selectedRow . Cells [ 1 ] . Text ;
mostrarFilaTabla ( 3 ) ;
//Limpia el grid de Active Directory
ddlTipoFormulario . Focus ( ) ;
llenarDDLtipoformulario ( ) ;
ddlTemporal = ( DropDownList ) tdLista . FindControl ( "ddlJefatura1" ) ;
llenarDDLjefatura ( ddlTemporal ) ;
ddlTemporal2 = ( DropDownList ) tdLista . FindControl ( "ddlJefatura2" ) ;
llenarDDLjefatura ( ddlTemporal2 ) ;
}
else
{
{ ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('El documento no puede ser reconsiderado.');</script>" ) ; }
}
}
if ( e . CommandName = = "editar" )
{
//limpiarCampos();
editarDocumento ( strNombreCarta ) ;
}
if ( e . CommandName = = "firmar" )
{
//limpiarCampos();
firmarDocumento ( strNombreCarta ) ;
}
if ( e . CommandName = = "ver" )
{
//limpiarCampos();
char delimitador = '-' ;
string [ ] arrayNombre = strNombreCarta . Split ( delimitador ) ;
string strResultado = string . Empty ;
string pdfPath = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) + @"\" + strNombreCarta + ".pdf" ;
string targetURL = "'../../DocumentosPDF/" + arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) + "/" + strNombreCarta + ".pdf'" ;
string ruta = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) ;
if ( System . IO . File . Exists ( pdfPath ) )
{
#region constancias
Documento oDoc = new Documento ( ) ;
byte [ ] bDoc = System . IO . File . ReadAllBytes ( pdfPath ) ;
//se carga el archivo y el registro a vision 2020
strResultado = oDoc . Archivar_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Constancia" , strNombreCarta + ".pdf" , bDoc ) ;
if ( strResultado = = string . Empty )
{
//File.Delete(pdfPath);
}
#endregion
}
//if (!File.Exists(pdfPath))
{
//obtener la constancia y ponerla en la carpeta compartida para el envio de correo
//se el registro de vision 2020
Documento oDoc = new Documento ( ) ;
strResultado = oDoc . Consultar_Documento ( arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) + "|Constancia" , strNombreCarta , strNombreCarta + ".pdf" ) ;
solicitudBL objSolicitudBL = new solicitudBL ( ) ;
objSolicitudBL . objSolicitudEL . PK = int . Parse ( Session [ "PKPROGRAMACION" ] . ToString ( ) ) ;
objSolicitudBL . objSolicitudEL . ORDEN = 6 ; //se valida la tarea 6 Validación y firma se encuentre finalizada
objSolicitudBL . objSolicitudEL . FKESTADO = 5 ;
objSolicitudBL . objSolicitudEL . FKESTADO2 = 8 ;
DataSet dsEncargadosActividades = objSolicitudBL . dsListaActividadesEncargado ( null ) ;
if ( dsEncargadosActividades . Tables [ 0 ] . Rows . Count > 0 )
{
int nTipoInspeccion = int . Parse ( dsEncargadosActividades . Tables [ 0 ] . Rows [ 0 ] [ "FKTIPOINSPECCION" ] . ToString ( ) ) ;
if ( strResultado ! = string . Empty & & strResultado ! = "No existe" )
{
EjecutarScript ( "abrirPDF('" + strResultado + "');" ) ;
}
}
else
{
if ( strResultado ! = string . Empty & & strResultado ! = "No existe" )
{
reader = new PdfReader ( strResultado ) ;
fs = null ;
document = null ;
if ( ! Directory . Exists ( ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\DocumentosVisor\" ) )
Directory . CreateDirectory ( ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\DocumentosVisor\" ) ;
if ( File . Exists ( ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\DocumentosVisor\" + strNombreCarta + ".pdf" ) )
File . Delete ( ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\DocumentosVisor\" + strNombreCarta + ".pdf" ) ;
document = new Document ( ) ;
string outputPdf = String . Format ( ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\DocumentosVisor\" + strNombreCarta + ".pdf" ,
Guid . NewGuid ( ) . ToString ( ) ) ;
fs = new FileStream ( outputPdf ,
FileMode . CreateNew ,
FileAccess . Write ) ;
//crear estampador
stamp = null ;
stamp = new PdfStamper ( reader , fs ) ;
byte [ ] USER = Encoding . ASCII . GetBytes ( Session [ "LOGIN" ] . ToString ( ) ) ;
byte [ ] OWNER = Encoding . ASCII . GetBytes ( Session [ "LOGIN" ] . ToString ( ) ) ;
//stamp.SetEncryption(USER, OWNER, PdfWriter.ALLOW_SCREENREADERS, PdfWriter.ENCRYPTION_AES_128);
BaseFont bf = BaseFont . CreateFont ( @"c:\windows\fonts\arial.ttf" , BaseFont . CP1252 , true ) ;
PdfGState gs = new PdfGState ( ) ;
gs . FillOpacity = 0.35F ;
gs . StrokeOpacity = 0.35F ;
//escribir texto en las paginas
for ( int nPag = 1 ; nPag < = reader . NumberOfPages ; nPag + + )
{
Rectangle tamPagina = reader . GetPageSizeWithRotation ( nPag ) ;
PdfContentByte over = stamp . GetOverContent ( nPag ) ;
over . BeginText ( ) ;
WriteTextToDocument ( bf , tamPagina , over , gs , "COPIA INVALIDA" ) ;
over . EndText ( ) ;
}
stamp . Close ( ) ;
reader . Close ( ) ;
//if (stamp != null) stamp.Close();
if ( fs ! = null ) fs . Close ( ) ;
if ( document ! = null ) document . Close ( ) ;
//System.Diagnostics.Process proc = new System.Diagnostics.Process();
//proc.StartInfo.FileName = ConfigurationManager.AppSettings["DocumentosPDF"].ToString() + @"\DocumentosVisor\" + strNombreCarta + ".pdf";
//proc.Start();
//proc.Close();
if ( System . IO . File . Exists ( ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\DocumentosVisor\" + strNombreCarta + ".pdf" ) )
{
#region constancias
Documento oDoc2 = new Documento ( ) ;
byte [ ] bDoc = System . IO . File . ReadAllBytes ( ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\DocumentosVisor\" + strNombreCarta + ".pdf" ) ;
//se carga el archivo y el registro a vision 2020
strResultado = oDoc2 . Archivar_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Constancia" , strNombreCarta + "Copia.pdf" , bDoc ) ;
if ( strResultado = = string . Empty )
{
//File.Delete(pdfPath);
}
oDoc2 = new Documento ( ) ;
strResultado = oDoc2 . Consultar_Documento ( arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) + "|Constancia" , strNombreCarta , strNombreCarta + "Copia.pdf" ) ;
if ( strResultado ! = string . Empty & & strResultado ! = "No existe" )
{
EjecutarScript ( "abrirPDF('" + strResultado + "');" ) ;
}
else
{
ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('Se presentó un problema al abrir el documento, intente de nuevo.');</script>" ) ;
}
#endregion
}
//strResultado += pdfPath + ";"; ;
//EjecutarScript("abrirPDF('" + ConfigurationManager.AppSettings["DocumentosPDF"].ToString() + @"\DocumentosVisor\" + strNombreCarta + ".pdf" + "');");
}
else
{
if ( strResultado = = string . Empty | | strResultado = = "No existe" )
ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No se ha generado el documento PDF." + pdfPath + "');</script>" ) ;
}
}
}
//EjecutarScript("abrirPDF(" + targetURL + ");");
// //System.Diagnostics.Process proc = new System.Diagnostics.Process();
// //proc.StartInfo.FileName = pdfPath;
// //proc.Start();
// //proc.Close();
// //EjecutarScript("JavaScript: window.open('" + targetURL + "','','width=500,height=245,left=350,top=50');");
}
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M15" , ex ) ;
}
finally
{
if ( reader ! = null )
reader . Close ( ) ;
//if (stamp != null) stamp.Close();
if ( fs ! = null ) fs . Close ( ) ;
if ( document ! = null ) document . Close ( ) ;
}
}
protected void grvListaCartaSolicitud_PageIndexChanging ( object sender , GridViewPageEventArgs e ) //M3
{
try
{
grvListaCartaSolicitud . PageIndex = e . NewPageIndex ;
obtenerCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M3" , ex ) ;
}
}
///<summary>
///Activa el metodo del boton Anterior, regresa a la primera fila de la tabla
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
protected void btnAnterior_Click ( object sender , EventArgs e ) //M3
{
try
{
obtenerCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
divDatosSuperiores . Visible = true ;
divDatosInferiores . Visible = false ;
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M3" , ex ) ;
}
}
/// <summary>
/// Activa el evento del boton Nuevo
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNuevo_Click ( object sender , EventArgs e ) //M8
{
try
{
//limpiarCampos();
ViewState [ "MODO" ] = "Nuevo" ;
mostrarFilaTabla ( 3 ) ;
//Limpia el grid de Active Directory
ddlTipoFormulario . Focus ( ) ;
llenarDDLtipoformulario ( ) ;
ddlTemporal = ( DropDownList ) tdLista . FindControl ( "ddlJefatura1" ) ;
llenarDDLjefatura ( ddlTemporal ) ;
ddlTemporal2 = ( DropDownList ) tdLista . FindControl ( "ddlJefatura2" ) ;
llenarDDLjefatura ( ddlTemporal2 ) ;
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M8" + MensajesAplicacion . GuardadoFallido . ToString ( ) , ex ) ;
}
}
/// <summary>
/// Activa el evento de guardar
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnGuardar_Click ( object sender , EventArgs e ) //M9
{
try
{
{
string strModo = ViewState [ "MODO" ] . ToString ( ) ;
string strDocumento = string . Empty ;
//if (ddlTipoFormulario.SelectedValue == "-1")
//{
// MensajeAlerta("Debe seleccionar el tipo de formulario.");
// ddlTipoFormulario.Focus();
//}
//else
{
if ( ddlJefatura1 . SelectedValue = = "-1" )
{
MensajeAlerta ( "Debe seleccionar la jefatura 1." ) ;
ddlJefatura1 . Focus ( ) ;
}
if ( ddlJefatura1 . SelectedValue = = ddlJefatura2 . SelectedValue )
{
MensajeAlerta ( "No se puede seleccionar la misma jefatura para ambas jefaturas." ) ;
ddlJefatura1 . Focus ( ) ;
}
else
{
inspeccionasBL objInspeccionasBL = new inspeccionasBL ( ) ;
objInspeccionasBL . objinspeccionasEL . FKSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
objInspeccionasBL . objinspeccionasEL . DESCRIPCIONESTADOINSPECCION = "Asignada" ;
DataSet dsInspeccionASBL = objInspeccionasBL . listarInspeccionesAS ( null ) ;
inspeccionapBL objInspeccionapBL = new inspeccionapBL ( ) ;
objInspeccionapBL . objinspeccionapEL . FKSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
objInspeccionapBL . objinspeccionapEL . DESCRIPCIONESTADOINSPECCION = "Asignada" ;
DataSet dsInspeccionPABL = objInspeccionapBL . listarInspecciones ( null ) ;
int nFKTipoConstancia = 0 ;
int nTipoInspeccion = 0 ;
if ( dsInspeccionASBL . Tables [ 0 ] . Rows . Count > 0 )
nTipoInspeccion = int . Parse ( dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "FKTIPOINSPECCION" ] . ToString ( ) ) ;
if ( dsInspeccionPABL . Tables [ 0 ] . Rows . Count > 0 )
nTipoInspeccion = int . Parse ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "FKTIPOINSPECCION" ] . ToString ( ) ) ;
#region Ambos
if ( nTipoInspeccion = = 3 )
{
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "true" & & dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 1 ; //Formulario N°1 SI SI
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "false" )
{
nFKTipoConstancia = 2 ; //Formulario N°2 NO NO
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
if ( dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "CRITECNICONOEXISTEDISPONIBILIDAD" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 6 ; //Formulario N°6 SI-NO CCR
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTECAPACIDADHIDRICAEXISTEDISPONIBILIDADAP" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 5 ; //Formulario N°5 NO-SI CCH
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
}
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "true" & & dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "false" )
{
nFKTipoConstancia = 4 ; //Formulario N°4 SI NO
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
if ( dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "CRITECNICONOEXISTEDISPONIBILIDAD" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 6 ; //Formulario N°6 SI-NO CCR
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
}
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 3 ; //Formulario N°4 NO SI
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTECAPACIDADHIDRICAEXISTEDISPONIBILIDADAP" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 5 ; //Formulario N°5 NO-SI CCH
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
}
}
#endregion
#region Agua potable
if ( nTipoInspeccion = = 1 )
{
nFKTipoConstancia = 0 ;
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 4 ; //Formulario N°4 SI NO
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "false" )
{
nFKTipoConstancia = 2 ; //Formulario N°2 NO NO
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
if ( dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAP" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionPABL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTECAPACIDADHIDRICAEXISTEDISPONIBILIDADAP" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 5 ; //Formulario N°5 NO-NO CCH
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
dsInspeccionPABL = null ;
}
#endregion
#region alcantarillado sanitario
if ( nTipoInspeccion = = 2 )
{
nFKTipoConstancia = 0 ;
if ( dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 3 ; //Formulario N°3 NO-SI
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
if ( dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "false" )
{
nFKTipoConstancia = 2 ; //Formulario N°2 NO NO
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
if ( dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "EXISTEDISPONIBILIDADINSPECCIONAS" ] . ToString ( ) . ToLower ( ) = = "false" & & dsInspeccionASBL . Tables [ 0 ] . Rows [ 0 ] [ "CRITECNICONOEXISTEDISPONIBILIDAD" ] . ToString ( ) . ToLower ( ) = = "true" )
{
nFKTipoConstancia = 6 ; //Formulario N°6 NO-NO CCR
strDocumento = GuardarDatos ( nFKTipoConstancia ) ;
generarDocumento ( strDocumento , nFKTipoConstancia . ToString ( ) ) ;
}
dsInspeccionASBL = null ;
}
#endregion
obtenerCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
MensajeInformativo ( AyABL . BASESDEDATOS . ADS + "Interfaz: " + MensajesAplicacion . GuardadoExitoso . ToString ( ) ) ;
}
}
}
}
catch ( Exception ex )
{
MensajeError ( "Error en R3M8" + MensajesAplicacion . GuardadoFallido . ToString ( ) , ex ) ;
}
}
protected void btnGuardarPDF_Click ( object sender , EventArgs e )
{
try
{
//FirmadorWeb.FirmadorWebSvcClient cliente = new FirmadorWeb.FirmadorWebSvcClient();
if ( documento ! = null & & documento . Firmas . Count ( ) > 0 )
{
//byte[] contenido = cliente.ObtenerContenidoDocumento(
// long.Parse(ViewState["DocumentoID"].ToString()),
// CodigoSistema);
//System.IO.File.WriteAllBytes(ConfigurationManager.AppSettings["DocumentosPDF"].ToString() + @"\" + Session["SOLICITUD"].ToString() + @"\" + ViewState["Documento"].ToString() + ".pdf", contenido);
//ViewState.Remove("DocumentoID");
////var uri = new System.Uri(ConfigurationManager.AppSettings["DocumentosPDF"].ToString() + @"\" + Session["SOLICITUD"].ToString() + @"\" + ViewState["Documento"].ToString() + ".pdf", UriKind.Absolute);
//string targetURL = "'../../DocumentosPDF/" + Session["SOLICITUD"].ToString() + "/" + ViewState["Documento"].ToString() + ".pdf'";
//EjecutarScript("abrirPDF(" + targetURL + ");");
//System.Diagnostics.Process proc = new System.Diagnostics.Process();
//proc.StartInfo.FileName = ConfigurationManager.AppSettings["DocumentosPDF"].ToString() + @"\" + Session["SOLICITUD"].ToString() + @"\" + ViewState["Documento"].ToString() + ".pdf'";
//proc.Start();
//proc.Close();
}
else
{
MensajeAlerta ( "El documento no se firmó correctamente por favor vuelava a intentarlo." ) ;
}
}
catch ( Exception ex )
{
MensajeError ( "Se produjo un error al firmar el documento pdf." , ex ) ;
}
ViewState [ "MODO" ] = string . Empty ;
ViewState [ "Documento" ] = string . Empty ;
}
#endregion
#region Metodos Personalizados ( R4 )
/// <summary>
/// Oculta las filas que lo requieran
/// </summary>
/// <param name="p_intFila"></param>
private void mostrarFilaTabla ( int p_intFila ) //M0
{
try
{
divDatosSuperiores . Visible = false ;
divDatosInferiores . Visible = false ;
switch ( p_intFila )
{
case 1 :
divDatosSuperiores . Visible = true ;
break ;
case 3 :
divDatosInferiores . Visible = true ;
break ;
}
}
catch ( Exception ex )
{
throw ex ;
}
}
/// <summary>
/// Metodo que se utiliza para remover el role asignado al usuario
/// </summary>
/// <param name="p_nPk"></param>
private bool eliminarCartaSolicitud ( int p_nPk ) //M1
{
bool blnValorRetornado = false ;
try
{
objCartaBL = new cartaBL ( ) ;
objCartaBL . objCartaEL . PK = p_nPk ;
objCartaBL . objCartaEL . FKESTADOCARTA = 3 ; //eliminado
objCartaBL . activarInactivarCarta ( ) ;
blnValorRetornado = true ;
}
catch ( Exception ex )
{
throw ex ;
}
return blnValorRetornado ;
}
#endregion
#region Metodos Controles a Datos ( R5 )
/// <summary>
/// guarda y modifica registros en la tabla.
/// </summary>
/// <returns></returns>
private string GuardarDatos ( int p_fkTipoFormulario ) //M0
{
string strValorRetornado = "" ;
int nValorRetornado = 0 ;
try
{
string strModo = ViewState [ "MODO" ] . ToString ( ) ;
DataSet ds = obtenerDocumento ( nNumSolicitudTMP , "" ) ;
int Contador = ds . Tables [ 0 ] . Rows . Count + 1 ;
objCartaBL = new cartaBL ( ) ;
objCartaBL . objCartaEL . FKNUMSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = ConfigurationManager . AppSettings [ "SIGLAS" ] . ToString ( ) + "-" + Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) + "-" + Contador . ToString ( ) + "-1" ; //SDAA - AÑO - CONTADOR - CONTADOR DOCUMENTO - CONTADOR VERSION
objCartaBL . objCartaEL . FECHAEMITIDO = DateTime . Now ;
objCartaBL . objCartaEL . FECHAVENCE = DateTime . Now . AddYears ( 1 ) ;
objCartaBL . objCartaEL . RENOVACION = 0 ;
objCartaBL . objCartaEL . ANOMBRE = int . Parse ( rdlAnombre . SelectedValue . ToString ( ) ) ;
objCartaBL . objCartaEL . FKJEFATURA1 = ddlJefatura1 . SelectedValue ;
objCartaBL . objCartaEL . NOMBREJEFATURA1 = ddlJefatura1 . SelectedItem . Text ;
objCartaBL . objCartaEL . FKJEFATURA2 = ddlJefatura2 . SelectedValue ;
objCartaBL . objCartaEL . NOMBREJEFATURA2 = ddlJefatura2 . SelectedItem . Text ;
objCartaBL . objCartaEL . FKTIPOFORMULARIO = p_fkTipoFormulario ;
objCartaBL . objCartaEL . FKESTADOCARTA = 1 ; //ASTATE
objCartaBL . objCartaEL . CODIGOCARTA = Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) ;
if ( strModo = = "Nuevo" )
{
nValorRetornado = objCartaBL . insertarCarta ( ) ;
strValorRetornado = objCartaBL . objCartaEL . NOMBREDOCUMENTO . ToString ( ) ;
strValorRetornado = ConfigurationManager . AppSettings [ "SIGLAS" ] . ToString ( ) + "-" + Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) + "-" + Contador . ToString ( ) + "-1_" ;
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": Se ha generado la carta " + objCartaBL . objCartaEL . NOMBREDOCUMENTO + " para la solicitud N° " + Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) ,
"frwCartaSolicitud.aspx" ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
}
if ( strModo = = "Reconsiderar" )
{
//aumentar el consecutivo del documento
Char delimiter = '-' ;
string [ ] arrayDoc = ViewState [ "RECONSIDERAR" ] . ToString ( ) . Split ( delimiter ) ; //SIGDD - AÑO - CONTADOR - CONTADOR DOCUMENTO - CONTADOR VERSION
objCartaBL . objCartaEL . NOMBREDOCUMENTO = arrayDoc [ 0 ] . ToString ( ) + "-" + arrayDoc [ 1 ] . ToString ( ) + "-" + arrayDoc [ 2 ] . ToString ( ) + "-" + arrayDoc [ 3 ] . ToString ( ) + "-" + ( int . Parse ( arrayDoc [ 4 ] . ToString ( ) ) + 1 ) . ToString ( ) + "_" ;
//objCartaBL.objCartaEL.NOMBREDOCUMENTO = arrayDoc[0].ToString() + "-" + arrayDoc[1].ToString() + "-" + arrayDoc[2].ToString() + "-" + (int.Parse(arrayDoc[3].ToString()) + 1).ToString();
nValorRetornado = objCartaBL . insertarCarta ( ) ;
strValorRetornado = objCartaBL . objCartaEL . NOMBREDOCUMENTO . ToString ( ) ;
strValorRetornado = arrayDoc [ 0 ] . ToString ( ) + "-" + arrayDoc [ 1 ] . ToString ( ) + "-" + arrayDoc [ 2 ] . ToString ( ) + "-" + ( int . Parse ( arrayDoc [ 3 ] . ToString ( ) ) + 1 ) . ToString ( ) ;
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": Se ha generado la carta " + strValorRetornado + " al reconsiderar, para la solicitud " + Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) ,
"frwCartaSolicitud.aspx" ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
}
obtenerCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
}
catch ( Exception ex )
{
throw ex ;
}
return strValorRetornado ;
}
private void generarDocumento ( string pstrDocumento , string strFKTipoConstancia )
{
try
{
string sourcePath = ConfigurationManager . AppSettings [ "DocumentosMachote" ] . ToString ( ) + @"\Formulario_N°" + strFKTipoConstancia + ".odt" ;
string targetPath = ConfigurationManager . AppSettings [ "DocumentosODT" ] . ToString ( ) + @"\" + pstrDocumento + ".odt" ;
if ( System . IO . File . Exists ( sourcePath ) )
{
System . IO . File . Copy ( sourcePath , targetPath , true ) ;
//string targetUrl = "../../../DocumentosODT/" + pstrDocumento + ".odt";
string targetUrl = "'../../../DocumentosODT/" + pstrDocumento + ".odt'" ;
if ( System . IO . File . Exists ( targetPath ) )
{
// EjecutarScript("abrirOdt(" + targetUrl + ");");
//{ ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script>javascript: abrirOdt('" + targetUrl + "');</script>"); }
}
}
2021-02-10 23:17:05 +00:00
else
{
{ ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No existe el documento por favor verifique.');</script>" ) ; }
2021-01-22 14:59:35 +00:00
2021-02-10 23:17:05 +00:00
}
2021-01-22 14:59:35 +00:00
//// To copy a file to another location and
//// overwrite the destination file if it already exists.
// System.IO.File.Copy(sourcePath, targetPath, true);
// System.Diagnostics.Process proc = new System.Diagnostics.Process();
// proc.StartInfo.FileName = targetPath;
// proc.Start();
// proc.Close();
}
catch ( Exception ex )
{
throw ex ;
}
}
private void editarDocumento ( string pstrDocumento )
{
try
{
string strResultado = string . Empty ;
string targetPath = ConfigurationManager . AppSettings [ "DocumentosODT" ] . ToString ( ) + @"\" + pstrDocumento + ".odt" ;
string targetUrl = "'../../DocumentosODT/" + pstrDocumento + ".odt'" ;
if ( ! System . IO . File . Exists ( targetPath ) )
{
targetPath = ConfigurationManager . AppSettings [ "DocumentosODT" ] . ToString ( ) + @"\" + pstrDocumento + "_.odt" ;
if ( ! System . IO . File . Exists ( targetPath ) )
{
targetPath = string . Empty ;
// ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script>javascript: MensajeInformativo('No existe el documento por favor verifique.');</script>");
}
}
if ( System . IO . File . Exists ( targetPath ) )
{
#region constancias
Documento oDoc = new Documento ( ) ;
byte [ ] bDoc = System . IO . File . ReadAllBytes ( targetPath ) ;
//se carga el archivo y el registro a vision 2020
strResultado = oDoc . Archivar_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Constancia" , pstrDocumento + "_.odt" , bDoc ) ;
if ( strResultado = = string . Empty )
{
// File.Delete(targetPath);
}
#endregion
}
//if (!File.Exists(targetPath))
{
//obtener la constancia y ponerla en la carpeta compartida para el envio de correo
//se el registro de vision 2020
Documento oDoc = new Documento ( ) ;
strResultado = oDoc . Consultar_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|Constancia" , pstrDocumento , pstrDocumento + "_.odt" ) ;
if ( strResultado ! = string . Empty & & strResultado ! = "No existe" )
{
//strResultado += pdfPath + ";"; ;
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . CONSULTA . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": Se ha descargado la constancia " + pstrDocumento . ToString ( ) + " para edición, de la solicitud " + Session [ "SOLICITUD" ] . ToString ( ) ,
Path . GetFileNameWithoutExtension ( Page . AppRelativeVirtualPath ) ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
EjecutarScript ( "abrirPDF('" + strResultado + "');" ) ;
}
else
{
ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No se ha generado el documento PDF." + targetPath + "');</script>" ) ;
}
}
}
catch ( Exception ex )
{
throw ex ;
}
}
private void firmarDocumento ( string pstrDocumento )
{
try
{
string sourcePath = ConfigurationManager . AppSettings [ "DocumentosMachote" ] . ToString ( ) + @"\SIGPC_firma_electronica .odt" ;
string targetPath = ConfigurationManager . AppSettings [ "DocumentosODT" ] . ToString ( ) + @"\" + pstrDocumento + "_" + Session [ "SOLICITUD" ] . ToString ( ) + "_.odt" ;
string pdfPath = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + Session [ "SOLICITUD" ] . ToString ( ) + @"\" + pstrDocumento + ".pdf" ;
List < string > signatarios = new List < string > ( ) ;
List < string > emails = new List < string > ( ) ;
if ( ! string . IsNullOrEmpty ( ConfigurationManager . AppSettings [ "CedulaFirmaSIGPC" ] . ToString ( ) ) )
{
signatarios . Add ( ConfigurationManager . AppSettings [ "CedulaFirmaSIGPC" ] . ToString ( ) ) ;
// emails.Add("jmonged@aya.go.cr");
}
#region constancias
if ( ! File . Exists ( pdfPath ) )
{
//obtener la constancia y ponerla en la carpeta compartida para el envio de correo
//strResultado = oDoc.Consultar_Documento(arrayNombre[1].ToString() + "-" + arrayNombre[2].ToString() + "-" + arrayNombre[3].ToString() + "|Constancia", row["NOMBREDOCUMENTOCARTA"].ToString(), row["NOMBREDOCUMENTOCARTA"].ToString() + ".pdf");
Documento oDoc = new Documento ( ) ;
string strResultado = oDoc . Visor_Documento ( lblNumSolicitud . Text + "|" + "Constancia" , lblNumSolicitud . Text . Trim ( ) , pdfPath , pstrDocumento + ".pdf" ) ;
if ( strResultado = = string . Empty | | strResultado = = "No existe" )
{
ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No se ha generado el documento PDF." + pdfPath + "');</script>" ) ;
}
}
#endregion
if ( System . IO . File . Exists ( pdfPath ) )
{
byte [ ] bytes = System . IO . File . ReadAllBytes ( pdfPath ) ;
//verificar si el documento ya se habia firmado
using ( FirmadorWeb . FirmadorWebSvcClient cliente = new FirmadorWeb . FirmadorWebSvcClient ( ) )
{
long idDocumentoFirmado = cliente . CrearDocumento (
pstrDocumento + ".pdf" ,
"Firma de documentos" ,
bytes ,
IdUsuarioSistemaCliente ,
signatarios . ToArray ( ) ,
emails . ToArray ( ) ,
CodigoSistema ,
"01" ) ;
// cliente.PonerOpcionesDocumento(idDocumentoFirmado, CodigoSistema, false, false, false);
documento . DocumentoID = idDocumentoFirmado ;
ViewState [ "DocumentoID" ] = idDocumentoFirmado ;
Session [ "Cedula" ] = ConfigurationManager . AppSettings [ "CedulaFirmaSIGPC" ] . ToString ( ) ;
_UrlFirmadorWeb = null ;
EjecutarScript ( "AbrirFirmadorWeb();" ) ;
ViewState [ "MODO" ] = "Firmador" ;
ViewState [ "Documento" ] = pstrDocumento ;
ObservacionesBL objObservacionesBL = new ObservacionesBL ( ) ;
//objObservacionesBL.objobservacionesEL.FKNUMSOLICITUD = strNumSolicitudTMP;
objObservacionesBL . objobservacionesEL . OBSERVACIONES = "El usuario " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) + " descargó la constancia " + pstrDocumento + ".pdf, para realizar la firma." ;
objObservacionesBL . objobservacionesEL . Fecha = DateTime . Now ;
objObservacionesBL . objobservacionesEL . FKSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
objObservacionesBL . objobservacionesEL . USUARIO = Session [ "LOGIN" ] . ToString ( ) ;
int nValorRetornado = objObservacionesBL . insertarObservaciones ( ) ;
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . FIRMAR . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": El usuario " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) + " descargó la constancia " + pstrDocumento + ".pdf, para realizar la firma." ,
Path . GetFileNameWithoutExtension ( Page . AppRelativeVirtualPath ) ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
//FirmadorWeb.Documento documentoFirmado = cliente.ObtenerDocumento(
// idDocumentoFirmado,
// CodigoSistema);
//if (documentoFirmado.Firmas.Count() == 0)
//{
// documento.DocumentoID = idDocumentoFirmado;
// ViewState["DocumentoID"] = idDocumentoFirmado;
// Session["Cedula"] = ConfigurationManager.AppSettings["CedulaFirmaSIGPC"].ToString();
// EjecutarScript("AbrirFirmadorWeb();");
//}
//else
//{
// MensajeInformativo("El documento ya fue firmado.");
//}
}
// System.IO.File.Copy(sourcePath, targetPath, true);
// string targetUrl = "'../../../DocumentosODT/" + pstrDocumento + "_" + Session["SOLICITUD"].ToString() + "_.odt'";
//// string targetUrl = "'../../../../DocumentosODT/" + pstrDocumento + ".odt'";
// if (System.IO.File.Exists(targetPath))
// {
// EjecutarScript("abrirOdt(" + targetUrl + ");");
// }
}
else
{
{ ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No se ha generado el documento PDF." + pdfPath + "');</script>" ) ; }
}
}
catch ( Exception ex )
{
throw ex ;
}
}
private void obtenerDocumentoFirmado ( )
{
try
{
//string sourcePath = ConfigurationManager.AppSettings["DocumentosMachote"].ToString() + @"\SIGPC_firma_electronica .odt";
//string targetPath = ConfigurationManager.AppSettings["DocumentosODT"].ToString() + @"\" + pstrDocumento + "_" + Session["SOLICITUD"].ToString() + "_.odt";
string pdfPath = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + Session [ "SOLICITUD" ] . ToString ( ) + @"\" + ViewState [ "Documento" ] + ".pdf" ;
if ( System . IO . File . Exists ( pdfPath ) )
{
byte [ ] bytes = System . IO . File . ReadAllBytes ( pdfPath ) ;
//verificar si el documento ya se habia firmado
using ( FirmadorWeb . FirmadorWebSvcClient cliente = new FirmadorWeb . FirmadorWebSvcClient ( ) )
{
byte [ ] contenido = cliente . ObtenerContenidoDocumento ( long . Parse ( ViewState [ "DocumentoID" ] . ToString ( ) ) , CodigoSistema ) ;
File . WriteAllBytes ( pdfPath , contenido ) ;
}
#region constancias
Documento oDoc = new Documento ( ) ;
byte [ ] bDoc = System . IO . File . ReadAllBytes ( pdfPath ) ;
//se carga el archivo y el registro a vision 2020
string strResultado = oDoc . Archivar_Documento ( strNumSolicitudTMP . ToString ( ) . Trim ( ) + "|" + "Constancia" , ViewState [ "Documento" ] + ".pdf" , bDoc ) ;
if ( strResultado = = string . Empty )
{
//File.Delete(pdfPath);
}
#endregion
}
else
{
{ ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No se pudo descargar el documento firmado por favor intente firmarlo de nuevo." + pdfPath + "');</script>" ) ; }
}
}
catch ( Exception ex )
{
throw ex ;
}
}
/// <summary>
/// guarda y modifica registros en la tabla.
/// </summary>
/// <returns></returns>
///
private int GuardarDatosActividad ( string p_accion , int p_nOrden )
{
int nValorRetornado = 0 ;
try
{
int nPkSolicitud = 0 ;
int nResultadoActualizar = 0 ;
string strMensajeContenido = "" ;
string strAsuntoCorreo = "" ;
string strPiePagina = "</BR> </BR></BR>AVISO DE CONFIDENCIALIDAD: este mensaje y la información incluida en él es confidencial y está dirigida únicamente al destinatario. Puede contener información privilegiada, confidencial, amparada por el secreto profesional o que no debe ser revelada. Si usted ha recibido este correo por error, por favor comunicarlo inmediatamente vía correo y tener la amabilidad de eliminarlo de su sistema. Queda notificado que no deberá copiar este mensaje, ni utilizar, divulgar, publicar o distribuir su contenido de modo alguno. Todo mensaje enviado a esta dirección de correo electrónico puede ser sujeto a inspección por alguien distinto de su receptor originario. La transmisión de correos no garantiza que el correo electrónico sea seguro o libre de error. Por consiguiente, se advierte que esta información pueda estar incompleta o ser poco precisa ya que toda información está sujeta a alterarse sin previo aviso.”" ;
string strDescripcionActividad = string . Empty ;
if ( p_nOrden = = 5 )
strDescripcionActividad = "confección de la constancia" ;
if ( p_nOrden = = 6 )
strDescripcionActividad = "validación y firma de la constancia" ;
solicitudBL objSolicitudBL = new solicitudBL ( ) ;
objSolicitudBL . objSolicitudEL . PK = int . Parse ( Session [ "PKPROGRAMACION" ] . ToString ( ) ) ;
objSolicitudBL . objSolicitudEL . FKUSUARIOXDEPENDENCIA = int . Parse ( Session [ "PKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) ;
objSolicitudBL . objSolicitudEL . ORDEN = p_nOrden ; //5:Confeccion de constancias 6:Validacion y firma
DataSet dsEncargadosActividades = objSolicitudBL . dsListaActividadesEncargado ( null ) ;
if ( dsEncargadosActividades . Tables [ 0 ] . Rows . Count > 0 )
{
if ( int . Parse ( dsEncargadosActividades . Tables [ 0 ] . Rows [ 0 ] [ "PKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) = = int . Parse ( Session [ "PKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) & & int . Parse ( dsEncargadosActividades . Tables [ 0 ] . Rows [ 0 ] [ "FKESTADO" ] . ToString ( ) ) ! = 5
& & int . Parse ( dsEncargadosActividades . Tables [ 0 ] . Rows [ 0 ] [ "FKESTADO" ] . ToString ( ) ) ! = 8 )
{
string strEncargadoActividad = dsEncargadosActividades . Tables [ 0 ] . Rows [ 0 ] [ "PKRESPONSABLEACTIVIDAD" ] . ToString ( ) ;
ObservacionesActividadesBL objObservacionesBL = new ObservacionesActividadesBL ( ) ;
objObservacionesBL . objobservacionesEL . DESCRIPCION = "\n" + DateTime . Now . ToString ( ) + " - " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) + " - Se " + p_accion + " la actividad " + strDescripcionActividad + " de la solicitud N° " + Session [ "SOLICITUD" ] . ToString ( ) + " por parte del usuario " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) ;
//objObservacionesBL.objobservacionesEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objObservacionesBL . objobservacionesEL . PKRESPONSABLEACTIVIDAD = int . Parse ( strEncargadoActividad ) ;
objObservacionesBL . objobservacionesEL . Fecha = DateTime . Now ;
objObservacionesBL . objobservacionesEL . TIPO = 1 ; //1:observaciones 2:devolucion
nValorRetornado = objObservacionesBL . insertarObservacionActividad ( ) ;
if ( nValorRetornado ! = 0 )
{
solicitudBL objSolicitud = new solicitudBL ( ) ;
objSolicitud . objresponsableActividadEL . FECHADEVOLUCION = DateTime . Now ;
foreach ( DataRow row in dsEncargadosActividades . Tables [ 0 ] . Rows )
{
objSolicitud . objresponsableActividadEL . PK = int . Parse ( row [ "PKRESPONSABLEACTIVIDAD" ] . ToString ( ) ) ;
if ( p_accion = = "finalizó" )
{
decimal nTiempoActividad = 0 ;
if ( row [ "CLASIFICACIONSOLICITUD" ] . ToString ( ) = = "Crecimiento vegetativo" )
nTiempoActividad = decimal . Parse ( row [ "TIEMPOCVACTIVIDAD" ] . ToString ( ) ) ;
if ( row [ "CLASIFICACIONSOLICITUD" ] . ToString ( ) = = "Desarrollo urbanistico" )
nTiempoActividad = decimal . Parse ( row [ "TIEMPODUACTIVIDAD" ] . ToString ( ) ) ;
objSolicitudBL . objSolicitudEL . ORDEN = p_nOrden ; //5:Confeccion de constancias 6:Validacion y firma
char [ ] separadorColumna = { '.' } ;
string [ ] strArrayTiempo = nTiempoActividad . ToString ( ) . Replace ( "," , "." ) . Split ( separadorColumna ) ;
DateTime dtFechaRecibido = DateTime . Parse ( row [ "FECHAASIGNACIONRESPONSABLEACTIVIDAD" ] . ToString ( ) ) . AddDays ( double . Parse ( strArrayTiempo [ 0 ] . ToString ( ) ) ) ;
if ( double . Parse ( strArrayTiempo [ 1 ] . ToString ( ) ) > 0 )
dtFechaRecibido = dtFechaRecibido . AddHours ( 4 ) ;
if ( dtFechaRecibido > DateTime . Now )
objSolicitud . objresponsableActividadEL . FKESTADO = 5 ; //finalizada a tiempo t_sgm_estadoactividad
else
objSolicitud . objresponsableActividadEL . FKESTADO = 8 ; //finalizada fuera de tiempo t_sgm_estadoactividad
strMensajeContenido = "La actividad " + strDescripcionActividad + " de la solicitud N° " + Session [ "SOLICITUD" ] . ToString ( ) + " ha sido concluida para ver los detalles, ingrese al sistema <a href=http://" + HttpContext . Current . Request . Url . Authority + "/Forms/wfrLogin.> SIGDD</a>" + strPiePagina ;
strAsuntoCorreo = "Conclusión de actividad - SIGDD" ;
nResultadoActualizar = objSolicitud . actualizarActividadSolicitud ( ) ;
if ( nResultadoActualizar > 0 )
{
#region Envio de correo
2021-03-03 22:34:22 +00:00
//AyABL.TRA.correoBL objcorreoBL = new AyABL.TRA.correoBL();
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
//nPkSolicitud = Convert.ToInt32(row[1].ToString());//AQUI INSERTAMOS LA PK DE LA SOLICITUD
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
//objcorreoBL.objcorreoEL.FKNUMSOLICITUD = nPkSolicitud;
//// objcorreoBL.objcorreoEL.CORREO = dsActividad.Tables[0].Rows[0]["LOGINUSUARIO"].ToString() + "@aya.go.cr";
//objcorreoBL.objcorreoEL.ASUNTO = strAsuntoCorreo;
//objcorreoBL.objcorreoEL.CONTENIDO = strMensajeContenido;
//objcorreoBL.objcorreoEL.FKUSUARIO = Convert.ToInt32(row["FKUSUARIOXDEPENDENCIA"].ToString());
//objcorreoBL.objcorreoEL.Fecha = DateTime.Now;
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
//nValorRetornado = objcorreoBL.insertarCorreo();
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
////poner la siguiente actividad en pendiente
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
//objSolicitudBL = new solicitudBL();
//objSolicitudBL.objSolicitudEL.PK = int.Parse(Session["PKPROGRAMACION"].ToString());
//objSolicitudBL.objSolicitudEL.ORDEN = p_nOrden + 1;
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
//DataSet dsEncargadosActividadesSiguiente = objSolicitudBL.dsListaActividadesEncargado(null);
//foreach (DataRow row6 in dsEncargadosActividadesSiguiente.Tables[0].Rows)
//{
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
// objSolicitud.objresponsableActividadEL.PK = int.Parse(row6["PKRESPONSABLEACTIVIDAD"].ToString()); ;
// objSolicitud.objresponsableActividadEL.FKESTADO = 3;//pendiente t_sgm_estadoactividad
// nResultadoActualizar = objSolicitud.actualizarActividadSolicitud();
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
// objcorreoBL.objcorreoEL.ASUNTO = strAsuntoCorreo;
// objcorreoBL.objcorreoEL.CONTENIDO = strMensajeContenido;
// objcorreoBL.objcorreoEL.FKUSUARIO = Convert.ToInt32(row6["FKUSUARIOXDEPENDENCIA"].ToString());
// objcorreoBL.objcorreoEL.Fecha = DateTime.Now;
2021-01-22 14:59:35 +00:00
2021-03-03 22:34:22 +00:00
//nValorRetornado = objcorreoBL.insertarCorreo();
//}
2021-01-22 14:59:35 +00:00
#endregion
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": La actividad " + strDescripcionActividad + " de la solicitud N° " + Session [ "SOLICITUD" ] . ToString ( ) + " ha sido finalizada por parte del encargado de la actividad: " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) . Trim ( ) ,
Path . GetFileNameWithoutExtension ( Page . AppRelativeVirtualPath ) ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
}
}
}
//if (p_accion == "edita")
//{
// //Poner la actividad 6 programacion en pendiente(3)
// objSolicitudBL = new solicitudBL();
// objSolicitudBL.objSolicitudEL.PK = int.Parse(Session["PKPROGRAMACION"].ToString());
// objSolicitudBL.objSolicitudEL.ORDEN = p_nOrden + 1;
// dsEncargadosActividades = objSolicitudBL.dsListaActividadesEncargado(null);
// foreach (DataRow row in dsEncargadosActividades.Tables[0].Rows)
// {
// objSolicitud.objresponsableActividadEL.PK = int.Parse(row["PKRESPONSABLEACTIVIDAD"].ToString()); ;
// objSolicitud.objresponsableActividadEL.FKESTADO = 3;//pendiente t_sgm_estadoactividad
// nResultadoActualizar = objSolicitud.actualizarActividadSolicitud();
// }
//}
}
}
}
}
catch ( Exception ex )
{
throw ex ;
}
return nValorRetornado ;
}
private static void WriteTextToDocument ( BaseFont bf , Rectangle tamPagina , PdfContentByte over , PdfGState gs , string texto )
{
try
{
over . SetGState ( gs ) ;
over . SetRGBColorFill ( 220 , 220 , 220 ) ;
over . SetTextRenderingMode ( PdfContentByte . TEXT_RENDER_MODE_STROKE ) ;
over . SetFontAndSize ( bf , 46 ) ;
Single anchoDiag = ( Single ) Math . Sqrt ( Math . Pow ( ( tamPagina . Height - 120 ) , 2 ) + Math . Pow ( ( tamPagina . Width - 60 ) , 2 ) ) ;
Single porc = ( Single ) 100 * ( anchoDiag / bf . GetWidthPoint ( texto , 46 ) ) ;
over . SetHorizontalScaling ( porc ) ;
double angPage = ( - 1 ) * Math . Atan ( ( tamPagina . Height - 60 ) / ( tamPagina . Width - 60 ) ) ;
over . SetTextMatrix ( ( float ) Math . Cos ( angPage ) , ( float ) Math . Sin ( angPage ) , ( float ) ( ( - 1F ) * Math . Sin ( angPage ) ) , ( float ) Math . Cos ( angPage ) , 30F , ( float ) tamPagina . Height - 60 ) ;
over . ShowText ( texto ) ;
}
catch ( Exception ex )
{
throw ex ;
}
}
#endregion
#region Métodos para generar token de seguridad del firmador web
/// <summary>
/// Identificador único definido por el sistema cliente para el documento incluído en el firmador web
/// </summary>
private string IdCorrelacionFirmadorWeb
{
get
{
return "01" ;
}
}
private FirmadorWeb . Documento _documento ;
protected FirmadorWeb . Documento documento
{
get
{
if ( _documento = = null )
{
using ( FirmadorWeb . FirmadorWebSvcClient cliente = new FirmadorWeb . FirmadorWebSvcClient ( ) )
{
// recuperar el documento usando el identificador de correlación
_documento = cliente . ObtenerDocumentoXIdCorrelacion (
IdCorrelacionFirmadorWeb , CodigoSistema ) ;
}
}
return _documento ;
}
}
private string _UrlFirmadorWeb ;
protected string UrlFirmadorWeb
{
get
{
if ( string . IsNullOrEmpty ( _UrlFirmadorWeb ) )
{
try
{
if ( IsPostBack )
_UrlFirmadorWeb = GenerarUrlFirmadorWeb ( documento . DocumentoID , ( string ) Session [ "Cedula" ] ) ;
}
catch ( Exception ex )
{
MensajeError ( "Se presentó un error con el servicio de firma digital." , ex ) ;
}
}
return _UrlFirmadorWeb ;
}
}
/// <summary>
/// Genera un url para la página del documento en el firmador web
/// Incluye en el url un token de seguridad para el firmador web
/// </summary>
/// <param name="idDocumento">Documento que se va a abrir en el firmador web</param>
/// <param name="cedula">Cédula del usuario actual</param>
/// <returns></returns>
private string GenerarUrlFirmadorWeb ( long idDocumento , string cedula )
{
return string . Format (
ConfigurationManager . AppSettings [ "UrlFirmadorWeb" ] ,
idDocumento ,
cedula ,
Server . UrlEncode (
Cipher (
string . Format ( "{0},{1}" , idDocumento , cedula )
)
)
) ;
}
/// <summary>
/// Encripta un valor usando la llave de encripción especificada en el parámetro LlaveEncripcionFW
/// Debe ser la misma llave que está configurada en el servicio
/// </summary>
/// <param name="value">Valor que se va a encriptar</param>
/// <returns>Valor encriptado</returns>
private static string Cipher ( string value )
{
string llaveEncripcionFW = ConfigurationManager . AppSettings [ "LlaveEncripcionFW" ] ;
Random rnd = new Random ( DateTime . Now . Millisecond ) ;
for ( int i = 0 ; i < 8 ; i + + )
value = "1234567890" [ rnd . Next ( 10 ) ] + value ;
value = "XYZ" + value ;
UTF7Encoding enc = new System . Text . UTF7Encoding ( ) ;
byte [ ] keyBytes = enc . GetBytes ( GetHash ( llaveEncripcionFW ) ) ;
TripleDES tdes = TripleDES . Create ( ) ;
byte [ ] desKey = new byte [ tdes . KeySize / 8 ] ;
for ( int i = 0 ; i < desKey . Length ; i + + )
desKey [ i ] = keyBytes [ i ] ;
tdes . Mode = CipherMode . CBC ;
tdes . Padding = PaddingMode . Zeros ;
byte [ ] plain = enc . GetBytes ( value ) ;
int cipheredSize = plain . Length / tdes . BlockSize ;
if ( plain . Length % tdes . BlockSize > 0 )
cipheredSize + + ;
cipheredSize * = tdes . BlockSize ;
byte [ ] ciphered = new byte [ cipheredSize ] ;
ICryptoTransform cry = tdes . CreateEncryptor ( desKey , desKey ) ;
byte [ ] input = new byte [ tdes . BlockSize ] ;
byte [ ] output = new byte [ tdes . BlockSize ] ;
int iPlain = 0 ;
int iCiphered = 0 ;
while ( iPlain < plain . Length )
{
int iInput = 0 ;
for ( ; iPlain < plain . Length & & iInput < input . Length ; iPlain + + )
input [ iInput + + ] = plain [ iPlain ] ;
for ( ; iInput < input . Length ; iInput + + )
input [ iInput ] = 0 ;
cry . TransformBlock ( input , 0 , input . Length , output , 0 ) ;
foreach ( Byte outputByte in output )
ciphered [ iCiphered + + ] = outputByte ;
}
return Convert . ToBase64String ( ciphered ) ;
}
public static string GetHash ( string value )
{
UTF7Encoding enc = new UTF7Encoding ( ) ;
byte [ ] bytes = enc . GetBytes ( value ) ;
return GetHash ( bytes ) ;
}
public static string GetHash ( byte [ ] value )
{
using ( SHA1Managed sha1 = new SHA1Managed ( ) )
{
sha1 . Initialize ( ) ;
byte [ ] hash = sha1 . ComputeHash ( value ) ;
return BitConverter . ToString ( hash ) . ToLower ( ) . Replace ( "-" , "" ) ;
}
}
#endregion
#region Metodos Datos a Controles ( R6 )
/// <summary>
/// LLena el listado de roles de usuario
/// </summary>
private void obtenerCartaSolicitud ( int nNumSolicitud , string strNombreCarta , int nPKReutiliza ) //M3
{
try
{
//Instancia el objeto
objCartaBL = new cartaBL ( ) ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitud ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = strNombreCarta ;
objCartaBL . objCartaEL . FKREUTILIZA = nPKReutiliza ;
if ( nPKReutiliza ! = 0 )
{
char [ ] separadorColumna = { '-' } ;
string [ ] arrSolicitud = Session [ "SOLICITUD" ] . ToString ( ) . Split ( separadorColumna ) ;
objCartaBL . objCartaEL . NUMEROSOLICITUD = arrSolicitud [ 1 ] . ToString ( ) ;
}
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
//ViewState["MODO"] = "Modificar";
grvListaCartaSolicitud . DataSource = ds ;
grvListaCartaSolicitud . DataBind ( ) ;
//General.detalleGridView(ds, grvListaCartaSolicitud, null);
mostrarFilaTabla ( 1 ) ;
}
else
{
ViewState [ "MODO" ] = "Nuevo" ;
mostrarFilaTabla ( 3 ) ;
}
}
catch ( Exception ex )
{
throw ex ;
}
}
/// <summary>
/// LLena el listado de roles de usuario
/// </summary>
private void verificarCartaSolicitud ( int nNumSolicitud , string strNombreCarta , int nPKReutiliza ) //M3
{
try
{
//Instancia el objeto
objCartaBL = new cartaBL ( ) ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitud ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = strNombreCarta ;
//objCartaBL.objCartaEL.FKREUTILIZA = nPKReutiliza;
objCartaBL . objCartaEL . FKESTADOCARTA = 1 ;
objCartaBL . objCartaEL . FKESTADOCARTA2 = 4 ;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
obtenerCartaSolicitud ( nNumSolicitud , strNombreCarta , nPKReutiliza ) ;
}
else
{
ViewState [ "MODO" ] = "Nuevo" ;
mostrarFilaTabla ( 3 ) ;
}
}
catch ( Exception ex )
{
throw ex ;
}
}
/// <summary>
/// Carga la informacion de un documento en especifico
/// </summary>
public DataSet obtenerDocumento ( int nNumSolicitud , string strNombreCarta ) //M3
{
try
{
//Instancia el objeto
objCartaBL = new cartaBL ( ) ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitud ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = strNombreCarta ;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
//ViewState["MODO"] = "Modificar";
mostrarFilaTabla ( 3 ) ;
ddlTipoFormulario . Focus ( ) ;
ddlTipoFormulario . SelectedValue = ds . Tables [ 0 ] . Rows [ 0 ] [ "FKTIPOFORMULARIO" ] . ToString ( ) ;
// ddlJefatura1.SelectedValue = ds.Tables[0].Rows[0]["FKJEFATURA1"].ToString();
//ddlJefatura2.SelectedValue = ds.Tables[0].Rows[0]["FKJEFATURA2"].ToString();
rdlAnombre . SelectedValue = ds . Tables [ 0 ] . Rows [ 0 ] [ "ANOMBRECARTA" ] . ToString ( ) ;
}
return ds ;
}
catch ( Exception ex )
{
throw ex ;
}
}
/// <summary>
/// Renovar agrega 12 meses a la fecha de vencimiento
/// </summary>
private bool RenovarDocumento ( int nNumSolicitud , string strNombreCarta , int p_nPk ) //M3
{
try
{
bool blnValorRetornado = false ;
int nValorRetornado = 0 ;
//Instancia el objeto
objCartaBL = new cartaBL ( ) ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitud ;
objCartaBL . objCartaEL . PK = p_nPk ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = strNombreCarta ;
objCartaBL . objCartaEL . CODIGOCARTA = Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) ;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
//aumentar el consecutivo del documento
Char delimiter = '-' ;
string [ ] arrayDoc = strNombreCarta . Split ( delimiter ) ; //SIGDD - AÑO - CONTADOR - CONTADOR DOCUMENTO - CONTADOR VERSION
strNombreCarta = arrayDoc [ 0 ] . ToString ( ) + "-" + arrayDoc [ 1 ] . ToString ( ) + "-" + arrayDoc [ 2 ] . ToString ( ) + "-" + arrayDoc [ 3 ] . ToString ( ) + "-" + ( int . Parse ( arrayDoc [ 4 ] . ToString ( ) ) + 1 ) . ToString ( ) + "-" + arrayDoc [ 5 ] . ToString ( ) ;
//strNombreCarta = arrayDoc[0].ToString() + "-" + arrayDoc[1].ToString() + "-" + arrayDoc[2].ToString() + "-" + (int.Parse(arrayDoc[3].ToString()) + 1).ToString();
int nNumDocumento = int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "RENOVACIONCARTA" ] . ToString ( ) ) + 1 ; // int.Parse(arrayDoc[4].ToString()) + 1;
if ( nNumDocumento < = 2 & & ( int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "FKESTADO" ] . ToString ( ) ) = = 1 ) ) //se valida que no tenga mas de dos renovaciones y que este activo
{
objCartaBL . objCartaEL . NOMBREDOCUMENTO = strNombreCarta ;
objCartaBL . objCartaEL . FECHAEMITIDO = DateTime . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "FECHAEMITIDOCARTA" ] . ToString ( ) ) ;
DateTime dtFechaVence = DateTime . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "FECHAVENCECARTA" ] . ToString ( ) ) ;
objCartaBL . objCartaEL . FECHAVENCE = dtFechaVence . AddYears ( 1 ) ;
objCartaBL . objCartaEL . RENOVACION = int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "RENOVACIONCARTA" ] . ToString ( ) ) + 1 ;
objCartaBL . objCartaEL . ANOMBRE = int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ANOMBRECARTA" ] . ToString ( ) ) ;
objCartaBL . objCartaEL . FKJEFATURA1 = ds . Tables [ 0 ] . Rows [ 0 ] [ "FKJEFATURA1" ] . ToString ( ) ;
objCartaBL . objCartaEL . FKJEFATURA2 = ds . Tables [ 0 ] . Rows [ 0 ] [ "FKJEFATURA2" ] . ToString ( ) ;
objCartaBL . objCartaEL . NOMBREJEFATURA1 = ds . Tables [ 0 ] . Rows [ 0 ] [ "NOMBREJEFATURA1CARTA" ] . ToString ( ) ;
objCartaBL . objCartaEL . NOMBREJEFATURA2 = ds . Tables [ 0 ] . Rows [ 0 ] [ "NOMBREJEFATURA2CARTA" ] . ToString ( ) ;
objCartaBL . objCartaEL . FKTIPOFORMULARIO = int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "FKTIPOFORMULARIO" ] . ToString ( ) ) ;
objCartaBL . objCartaEL . FKESTADOCARTA = int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "FKESTADO" ] . ToString ( ) ) ;
//se ingresa el nuevo registro con el contador aumentado
nValorRetornado = objCartaBL . insertarCarta ( ) ;
//se crea el nuevo documento
generarDocumento ( strNombreCarta , ds . Tables [ 0 ] . Rows [ 0 ] [ "FKTIPOFORMULARIO" ] . ToString ( ) ) ;
//Se cambia el estado a renovacion
if ( nValorRetornado > 0 )
{
objCartaBL = new cartaBL ( ) ;
objCartaBL . objCartaEL . PK = p_nPk ;
objCartaBL . objCartaEL . FKESTADOCARTA = 4 ; //renovacion
objCartaBL . activarInactivarCarta ( ) ;
}
}
else
{
if ( nNumDocumento > 2 )
{ ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('El documento no puede ser renovado mas de dos veces.');</script>" ) ; }
if ( int . Parse ( ds . Tables [ 0 ] . Rows [ 0 ] [ "FKESTADO" ] . ToString ( ) ) ! = 1 )
{ ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('El documento no puede ser renovado.');</script>" ) ; }
}
if ( nValorRetornado > 0 )
blnValorRetornado = true ;
return blnValorRetornado ;
}
catch ( Exception ex )
{
throw ex ;
}
}
/// <summary>
/// Llena el dropdownlist de tipo de formulario
/// </summary>
private void llenarDDLtipoformulario ( ) //M6
{
try
{
//Limpia el control
ddlTipoFormulario . Items . Clear ( ) ;
//Instancia el bjeto
objTipoCartaBL = new tipoCartaBL ( ) ;
//Asigna datos al atributo
//Carga la información en un dataset
DataSet dsTipoFormualrio = objTipoCartaBL . dsListaTipoCarta ( null ) ;
if ( dsTipoFormualrio . Tables [ 0 ] . Rows . Count ! = 0 )
{
ddlTipoFormulario . DataSource = dsTipoFormualrio ;
ddlTipoFormulario . DataTextField = dsTipoFormualrio . Tables [ 0 ] . Columns [ "NOMBREMACHOTETIPOCARTA" ] . ColumnName ;
ddlTipoFormulario . DataValueField = dsTipoFormualrio . Tables [ 0 ] . Columns [ "PKTIPOCARTA" ] . ColumnName ;
ddlTipoFormulario . DataBind ( ) ;
ddlTipoFormulario . Items . Insert ( 0 , new System . Web . UI . WebControls . ListItem ( "Seleccione" , "-1" ) ) ;
}
else
ddlTipoFormulario . Items . Insert ( 0 , new System . Web . UI . WebControls . ListItem ( "----- No existen opciones -----" , "-1" ) ) ;
}
catch ( Exception ex )
{
throw ex ;
}
}
/// <summary>
/// Llena el dropdownlist de tipo de jefatura
/// </summary>
/// <summary>
/// Llena el dropdownlist de Cantonales según la aplicación
/// </summary>
private void llenarDDLjefatura ( DropDownList ddlTMP ) //M3
{
try
{
//Limpia el control
ddlTMP . Items . Clear ( ) ;
//Instancia el bjeto
objUsuarioBL = new usuarioBL ( ) ;
//Carga la información en un dataset
DataSet dsRegion = objUsuarioBL . dsListaUsuariosJefatura ( null ) ;
objUsuarioAyABL = new UsuarioBL ( ) ;
DataSet ds2 = objUsuarioAyABL . dsListaUsuarios ( null ) ;
DataTable dtJefes = new DataTable ( ) ;
dtJefes . Columns . Add ( "USUARIOUSUARIOXDEPENDENCIA" ) ;
dtJefes . Columns . Add ( "NOMBRECOMPLETO" ) ;
if ( dsRegion . Tables [ 0 ] . Rows . Count ! = 0 )
{
foreach ( DataRow row in dsRegion . Tables [ 0 ] . Rows )
{
foreach ( DataRow rowUsuario in ds2 . Tables [ 0 ] . Rows )
{
if ( row [ 1 ] . ToString ( ) = = rowUsuario [ 1 ] . ToString ( ) )
{
DataRow rowFinal = dtJefes . NewRow ( ) ;
rowFinal [ "USUARIOUSUARIOXDEPENDENCIA" ] = row [ 1 ] . ToString ( ) ;
rowFinal [ "NOMBRECOMPLETO" ] = rowUsuario [ 12 ] . ToString ( ) ;
dtJefes . Rows . Add ( rowFinal ) ;
}
}
}
}
if ( dtJefes . Rows . Count ! = 0 )
{
ddlTMP . DataSource = dtJefes ;
ddlTMP . DataTextField = dtJefes . Columns [ "NOMBRECOMPLETO" ] . ColumnName ;
ddlTMP . DataValueField = dtJefes . Columns [ "USUARIOUSUARIOXDEPENDENCIA" ] . ColumnName ;
ddlTMP . DataBind ( ) ;
ddlTMP . Items . Insert ( 0 , new System . Web . UI . WebControls . ListItem ( "Seleccione" , "-1" ) ) ;
}
else
ddlTMP . Items . Insert ( 0 , new System . Web . UI . WebControls . ListItem ( "----- Vacio -----" , "-1" ) ) ;
}
catch ( Exception ex )
{
throw ex ;
}
}
#endregion
protected void grvListaCartaSolicitud_RowDataBound ( object sender , GridViewRowEventArgs e )
{
try
{
GridViewRow selectedRow = e . Row ;
//if (e.Row.RowType == DataControlRowType.Header)
//{
// e.Row.Cells[13].Visible = false;
// e.Row.Cells[11].Visible = false;
//}
if ( e . Row . RowType = = DataControlRowType . DataRow )
{
e . Row . Cells [ 8 ] . Visible = false ;
grvListaCartaSolicitud . Columns [ 8 ] . Visible = false ;
e . Row . Cells [ 8 ] . ToolTip = "Inactivar documento" ;
e . Row . Cells [ 9 ] . ToolTip = "Renovar documento" ;
//e.Row.Cells[9].ToolTip = "Reconsiderar documento";
e . Row . Cells [ 10 ] . ToolTip = "Editar documento" ;
e . Row . Cells [ 11 ] . ToolTip = "Firmar documento" ;
e . Row . Cells [ 12 ] . ToolTip = "Ver documento" ;
e . Row . Cells [ 11 ] . Visible = false ;
grvListaCartaSolicitud . Columns [ 11 ] . Visible = true ;
grvListaCartaSolicitud . Columns [ 10 ] . Visible = true ;
//e.Row.Cells[11].Style.Add("Opacity", "0.5");
if ( nPKReutilizaTMP ! = int . Parse ( e . Row . Cells [ 7 ] . Text ) )
{
string targetPath = ConfigurationManager . AppSettings [ "DocumentosODT" ] . ToString ( ) + @"\" + selectedRow . Cells [ 1 ] . Text + ".odt" ;
string targetUrl = "~/../../../DocumentosODT/" + selectedRow . Cells [ 1 ] . Text + ".odt" ;
string targetUrlFirmar = "../../DocumentosPDF/" + Session [ "SOLICITUD" ] . ToString ( ) . Trim ( ) + "/" + selectedRow . Cells [ 1 ] . Text + ".pdf" ;
//LinkButton lnk = (LinkButton)e.Row.FindControl("lnk_Editar");
//LinkButton lnkFirmar = (LinkButton)e.Row.FindControl("lnk_Firmar");
//if (System.IO.File.Exists(targetPath))
//{
// lnk.Attributes.Add("href", targetUrl);
// lnkFirmar.Attributes.Add("onClick", "JavaScript: window.open('" + targetUrlFirmar + "','','_blank','width=500,height=245,left=350,top=400')");
//}
}
//else
//{
// { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script>javascript: MensajeInformativo('No existe el documento por favor verifique.');</script>"); }
//}
//Request["d"].ToString() = "constancia" viene de gestion de trabajo
if ( nPKReutilizaTMP = = int . Parse ( e . Row . Cells [ 7 ] . Text ) | | e . Row . Cells [ 6 ] . Text = = "Inactivo" | | Request [ "d" ] . ToString ( ) = = "deshabilitar" | | e . Row . Cells [ 13 ] . Text . Trim ( ) ! = strNumSolicitudTMP . Trim ( ) )
{
e . Row . Cells [ 8 ] . Visible = false ;
grvListaCartaSolicitud . Columns [ 8 ] . Visible = false ;
e . Row . Cells [ 9 ] . Visible = false ;
grvListaCartaSolicitud . Columns [ 9 ] . Visible = false ;
e . Row . Cells [ 10 ] . Visible = false ;
//grvListaCartaSolicitud.Columns[10].Visible = false;
//e.Row.Cells[11].Visible = false;
//grvListaCartaSolicitud.Columns[11].Visible = false;
//e.Row.Cells[11].Enabled = false;
//e.Row.Cells[8].Style.Add("Opacity", "0.5");
//e.Row.Cells[9].Style.Add("Opacity", "0.5");
//e.Row.Cells[10].Style.Add("Opacity", "0.5");
//e.Row.Cells[11].Style.Add("Opacity", "0.5");
}
if ( e . Row . Cells [ 13 ] . Text . Trim ( ) = = strNumSolicitudTMP . Trim ( ) & & Request [ "d" ] . ToString ( ) = = "firmar" & & e . Row . Cells [ 6 ] . Text = = "Activo" )
{
e . Row . Cells [ 8 ] . Visible = false ;
grvListaCartaSolicitud . Columns [ 8 ] . Visible = false ;
//e.Row.Cells[9].Visible = false;
e . Row . Cells [ 10 ] . Visible = false ;
//grvListaCartaSolicitud.Columns[10].Visible = false;
e . Row . Cells [ 11 ] . Visible = true ;
//grvListaCartaSolicitud.Columns[11].Visible = true;
}
if ( Request [ "d" ] . ToString ( ) = = "deshabilitar" | | Request [ "d" ] . ToString ( ) = = "finalizado" )
{
e . Row . Cells [ 8 ] . Visible = false ;
grvListaCartaSolicitud . Columns [ 8 ] . Visible = false ;
e . Row . Cells [ 9 ] . Visible = false ;
grvListaCartaSolicitud . Columns [ 9 ] . Visible = false ;
e . Row . Cells [ 10 ] . Visible = true ;
grvListaCartaSolicitud . Columns [ 10 ] . Visible = false ;
e . Row . Cells [ 11 ] . Visible = false ;
//grvListaCartaSolicitud.Columns[11].Visible = false;
}
if ( e . Row . Cells [ 13 ] . Text . Trim ( ) = = strNumSolicitudTMP . Trim ( ) & & Request [ "d" ] . ToString ( ) = = "constancia" & & e . Row . Cells [ 6 ] . Text = = "Activo" )
{
e . Row . Cells [ 10 ] . Visible = true ;
}
e . Row . Cells [ 13 ] . Visible = false ;
// grvListaCartaSolicitud.Columns[13].Visible = false;
if ( Request [ "d" ] . ToString ( ) = = "firmar" )
{
grvListaCartaSolicitud . Columns [ 11 ] . Visible = true ;
grvListaCartaSolicitud . Columns [ 10 ] . Visible = false ;
}
else
{
grvListaCartaSolicitud . Columns [ 11 ] . Visible = false ;
}
if ( Request [ "d" ] . ToString ( ) = = "constancia" )
{
grvListaCartaSolicitud . Columns [ 10 ] . Visible = true ;
grvListaCartaSolicitud . Columns [ 11 ] . Visible = false ;
}
//else
//{
// grvListaCartaSolicitud.Columns[10].Visible = false;
//}
}
}
catch ( Exception )
{ }
finally
{
}
}
protected void btnFinalizar_Click ( object sender , EventArgs e )
2021-02-23 19:07:27 +00:00
{
2021-01-22 14:59:35 +00:00
try
{
int nActividad = 5 ; //confeccion de constancia
if ( Request [ "d" ] ! = null )
{
if ( Request [ "d" ] . ToString ( ) = = "firmar" )
nActividad = 6 ; //validacion y firma de documentos
}
if ( VerificarConstancias ( nActividad ) )
{
#region constancias
Documento oDoc = new Documento ( ) ;
bool bDocumentosAlmacenados = false ;
char delimitador = '-' ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ; ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = string . Empty ;
//objCartaBL.objCartaEL.FKREUTILIZA = nPKReutiliza;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
//ViewState["MODO"] = "Modificar";
foreach ( DataRow row in ds . Tables [ 0 ] . Rows )
{
if ( row [ "DESCRIPCIONESTADOCARTA" ] . ToString ( ) = = "Activo" )
{
string [ ] arrayNombre = row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) . Split ( delimitador ) ;
string pdfPathConstancia = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) + @"\" + row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + ".pdf" ;
byte [ ] bDoc = System . IO . File . ReadAllBytes ( pdfPathConstancia ) ;
//se carga el archivo y el registro a vision 2020
oDoc = new Documento ( ) ;
2021-02-16 23:18:53 +00:00
string strResultado = "" ;
2021-01-22 14:59:35 +00:00
if ( strResultado = = string . Empty )
{
oDoc = new Documento ( ) ;
2021-02-16 23:18:53 +00:00
strResultado = "s" ;
2021-01-22 14:59:35 +00:00
if ( strResultado ! = string . Empty & & strResultado ! = "No existe" )
{
//strResultado += pdfPath + ";"; ;
//File.Delete(pdfPathConstancia);
bDocumentosAlmacenados = true ;
}
else
{
ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No se ha generado el documento PDF. Debe generar el documento pdf presionando el boton ExportarPDF desde el documento editable.');</script>" ) ;
bDocumentosAlmacenados = false ;
return ;
}
2021-02-16 23:18:53 +00:00
2021-01-22 14:59:35 +00:00
}
//else
// bResultado = false;
}
}
if ( bDocumentosAlmacenados )
{
GuardarDatosActividad ( "finalizó" , nActividad ) ;
if ( nActividad = = 5 )
{
MensajeInformativo ( "Finalizó con éxito la actividad 5 Administración de constancias." ) ;
//cancelar notificacion
notificacionBL objNotificacionBL = new notificacionBL ( ) ;
objNotificacionBL . objnotificacionEL . ID_DOCUMENTO = Session [ "SOLICITUD" ] . ToString ( ) + " - Confección de constancias" ;
objNotificacionBL . objnotificacionEL . status = "00" ;
objNotificacionBL . objnotificacionEL . message = "OK" ;
int nValorRetornado = objNotificacionBL . cancelarNotificacion ( objNotificacionBL . objnotificacionEL ) ;
}
if ( nActividad = = 6 )
{
MensajeInformativo ( "Finalizó con éxito la actividad 6 Validación y firma." ) ;
//cancelar notificacion
notificacionBL objNotificacionBL = new notificacionBL ( ) ;
objNotificacionBL . objnotificacionEL . ID_DOCUMENTO = Session [ "SOLICITUD" ] . ToString ( ) + " - Validación y firma" ;
objNotificacionBL . objnotificacionEL . status = "00" ;
objNotificacionBL . objnotificacionEL . message = "OK" ;
int nValorRetornado = objNotificacionBL . cancelarNotificacion ( objNotificacionBL . objnotificacionEL ) ;
2021-02-23 19:07:27 +00:00
2021-03-03 22:34:22 +00:00
#region Notificacion
if ( chkNotificacion . Checked )
{
if ( VerificarNotificacion ( ) )
{
int nNumSolicitudTMP = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
if ( File . Exists ( ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + lblNumSolicitud . Text ) )
Directory . Delete ( ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + lblNumSolicitud . Text , true ) ;
//GuardarDocumentoVision2020(nNumSolicitudTMP);
programacionsolicitudBL objprogramacionsolicitudBL = new programacionsolicitudBL ( ) ;
objprogramacionsolicitudBL . objprogramacionsolicitudEL . FKESTADOPROGRAMACION = 3 ;
objprogramacionsolicitudBL . objprogramacionsolicitudEL . FKSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
objprogramacionsolicitudBL . objprogramacionsolicitudEL . PK = int . Parse ( Session [ "PKPROGRAMACION" ] . ToString ( ) ) ;
int nPKProgramacionSolicitud = objprogramacionsolicitudBL . modificarprogramacionsolicitud ( ) ;
if ( nPKProgramacionSolicitud = = objprogramacionsolicitudBL . objprogramacionsolicitudEL . FKSOLICITUD )
{
GuardarDatosActividadCheked ( "finalizó" ) ;
2021-02-23 19:07:27 +00:00
2021-03-03 22:34:22 +00:00
MensajeInformativo ( "Finalizó con éxito la actividad 7 Notificación al usuario." ) ;
//cancelar notificacion
2021-02-23 19:07:27 +00:00
2021-03-03 22:34:22 +00:00
objNotificacionBL . objnotificacionEL . ID_DOCUMENTO = Session [ "SOLICITUD" ] . ToString ( ) + " - Notificación al usuario" ;
objNotificacionBL . objnotificacionEL . status = "00" ;
objNotificacionBL . objnotificacionEL . message = "OK" ;
nValorRetornado = objNotificacionBL . cancelarNotificacion ( objNotificacionBL . objnotificacionEL ) ;
}
else
{
MensajeAlerta ( "Se presento un problema al finalizar la actividad por favor intente de nuevo." ) ;
}
2021-02-23 19:07:27 +00:00
2021-03-03 22:34:22 +00:00
}
else
MensajeAlerta ( "Falta finalizar la notificación al usuario." ) ;
}
#endregion
2021-02-23 19:07:27 +00:00
}
2021-01-22 14:59:35 +00:00
//ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script>javascript: MensajeInformativo('Se ha generado el documento PDF. ');</script>");
}
}
#endregion
}
else
MensajeAlerta ( "Falta finalizar la generación de constancias." ) ;
}
catch ( Exception ex )
{
MensajeError ( "Se presentó un error al finalizar la actividad." , ex ) ;
}
}
public bool VerificarConstancias ( int p_nOrden )
{
bool bValorRetornado = false ;
try
{
//Instancia el objeto
objCartaBL = new cartaBL ( ) ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitudTMP ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = string . Empty ;
//objCartaBL.objCartaEL.FKREUTILIZA = nPKReutilizaTMP;
objCartaBL . objCartaEL . FKESTADOCARTA = 1 ;
objCartaBL . objCartaEL . FKESTADOCARTA2 = 4 ;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
//se el registro de vision 2020
Documento oDoc = new Documento ( ) ;
string strResultado = string . Empty ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( DataRow row in ds . Tables [ 0 ] . Rows )
{
string pdfPath = ConfigurationManager . AppSettings [ "DocumentosPDF" ] . ToString ( ) + @"\" + Session [ "SOLICITUD" ] . ToString ( ) + @"\" + row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + ".pdf" ;
#region constancias
if ( ! File . Exists ( pdfPath ) )
{
//obtener la constancia y ponerla en la carpeta compartida para el envio de correo
char delimitador = '-' ;
string [ ] arrayNombre = row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) . Split ( delimitador ) ;
2021-02-10 23:17:05 +00:00
strResultado = oDoc . Consultar_Documento ( arrayNombre [ 1 ] . ToString ( ) + "-" + arrayNombre [ 2 ] . ToString ( ) + "-" + arrayNombre [ 3 ] . ToString ( ) + "|Constancia" , row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) , row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + ".pdf" ) ;
2021-01-22 14:59:35 +00:00
2021-02-09 22:18:21 +00:00
string Archivo = row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + ".pdf" ;
2021-02-10 23:17:05 +00:00
if ( File . Exists ( pdfPath ) )
2021-02-09 22:18:21 +00:00
{
2021-02-10 23:17:05 +00:00
strResultado = "EXISTE" ;
2021-02-09 22:18:21 +00:00
}
2021-02-16 23:18:53 +00:00
strResultado = "." ;
2021-01-22 14:59:35 +00:00
if ( strResultado = = string . Empty | | strResultado = = "No existe" )
{
ClientScript . RegisterStartupScript ( this . GetType ( ) , "Error" , "<script>javascript: MensajeInformativo('No se ha generado el documento PDF. Debe exportar el documento desde el archivo editable presionando EnviarPDF" + pdfPath + "');</script>" ) ;
bValorRetornado = false ;
return bValorRetornado ;
}
}
#endregion
if ( System . IO . File . Exists ( pdfPath ) )
{
bValorRetornado = true ;
if ( p_nOrden = = 6 & & chkFirmado . Checked = = true ) //revisar firma
{
oDoc = new Documento ( ) ;
//se transaforma el archivo a un arreglo de bytes
byte [ ] bDoc = System . IO . File . ReadAllBytes ( pdfPath ) ;
string nombreAdjunto = row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) ;
//nombreAdjunto = nombreAdjunto.Replace(" ", "_");
//se verifica que el archivo a subir este firmado
using ( FirmadorWeb . FirmadorWebSvcClient cliente = new FirmadorWeb . FirmadorWebSvcClient ( ) )
{
FirmadorWeb . FirmaDigital1 [ ] signatures = null ;
//Trace.Write("Paso 1");
//try
//{
//throw new Exception("Excepcion volutaria");
signatures =
cliente . ValidarDocumento (
row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + ".pdf" ,
bDoc
) ;
if ( signatures . Count ( ) > 0 )
{
if ( signatures [ 0 ] . Estado . ToString ( ) = = "Invalido" )
{
MensajeAlerta ( "La firma digital en el documento " + row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + " no es válida." ) ;
return false ;
}
}
if ( signatures . Count ( ) = = 0 )
{
MensajeAlerta ( "El documento " + row [ "NOMBREDOCUMENTOCARTA" ] . ToString ( ) + " no ha sido firmado por favor realice el proceso de firma digital." ) ;
return false ;
}
}
}
}
else
{
bValorRetornado = false ;
return bValorRetornado ;
}
}
}
if ( p_nOrden = = 6 ) //6:validacion y firma de documentos
{
//modificar el estado de la firma
solicitudBL objSolicitudBL = new solicitudBL ( ) ;
objSolicitudBL . objSolicitudEL . PK = int . Parse ( Session [ "PKPROGRAMACION" ] . ToString ( ) ) ;
objSolicitudBL . objSolicitudEL . FKUSUARIOXDEPENDENCIA = int . Parse ( Session [ "PKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) ;
objSolicitudBL . objSolicitudEL . ORDEN = p_nOrden ; //6:validacion y firma de documentos
objSolicitudBL . objSolicitudEL . VALIDACIONFIRMARESPONSABLEACTIVIDAD = false ;
DataSet dsEncargadoSolicitudFirma = objSolicitudBL . dsListaActividadesEncargadoFirma ( null ) ;
foreach ( DataRow row in dsEncargadoSolicitudFirma . Tables [ 0 ] . Rows )
{
objSolicitudBL . objresponsableActividadEL . VALIDACIONFIRMA = true ;
objSolicitudBL . objresponsableActividadEL . PK = int . Parse ( row [ "PKRESPONSABLEACTIVIDAD" ] . ToString ( ) ) ;
int nResultActualizarFirma = objSolicitudBL . actualizarFirmaActividadSolicitud ( ) ;
}
//verificar que no faltan firmas
objSolicitudBL = new solicitudBL ( ) ;
objSolicitudBL . objSolicitudEL . PK = int . Parse ( Session [ "PKPROGRAMACION" ] . ToString ( ) ) ;
//objSolicitudBL.objSolicitudEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objSolicitudBL . objSolicitudEL . ORDEN = p_nOrden ; //6:validacion y firma de documentos
objSolicitudBL . objSolicitudEL . VALIDACIONFIRMARESPONSABLEACTIVIDAD = false ;
DataSet dsEncargadosActividades = objSolicitudBL . dsListaActividadesEncargadoFirma ( null ) ;
if ( dsEncargadosActividades . Tables [ 0 ] . Rows . Count > 0 & & chkFirmado . Checked = = true ) //revisar firma
{
bValorRetornado = false ;
foreach ( DataRow row in dsEncargadosActividades . Tables [ 0 ] . Rows )
{
string strPiePagina = "</BR> </BR></BR>AVISO DE CONFIDENCIALIDAD: este mensaje y la información incluida en él es confidencial y está dirigida únicamente al destinatario. Puede contener información privilegiada, confidencial, amparada por el secreto profesional o que no debe ser revelada. Si usted ha recibido este correo por error, por favor comunicarlo inmediatamente vía correo y tener la amabilidad de eliminarlo de su sistema. Queda notificado que no deberá copiar este mensaje, ni utilizar, divulgar, publicar o distribuir su contenido de modo alguno. Todo mensaje enviado a esta dirección de correo electrónico puede ser sujeto a inspección por alguien distinto de su receptor originario. La transmisión de correos no garantiza que el correo electrónico sea seguro o libre de error. Por consiguiente, se advierte que esta información pueda estar incompleta o ser poco precisa ya que toda información está sujeta a alterarse sin previo aviso.”" ;
string strAsuntoCorreo = "Conclusión de actividad - SIGDD" ;
string strMensajeContenido = "La actividad validación y firma de la solicitud N° " + Session [ "SOLICITUD" ] . ToString ( ) + " no puede ser concluida hasta que se firmen las constancias, ingrese al sistema <a href=http://" + HttpContext . Current . Request . Url . Authority + "/Forms/wfrLogin.> SIGDD</a>" + strPiePagina ;
AyABL . TRA . correoBL objcorreoBL = new AyABL . TRA . correoBL ( ) ;
int nPkSolicitud = Convert . ToInt32 ( row [ 1 ] . ToString ( ) ) ; //AQUI INSERTAMOS LA PK DE LA SOLICITUD
objcorreoBL . objcorreoEL . FKNUMSOLICITUD = nPkSolicitud ;
// objcorreoBL.objcorreoEL.CORREO = dsActividad.Tables[0].Rows[0]["LOGINUSUARIO"].ToString() + "@aya.go.cr";
objcorreoBL . objcorreoEL . ASUNTO = strAsuntoCorreo ;
objcorreoBL . objcorreoEL . CONTENIDO = strMensajeContenido ;
objcorreoBL . objcorreoEL . FKUSUARIO = Convert . ToInt32 ( row [ "FKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) ;
objcorreoBL . objcorreoEL . Fecha = DateTime . Now ;
int nValorRetornado = objcorreoBL . insertarCorreo ( ) ;
MensajeAlerta ( "Falta finalizar la firma de documentos por parte del usuario " + CultureInfo . CurrentCulture . TextInfo . ToTitleCase ( row [ "NOMBRECOMPLETO" ] . ToString ( ) . ToLower ( ) ) ) ;
}
}
//verificar que los documentos se encuentran firmados
}
}
catch ( Exception ex )
{
throw ex ;
}
return bValorRetornado ;
}
2021-02-23 19:07:27 +00:00
private bool VerificarNotificacion ( )
{
bool bValor = false ;
try
{
if ( chkCFIA . Checked = = false )
{
notificacionClienteBL objNotificacionClienteBL = new notificacionClienteBL ( ) ;
objNotificacionClienteBL . objnotificacionClienteEL . FKSOLICITUD = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
DataSet ds = objNotificacionClienteBL . listarNotificacionCliente ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count ! = 0 )
{
bValor = true ;
}
}
else
{
string strRutaArchivosAdjuntos = string . Empty ;
int nNumSolicitudTMP = int . Parse ( Session [ "PKSOLICITUD" ] . ToString ( ) ) ;
strRutaArchivosAdjuntos = obtenerCartaSolicitud ( nNumSolicitudTMP ) ;
//crear documento zip con los archivos adjuntos
string strRutaDocumentos = ConfigurationManager . AppSettings [ "RutaPdfAdjuntosSql" ] . ToString ( ) + @"\" + lblNumSolicitud . Text ;
DirectoryInfo diCarpeta = new DirectoryInfo ( strRutaDocumentos ) ;
ZipFile zip = new ZipFile ( ) ;
foreach ( FileInfo fi in diCarpeta . GetFiles ( ) )
{
if ( fi . Extension = = ".pdf" )
zip . AddFile ( strRutaDocumentos + @"\" + fi . Name , "" ) ;
}
string strRutaDocZip = strRutaDocumentos + @"\" + lblNumSolicitud . Text + ".zip" ;
zip . Save ( strRutaDocZip ) ;
//ser verifica el resultado de la solicitud
solicitudBL objSolicitudBL = new solicitudBL ( ) ;
objSolicitudBL . objSolicitudEL . PK = int . Parse ( strPKSolicitudTMP ) ;
DataSet dsSolicitud = objSolicitudBL . dsExisteSolicitud ( null ) ;
if ( dsSolicitud . Tables [ 0 ] . Rows . Count > 0 & & dsSolicitud . Tables [ 0 ] . Rows [ 0 ] [ "DESCRIPCIONDESCRIPCIONCFIA" ] . ToString ( ) ! = "N/A" & & dsSolicitud . Tables [ 0 ] . Rows [ 0 ] [ "DESCRIPCIONDESCRIPCIONCFIA" ] . ToString ( ) ! = string . Empty )
{
nNumeroSolicitudCFIA = int . Parse ( dsSolicitud . Tables [ 0 ] . Rows [ 0 ] [ "DESCRIPCIONDESCRIPCIONCFIA" ] . ToString ( ) ) ;
}
//enviar notificacion a CFIA con el servicio de respuesta
if ( File . Exists ( strRutaDocZip ) & & nNumeroSolicitudCFIA ! = 0 )
{
APCR_WCF_Respuesta . ServicioClient wcfCfia = new APCR_WCF_Respuesta . ServicioClient ( ) ;
APCR_WCF_Respuesta . Respuestas respuestaAPCR ;
byte [ ] bRespuestaZip = System . IO . File . ReadAllBytes ( strRutaDocZip ) ;
respuestaAPCR = wcfCfia . RespuestaSolicitud ( nNumeroSolicitudCFIA , txtObservaciones . Text , 3 , Session [ "LOGIN" ] . ToString ( ) , bRespuestaZip , 3 , ConfigurationManager . AppSettings [ "LLAVEAPCR" ] . ToString ( ) ) ;
if ( respuestaAPCR . Respuesta = = true )
{
bValor = true ;
}
else
{
bValor = false ;
MensajeAlerta ( "Se presento el siguiente problema a la hora de notificar al CFIA: " + respuestaAPCR . DescripcionError ) ;
}
}
}
}
catch ( Exception ex )
{
throw ex ;
}
return bValor ;
}
2021-03-03 22:34:22 +00:00
private int GuardarDatosActividadCheked ( string p_accion ) //M0
2021-02-23 19:07:27 +00:00
{
int nValorRetornado = 0 ;
try
{
AyABL . TRA . correoBL objcorreoBL = new AyABL . TRA . correoBL ( ) ;
//string strModo = ViewState["MODO"].ToString();
int nPkSolicitud = 0 ;
int nResultadoActualizar = 0 ;
string strMensajeContenido = "" ;
string strAsuntoCorreo = "" ;
string strPiePagina = "</BR> </BR></BR>AVISO DE CONFIDENCIALIDAD: este mensaje y la información incluida en él es confidencial y está dirigida únicamente al destinatario. Puede contener información privilegiada, confidencial, amparada por el secreto profesional o que no debe ser revelada. Si usted ha recibido este correo por error, por favor comunicarlo inmediatamente vía correo y tener la amabilidad de eliminarlo de su sistema. Queda notificado que no deberá copiar este mensaje, ni utilizar, divulgar, publicar o distribuir su contenido de modo alguno. Todo mensaje enviado a esta dirección de correo electrónico puede ser sujeto a inspección por alguien distinto de su receptor originario. La transmisión de correos no garantiza que el correo electrónico sea seguro o libre de error. Por consiguiente, se advierte que esta información pueda estar incompleta o ser poco precisa ya que toda información está sujeta a alterarse sin previo aviso.”" ;
solicitudBL objSolicitudBL = new solicitudBL ( ) ;
objSolicitudBL . objSolicitudEL . PK = int . Parse ( Session [ "PKPROGRAMACION" ] . ToString ( ) ) ;
2021-03-03 22:34:22 +00:00
objSolicitudBL . objSolicitudEL . ORDEN = 7 ;
2021-02-23 19:07:27 +00:00
DataSet dsEncargadosActividades = objSolicitudBL . dsListaActividadesEncargado ( null ) ;
if ( dsEncargadosActividades . Tables [ 0 ] . Rows . Count > 0 )
{
string strEncargadoActividad = dsEncargadosActividades . Tables [ 0 ] . Rows [ 0 ] [ "PKRESPONSABLEACTIVIDAD" ] . ToString ( ) ;
ObservacionesActividadesBL objObservacionesBL = new ObservacionesActividadesBL ( ) ;
//objObservacionesBL.objobservacionesEL.FKNUMSOLICITUD = strNumSolicitudTMP;
objObservacionesBL . objobservacionesEL . DESCRIPCION = "\n" + DateTime . Now . ToString ( ) + " - " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) + " - Se " + p_accion + " la notificación al usuario por parte del encargado : " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) ;
objObservacionesBL . objobservacionesEL . FKUSUARIOXDEPENDENCIA = int . Parse ( Session [ "PKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) ;
objObservacionesBL . objobservacionesEL . PKRESPONSABLEACTIVIDAD = int . Parse ( strEncargadoActividad ) ;
objObservacionesBL . objobservacionesEL . Fecha = DateTime . Now ;
objObservacionesBL . objobservacionesEL . TIPO = 1 ;
//objObservacionesBL.objobservacionesEL.FKSOLICITUD = nPKSolicitud;
//objObservacionesBL.objobservacionesEL.USUARIO = Session["LOGIN"].ToString();
nValorRetornado = objObservacionesBL . insertarObservacionActividad ( ) ;
if ( nValorRetornado ! = 0 )
{
solicitudBL objSolicitud = new solicitudBL ( ) ;
//objSolicitud.objresponsableActividadEL.PK = int.Parse(Session["PKRESPONSABLEACTIVIDAD"].ToString());
//poner la actividad actual en estado correspondiente
objSolicitud . objresponsableActividadEL . FECHADEVOLUCION = DateTime . Now ;
foreach ( DataRow row in dsEncargadosActividades . Tables [ 0 ] . Rows )
{
objSolicitud . objresponsableActividadEL . PK = int . Parse ( row [ "PKRESPONSABLEACTIVIDAD" ] . ToString ( ) ) ;
if ( p_accion = = "finalizó" )
{
decimal nTiempoActividad = 0 ;
if ( row [ "CLASIFICACIONSOLICITUD" ] . ToString ( ) = = "Crecimiento vegetativo" )
nTiempoActividad = decimal . Parse ( row [ "TIEMPOCVACTIVIDAD" ] . ToString ( ) ) ;
if ( row [ "CLASIFICACIONSOLICITUD" ] . ToString ( ) = = "Desarrollo urbanistico" )
nTiempoActividad = decimal . Parse ( row [ "TIEMPODUACTIVIDAD" ] . ToString ( ) ) ;
char [ ] separadorColumna = { '.' } ;
string [ ] strArrayTiempo = nTiempoActividad . ToString ( ) . Replace ( "," , "." ) . Split ( separadorColumna ) ;
DateTime dtFechaRecibido = DateTime . Parse ( row [ "FECHAASIGNACIONRESPONSABLEACTIVIDAD" ] . ToString ( ) ) . AddDays ( double . Parse ( strArrayTiempo [ 0 ] . ToString ( ) ) ) ;
if ( double . Parse ( strArrayTiempo [ 1 ] . ToString ( ) ) > 0 )
dtFechaRecibido = dtFechaRecibido . AddHours ( 4 ) ;
if ( dtFechaRecibido > DateTime . Now )
objSolicitud . objresponsableActividadEL . FKESTADO = 5 ; //finalizada a tiempo t_sgm_estadoactividad
else
objSolicitud . objresponsableActividadEL . FKESTADO = 8 ; //finalizada fuera de tiempo t_sgm_estadoactividad
strMensajeContenido = "La actividad " + Session [ "DESCRIPCIONACTIVIDAD" ] . ToString ( ) + " de la solicitud N° " + Session [ "SOLICITUD" ] . ToString ( ) + " ha sido concluida para ver los detalles, ingrese al sistema <a href=http://" + HttpContext . Current . Request . Url . Authority + "/Forms/wfrLogin.> SIGDD</a>" + strPiePagina ;
strAsuntoCorreo = "Conclusión de actividad - SIGDD" ;
//cancelar notificacion
notificacionBL objNotificacionBL = new notificacionBL ( ) ;
objNotificacionBL . objnotificacionEL . ID_DOCUMENTO = Session [ "SOLICITUD" ] . ToString ( ) + " - Notificación al usuario" ;
objNotificacionBL . objnotificacionEL . status = "00" ;
objNotificacionBL . objnotificacionEL . message = "OK" ;
nValorRetornado = objNotificacionBL . cancelarNotificacion ( objNotificacionBL . objnotificacionEL ) ;
}
nResultadoActualizar = objSolicitud . actualizarActividadSolicitud ( ) ;
}
#region Envio de correo
2021-03-03 22:34:22 +00:00
int nActividad = 7 ;
2021-02-23 19:07:27 +00:00
//if (nActividad > 2)
// nActividad = 2;//SE ENVIA PARA REPROGRAMAR11
//else
// nActividad = 1;
//se envia correo a los encargados de la actividad 3
objSolicitudBL . objSolicitudEL . PK = int . Parse ( Session [ "PKPROGRAMACION" ] . ToString ( ) ) ;
objSolicitudBL . objSolicitudEL . ORDEN = nActividad ;
dsEncargadosActividades = objSolicitudBL . dsListaActividadesEncargado ( null ) ;
if ( dsEncargadosActividades . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( DataRow row in dsEncargadosActividades . Tables [ 0 ] . Rows )
{
nPkSolicitud = Convert . ToInt32 ( row [ 1 ] . ToString ( ) ) ; //AQUI INSERTAMOS LA PK DE LA SOLICITUD
objcorreoBL . objcorreoEL . FKNUMSOLICITUD = nPkSolicitud ;
// objcorreoBL.objcorreoEL.CORREO = dsActividad.Tables[0].Rows[0]["LOGINUSUARIO"].ToString() + "@aya.go.cr";
objcorreoBL . objcorreoEL . ASUNTO = strAsuntoCorreo ;
objcorreoBL . objcorreoEL . CONTENIDO = strMensajeContenido ;
objcorreoBL . objcorreoEL . FKUSUARIO = Convert . ToInt32 ( row [ "FKUSUARIOXDEPENDENCIA" ] . ToString ( ) ) ;
objcorreoBL . objcorreoEL . Fecha = DateTime . Now ;
nValorRetornado = objcorreoBL . insertarCorreo ( ) ;
}
}
#endregion
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + "Se finaliza la notificación al usuario por parte del encargado: " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) . Trim ( ) + " para la solicitud N° " + Session [ "SOLICITUD" ] . ToString ( ) ,
Path . GetFileNameWithoutExtension ( Page . AppRelativeVirtualPath ) ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
}
}
GuardarEventoBitacora (
Session [ "LOGIN" ] . ToString ( ) ,
AccionBitacora . INSERT . ToString ( ) ,
MensajesBitacora . IngresarRegistro + ": Se ingreso una nueva observacion: Se finaliza la notificación al usuario por parte del encargado: " + Session [ "NOMBREEMPLEADO" ] . ToString ( ) . Trim ( ) ,
Path . GetFileNameWithoutExtension ( Page . AppRelativeVirtualPath ) ,
Convert . ToInt32 ( ConfigurationManager . AppSettings [ "pkApp" ] )
) ;
}
catch ( Exception ex )
{
throw ex ;
}
return nValorRetornado ;
}
2021-01-22 14:59:35 +00:00
private void AbrirVentanaEmergenteDevolucion ( )
{
{
EjecutarScript ( "VentanaEmergenteAbrirDevolucion('frwDevolucionActividadesSolicitud.aspx');" ) ;
ViewState [ "POPUP" ] = "VentanaEmergente" ;
//Instancia el objeto
objCartaBL = new cartaBL ( ) ;
//Asigna un valor al atributo de referencia del objeto
objCartaBL . objCartaEL . FKNUMSOLICITUD = nNumSolicitudTMP ;
objCartaBL . objCartaEL . NOMBREDOCUMENTO = string . Empty ;
//objCartaBL.objCartaEL.FKREUTILIZA = nPKReutilizaTMP;
//Carga en un dataset la información
DataSet ds = objCartaBL . listarCartas ( ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( DataRow row in ds . Tables [ 0 ] . Rows )
{
int nPK = int . Parse ( row [ "PKCARTA" ] . ToString ( ) ) ;
eliminarCartaSolicitud ( nPK ) ;
}
obtenerCartaSolicitud ( nNumSolicitudTMP , "" , nPKReutilizaTMP ) ;
}
}
}
}