private void Initialize()
        {
            try
            {
                //Inicializa conexion sqlite
                Ambiente.SqliteConnectionString = Application.StartupPath + @"\config.s3db";
                Ambiente.SqliteConnection       = new SQLiteConnection(string.Format("Data Source={0};Version=3;", Ambiente.SqliteConnectionString));
                Ambiente.SqliteConnection.Open();


                conexionController = new ConexionController();
                //Llenar Empresas
                CboEmpresa.DataSource    = conexionController.SelectAll();
                CboEmpresa.DisplayMember = "Empresa";
                CboEmpresa.ValueMember   = "ConexionId";
                CboEmpresa.SelectedIndex = 0;

                //Llenar Establecimientos
                //CboEstablecimineto.DataSource = conexionController.SelectAll();
                CboEstablecimineto.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string Rut  = context.Request.QueryString["Rut"];
                string Mes  = context.Request.QueryString["Mes"];
                string Anio = context.Request.QueryString["Anio"];

                string usuario    = context.Request.QueryString["Usuario"];
                string contrasena = context.Request.QueryString["Clave"];

                string retorno = "ERROR";

                ConexionController conexion = new ConexionController();
                try
                {
                    if (!string.IsNullOrEmpty(usuario) && !string.IsNullOrEmpty(contrasena))
                    {
                        retorno = conexion.connectionsSAP(usuario, contrasena);
                    }

                    if (string.IsNullOrEmpty(retorno))
                    {
                        RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(conexion.connectorConfig);
                        RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                        IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZHR_LIQ_SUE");

                        BapiGetUser.SetValue("I_RUT", Rut);
                        BapiGetUser.SetValue("I_MES", Mes);
                        BapiGetUser.SetValue("I_ANO", Anio);


                        BapiGetUser.Invoke(SapRfcDestination);

                        Byte[] bytes = (Byte[])BapiGetUser.GetValue("PDF_LIQUI");

                        using (MemoryStream input = new MemoryStream(bytes))
                        {
                            using (MemoryStream output = new MemoryStream())
                            {
                                string    password = Rut;
                                PdfReader reader   = new PdfReader(input);
                                PdfEncryptor.Encrypt(reader, output, true, password, password, PdfWriter.ALLOW_SCREENREADERS);
                                bytes = output.ToArray();
                            }
                        }
                        context.Response.Buffer  = true;
                        context.Response.Charset = "";
                        context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        context.Response.ContentType = "application/pdf";
                        context.Response.BinaryWrite(bytes);
                        context.Response.Flush();
                        context.Response.End();
                    }
                }
                catch (Exception e)
                {
                }
                finally
                {
                }
            }
            catch (Exception ex)
            {
            }
        }