Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            this.toolStripStatusLabel1.Text = string.Empty;
            TelnetPDF.ClassParametrosTelnetPDF cp = new TelnetPDF.ClassParametrosTelnetPDF();
            cp.FileRoute  = "c:\\temp\\";                                               //"D:\\TelnetPDF\\WebApplicationTelnetPDF\\WebApplicationTelnetPDF\\files\\";
            cp.Imageroute = ConfigurationSettings.AppSettings["ImageRoute"];
            cp.Urlpath    = ConfigurationSettings.AppSettings["Urlpath"].ToString();    // "/files/";
            cp.Urlmensaje = ConfigurationSettings.AppSettings["Urlmensaje"].ToString(); // "Descargar Archivo Aqui";
            cp.CantidadCamposxRegistro       = ConfigurationSettings.AppSettings["CantidadCamposxRegistro"].ToString();
            cp.CnnStringSqlServerSinPassword = ConfigurationSettings.AppSettings["CnnStringSqlServerSinPassword"].ToString();
            cp.CuentaUniverse = ConfigurationSettings.AppSettings["CuentaUniverse"].ToString();
            cp.PasswordSqlServerEncriptado = ConfigurationSettings.AppSettings["PasswordSqlServerEncriptado"].ToString();
            cp.PasswordUniverseEncriptado  = ConfigurationSettings.AppSettings["PasswordUniverseEncriptado"].ToString();
            cp.ServerUniverse  = ConfigurationSettings.AppSettings["ServerUniverse"].ToString();
            cp.UsuarioUniverse = ConfigurationSettings.AppSettings["UsuarioUniverse"].ToString();
            cp.LogFile         = ConfigurationSettings.AppSettings["PathLog"].ToString();
            cp.FontRoute       = ConfigurationSettings.AppSettings["FontRoute"].ToString();

            TelnetPDF.comprobantesPDF ts = new TelnetPDF.comprobantesPDF();
            string res = ts.GenerarFactura(this.sNumeroComprobante.Text.Trim(), cp, true, true);

            toolStripStatusLabel1.Text = "Generacion Finalizada:" + res;
            // MessageBox.Show("Generacion Finalizada:" + res, "OK", MessageBoxButtons.OK);

            Cursor.Current = Cursors.Default;
        }
Beispiel #2
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            Cursor.Current             = Cursors.WaitCursor;
            toolStripStatusLabel1.Text = "";

            Stream         myStream        = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            int            counter         = 0;
            string         line;
            IList <string> DatosComprobante = new List <string>();


            Cursor.Current             = Cursors.WaitCursor;
            toolStripStatusLabel1.Text = "";

            TelnetPDF.ClassParametrosTelnetPDF cp = new TelnetPDF.ClassParametrosTelnetPDF
            {
                FileRoute = "c:\\temp\\",         //"D:\\TelnetPDF\\WebApplicationTelnetPDF\\WebApplicationTelnetPDF\\files\\";

                Imageroute = ConfigurationSettings.AppSettings["ImageRoute"],
                Urlpath    = ConfigurationSettings.AppSettings["Urlpath"].ToString(),    // "/files/";
                Urlmensaje = ConfigurationSettings.AppSettings["Urlmensaje"].ToString(), // "Descargar Archivo Aqui";
                Archivo    = ConfigurationSettings.AppSettings["Archivo"].ToString(),
                Archivo2   = ConfigurationSettings.AppSettings["Archivo2"].ToString(),
                CantidadCamposxRegistro       = ConfigurationSettings.AppSettings["CantidadCamposxRegistro"].ToString(),
                CnnStringSqlServerSinPassword = ConfigurationSettings.AppSettings["CnnStringSqlServerSinPassword"].ToString(),
                CuentaUniverse = ConfigurationSettings.AppSettings["CuentaUniverse"].ToString(),

                PasswordSqlServerEncriptado = ConfigurationSettings.AppSettings["PasswordSqlServerEncriptado"].ToString(),
                PasswordUniverseEncriptado  = ConfigurationSettings.AppSettings["PasswordUniverseEncriptado"].ToString(),
                Path            = ConfigurationSettings.AppSettings["Path"].ToString(),
                Path2           = ConfigurationSettings.AppSettings["Path2"].ToString(),
                ServerUniverse  = ConfigurationSettings.AppSettings["ServerUniverse"].ToString(),
                UsuarioUniverse = ConfigurationSettings.AppSettings["UsuarioUniverse"].ToString(),
                LogFile         = ConfigurationSettings.AppSettings["PathLog"].ToString(),
                FontRoute       = ConfigurationSettings.AppSettings["FontRoute"].ToString()
            };

            TelnetPDF.comprobantesPDF ts = new TelnetPDF.comprobantesPDF();



            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    System.IO.StreamReader file = new System.IO.StreamReader(@openFileDialog1.FileName);
                    int iSkip = 0;
                    toolStripProgressBar1.Value = 0;
                    while ((line = file.ReadLine()) != null)
                    {
                        line = line.Replace('þ', '|');
                        DatosComprobante.Add(line);
                        counter++;
                    }


                    toolStripProgressBar1.Maximum = counter;
                    int LngLotes;
                    if (counter < 250)
                    {
                        LngLotes = counter;
                    }
                    else
                    {
                        LngLotes = 250;
                    }

                    //analizo la cantidad de lotes a procesar
                    int cantidadlotes = counter / LngLotes;


                    for (int i = 1; i <= cantidadlotes; i++)
                    {
                        var subList = DatosComprobante.Skip(iSkip).Take(LngLotes).ToList();
                        //  if (i == 4)
                        //  {
                        string p = ts.GenerarFacturasLotes(subList, cp, true, true, i.ToString());
                        // }
                        //list.Skip(2).Take(5).ToList();
                        toolStripProgressBar1.Value = (i * LngLotes);
                        iSkip = iSkip + LngLotes;
                    }

                    Cursor.Current             = Cursors.Default;
                    toolStripStatusLabel1.Text = "Lote Creado";
                }



                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }