Пример #1
0
 public static bool UploadFTP(string FilePath, string RemotePath, string Login, string Password)
 {
     try
     {
         using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             string        url = Path.Combine(RemotePath, Path.GetFileName(FilePath)).ToLower();
             FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(url);
             ftp.Credentials   = new NetworkCredential(Login, Password);
             ftp.Method        = WebRequestMethods.Ftp.UploadFile;
             ftp.KeepAlive     = false;
             ftp.UseBinary     = true;
             ftp.ContentLength = fs.Length;
             ftp.Proxy         = null;
             fs.Position       = 0;
             int    buffLength = 2048;
             byte[] buff       = new byte[buffLength];
             int    contentLen;
             using (Stream strm = ftp.GetRequestStream())
             {
                 contentLen = fs.Read(buff, 0, buffLength);
                 while (contentLen != 0)
                 {
                     strm.Write(buff, 0, contentLen);
                     contentLen = fs.Read(buff, 0, buffLength);
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "UtilFtp ~ UploadFTP");
         return(false);
     }
 }
Пример #2
0
 public void CapturarChecado(DPFP.Sample Sample)
 {
     try
     {
         if (DatosHuellas == null)
         {
             Usuario_Negocio UN       = new Usuario_Negocio();
             Usuario         DatosAux = new Usuario {
                 Conexion = Comun.Conexion
             };
             UN.ObtenerHuellasDigitales(DatosAux);
             DatosHuellas = DatosAux.TablaDatos;
         }
         VerificarChecado(FrmChecar, Sample, DatosHuellas, ref acceso, ref IDUsuario);
         if (acceso == true)
         {
             bool Concluido = false;
             this.FrmChecar.Invoke(new Function(delegate()
             {
                 Concluido = FrmChecar.Checar(IDUsuario);
             }));
             if (Concluido)
             {
                 FrmChecar.DialogResult = DialogResult.OK;
                 Template = null;
                 FrmChecar.Lector.Stop();
                 FrmChecar.Lector = new LectorHuella();
             }
             else
             {
                 FrmChecar.Lector.Stop();
                 FrmChecar.Invoke(new Function(delegate()
                 {
                     FrmChecar.lblInstrucciones.Text      = "Error al procesar la huella.";
                     FrmChecar.lblInstrucciones.BackColor = Color.Red;
                 }));
                 Thread.Sleep(2400);
                 Template         = null;
                 FrmChecar.Lector = new LectorHuella();
                 FrmChecar.frmChecarEntradaSalida_Load(new object(), new EventArgs());
             }
         }
         else
         {
             FrmChecar.Invoke(new Function(delegate()
             {
                 FrmChecar.lblInstrucciones.Text      = "Huella no registrada.";
                 FrmChecar.lblInstrucciones.BackColor = Color.Red;
             }));
             Thread.Sleep(2400);
             FrmChecar.Invoke(new Function(delegate()
             {
                 FrmChecar.lblInstrucciones.Text      = "Use el lector para escanear su huella digital.";
                 FrmChecar.lblInstrucciones.BackColor = Color.GreenYellow;
             }));
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "LectorHuella ~ CapturarChecado");
     }
 }