Ejemplo n.º 1
0
        public void desc_ar()

        {
            int           hora = 3600000;
            string        query = "SELECT dir_ip FROM medellin_conf..c_com_equip_ip", archivo;
            SqlConnection Conexion = SqlConnect.ConexionSQL();

            Conexion.Open();
            SqlCommand comando = new SqlCommand(query, Conexion);

            comando.CommandText = "SELECT dir_ip FROM medellin_conf..c_com_equip_ip";
            string        result = "";
            SqlDataReader dr     = comando.ExecuteReader();

            while (dr.Read())
            {
                archivo = dr.GetString(dr.GetOrdinal("dir_ip"));
                EscribeLog.escribe("comprobando archivos en el dir " + archivo.ToString(), Logarchivo);
                string[] ip = archivo.Split('.');

                result = listaftp(archivo, ip[3]);
                EscribeLog.escribe(result, Logarchivo);
            }
            Conexion.Close();
            hora = hora * 24;
            EscribeLog.escribe("se finaliza la tarea de descargar", Logarchivo);
            DateTime horaaa = DateTime.Now;

            Ult_des_ERU.Text = horaaa.ToString();
        }
Ejemplo n.º 2
0
        static string descargarFic(string ficFTP, string user, string pass, string dirLocal)
        {
            FtpWebRequest dirFtp = ((FtpWebRequest)FtpWebRequest.Create(ficFTP));

            // Los datos del usuario (credenciales)
            NetworkCredential cr = new NetworkCredential(user, pass);

            dirFtp.Credentials = cr;
            // El comando a ejecutar usando la enumeración de WebRequestMethods.Ftp
            dirFtp.Method = WebRequestMethods.Ftp.DownloadFile;

            // Obtener el resultado del comando
            //StreamReader reader =new StreamReader(dirFtp.GetResponse().GetResponseStream());
            FtpWebResponse response;

            try
            {
                EscribeLog.escribe("se intenta descargar el archivo " + ficFTP, Logarchivo);
                response = (FtpWebResponse)dirFtp.GetResponse();
            }
            catch (System.Net.WebException e)
            {
                EscribeLog.escribe("error al descargar archivo " + ficFTP, Logarchivo);
                return(e.ToString());
            }
            Stream responseStream = response.GetResponseStream();


            // Guardarlo localmente

            string ficLocal = Path.Combine(dirLocal, Path.GetFileName(ficFTP));

            EscribeLog.escribe("creando dir local  " + ficLocal, Logarchivo);
            FileStream ws = new FileStream(ficLocal, FileMode.Create);
            int        Lh = 1024;

            Byte[] buffer     = new Byte[Lh];
            int    bytesRead  = responseStream.Read(buffer, 0, Lh);
            int    bytesRead1 = bytesRead;

            EscribeLog.escribe("Se inicia la descarga", Logarchivo);
            while (bytesRead > 0)
            {
                //bytesRead1 =bytesRead1-bytesRead;
                //escribe(" se descargan "+ bytesRead1+" bytes");
                ws.Write(buffer, 0, bytesRead);
                bytesRead = responseStream.Read(buffer, 0, Lh);
            }
            EscribeLog.escribe("Se finaliza la descarga", Logarchivo);
            //StreamWriter sw = new StreamWriter(ficLocal, false, Encoding.UTF8);
            //sw.Write(res);
            ws.Close();
            response.Close();
            return("se descargo el archivo" + ficFTP.ToString());
        }
Ejemplo n.º 3
0
        public static void Mail(string[] Mensaje, string Data)
        {
            Logarchivo = "MAIL.txt";
            DateTime     TimeMail     = DateTime.Now;
            DateTime     Timeahora    = TimeMail.AddDays(-1);
            string       TimeMail1    = Timeahora.ToString("yyyy-MM-dd");
            var          fromAddress  = new MailAddress("*****@*****.**", "Rutina Hermes");
            var          toAddress    = new MailAddress("*****@*****.**", "Santiago Agudelo");
            const string fromPassword = "******";
            string       subject      = "Hermes | FDT | Menos de 90% de datos en el día " + TimeMail1;
            string       body         = "<html xmlns= \"http://www.w3.org/1999/xhtml \" lang = \"es\" xml: lang = \"es\" >" +
                                        "<head><meta http - equiv = \"Content-Type\" content = \"text/html; charset=UTF-8 \" /></ head ><body> " +
                                        "<h1> Listado de carriles</h1>" + Data + "<table border=\"1\" bordercolor=\"666633\" cellpadding=\"2\" cellspacing=\"0\"><tr>" +
                                        "<th scope= \"col\"> Carril </th>" +
                                        " <th scope= \"col\">Número de registros </th> " +
                                        "</tr> " + string.Join("", Mensaje) + "</table></ body ></ html >";
            MailAddress copyD = new MailAddress("*****@*****.**", "David Martinez");
            MailAddress copyE = new MailAddress("*****@*****.**", "Elmer Usuga");
            MailAddress copyS = new MailAddress("*****@*****.**", "SIER");
            var         smtp  = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                IsBodyHtml = true,
                Body = body
            })
                try
                {
                    message.CC.Add(copyD);
                    message.CC.Add(copyE);
                    message.CC.Add(copyS);
                    smtp.Send(message);
                    EscribeLog.escribe(" Se envió mail correctamente con el mensaje -> " + Mensaje + TimeMail1, Logarchivo);
                }
                catch (Exception ex)
                {
                    EscribeLog.escribe(" Lo siento en algún lado me perdí este debe ser el error:" + ex, Logarchivo);
                }
        }
Ejemplo n.º 4
0
        public void JMS()
        {
            Logarchivo = "JMS.txt";

            string Proceso = "InterfazIntegracionesJMS-Final";

            Process[] JMS = Process.GetProcessesByName(Proceso);
            if (JMS.Length == 1)
            {
                EscribeLog.escribe(",El proceso " + Proceso + " esta corriendo", Logarchivo);

                this.label13.Visible   = true;
                this.label13.Text      = "Running";
                this.label13.BackColor = Color.Green;
            }
            else
            {
                if (JMS.Length == 0)
                {
                    EscribeLog.escribe(",El proceso " + Proceso + " esta detenido", Logarchivo);

                    //string Mensaje = "La BDV MTV se encuentra detenida a esta hora -> ";
                    //EnviarMail.Mail(Mensaje);
                    this.label13.Visible   = true;
                    this.label13.Text      = "Stopped";
                    this.label13.BackColor = Color.Red;
                }
                if (JMS.Length > 1)
                {
                    EscribeLog.escribe(",El proceso " + Proceso + " esta más de una vez", Logarchivo);

                    //string Mensaje = "La BDV MTV se encuentra duplicada a esta hora -> ";
                    //EnviarMail.Mail(Mensaje);
                    this.label13.Visible   = true;
                    this.label13.Text      = "Duplicated";
                    this.label13.BackColor = Color.Yellow;
                }
                return;
            }
        }
Ejemplo n.º 5
0
        public void Kernel()
        {
            Logarchivo = "Kernel.txt";
            string Proceso = "Kernel-final";

            Process[] Kernel = Process.GetProcessesByName(Proceso);
            if (Kernel.Length == 1)
            {
                EscribeLog.escribe(",El proceso " + Proceso + " esta corriendo", Logarchivo);

                this.label4.Visible   = true;
                this.label4.Text      = "Running";
                this.label4.BackColor = Color.Green;
            }
            else
            {
                if (Kernel.Length == 0)
                {
                    EscribeLog.escribe(",El proceso " + Proceso + " esta detenido", Logarchivo);

                    //string Mensaje = "La BDV Kernel se encuentra detenida a esta hora -> ";
                    //EnviarMail.Mail(Mensaje);
                    this.label4.Visible   = true;
                    this.label4.Text      = "Stopped";
                    this.label4.BackColor = Color.Red;
                }
                if (Kernel.Length > 1)
                {
                    EscribeLog.escribe(",El proceso " + Proceso + " esta más de una vez", Logarchivo);

                    //string Mensaje = "La BDV Kernel se encuentra duplicada a esta hora -> ";
                    //EnviarMail.Mail(Mensaje);
                    this.label4.Visible   = true;
                    this.label4.Text      = "Duplicated";
                    this.label4.BackColor = Color.Yellow;
                }
                return;
            }
        }
Ejemplo n.º 6
0
        public void ETD()
        {
            Logarchivo = "BdvETD.txt";
            string Proceso = "BDVIntegNTCIP-ETD";

            Process[] BdvETD = Process.GetProcessesByName(Proceso);
            if (BdvETD.Length == 1)
            {
                EscribeLog.escribe(",El proceso " + Proceso + " esta corriendo", Logarchivo);
                this.label12.Visible   = true;
                this.label12.Text      = "Running";
                this.label12.BackColor = Color.Green;
            }
            else
            {
                if (BdvETD.Length == 0)
                {
                    EscribeLog.escribe(",El proceso " + Proceso + " esta detenido", Logarchivo);

                    //string Mensaje = "La BDV ETD se encuentra detenida a esta hora -> ";
                    //EnviarMail.Mail(Mensaje);
                    this.label12.Visible   = true;
                    this.label12.Text      = "Stopped";
                    this.label12.BackColor = Color.Red;
                }
                if (BdvETD.Length > 1)
                {
                    EscribeLog.escribe(",El proceso " + Proceso + ",esta más de una vez", Logarchivo);
                    //string Mensaje = "La BDV ETD se encuentra duplicada a esta hora -> ";
                    //EnviarMail.Mail(Mensaje);
                    this.label12.Visible   = true;
                    this.label12.Text      = "Duplicated";
                    this.label12.BackColor = Color.Yellow;
                }
                return;
            }
        }
Ejemplo n.º 7
0
        public void AVL()
        {
            Logarchivo = "AVL.txt";

            StreamReader objReader = new StreamReader("C:/Traza/EstadosLOG/Logistica.txt");
            string       sLine;
            ArrayList    arrLOG = new ArrayList();

            while (!objReader.EndOfStream)
            {
                sLine = objReader.ReadLine();
                if (!string.IsNullOrWhiteSpace(sLine))
                {
                    arrLOG.Add(sLine);
                }
            }
            for (int i = 0; i < arrLOG.Count; i++)
            {
                string a = @"C:\AreaTrafico\Proyectos\Medellin\bin\Bdv_ES_CProg-Final.exe SIGA\COLOMBIA\BDV_ES_AVL";
                string b = arrLOG[i].ToString();
                if (a == b)
                {
                    CountVAL = CountVAL + 1;

                    break;
                }
            }
            objReader.Close();
            if (CountVAL == 1)
            {
                this.label7.Visible   = true;
                this.label7.Text      = "Running";
                this.label7.BackColor = Color.Green;
                EscribeLog.escribe(",El proceso Bdv_Fotodetección esta corriendo", Logarchivo);

                CountVAL = 0;
                return;
            }
            else if (CountVAL > 1)
            {
                this.label7.Visible   = true;
                this.label7.Text      = "Duplicated";
                this.label7.BackColor = Color.Yellow;
                EscribeLog.escribe(",El proceso Bdv_Fotodetección esta duplicado", Logarchivo);

                CountVAL = 0;
                //string Mensaje = "La BDV Logistica se encuentra duplicada a esta hora -> ";
                //EnviarMail.Mail(Mensaje);
                return;
            }
            else if (CountVAL == 0)
            {
                this.label7.Visible   = true;
                this.label7.Text      = "Stopped";
                this.label7.BackColor = Color.Red;
                EscribeLog.escribe(",El proceso Bdv_Fotodetección esta detenido", Logarchivo);

                CountVAL = 0;
                //string Mensaje = "La BDV Logistica se encuentra detenida a esta hora -> ";
                //EnviarMail.Mail(Mensaje);
                return;
            }
        }
Ejemplo n.º 8
0
        public void CCTV()
        {
            Logarchivo = "DAI.txt";
            DateTime Val  = DateTime.Now;
            string   Val1 = Val.ToString("HH:mm");

            if (Val1.Contains("10:15"))
            {
                val += 1;
                Conexion.Open();
                DateTime   Ahora       = DateTime.Now;
                DateTime   Ahora1      = Ahora.AddDays(-1);
                string     AhoraString = Ahora1.ToString("yyyy-MM-dd");
                SqlCommand da          = new SqlCommand("SELECT * FROM MEDELLIN_HIST..Seg_reg_min" +
                                                        " where fecha > '" + AhoraString + " 00:00:00.000' and c_registros <= 1296 and nombre like 'DAI-%' " +
                                                        "order by fecha desc ", Conexion);
                SqlDataReader leer;
                int           count     = 0;
                string[]      nombre    = new string[400];
                string[]      CRegistro = new string[400];
                leer = da.ExecuteReader();
                while (leer.Read() == true)
                {
                    nombre[count]    = leer[1].ToString();
                    CRegistro[count] = leer[2].ToString();
                    count            = 1 + count;
                }
                try
                {
                    if (count == 0)
                    {
                        EscribeLog.escribe("Todos los datos están completos", Logarchivo);
                        this.lblCCTV.Visible   = true;
                        this.lblCCTV.Text      = "Running";
                        this.lblCCTV.BackColor = Color.Green;
                        Conexion.Close();
                    }
                    else
                    {
                        EscribeLog.escribe("Algunos carriles tienen problema escritos", Logarchivo);
                        this.lblCCTV.Visible   = true;
                        this.lblCCTV.Text      = "Warnning";
                        this.lblCCTV.BackColor = Color.Yellow;
                        string   Data;
                        string[] Mensaje = new string[count];
                        for (int i = 0; i < count; i++)
                        {
                            Mensaje[i] = "<tr><td>" + nombre[i].ToString() + "</td><td  align=\"center\" >" + CRegistro[i].ToString() + "</td></tr>";
                        }
                        if (count > 150)
                        {
                            Data = "<h2 style = \"color: red; \" > Carriles afectados " + count + "</h2 >";
                        }
                        else
                        {
                            Data = "<h2 style = \"color: black; \" > Carriles afectados " + count + "</ h2 >";
                        }
                        EnviarMailDAI.Mail(Mensaje, Data);
                        Conexion.Close();
                        return;
                    }
                }
                catch (SqlException e)
                {
                    EscribeLog.escribe(e.ToString(), Logarchivo);
                    Conexion.Close();
                }
            }
        }
Ejemplo n.º 9
0
        public String listaftp(string archivo, string dir)
        {
            string nombre = " ", result = "";


            String Rp = "ftp://" + archivo + "/datos/", usr = "******", pa = "etdi";

            EscribeLog.escribe("leyendo lista de archivos remotos", Logarchivo);
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Rp);

            request.Method = WebRequestMethods.Ftp.ListDirectory;

            request.Credentials = new NetworkCredential(usr, pa);
            FtpWebResponse response;

            try
            {
                EscribeLog.escribe("intentado establecer conexion a la dir: " + archivo, Logarchivo);
                response = (FtpWebResponse)request.GetResponse();
            }
            catch (System.Net.WebException e)
            {
                EscribeLog.escribe("error al intentar conectar con la dir: " + archivo, Logarchivo);
                return(e.ToString());
            }

            Stream       responseStream = response.GetResponseStream();
            StreamReader reader         = new StreamReader(responseStream);

            string names = reader.ReadToEnd();
            string path  = @"C:\ftp\" + dir;

            //foreach ()
            //DirectoryInfo di = new DirectoryInfo(@"C:\ftp\");
            if (Directory.Exists(path))
            {
            }
            else
            {
                Directory.CreateDirectory(path);
            }

            DirectoryInfo di = new DirectoryInfo(path);
            string        a1 = ".DAT";

            foreach (string b in names.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList())
            {
                //int comp = string.Compare(b, a1);
                if (b.EndsWith(a1))
                {
                    var fi = di.GetFiles(b);
                    if (fi.LongLength == 0)
                    {
                        //listView1.Items.Add(b.ToString() + " El archivo no se encuentra descargado ");
                        string desc = Rp + b;
                        nombre = desc;
                        EscribeLog.escribe("el arcivo no se encuentra local, se inicia descarga ", Logarchivo);
                        result = descargarFic(desc, usr, pa, path);
                        EscribeLog.escribe(result, Logarchivo);
                    }
                    else
                    {
                        result = " El archivo " + Rp + b + " ya se encuentra descargado ";
                        EscribeLog.escribe(result, Logarchivo);
                    }
                }
            }
            reader.Close();
            response.Close();
            return("Descarga finalizada");
        }