/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// private List <GruaTrenData> leerDatosGrua(string startDate, string endDate) { List <GruaTrenData> datos = new List <GruaTrenData>(); GruaTrenData d = new GruaTrenData(); string query = "op=historico&startdate=" + startDate + "&enddate=" + endDate; string url = this.remoteUrl + query; try { HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest; string result = null; using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(resp.GetResponseStream()); result = reader.ReadToEnd(); datos = extraerDatos(result); } } catch (Exception ex) { MessageBox.Show("Error al realizar llamada al servidor: " + this.remoteUrl + query); datos = null; log.Error("Error en Thread PiMonitor: " + ex.Message); } return(datos); }
/// <summary> /// /// /// </summary> /// <param name="rawData"></param> /// <returns></returns> private List <GruaTrenData> extraerDatosTiempoReal(string rawData) { List <GruaTrenData> datos = null; string[] split = rawData.Split(new Char[] { '\n' }); char signo; foreach (string s in split) { string[] items = s.Split(new Char[] { ';' }); if (items.Length >= 2) { GruaTrenData d = new GruaTrenData(); d.Fecha = items[4]; d.Valor = items[3]; d.Signo = items[2]; d.Carro = Convert.ToInt32(items[5]); d.Palpa = Convert.ToInt32(items[6]); d.Twisl = Convert.ToInt32(items[7]); d.Subir = Convert.ToInt32(items[8]); d.Tw1 = (int)Convert.ToDouble(items[9]); d.Tw2 = (int)Convert.ToDouble(items[10]); d.Tw3 = (int)Convert.ToDouble(items[11]); d.Tw4 = (int)Convert.ToDouble(items[12]); if (datos == null) { datos = new List <GruaTrenData>(); } datos.Add(d); } } return(datos); }
public kemen() { InitializeComponent(); this.remoteUrl = cnfValues["remoteUrl"]; lblFecha.Text = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); threadPiMonitor = new Thread(this.executePiMonitor); threadMaxDayMonitor = new Thread(this.executeMaxDayMonitor); threadPiMonitor.Start(); lastGrabado = DateTime.Now; if (Convert.ToInt16(cnfValues["displayGrua"]) == 1) // Deshabilitamos controles en caso de ser aplicativo de cabina { btnVer.Enabled = false; btnExportar.Enabled = false; button1.Enabled = false; btnConfig.Enabled = false; btnVerMini.Enabled = false; } datosGruaTren = new GruaTrenData(); //threadMaxDayMonitor.Start(); }