Пример #1
0
        public Resultado SubirBoletinAlFtp_New(string archivo)
        {
            var rt = new Resultado();

            try
            {
                var ind       = archivo.IndexOf("boletin");
                var contenido = "";
                if (ind > 0)
                {
                    contenido = archivo.Substring(ind);
                }
                var ubicacion = archivo.Substring(0, ind);

                MsgDebug("ACTUALIZANDO MONITOR BOLETN DEL HOSTING");
                var r01 = _offLine.MonitorBoletin_Actualizar(contenido);
                if (r01.Result == DtoLib.Enumerados.EnumResult.isError)
                {
                    MsgDebug("PROCESO FINALIZO CON ERROR");
                    rt.Mensaje = r01.Mensaje;
                    rt.Result  = Enumerados.EnumResult.isError;
                    return(rt);
                }

                ////CREAR ARCHIVO indice.txt EN LOCAL
                //MsgDebug("Creando Archivo Local: indice.txt");
                //StreamWriter fichero; //Clase que representa un fichero
                //fichero = File.CreateText(@ubicacion + "\\indice.txt"); //Creamos un fichero
                //fichero.WriteLine(contenido); // Lo mismo que cuando escribimos por consola
                //fichero.Close();

                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@ubicacion + "\\indice.txt", false))
                //{
                //    file.WriteLine(contenido);
                //}

                //MsgDebug("Eliminando Archivo Del Hosting: indice.txt");
                //FtpWebRequest  request = (FtpWebRequest)WebRequest.Create(_ftpHost + @"//entradaBol//indice.txt");
                //request.Method = WebRequestMethods.Ftp.DeleteFile;
                //request.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
                //FtpWebResponse response  = (FtpWebResponse)request.GetResponse();
                //response.Close();

                //MsgDebug("Eliminando Archivo Del Hosting: indice.txt");
                //try
                //{
                //    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(_ftpHost + @"//entradaBol//indice.txt");
                //    request.Method = WebRequestMethods.Ftp.DeleteFile;
                //    request.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
                //    using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
                //    {
                //        MsgDebug(response.StatusDescription);
                //    }
                //}
                //catch (Exception ex)
                //{
                //    MsgDebug("ERROR AL TRATAR DE ELIMINAR ARCHIVO DEL HOSTING: indice.txt" + ex.Message);
                //}

                //var localFile = @ubicacion + "\\indice.txt";
                ////CREAR ARCHIVO indice.txt EN HOSTING
                //MsgDebug("Creando Archivo HOSTING: indice.txt");
                //using (var client = new WebClient())
                //{
                //    client.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
                //    client.UploadFile(_ftpHost + @"//entradaBol//indice.txt", WebRequestMethods.Ftp.UploadFile, localFile);
                //}

                //FtpWebRequest ftpRequest = null;
                //FtpWebResponse ftpResponse = null;
                //ftpRequest = (FtpWebRequest)WebRequest.Create(_ftpHost + @"//entradaBol//indice.txt");
                //ftpRequest.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
                //ftpRequest.UseBinary = true;
                //ftpRequest.UsePassive = true;
                //ftpRequest.KeepAlive = true;
                //ftpRequest.Method = WebRequestMethods.Ftp.Rename;
                //ftpRequest.RenameTo = "indice2.txt";
                //ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                //ftpResponse.Close();
                //ftpRequest = null;

                MsgDebug("Subiendo Boletin: " + archivo);
                SubirArchivo(archivo, _ftpHost + @"//entradaBol//");

                MsgDebug("PROCESO REALIZADO CON EXITO.......");
            }
            catch (Exception ex)
            {
                MsgDebug("PROCESO FINALIZO CON ERROR.......");
                rt.Mensaje = ex.Message;
                rt.Result  = Enumerados.EnumResult.isError;
            }

            return(rt);
        }