Advertisement
Guest User

codigo_antiguo

a guest
Feb 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 35.52 KB | None | 0 0
  1. //Archvo de configuracion xml
  2.             //XmlDocument doc = new XmlDocument();
  3.             //doc.PreserveWhitespace = true;
  4.             //doc.Load("appConfig.xml");
  5.  
  6.             //-----------------------------varibale controladora del tiempo-----------------------------------//
  7.             DateTime tiempoInicial = DateTime.Now;
  8.             TimeSpan tiempoLimite = TimeSpan.ParseExact("00:06:00.1238983", "c", null);
  9.             DateTime tiempoFinal;
  10.             TimeSpan tiempoTotal;
  11.             //-----------------------------variables Partes procesales---------------------------------------//
  12.             string expediente = null;
  13.             string organoJuris = null;
  14.             string juez = null;
  15.             DateTime? fechaInicio = null;
  16.             string observacion = null;
  17.             string materia = null;
  18.             string etapaProcesal = null;
  19.             string ubicacion = null;
  20.             string sumilla = null;
  21.             string distritojudi = null;
  22.             string especialistaLegal = null;
  23.             string proceso = null;
  24.             string especialidad = null;
  25.             string estado = null;
  26.             string motivoConclusion = null;
  27.             DateTime? fechaConclusion = null;
  28.             //-----------------------variables partes procesales------------------------------------------------//
  29.             string parte = null;
  30.             string tipoPersona = null;
  31.             string apellidoRazon = null;
  32.             string apellidoMaterno = null;
  33.             string nombres = null;
  34.             //-------------------------variables de la actuacion ------------------------------------------------//
  35.             DateTime? fechaResolucion = null;
  36.             string resolucion = null;
  37.             string tipoNotificacion = null;
  38.             string sumillaAct = null;
  39.             string descUsuario = null;
  40.             string acto = null;
  41.             string fojas = null;
  42.             string proveido = null;
  43.             DateTime? FechaIngreso = null;
  44.             //-------------------- variables de la notificacion -----------------------------------------------//
  45.             string nombreNotifi = null;
  46.             string destinatario = null;
  47.             DateTime? fechaEnvio = null;
  48.             string anexo = null;
  49.             string formaEntrega = null;
  50.             //-----------------------variables de los detalles de la notificacion -------------------------------------------------//
  51.             DateTime? fechaResolu = null;
  52.             DateTime? notificacionImpresa = null;
  53.             DateTime? enviadaCentral = null;
  54.             DateTime? recepcionadaCentral = null;
  55.             DateTime? notificacionDestinatario = null;
  56.             DateTime? cargoDevuelto;
  57.             string diasDesdeResolucionNotificacionImpresa = null;
  58.             string diasDesdeResolucionEnviadaCentral = null;
  59.             string diasDesdeResolucionRecepcionadaCentral = null;
  60.             string diasDesdeResolucionNotificacionDestinatario = null;
  61.             string diasDesdeResolucionCargoDevueltoJuzgado = null;
  62.             //---------------------arreglo de paginas de la pagina----------------------------------------------------------------------//
  63.             int[] ArregloPagi = new int[] { 2, 5, 8, 7, 8, 4, 5, 6, 7, 8 };
  64.             int contPag = 0;
  65.             //---------------------------------------------------------------------------------------------------------------------------//
  66.             //------------------------------------variable para controlar el scroll de la pagina-------------------------------------------//
  67.             Actions actions = new Actions(driver);
  68.             //-----------------------------------------------------------------------------------------------------------------------------//
  69.             List<ActuacionDto> actuaciones = new List<ActuacionDto>();
  70.             List<NotificacionDto> notificaciones = new List<NotificacionDto>();
  71.             List<PartesProcesalesDto> partesProcesales = new List<PartesProcesalesDto>();
  72.             CasoExpedienteDto casoExpediente = new CasoExpedienteDto();
  73.             if (objCasoConData != null)
  74.             {
  75.                 actuaciones = objCasoConData.actuacion;
  76.                 partesProcesales = objCasoConData.partesPro;
  77.             }
  78.             ActuacionDto objAct;
  79.             NotificacionDto objNot;
  80.             ReporteExpedienteDto objRepo;
  81.             var htmlDoc = new HtmlDocument();
  82.             using (driver)
  83.             {
  84.                 if (objCasoConData == null)
  85.                 {
  86.                     Thread.Sleep(2000);
  87.                     try
  88.                     {
  89.                         var html = driver.FindElementByXPath("//*[@id=\"divDetalles\"]").Text;
  90.                     }
  91.                     catch
  92.                     {
  93.                         Thread.Sleep(15000);
  94.                     }
  95.                     //En devolver un resultado entonces esto devuelve un delay para que no se pare la ejecucion
  96.                     string[] array = driver.FindElementByXPath("//*[@id=\"divCuerpo\"]/div[3]/div[1]/b").Text.Split(' ');
  97.                     int cantidad = Int32.Parse(array[5]);
  98.                     driver.FindElementByXPath("//*[@id=\"command\"]/button/img").Click();
  99.                     Thread.Sleep(1000);
  100.                 }
  101.  
  102.  
  103.                 string htmlPagina = driver.PageSource;
  104.                 htmlDoc.LoadHtml(htmlPagina);
  105.                 //*[@id="accordionX"]/div[3]
  106.                 //Aqui guardo el texto del div denominado en la pagina "reporte de expediente"
  107.                 //Extraccion de variables  de la seccion resporte de expediente
  108.                 expediente = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[2]/b").Text;
  109.                 organoJuris = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[4]").Text;
  110.                 juez = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[8]").Text;
  111.                 string valorFechaInicio = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[12]").Text;
  112.  
  113.                 if (DateTime.TryParse(valorFechaInicio, System.Globalization.CultureInfo.GetCultureInfo("es-PE"), System.Globalization.DateTimeStyles.None, out var fechaInicioDate))
  114.                 {
  115.                     fechaInicio = fechaInicioDate;
  116.                 }
  117.                 observacion = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[16]").Text;
  118.                 materia = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[20]").Text;
  119.                 etapaProcesal = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[24]").Text;
  120.                 ubicacion = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[28]").Text;
  121.                 sumilla = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[32]").Text;
  122.                 distritojudi = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[6]").Text;
  123.                 especialistaLegal = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[10]").Text;
  124.                 proceso = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[14]").Text;
  125.                 especialidad = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[18]").Text;
  126.                 estado = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[22]").Text;
  127.                 motivoConclusion = driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[30]").Text;
  128.                 try
  129.                 {
  130.                     fechaConclusion = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"gridRE\"]/div[26]").Text, "dd/MM/yyyy", null);
  131.                 }
  132.                 catch
  133.                 {
  134.                     Console.Write("La fecha conclusion no ha sido encontrada en este expediente \n");
  135.                     fechaConclusion = null;
  136.                 }
  137.                 objRepo = new ReporteExpedienteDto
  138.                 {
  139.                     NumeroExpediente = expediente,
  140.                     OrganoJurisdiccional = organoJuris,
  141.                     Juez = juez,
  142.                     FechaInicio = fechaInicio,
  143.                     Observacion = observacion,
  144.                     Materia = materia,
  145.                     Etapa = etapaProcesal,
  146.                     Ubicacion = ubicacion,
  147.                     Sumilla = sumilla,
  148.                     DistritoJudicial = distritojudi,
  149.                     EspecialistaLegal = especialistaLegal,
  150.                     Proceso = proceso,
  151.                     Especialidad = especialidad,
  152.                     Estado = estado,
  153.                     FechaConclusion = fechaConclusion,
  154.                     Existencia = true,
  155.                     MotivoConclusion = motivoConclusion
  156.                 };
  157.                 //------------------------------------------------------------------------------------------------------------//
  158.  
  159.                 //----------extracción de datos de la sección de partes procesales -------------------------------------------//
  160.                 if (partesProcesales.Count == 0)
  161.                 {
  162.                     int numeroPartesProcesales = (htmlDoc.DocumentNode.SelectNodes("//div[@class='partes']").Count);
  163.                     PartesProcesalesDto objeto;
  164.                     for (int g = 2; g <= numeroPartesProcesales; g++)
  165.                     {
  166.                         try
  167.                         {
  168.                             parte = driver.FindElementByXPath("//*[@id=\"collapseTwo\"]/div/div[" + g + "]/div[1]").Text;
  169.                         }
  170.                         catch
  171.                         {
  172.                             Console.WriteLine("Este expediente no tiene partes procesales");
  173.                             break;
  174.                         }
  175.  
  176.                         tipoPersona = driver.FindElementByXPath("//*[@id=\"collapseTwo\"]/div/div[" + g + "]/div[2]").Text;
  177.                         apellidoRazon = driver.FindElementByXPath("//*[@id=\"collapseTwo\"]/div/div[" + g + "]/div[3]").Text;
  178.                         try
  179.                         {
  180.                             apellidoMaterno = driver.FindElementByXPath("//*[@id=\"collapseTwo\"]/div/div[" + g + "]/div[4]").Text;
  181.                         }
  182.                         catch
  183.                         {
  184.                             Console.WriteLine("Esta parte procesal no tiene apellido materno");
  185.                             apellidoMaterno = null;
  186.                         }
  187.                         try
  188.                         {
  189.                             nombres = driver.FindElementByXPath("//*[@id=\"collapseTwo\"]/div/div[" + g + "]/div[5]").Text;
  190.                         }
  191.                         catch
  192.                         {
  193.                             Console.WriteLine("Esta parte procesal no tiene nombres");
  194.                             nombres = null;
  195.                         }
  196.                         objeto = new PartesProcesalesDto
  197.                         {
  198.                             parte = parte,
  199.                             tipoPersona = tipoPersona,
  200.                             apellidoRazon = apellidoRazon,
  201.                             apellidoMaterno = apellidoMaterno,
  202.                             nombres = nombres
  203.                         };
  204.                         partesProcesales.Add(objeto);
  205.                     }
  206.                 }
  207.                 //Aqui guardo el texto del div denominado en la pagina "Partes procesales" y en la siguiente linea lo guardo en un archivo de texto
  208.  
  209.                 string prueba = driver.FindElementByXPath("//*[@id=\"paginacion1\"]").Text;
  210.                 string[] paginas = Regex.Split(prueba, "\n");
  211.                 int numeroPagin = (paginas.Length) - 2;                                                   //Aqui obtengo el numero de paginas de la seccion  de "SEGUIMIENTO DEL DETALLE"
  212.                 Console.Write("Hay " + numeroPagin + " paginas para consultar \n");
  213.                 IWebElement botonDescargar;
  214.                 string verifyActuacion;
  215.                 int actuacionSiguiente;
  216.                 int cantActu;
  217.  
  218.                 //---------------------------------En esta seccion encuentro la cantidad total de actuaciones--------------------------------------------------//
  219.  
  220.                 int cantidadActuaciones = 0;
  221.                 int contador = 1;
  222.  
  223.                 // TODO : ¿Como obtiene el numero de actuaciones?
  224.                 while (true)
  225.                 {
  226.                     try
  227.                     {
  228.                         cantidadActuaciones = cantidadActuaciones + htmlDoc.DocumentNode.SelectNodes("//div[@id='collapseThree']/div[@class='panel-body pnl-seg cpnlSeguimiento cpnlSeguimiento" + contador + "']").Count;
  229.                         contador++;
  230.                     }
  231.                     catch
  232.                     {
  233.                         break;
  234.                     }
  235.  
  236.                 }
  237.                 //-------------------------------------------------------------------------------------------------------------------------------------------------//
  238.  
  239.                 int i = 1;
  240.                 //Es para que empieze a extraer datos desde donde habia quedado cuando se activo la excepcion de tiempo de sesion
  241.                 if (actuaciones.Count != 0)
  242.                 {
  243.                     int contPagina = 0;
  244.                     while (contPagina != numeroPaginador)
  245.                     {
  246.                         var paginador = driver.FindElementByXPath("//*[@id=\"paginacion2\"]/li[" + ArregloPagi[contPagina] + "]/a");
  247.                         ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", paginador);
  248.                         paginador.Click();
  249.                         Thread.Sleep(1000);
  250.                         contPagina++;
  251.                     }
  252.                     contPag = numeroPaginador;
  253.                     i = (objCasoConData.actuacion.Count) + 1;
  254.  
  255.                 }
  256.  
  257.                 for (; i <= cantidadActuaciones; i++)
  258.                 {
  259.                     FechaIngreso = null;
  260.                     fechaResolucion = null;
  261.                     notificaciones = new List<NotificacionDto>();
  262.                     try
  263.                     {
  264.  
  265.                         FechaIngreso = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[1]/div[1]/div[2]").Text, "dd/MM/yyyy HH:mm", null);
  266.                     }
  267.                     catch
  268.                     {
  269.                         try
  270.                         {
  271.                             fechaResolucion = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[1]/div[1]/div[2]").Text, "dd/MM/yyyy", null);
  272.                         }
  273.                         catch
  274.                         {
  275.                             //TODO: El martes me explica porque rompe aqui el for cuando no encuentra fecha ingreso no fecha resolución
  276.                             break;
  277.                         }
  278.                     }
  279.                     IWebElement actuacion = null;
  280.                     if (NodoExist.existsElement(driver, out actuacion, "//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]"))
  281.                     {
  282.  
  283.                         ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", actuacion);
  284.                         Thread.Sleep(150);
  285.                         //---------------------------------Extrae los datos de actuacion del expediente -----------------------------------------//
  286.                         resolucion = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[1]/div[2]/div[2]").Text;
  287.                         tipoNotificacion = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[1]/div[3]/div[2]").Text;
  288.                         sumillaAct = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[3]/div[1]/div[2]").Text;
  289.                         descUsuario = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[3]/div[2]/div[2]").Text;
  290.                         acto = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[2]/div[1]/div[2]").Text;
  291.                         fojas = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[1]/div[2]/div[2]/div[2]").Text;
  292.                         proveido = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/ div[2]/div/div[1]/div[2]/div[3]/div[2]").Text;
  293.                         botonDescargar = null;
  294.                         if (NodoExist.existsElement(driver, out botonDescargar, "//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div[1]/div[1]/div[4]/div[1]"))
  295.                         {
  296.                             if (botonDescargar.Text == "DESCARGAR")
  297.                             {
  298.                                 driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div[1]/div[1]/div[4]/div[1]").Click();
  299.                                 if (i == cantidadActuaciones)
  300.                                 {
  301.                                     Thread.Sleep(5000);
  302.                                 }
  303.                                 Console.Write("La actuacion numero " + i + " SI tiene documento disponible para descargar \n");
  304.                             }
  305.                             else
  306.                             {
  307.                                 Console.Write("La actuacion numero " + i + " NO tiene documento disponible para descargar \n");
  308.                             }
  309.                         }
  310.                         else
  311.                         {
  312.                             Console.Write("La actuacion numero " + i + " NO tiene documento disponible para descargar \n");
  313.                         }
  314.                         IWebElement verificacionExistenciaNotificacion = null;
  315.                         if (NodoExist.existsElement(driver, out verificacionExistenciaNotificacion, "//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div[1]/div[2]"))
  316.                         {
  317.                             //Verificamos si hay notificaciones
  318.  
  319.                             if (string.IsNullOrWhiteSpace(driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div[1]/div[2]").Text) == false)
  320.                             {
  321.                                 Console.Write("La actuacion numero " + i + " SI tiene notificaciones \n");
  322.                                 int numeroNotificacionesActuacion = htmlDoc.DocumentNode.SelectNodes("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[2]/div[@class='panel-body']").Count;
  323.                                 for (int k = 1; k <= numeroNotificacionesActuacion; k++)
  324.                                 {
  325.                                     IWebElement notificacion = null;
  326.                                     if (NodoExist.existsElement(driver, out notificacion, "//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[2]/div[" + k + "]"))
  327.                                     {
  328.                                         ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", notificacion);
  329.                                         Thread.Sleep(300);
  330.                                         IWebElement nombreNotifiExiste = null;
  331.                                         IWebElement destinatarioExistente = null;
  332.                                         IWebElement fechaEnvioExistente = null;
  333.                                         IWebElement anexoExistente = null;
  334.                                         if (NodoExist.existsElement(driver, out nombreNotifiExiste, "//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[2]/div[" + k + "]/div/h5"))
  335.                                         {
  336.                                             if (!string.IsNullOrWhiteSpace(nombreNotifiExiste.Text))
  337.                                             {
  338.                                                 nombreNotifi = nombreNotifiExiste.Text;
  339.                                             }
  340.                                             else
  341.                                             {
  342.                                                 nombreNotifi = null;
  343.                                             }
  344.  
  345.                                         }
  346.                                         if (NodoExist.existsElement(driver, out destinatarioExistente, "//*[@id=\"pnlSeguimiento" + i + "\"]/ div[2]/div/div[2]/div[" + k + "]/div/div[1]/div[1]/div[2]"))
  347.                                         {
  348.                                             if (!string.IsNullOrWhiteSpace(destinatarioExistente.Text))
  349.                                             {
  350.                                                 destinatario = destinatarioExistente.Text;
  351.                                             }
  352.                                             else
  353.                                             {
  354.                                                 destinatario = null;
  355.                                             }
  356.                                         }
  357.                                         if (NodoExist.existsElement(driver, out fechaEnvioExistente, "//*[@id=\"pnlSeguimiento" + i + "\"]/ div[2]/div/div[2]/div[" + k + "]/div/div[1]/div[2]/div[2]"))
  358.                                         {
  359.                                             if (!string.IsNullOrWhiteSpace(fechaEnvioExistente.Text))
  360.                                             {
  361.                                                 fechaEnvio = DateTime.ParseExact(fechaEnvioExistente.Text, "dd/MM/yyyy HH:mm", null);
  362.                                             }
  363.                                             else
  364.                                             {
  365.                                                 fechaEnvio = null;
  366.                                             }
  367.                                         }
  368.  
  369.                                         if (NodoExist.existsElement(driver, out anexoExistente, "//*[@id=\"pnlSeguimiento" + i + "\"]/ div[2]/div/div[2]/div[" + k + "]/div/div[2]/div[1]/div[2]"))
  370.                                         {
  371.                                             if (string.IsNullOrWhiteSpace(anexoExistente.Text))
  372.                                             {
  373.                                                 anexo = anexoExistente.Text;
  374.                                             }
  375.                                             else
  376.                                             {
  377.                                                 anexo = null;
  378.                                             }
  379.                                         }
  380.                                         try
  381.                                         {
  382.                                             formaEntrega = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[2]/div[" + k + "]/div/div[2]/div[2]/div[2]").Text;
  383.                                         }
  384.                                         catch
  385.                                         {
  386.                                             formaEntrega = null;
  387.                                         }
  388.  
  389.                                         var botonDeta = driver.FindElementByXPath("//*[@id=\"pnlSeguimiento" + i + "\"]/div[2]/div/div[2]/div[" + k + "]/div/div[3]/div/button");
  390.                                         botonDeta.Click();
  391.                                         Thread.Sleep(300);
  392.                                         //Se guardan los detalles de las notificaciones  
  393.                                         //Las excepciones son el caso de que no encuentre el dato y no interrumpa la ejecucion del programa
  394.                                         try
  395.                                         {
  396.                                             fechaResolu = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/div/div[2]/div/div/div[3]/div[2]/div[1]/div[2]").Text, "dd/MM/yyyy", null);
  397.                                         }
  398.                                         catch
  399.                                         {
  400.                                             Console.WriteLine("La fecha de resolución no existe en esta notificación \n");
  401.                                             fechaResolu = null;
  402.                                         }
  403.                                         try
  404.                                         {
  405.                                             notificacionImpresa = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/ div/div[2]/div/div/div[3]/div[2]/div[2]/div[2]").Text, "dd/MM/yyyy", null);
  406.                                             diasDesdeResolucionNotificacionImpresa = driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/div/div[2]/div/div/div[3]/div[2]/div[2]/div[3]").Text;
  407.                                         }
  408.                                         catch
  409.                                         {
  410.                                             Console.WriteLine("La notificacion Impresa no existe en esta notificación \n");
  411.                                             notificacionImpresa = null;
  412.                                             diasDesdeResolucionNotificacionImpresa = "";
  413.                                         }
  414.                                         try
  415.                                         {
  416.                                             enviadaCentral = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/div/div[2]/div/div/div[3]/div[2]/div[3]/div[2]").Text, "dd/MM/yyyy", null);
  417.                                             diasDesdeResolucionEnviadaCentral = driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/div/div[2]/div/div/div[3]/div[2]/div[3]/div[3]").Text;
  418.                                         }
  419.                                         catch
  420.                                         {
  421.                                             Console.WriteLine("La Enviada a la Central de Notificación o Casilla Electrónica: no existe en esta notificación \n");
  422.                                             enviadaCentral = null;
  423.                                             diasDesdeResolucionEnviadaCentral = "";
  424.                                         }
  425.                                         try
  426.                                         {
  427.                                             recepcionadaCentral = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/ div/div[2]/div/div/div[3]/div[2]/div[4]/div[2]").Text, "dd/MM/yyyy", null);
  428.                                             diasDesdeResolucionRecepcionadaCentral = driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/ div/div[2]/div/div/div[3]/div[2]/div[4]/div[3]").Text;
  429.                                         }
  430.                                         catch
  431.                                         {
  432.                                             Console.WriteLine("La Recepcionada en la central de Notificación no existe en esta notificación \n");
  433.                                             recepcionadaCentral = null;
  434.                                             diasDesdeResolucionRecepcionadaCentral = "";
  435.                                         }
  436.                                         try
  437.                                         {
  438.                                             notificacionDestinatario = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/ div/div[2]/div/div/div[4]/div[2]/div[1]/div[2]").Text, "dd/MM/yyyy", null);
  439.                                             diasDesdeResolucionNotificacionDestinatario = driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/ div/div[2]/div/div/div[4]/div[2]/div[1]/div[3]").Text;
  440.                                         }
  441.                                         catch
  442.                                         {
  443.                                             Console.WriteLine("La Notificacion al destinatario no existe en esta notificación \n");
  444.                                             notificacionDestinatario = null;
  445.                                             diasDesdeResolucionNotificacionDestinatario = "";
  446.                                         }
  447.                                         try
  448.                                         {
  449.                                             cargoDevuelto = DateTime.ParseExact(driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/ div/div[2]/div/div/div[4]/div[2]/div[2]/div[2]").Text, "dd/MM/yyyy", null);
  450.                                             diasDesdeResolucionCargoDevueltoJuzgado = driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/ div/div[2]/div/div/div[4]/div[2]/div[2]/div[3]").Text;
  451.                                         }
  452.                                         catch
  453.                                         {
  454.                                             Console.WriteLine("La cargo devuelto no existe en esta notificación \n");
  455.                                             cargoDevuelto = null;
  456.                                             diasDesdeResolucionCargoDevueltoJuzgado = "";
  457.                                         }
  458.                                         driver.FindElementByXPath("//*[@id=\"modal-dialog-" + i + "-" + k + "\"]/div/div[2]/div/div/div[6]/div[2]/button").Click();
  459.  
  460.                                         // En esta parte creo el objeto le seteo los valores necesario y luego lo agrego en la List de notificaciones
  461.  
  462.                                         objNot = new NotificacionDto
  463.                                         {
  464.                                             nombre = nombreNotifi,
  465.                                             destinatario = destinatario,
  466.                                             fechaEnvio = fechaEnvio,
  467.                                             anexos = anexo,
  468.                                             formaEntrega = formaEntrega,
  469.                                             fechaResolucion = fechaResolu,
  470.                                             notificacionImpresa = notificacionImpresa,
  471.                                             enviadaCentralNotificacion = enviadaCentral,
  472.                                             RecepcionadaCentral = recepcionadaCentral,
  473.                                             CargoDevueltoJuzgado = cargoDevuelto,
  474.                                             diasDesdeResolucionCargoDevueltoJuzgado = diasDesdeResolucionCargoDevueltoJuzgado,
  475.                                             diasDesdeResolucionNotificacionDestinatario = diasDesdeResolucionNotificacionDestinatario,
  476.                                             diasDesdeResolucionRecepcionadaCentral = diasDesdeResolucionRecepcionadaCentral,
  477.                                             diasDesdeResolucionNotificacionImpresa = diasDesdeResolucionNotificacionImpresa,
  478.                                             diasDesdeResolucionEnviadaCentral = diasDesdeResolucionEnviadaCentral
  479.                                         };
  480.                                         notificaciones.Add(objNot);
  481.                                     }
  482.                                     else
  483.                                     {
  484.                                         Console.WriteLine("La actuacion numero {0} tiene {1} de notificaciones", i, (k - 1));
  485.                                         break;
  486.                                     }
  487.  
  488.  
  489.                                 }
  490.  
  491.                             }
  492.                         }
  493.                         else
  494.                         {
  495.                             Console.Write("La actuacion numero " + i + " NO tiene notificaciones \n");
  496.                         }
  497.                         objAct = new ActuacionDto
  498.                         {
  499.                             fechaResolucion = fechaResolucion,
  500.                             resolucion = resolucion,
  501.                             tipoNotificacion = tipoNotificacion,
  502.                             sumilla = sumillaAct,
  503.                             descUsuario = descUsuario,
  504.                             acto = acto,
  505.                             fojas = fojas,
  506.                             proveido = proveido,
  507.                             notificaciones = notificaciones,
  508.                             FechaIngreso = FechaIngreso
  509.                         };
  510.                         actuaciones.Add(objAct);
  511.                         casoExpediente.reporteExp = objRepo;
  512.                         casoExpediente.partesPro = partesProcesales;
  513.                         casoExpediente.actuacion = actuaciones;
  514.  
  515.  
  516.  
  517.                         //En la siguientes lineas verifico si hay mas actuaciones por revizar
  518.  
  519.                         actuacionSiguiente = i + 1;
  520.                         IWebElement actuacionVerificacion = null;
  521.                         if (NodoExist.existsElement(driver, out actuacionVerificacion, "//*[@id=\"pnlSeguimiento" + actuacionSiguiente + "\"]/div[2]"))
  522.                         {
  523.                             ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", actuacionVerificacion);
  524.                             verifyActuacion = driver.FindElementById("pnlSeguimiento" + actuacionSiguiente).Text;
  525.                             if (verifyActuacion == "")
  526.                             {
  527.                                 tiempoFinal = DateTime.Now;
  528.  
  529.                                 //Crea un "intervalo temporal"
  530.                                 tiempoTotal = new TimeSpan(tiempoFinal.Ticks - tiempoInicial.Ticks);
  531.  
  532.                                 if (contPag == ArregloPagi.Length + 1) contPag = 6;
  533.                                 var paginador = driver.FindElementByXPath("//*[@id=\"paginacion2\"]/li[" + ArregloPagi[contPag] + "]/a");
  534.                                 Thread.Sleep(300);
  535.                                 paginador.Click();
  536.                                 Thread.Sleep(300);
  537.  
  538.  
  539.                                 contPag++;
  540.                                 if (tiempoTotal >= tiempoLimite && casoExpediente.actuacion.Count != cantidadActuaciones)
  541.                                 {
  542.                                     try
  543.                                     {
  544.                                         driver.Navigate().Refresh();
  545.                                     }
  546.                                     catch (Exception ex)
  547.                                     {
  548.                                         Console.WriteLine(ex.Message);
  549.                                     }
  550.  
  551.  
  552.                                     extraccionDatos(driver, casoExpediente, (contPag));
  553.                                 }
  554.                             }
  555.                         }
  556.                         else
  557.                         {
  558.                             if (casoExpediente.actuacion.Count == cantidadActuaciones)
  559.                             {
  560.                                 Console.WriteLine("Se han extraido todas las actuaciones sin excepcion \n");
  561.                                 return casoExpediente;
  562.                             }
  563.                             else
  564.                             {
  565.                                 // Si no concuerdan la cantidad de actuaciones con las extraidas vuelve a extraerlas para que cumpla la condicion que sean todas las actuaciones
  566.  
  567.                                 driver.Navigate().Refresh();
  568.                                 extraccionDatos(driver);
  569.                             }
  570.  
  571.                             Console.WriteLine("Se ha finalizado la extracción de datos de este expediente \n");
  572.                             break;
  573.                         }
  574.                     }
  575.  
  576.                     else
  577.                     {
  578.  
  579.                         cantActu = i;
  580.                     }
  581.                 }
  582.  
  583.                 return casoExpediente;
  584.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement