예제 #1
0
        public void Download(dsDatos.MantisEstadoRow mantisEstadoRow)
        {
            if (!LoginOK)
            {
                return;
            }
            var str = GetMantisHtml(mantisEstadoRow.Nro.ToString()).Result;
            var doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(str);
            getFromHeader(doc, mantisEstadoRow);
        }
예제 #2
0
        private static void getFromHeader(HtmlAgilityPack.HtmlDocument doc, dsDatos.MantisEstadoRow newMantisEstadoRow)
        {
            try
            {
                var tHead      = doc.DocumentNode.Descendants("table").ToList()[2];
                var trs        = tHead.Descendants("tr").ToList();
                var trEstado   = trs[9];
                var trProyecto = trs[4];
                var trTipo     = trs[4];
                var trVersion  = trs[12];
                var trFecha    = trs[23];
                var trResumen  = trs[14];


                var estado   = Regex.Replace(trEstado.Descendants("td").ToList()[1].InnerText, @"\t|\n|\r", "");
                var proyecto = Regex.Replace(trProyecto.Descendants("td").ToList()[1].InnerText, @"\t|\n|\r", "");
                var tipo     = Regex.Replace(trTipo.Descendants("td").ToList()[2].InnerText, @"\t|\n|\r", "");
                var version  = Regex.Replace(trVersion.Descendants("td").ToList()[3].InnerText, @"\t|\n|\r", "");
                var fecha    = Regex.Replace(trFecha.Descendants("td").ToList()[1].InnerText, @"\t|\n|\r", "");
                var resumen  = Regex.Replace(trResumen.Descendants("td").ToList()[1].InnerText, @"\t|\n|\r", "");


                var timeRecord = doc.DocumentNode.Descendants("div")
                                 .Where(x => x.Attributes["id"]?.Value == "timerecord_open")
                                 .FirstOrDefault()
                                 .Descendants("td")
                                 .Select(x => x?.InnerText)
                                 .ToList();

                var tdHoras = timeRecord[timeRecord.Count - 5];
                var horas   = Regex.Replace(tdHoras, @"\t|\n|\r|:00", "");

                newMantisEstadoRow.Estado   = estado;
                newMantisEstadoRow.Proyecto = proyecto;
                newMantisEstadoRow.Version  = version;
                newMantisEstadoRow.Fecha    = fecha;
                newMantisEstadoRow.HrsTotal = horas;
                newMantisEstadoRow.Tipo     = tipo;
                newMantisEstadoRow.Resumen  = resumen;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                newMantisEstadoRow.Estado   = "";
                newMantisEstadoRow.Proyecto = "";
                newMantisEstadoRow.Version  = "";
                newMantisEstadoRow.Fecha    = "";
                newMantisEstadoRow.HrsTotal = "0";
                newMantisEstadoRow.Tipo     = "";
                newMantisEstadoRow.Resumen  = "";
            }
        }