Exemplo n.º 1
0
        /// <summary>
        /// Sube en el servidor el archivo Linea de captura de la declaración
        /// </summary>
        /// <returns></returns>
        public bool UploadLineaCaptura()
        {
            try
            {
                if (!string.IsNullOrEmpty(ofdLineaCaptura.FileName))
                {
                    // Guardamos el archivo en la nueva carpeta creada
                    string FullPath = string.Format("{0}/{1}/{2}/-Declaraciones/{3}/", FTPCredentials.Path, ConnectionString.FolderConnection, _Editar.sClient, _Editar.iIdStatement);

                    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(string.Format("ftp://{0}/{1}.pdf", FullPath, _Editar.iIdStatement));
                    request.Method      = WebRequestMethods.Ftp.DeleteFile;
                    request.Credentials = new NetworkCredential(FTPCredentials.User, FTPCredentials.Password);
                    FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                    response.Close();

                    // Creamos la carpeta donde se guardara el archivo de la declaración
                    FTPServer.CreateDirectory(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/-Declaraciones/{1}/", _Editar.sClient, _Editar.iIdStatement));
                    FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(ofdLineaCaptura.FileName), ofdLineaCaptura.FileName);
                    // Renombramos el archivo guardado
                    FTPServer.RenameFile(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(ofdLineaCaptura.FileName), _Editar.iIdStatement.ToString() + Path.GetExtension(ofdLineaCaptura.FileName));
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sube en el servidor el archivo Linea de captura de la declaración
 /// </summary>
 /// <param name="sIdDeclaracion">Id de la de declaración</param>
 public void SubirLineaCaptura(string sIdDeclaracion)
 {
     try
     {
         // Creamos la carpeta donde se guardara el archivo de la declaración
         FTPServer.CreateDirectory(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/-Declaraciones/{1}/", _AltaDeclaracion.Cliente.sCliente, sIdDeclaracion));
         // Guardamos el archivo en la nueva carpeta creada
         string FullPath = string.Format("{0}/{1}/{2}/-Declaraciones/{3}/", FTPCredentials.Path, ConnectionString.FolderConnection, _AltaDeclaracion.Cliente.sCliente, sIdDeclaracion);
         FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(ofdLineaCaptura.FileName), ofdLineaCaptura.FileName);
         // Renombramos el archivo guardado
         FTPServer.RenameFile(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(ofdLineaCaptura.FileName), sIdDeclaracion + Path.GetExtension(ofdLineaCaptura.FileName));
     }
     catch (Exception)
     {
         //throw;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Realiza la carga del archivo de pago de la declaración en el servidor
        /// </summary>
        /// <returns></returns>
        public bool UploadArchivoPago()
        {
            try
            {
                if (sEstadoPago == "Pagada")
                {
                    if (!string.IsNullOrEmpty(openFileDialogDocumento.FileName))
                    {
                        //VALIDA SI LOS DIRECTORIO EXISTEN, SI NO, SE CREAN LAS CARPETAS
                        FTPServer.CreateDirectory(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{1}/{2}/", _Editar.sClient, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy")));

                        //CUENTA CUANTOS ARCHIVOS EXISTEN EN EL DIRECTORIO
                        int i = FTPServer.CountFileList(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{1}/{2}/", _Editar.sClient, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy")));

                        //COPIA Y CAMBIA EL NOMBRE DE LOS ARCHIVO SELECCIONADOS EN EL CONTROL OPENFILEDIALOG
                        foreach (string fileName in openFileDialogDocumento.FileNames)
                        {
                            //COPIA Y CAMBIO DE NOMBRE DEL ARCHIVO
                            i++;
                            string FullPath = string.Format("{0}/{1}/{2}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{3}/{4}", FTPCredentials.Path, ConnectionString.FolderConnection, _Editar.sClient, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy"));
                            FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), fileName);
                            FTPServer.RenameFile(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), i.ToString() + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName));

                            //GUARDA UN REGISTRO DE LA RUTA DONDE SE GUARDO EL ARCHIVO
                            new Adjunto().insertarAdjunto(new Adjunto()
                            {
                                iIdDeclaracion        = _Editar.iIdStatement,
                                iIdRegistroObligacion = int.Parse(cbDecTipo.SelectedValue.ToString()),
                                iIdCliente            = _Editar.iIdClient,
                                sAdjunto = string.Format("{0}/{1}/{2}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{3}/{4}/{5}", FTPCredentials.Path, ConnectionString.FolderConnection, _Editar.sClient, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy"), i.ToString() + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName))
                            });
                        }
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Método Público para copiar archivos al servidor
        /// </summary>
        public void cargarArchivos()
        {
            try
            {
                string sNoFolder = Cliente.iIdRegimen == 1 ? "26" : "25";
                // VALIDA SI LOS DIRECTORIO EXISTEN, SI NO, SE CREAN LAS CARPETAS
                FTPServer.CreateDirectory(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/{3}. Otros/Obligaciones Fiscales/{1}/{2}/", Cliente.sCliente, lblDetalleObligacion.Text, DateTime.Now.ToString("dd-MM-yyyy"), sNoFolder));

                //RECORRE LOS ARCHIVOS SELCCIONADOS DEL CONTROL OPENFILEDIALOG Y COPIA AL SERVIDOR
                int i = 0;
                foreach (string fileName in openFileDialogDocumento.FileNames)
                {
                    i++;
                    string FullPath = string.Format("{0}/{1}/{2}/{5}. Otros/Obligaciones Fiscales/{3}/{4}", FTPCredentials.Path, ConnectionString.FolderConnection, Cliente.sCliente, lblDetalleObligacion.Text, DateTime.Now.ToString("dd-MM-yyyy"), sNoFolder);
                    FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), fileName);
                    FTPServer.RenameFile(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), i.ToString() + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName));
                }
            }
            catch (Exception)
            {
                //MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Realiza la carga del archivo de pago de la declaración en el servidor
        /// </summary>
        public void cargarArchivos(int iIdDeclaracion)
        {
            //VALIDA SI ESTADO DE PAGO ESTA EN "PAGADA"
            if (iEstadoPago == 3)
            {
                try
                {
                    // VALIDA SI LOS DIRECTORIO EXISTEN, SI NO, SE CREAN LAS CARPETAS
                    FTPServer.CreateDirectory(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{1}/{2}/", _AltaDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy")));

                    //CUENTA CUANTOS ARCHIVOS EXISTEN EN EL DIRECTORIO
                    int i = FTPServer.CountFileList(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{1}/{2}/", _AltaDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy")));

                    //COPIA Y CAMBIA EL NOMBRE DE LOS ARCHIVO SELECCIONADOS EN EL CONTROL OPENFILEDIALOG
                    foreach (string fileName in openFileDialogDocumento.FileNames)
                    {
                        //COPIA Y CAMBIO DE NOMBRE DEL ARCHIVO
                        i++;
                        string FullPath = string.Format("{0}/{1}/{2}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{3}/{4}", FTPCredentials.Path, ConnectionString.FolderConnection, _AltaDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy"));
                        FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), fileName);
                        FTPServer.RenameFile(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), i.ToString() + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName));

                        //GUARDA UN REGISTRO DE LA RUTA DONDE SE GUARDO EL ARCHIVO
                        new Adjunto().insertarAdjunto(new Adjunto()
                        {
                            iIdDeclaracion        = iIdDeclaracion,
                            iIdRegistroObligacion = int.Parse(sDecTipo),
                            iIdCliente            = Cliente.iIdCliente,
                            sAdjunto = string.Format("{0}/{1}/{2}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{3}/{4}/{5}", FTPCredentials.Path, ConnectionString.FolderConnection, _AltaDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy"), i.ToString() + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName))
                        });
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Realiza la carga del archivo de pago de la declaración en el servidor
        /// </summary>
        public void cargarArchivos(int iIdDeclaracion)
        {
            //VALIDA SI ESTADO DE PAGO ESTA EN "PAGADA"
            if (iEstadoPago == 3)
            {
                try
                {
                    // VALIDA SI LOS DIRECTORIO EXISTEN, SI NO, SE CREAN LAS CARPETAS
                    FTPServer.CreateDirectory(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{1}/{2}/", _EditarDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy")));

                    //CUENTA CUANTOS ARCHIVOS EXISTEN EN EL DIRECTORIO
                    int i = FTPServer.CountFileList(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, string.Format(@"{0}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{1}/{2}/", _EditarDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy")));

                    //COPIA Y CAMBIA EL NOMBRE DE LOS ARCHIVO SELECCIONADOS EN EL CONTROL OPENFILEDIALOG
                    foreach (string fileName in openFileDialogDocumento.FileNames)
                    {
                        //COPIA Y CAMBIO DE NOMBRE DEL ARCHIVO
                        i++;
                        string FullPath = string.Format("{0}/{1}/{2}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{3}/{4}", FTPCredentials.Path, ConnectionString.FolderConnection, _EditarDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy"));
                        FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), fileName);
                        FTPServer.RenameFile(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(fileName), i.ToString() + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName));

                        //GUARDA UN REGISTRO DE LA RUTA DONDE SE GUARDO EL ARCHIVO
                        new Adjunto().insertarAdjunto(new Adjunto()
                        {
                            iIdDeclaracion        = iIdDeclaracion,
                            iIdRegistroObligacion = int.Parse(sDecTipo),
                            iIdCliente            = Cliente.iIdCliente,
                            sAdjunto = string.Format("{0}/{1}/{2}/04. Declaraciones, acuses y pagos de impuestos federales/Pagos/{3}/{4}/{5}", FTPCredentials.Path, ConnectionString.FolderConnection, _EditarDeclaracion.Cliente.sCliente, sDecTipoTx, DateTime.Now.ToString("dd-MM-yyyy"), i.ToString() + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName))
                        });
                    }
                }
                catch (Exception)
                {
                }
            }
            //       //VALIDA SI ESTADO DE PAGO ESTA EN "PAGADA"
            //       if (iEstadoPago == 3)
            //       {
            //           try
            //           {
            ////VALIDA SI LOS DIRECTORIO EXISTEN, SI NO, SE CREAN LAS CARPETAS
            //if (!Directory.Exists(@"\\192.168.1.34\\Documentos\\" + LogicaCC.ConnectionString.FolderConnection + "\\Documentos\\Clientes\\" + sCliente + "\\" + "Expediente en Linea\\04. Declaraciones, acuses y pagos de impuestos federales\\Pagos\\" + txtDecTipo.Text + "\\" + DateTime.Now.ToString("dd-MM-yyyy")))
            //	Directory.CreateDirectory(@"\\192.168.1.34\\Documentos\\" + LogicaCC.ConnectionString.FolderConnection + "\\Documentos\\Clientes\\" + sCliente + "\\" + "Expediente en Linea\\04. Declaraciones, acuses y pagos de impuestos federales\\Pagos\\" + txtDecTipo.Text + "\\" + DateTime.Now.ToString("dd-MM-yyyy"));

            //               //CUENTA EL NÚMERO DE ARCHIVOS EN EL DIRECTORIO
            //               var fileCount = (from file in Directory.EnumerateFiles(@"\\192.168.1.34\\Documentos\\" + LogicaCC.ConnectionString.FolderConnection + "\\Documentos\\Clientes\\" + iIdCliente + "\\" + "Declaraciones" + "\\" + txtDecTipo.Name + "\\" + DateTime.Now.ToString("dd-MM-yyyy")) select file).Count();
            //               int i = fileCount - 1;

            //               //GUARDA LOS ARCHIVOS SELECCIONADOS EN EL CONTROL OPENFILEDIALOG
            //               foreach (string fileName in openFileDialogDocumento.FileNames)
            //               {
            //                   //COPIA Y CAMBIO DE NOMBRE DEL ARCHIVO
            //                   i++;
            //                   File.Copy(fileName, @"\\192.168.1.34\\Documentos\\" + LogicaCC.ConnectionString.FolderConnection + "\\Documentos\\Clientes\\" + sCliente + "\\" + "Expediente en Linea\\04. Declaraciones, acuses y pagos de impuestos federales\\Pagos\\" + txtDecTipo.Text + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + "\\" + Path.GetFileName(fileName));
            //                   File.Move(@"\\192.168.1.34\\Documentos\\" + LogicaCC.ConnectionString.FolderConnection + "\\Documentos\\Clientes\\" + sCliente + "\\" + "Expediente en Linea\\04. Declaraciones, acuses y pagos de impuestos federales\\Pagos\\" + txtDecTipo.Text + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + "\\" + Path.GetFileName(fileName), @"\\192.168.1.34\\Documentos\\" + LogicaCC.ConnectionString.FolderConnection + "\\Documentos\\Clientes\\" + sCliente + "\\" + "Expediente en Linea\\04. Declaraciones, acuses y pagos de impuestos federales\\Pagos\\" + txtDecTipo.Text + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + "\\" + i + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName));

            //                   //SE GUARDA REGISTRO DEL ADJUNTO DEN LA BD
            //                   new Adjunto().insertarAdjunto(new Adjunto()
            //                   {
            //                       iIdDeclaracion        = iIdDeclaracion,
            //                       iIdRegistroObligacion = int.Parse(txtDecTipo.Name.ToString()),
            //                       iIdCliente            = iIdCliente,
            //                       sAdjunto              = @"\\192.168.1.34\\Documentos\\" + LogicaCC.ConnectionString.FolderConnection + "\\Documentos\\Clientes\\" + iIdCliente + "\\" + "Declaraciones" + "\\" + txtDecTipo.Name + "\\" + DateTime.Now.ToString("dd-MM-yyyy") + "\\" + i + DateTime.Now.ToString("ddMMyyyy") + Path.GetExtension(fileName)
            //                   });
            //               }

            //               //SE INICIALIZA AL APARTADO PARA SUBIR ARCHIVOS
            //               txtRutaArchivo.Text              = string.Empty;
            //               openFileDialogDocumento.FileName = "";
            //           }
            //           catch (Exception)
            //           {
            //           }
            //       }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Crea un directorio a partir de una ruta, si este existe, se omitira la creación
 /// </summary>
 /// <param name="sDirectorio">Ruta a crear</param>
 public void CreateDirectoryFTP(string sDirectorio)
 {
     FTPServer.CreateDirectory(FTPCredentials.Path, FTPCredentials.User, FTPCredentials.Password, sDirectorio);
 }