Esempio n. 1
0
        public static eAjax fnEliminaDocumento(int sCodigo, string sRuta)
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }
            try
            {
                DocumentosDAO dao    = new DocumentosDAO();
                var           result = dao.fnEliminaDocumento(sCodigo);
                if (result >= 1)
                {
                    DeleteFile("ftp://ftp.site4now.net" + sRuta, "xxeguxx-001", "tornadesco.1");
                    oeAjax.iTipoResultado = 1;
                }
                else
                {
                    oeAjax.iTipoResultado = -1;
                    oeAjax.sMensajeError  = "Ocurrio Un Error Al Eliminar Documento";
                }
            }
            catch (Exception ex) {
                oeAjax.sMensajeError = ex.Message;
            }

            return(oeAjax);
        }
        public static eAjax fnFirmasDisponibles()
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }

            try
            {
                List <eSeguridad> lstSeguridad = new List <eSeguridad>();
                lstSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
                string        sUsuarioAuditoria = lstSeguridad[0].strUsuario;
                int           iIdEmpres         = Convert.ToInt32(lstSeguridad[0].iIdEmpresa);
                int           iIdTrabajador     = Convert.ToInt32(lstSeguridad[0].iIdTrabajador);
                DocumentosDAO dao     = new DocumentosDAO();
                string        sresult = dao.fnCantFirmasDisponibles(iIdEmpres);
                oeAjax.iTipoResultado = 1;
                oeAjax.sValor1        = sresult;
            }
            catch (Exception ex)
            {
                oeAjax.sMensajeError = ex.Message;
            }
            return(oeAjax);
        }
Esempio n. 3
0
        public static eAjax fnEnviarDocumento(string sRutaDocumento, string sNombreDocumento, string sTipoArchivo, string sCorreo, string sDescripcion)
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }
            try
            {
                var vDocument = sNombreDocumento + '.' + sTipoArchivo;
                var vresult   = DownloadFileNODELETE("ftp://ftp.site4now.net" + sRutaDocumento, sNombreDocumento, "xxeguxx-001", "tornadesco.1", @AppDomain.CurrentDomain.BaseDirectory + "Documentos\\");
                if (vresult != "")
                {
                    EnviarCorreo(sCorreo, sDescripcion, sNombreDocumento);
                }

                oeAjax.iTipoResultado = 1;
                oeAjax.sValor1        = vresult;
            }
            catch (Exception ex)
            {
                oeAjax.sMensajeError = ex.Message;
            }

            return(oeAjax);
        }
        public static eAjax fnCompraPlan(int iIdPlan, int sMarca, decimal dTotal, int iCantidadFirmas)
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }
            try
            {
                List <eSeguridad> lstSeguridad = new List <eSeguridad>();
                lstSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
                string sUsuarioAuditoria = lstSeguridad[0].strUsuario;
                int    iIdEmpresa        = Convert.ToInt32(lstSeguridad[0].iIdEmpresa);

                PlanesDAO dao     = new PlanesDAO();
                int       iresult = dao.fnCompraPlan(iIdEmpresa, iIdPlan, sMarca, dTotal, iCantidadFirmas);
                oeAjax.iTipoResultado = 1;
                oeAjax.sValor1        = Convert.ToString(iresult);
            }
            catch (Exception e)
            {
                oeAjax.iTipoResultado = 2;
                oeAjax.sMensajeError  = "Ocurrió un error al momento de cargar la información por favor comuníquese con el administrador del sistema. </br>" + e.ToString();
            }



            return(oeAjax);
        }
        public static eAjax fnRegistraTrabajador(string vNombre, string vApellidoPaterno, string vApellidoMaterno, string vDni, string vUsuario, string vClave, string vTelefono, int vRol)
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }

            eAjax             oAjax        = new eAjax();
            TrabajadorDAO     dao          = new TrabajadorDAO();
            List <eSeguridad> lstSeguridad = new List <eSeguridad>();

            lstSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
            string sUsuarioAuditoria = lstSeguridad[0].strUsuario;
            int    iIdCargo          = Convert.ToInt32(lstSeguridad[0].iIdCargo);
            int    iIdempresa        = Convert.ToInt32(lstSeguridad[0].iIdEmpresa);
            int    iresult           = dao.fnRegistraTrabajador(vNombre, vApellidoPaterno, vApellidoMaterno, vDni, vUsuario, vClave, vTelefono, vRol, iIdCargo, iIdempresa);

            if (iresult > 0)
            {
                oAjax.iTipoResultado = 1;
            }
            else
            {
                oAjax.iTipoResultado = -1;
                oAjax.sMensajeError  = "Ocurrio Un Error Al Registrar Plan";
            }

            return(oAjax);
        }
        public static eAjax fnExisteDocumentoPrincipal(string sRutaDocumento, string sNombreDocumento, string sTipoArchivo)
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }
            try
            {
                var vDocument = sNombreDocumento + '.' + sTipoArchivo;

                var vresult = DownloadFile("ftp://ftp.site4now.net//documentos//cargados//", vDocument, "xxeguxx-001", "tornadesco.1", @AppDomain.CurrentDomain.BaseDirectory + "Documentos\\");
                oeAjax.iTipoResultado = 1;
                oeAjax.sValor1        = vresult;
            }
            catch (Exception ex)
            {
                oeAjax.sMensajeError = ex.Message;
            }

            return(oeAjax);
        }
Esempio n. 7
0
        public static eAjax fnEliminaEmpresa(int iIdEmpresa)
        {
            eAjax        oAjax   = new eAjax();
            EmpresaDAOcs dao     = new EmpresaDAOcs();
            int          sresult = dao.fnEliminaEmpresa(iIdEmpresa);

            oAjax.iTipoResultado = 1;
            return(oAjax);
        }
        public static eAjax fnListaPlanes()
        {
            eAjax     oAjax   = new eAjax();
            PlanesDAO dao     = new PlanesDAO();
            string    iresult = dao.fnListaPlanes();

            oAjax.iTipoResultado = 1;
            oAjax.sValor1        = iresult;
            return(oAjax);
        }
Esempio n. 9
0
        public static eAjax fnListaUbigeo()
        {
            eAjax        oAjax   = new eAjax();
            EmpresaDAOcs dao     = new EmpresaDAOcs();
            string       sresult = dao.fnListaUbigeo();

            oAjax.iTipoResultado = 1;
            oAjax.sValor1        = sresult;

            return(oAjax);
        }
        public static eAjax fnListaRoles()
        {
            eAjax    oAjax   = new eAjax();
            RolesDAO dao     = new RolesDAO();
            string   sresult = dao.fnListaRol();

            oAjax.iTipoResultado = 1;
            oAjax.sValor1        = sresult;

            return(oAjax);
        }
        public static eAjax fnListaTrabajadores()
        {
            eAjax             oAjax        = new eAjax();
            TrabajadorDAO     dao          = new TrabajadorDAO();
            List <eSeguridad> lstSeguridad = new List <eSeguridad>();

            lstSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
            int    idEmpresa = Convert.ToInt32(lstSeguridad[0].iIdEmpresa);
            string iresult   = dao.fnListaTrabajadores(idEmpresa);

            oAjax.iTipoResultado = 1;
            oAjax.sValor1        = iresult;
            return(oAjax);
        }
Esempio n. 12
0
        public static eAjax fnListaPlanes()
        {
            eAjax oAjax = new eAjax();

            List <eSeguridad> lsSeguridad = new List <eSeguridad>();

            lsSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
            string sIdRol = Convert.ToString(lsSeguridad[0].iIdrol);

            oAjax.iTipoResultado = 1;


            oAjax.sValor1 = sIdRol;
            return(oAjax);
        }
        public static eAjax fnListaroles()
        {
            eAjax         oAjax = new eAjax();
            TrabajadorDAO dao   = new TrabajadorDAO();

            List <eSeguridad> lstSeguridad = new List <eSeguridad>();

            lstSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
            string sUsuarioAuditoria = lstSeguridad[0].strUsuario;
            int    iIdCargo          = Convert.ToInt32(lstSeguridad[0].iIdrol);
            string iresult           = dao.fnListaRoles(iIdCargo);

            oAjax.iTipoResultado = 1;
            oAjax.sValor1        = iresult;
            return(oAjax);
        }
        public static eAjax fnEliminaPlan(int iIdPlan)
        {
            eAjax     oAjax   = new eAjax();
            PlanesDAO dao     = new PlanesDAO();
            int       iresult = dao.fnEliminaPlan(iIdPlan);

            if (iresult > 0)
            {
                oAjax.iTipoResultado = 1;
            }
            else
            {
                oAjax.iTipoResultado = -1;
                oAjax.sMensajeError  = "Ocurrio Un Error Al Eliminar Plan";
            }

            return(oAjax);
        }
        public static eAjax fnActualizaPlan(int iIdPlan, string sDescripcion, int iCantidad, decimal dPrecio)
        {
            eAjax     oAjax   = new eAjax();
            PlanesDAO dao     = new PlanesDAO();
            int       iresult = dao.fnActualizaPlan(iIdPlan, sDescripcion, iCantidad, dPrecio);

            if (iresult > 0)
            {
                oAjax.iTipoResultado = 1;
            }
            else
            {
                oAjax.iTipoResultado = -1;
                oAjax.sMensajeError  = "Ocurrio Un Error Al Actualizar Plan";
            }

            return(oAjax);
        }
        public static eAjax fnEliminaTrabajador(int iIdTrabajador)
        {
            eAjax         oAjax   = new eAjax();
            TrabajadorDAO dao     = new TrabajadorDAO();
            int           iresult = dao.fnEliminaTrabajador(iIdTrabajador);

            if (iresult > 0)
            {
                oAjax.iTipoResultado = 1;
            }
            else
            {
                oAjax.iTipoResultado = -1;
                oAjax.sMensajeError  = "Ocurrio Un Error Al Eliminar Trabajador";
            }

            return(oAjax);
        }
Esempio n. 17
0
        public static eAjax CerrarSesion()
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            try
            {
                //var sesion = HttpContext.Current.Session["leSeguridad"];

                HttpContext.Current.Session.Clear();
                HttpContext.Current.Session.Abandon();
                HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
                oeAjax.iTipoResultado = 1;
            }
            catch (Exception e)
            {
                oeAjax.iTipoResultado = 2;
                oeAjax.sMensajeError  = "Ocurrió un error al Cerrar Sesion por favor comuníquese con el administrador del sistema. </br>" + e.ToString();
            }
            return(oeAjax);
        }
Esempio n. 18
0
        public static eAjax fnGuardaDocumento(string sNombreDocumento, string sDescripcion, int iTrabajador, string sNomDoc, string sFormato)
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }

            try
            {
                //DownloadFile("ftp://ftp.site4now.net//documentos//cargados//", "AVISO.pdf", "xxeguxx-001", "tornadesco.1", @AppDomain.CurrentDomain.BaseDirectory + "Documentos\\");

                List <eSeguridad> lstSeguridad = new List <eSeguridad>();
                lstSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
                int           iIdTrabajador = Convert.ToInt32(lstSeguridad[0].iIdTrabajador);
                int           iIdEmpres     = Convert.ToInt32(lstSeguridad[0].iIdEmpresa);
                DocumentosDAO dao           = new DocumentosDAO();

                var vruta = @AppDomain.CurrentDomain.BaseDirectory + "Documentos\\" + sNomDoc;
                var i     = dao.fnRegistraDocumento(iIdEmpres, sNombreDocumento, sDescripcion, sFormato, iIdTrabajador, iTrabajador, "\\documentos\\cargados\\" + sNomDoc);
                if (i >= 1)
                {
                    UploadFTP(vruta, "ftp://ftp.site4now.net/", "xxeguxx-001", "tornadesco.1");
                }
                File.Delete(vruta);
                oeAjax.iTipoResultado = 1;
            }
            catch (Exception ex)
            {
                oeAjax.sMensajeError = ex.Message;
            }
            return(oeAjax);
        }
Esempio n. 19
0
        public static eAjax fnValida(string sUsuario, string sClave)
        {
            eAjax        oAjax = new eAjax();
            EmpresaDAOcs dao   = new EmpresaDAOcs();

            string sresult = dao.fnValidaInicio(sUsuario, sClave);

            if (sresult != "")
            {
                var vsplit = sresult.Split('|');
                System.Web.HttpContext context = System.Web.HttpContext.Current;
                context.Response.ContentType = "application/json";

                List <eSeguridad> leSeguridad = new List <eSeguridad>();
                eSeguridad        oe          = new eSeguridad();
                oe.strUsuario       = vsplit[0];
                oe.strPassword      = vsplit[1];
                oe.sPersonal        = vsplit[2];
                oe.iIdrol           = Convert.ToInt32(vsplit[3]);
                oe.iIdCargo         = Convert.ToInt32(vsplit[4]);
                oe.iIdEmpresa       = Convert.ToInt32(vsplit[5]);
                oe.sNombreEmpresa   = Convert.ToString(vsplit[6]);
                oe.iIdTrabajador    = Convert.ToInt32(vsplit[7]);
                oe.sRutaCertificado = Convert.ToString(vsplit[8]);
                leSeguridad.Add(oe);
                HttpContext.Current.Session["leSeguridad"] = leSeguridad;
                oAjax.sValor1        = vsplit[3] + '|' + vsplit[4];
                oAjax.iTipoResultado = 1;
            }
            else
            {
                oAjax.iTipoResultado = -1;
                oAjax.sMensajeError  = "Usuario Contrasena Incorrecto";
            }


            return(oAjax);
        }
        public static eAjax fnFirmaDocumento(string sCodigo, string sRuta, string sNombre, string sFormato)
        {
            eAjax oeAjax = new eAjax();

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            context.Response.ContentType = "application/json";
            if (HttpContext.Current.Session["leSeguridad"] == null)
            {
                oeAjax.iTipoResultado = 99;
                oeAjax.sMensajeError  = "Fin Session";
                return(oeAjax);
            }

            try
            {
                List <eSeguridad> lstSeguridad = new List <eSeguridad>();
                lstSeguridad = (List <eSeguridad>)HttpContext.Current.Session["leSeguridad"];
                string    sUsuarioAuditoria = lstSeguridad[0].strUsuario;
                int       iIdEmpres         = Convert.ToInt32(lstSeguridad[0].iIdEmpresa);
                int       iIdTrabajador     = Convert.ToInt32(lstSeguridad[0].iIdTrabajador);
                string    sCertificado      = Convert.ToString(lstSeguridad[0].sRutaCertificado);
                PlanesDAO daoplan           = new PlanesDAO();
                int       iresult           = daoplan.fnListafirmaDisponibles(iIdEmpres);
                if (iresult == 0)
                {
                    oeAjax.iTipoResultado = -1;
                    oeAjax.sMensajeError  = "No Cuenta Con Firmas Disponibles";
                }
                else
                {
                    if (sCertificado != "")
                    {
                        DocumentosDAO dao     = new DocumentosDAO();
                        var           vresult = DownloadFileNODELETE("ftp://ftp.site4now.net//documentos//cargados//", sNombre, "xxeguxx-001", "tornadesco.1", @AppDomain.CurrentDomain.BaseDirectory + "Documentos\\");
                        //Si Descargo El Documento
                        if (vresult != "")
                        {
                            var certificado      = new Certificado(sCertificado);
                            var firmante         = new Firmante(certificado);
                            var vrutaDocOriginal = @AppDomain.CurrentDomain.BaseDirectory + "Documentos\\" + sNombre;
                            var vrutaDocFirma    = @AppDomain.CurrentDomain.BaseDirectory + "Documentos\\Firmados\\" + sNombre;
                            //firmante.Firmar(@"c:\demos\documento.pdf", @"c:\demos\documento-firmado.pdf");
                            firmante.Firmar(vrutaDocOriginal, vrutaDocFirma);
                            var notario         = new Notario(certificado);
                            var documentoValido = notario.CertificarDocumento(vrutaDocFirma);
                            if (documentoValido == true)
                            {
                                //transfiere el documento firmado
                                UploadFTP(vrutaDocFirma, "ftp://ftp.site4now.net/", "firmante", "tornadesco.1");
                                var i = dao.fnFirmaDocumento(Convert.ToInt32(sCodigo), @"\\documentos\\firmados\\" + sNombre);
                                File.Delete(vrutaDocOriginal);
                                File.Delete(vrutaDocFirma);
                                oeAjax.iTipoResultado = 1;
                            }
                        }
                    }
                    else
                    {
                        oeAjax.iTipoResultado = -1;
                        oeAjax.sMensajeError  = "No Cuenta Con Un Certificado Asignado";
                    }
                }



                //string sresult = dao.fnListaDocumentoPendientes(iIdEmpres, iIdTrabajador);
                //oeAjax.iTipoResultado = 1;
                //oeAjax.sValor1 = sresult;
            }
            catch (Exception ex)
            {
                oeAjax.sMensajeError = ex.Message;
            }
            return(oeAjax);
        }