Example #1
0
 WS_Info.UsuarioVO getToken()
 {
     WS_Info.UsuarioVO _token = new WS_Info.UsuarioVO();
     _token.Usuario    = Properties.Settings.Default.UsuarioConectar;
     _token.ContraseƱa = Properties.Settings.Default.ContrasenaConectar;
     _token.Equipo     = System.Environment.MachineName.ToString();
     return(_token);
 }
Example #2
0
        bool EnviarDatos(WS_Info.Compra _compra, WS_Info.UsuarioVO _token)
        {
            bool _valido = false;

            try
            {
                WS_Info.WS_InfoSoapClient ws = new WS_Info.WS_InfoSoapClient();
                ws.CompraNueva(_token, _compra);
                _valido = true;
            }
            catch
            {
                _valido = false;
            }
            return(_valido);
        }
Example #3
0
        bool EnviarDatos(WS_Info.VentaVO _venta, WS_Info.UsuarioVO _token)
        {
            bool _valido = false;

            try
            {
                WS_Info.WS_InfoSoapClient ws = new WS_Info.WS_InfoSoapClient();
                ws.VentaNueva(_token, _venta);
                _valido = true;
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Imposible Transmitir " + ex.Message);
                _valido = false;
            }
            return(_valido);
        }
Example #4
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            int    porcentaje = 0;
            Random rand       = new Random();

            if (worker.CancellationPending)
            {
                e.Cancel = true;
            }
            WS_Info.UsuarioVO _token = new WS_Info.UsuarioVO();
            _token.Usuario    = Properties.Settings.Default.UsuarioConectar;
            _token.ContraseƱa = Properties.Settings.Default.ContrasenaConectar;
            _token.Equipo     = System.Environment.MachineName.ToString();
            Sincronizar(_token);
            porcentaje = 100;
            // report progress
            worker.ReportProgress(porcentaje, porcentaje);
            // simulate operation step
            System.Threading.Thread.Sleep(rand.Next(100, 1000));
        }
Example #5
0
        void Sincronizar(WS_Info.UsuarioVO _token)
        {
            DateTime                   Hoy               = DateTime.Now;
            PuntoVenta_Business        oPuntoVenta       = new PuntoVenta_Business();
            List <WS_Info.ProductoVO>  _listaProducto    = new List <WS_Info.ProductoVO>();
            List <WS_Info.ProveedorVO> _listaProveedores = new List <WS_Info.ProveedorVO>();
            bool _sincronizacion = false;

            String filename = Properties.Settings.Default.Files.ToString() + "\\" +
                              Properties.Settings.Default.ListaProductos + Hoy.Year.ToString() + Hoy.Month.ToString() + Hoy.Day.ToString() + ".txt";

            String filenameProveedores = Properties.Settings.Default.Files.ToString() + "\\" +
                                         Properties.Settings.Default.ListaProveedores + Hoy.Year.ToString() + Hoy.Month.ToString() + Hoy.Day.ToString() + ".txt";

            try
            {
                WS_Info.WS_InfoSoapClient ws = new WS_Info.WS_InfoSoapClient();
                _listaProducto    = ws.ConsultarProductos(_token).ToList <WS_Info.ProductoVO>();
                _listaProveedores = ws.ConsultarProveedores(_token).ToList <WS_Info.ProveedorVO>();
                _sincronizacion   = true;
            }
            catch (Exception ex)
            {
                _sincronizacion = false;
                MessageBox.Show("No se pudo sincronizar, intente mas tarde " + ex.Message);
            }

            if (!File.Exists(filename) && _sincronizacion == true)
            {
                foreach (string _archivo in Directory.GetFiles(Properties.Settings.Default.Files.ToString()))
                {
                    int longitud = _archivo.Length;
                    if (_archivo.Substring(longitud - 3, 3) == "txt")
                    {
                        File.Delete(_archivo);
                    }
                }
                oPuntoVenta.Serializar(filename, _listaProducto);
                oPuntoVenta.Serializar(filenameProveedores, _listaProveedores);
            }
        }