Exemplo n.º 1
0
        private void SaveCases(PalmCaseInfoClass InfoCases)
        {
            using (CaseEntities Ctx = new CaseEntities())
            {
                foreach (var WrkCase in InfoCases.ListaCasos)
                {
                    // Salvar Info en MainCases
                    MAINCAS Mc = new MAINCAS();
                    Mc.ID              = Guid.NewGuid();
                    Mc.COUNTY          = County;
                    Mc.CASENUMBER      = CleanString(WrkCase.CaseNumber);
                    Mc.CASETYPE        = WrkCase.CaseType;
                    Mc.CASESTATUS      = WrkCase.CaseStatus;
                    Mc.PRIMARY_PARTY   = WrkCase.PrimaryParty;
                    Mc.SECONDARY_PARTY = WrkCase.SecondaryParty;
                    Mc.FILEDATE        = WrkCase.FileDate;
                    Mc.NOTES           = WrkCase.Courts;

                    Ctx.MAINCASES.Add(Mc);
                }

                // Salvar Cuantos Records por fecha.
                RecordsXdia Rdia = new RecordsXdia();
                Rdia.COUNTY = InfoCases.County;
                Rdia.DATE1  = StartDay;
                Rdia.DATE2  = EndDay;
                Rdia.CASOS  = InfoCases.NumberOfCases;
                Ctx.RecordsXdias.Add(Rdia);

                // Save Changes.
                var x = Ctx.SaveChanges();
            }
        }
Exemplo n.º 2
0
        private void MainBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            // Determinar en Que pagina Estoy.
            // Tomar Desicion // CASE
            // Darle a Pagina Anterior.
            if (cbGetCases.Checked)
            {
                int Activity = 0;

                var WPDoc        = new HtmlAgilityPack.HtmlDocument();
                var doc          = ((MainForm)Application.OpenForms[0]).MainBrowser.Document;
                var renderedHtml = doc.GetElementsByTagName("HTML")[0].OuterHtml;
                WPDoc.LoadHtml(renderedHtml);

                var SearchBtn    = doc.GetElementById("ctl00$cphBody$cmdSearch");
                var CancelBtn    = doc.GetElementById("ctl00$cphBody$cmdClear");
                var ViewElements = doc.GetElementById("cphBody_cmbPageSize");

                if (SearchBtn != null && CancelBtn != null)
                {
                    Activity = 1;
                }

                if (ViewElements != null)
                {
                    if (ViewElements.OuterHtml.IndexOf("selected=\"selected\" value=\"All\">") > 0)
                    {
                        Activity = 3;
                    }
                    else
                    {
                        Activity = 2;
                    }
                }

                if (renderedHtml.Contains("Modify your search criteria by selecting the Search Criteria tab"))
                {
                    Activity = 4;
                }

                switch (Activity)
                {
                //ctl00$cphBody$gvSearch$ctl09$txtParameter: 01 / 01 / 2013
                //ctl00$cphBody$gvSearch$ctl10$txtParameter: 02 / 01 / 2013
                //ctl00$cphBody$gvSearch$ctl11$cmbParameterPostBack: 101
                //ctl00$cphBody$gvSearch$ctl12$cmbParameterNoPostBack: 146
                //ctl00$cphBody$gvSearch$ctl13$cmbParameterNoPostBack: 96

                case 1:
                {
                    var BeginDate = doc.GetElementById("cphBody_gvSearch_txtParameter_7");
                    var EndDate   = doc.GetElementById("cphBody_gvSearch_txtParameter_8");
                    var CourtType = doc.GetElementById("cphBody_gvSearch_cmbParameterPostBack_9");
                    CourtType.SetAttribute("Value", "101");
                    var CaseType = doc.GetElementById("cphBody_gvSearch_cmbParameterNoPostBack_10");
                    Thread.Sleep(2000);
                    // var SearchDate = GetMeDate();
                    SelectNewDayRange();
                    BeginDate.SetAttribute("Value", StartDay.ToString("MM/dd/yyyy"));
                    EndDate.SetAttribute("Value", EndDay.ToString("MM/dd/yyyy"));

                    CaseType.SetAttribute("Value", "146");

                    SearchBtn.InvokeMember("Click");
                    logclick("Search");
                    break;
                }

                case 2:
                {
                    ViewElements.SetAttribute("Value", "All");
                    ViewElements.InvokeMember("onChange");
                    // MainBrowser.Refresh(WebBrowserRefreshOption.Completely);
                    logclick("Search");
                    break;
                }

                case 3:
                {
                    PalmCaseInfoClass CInfo = new PalmCaseInfoClass();
                    CInfo.County = County;
                    // Tomar Casos en el Dia;
                    var CasosDiaStr = doc.GetElementById("cphBody_lblRecordsReturned");
                    if (CasosDiaStr != null)
                    {
                        CInfo.NumberOfCases = Convert.ToInt32(CasosDiaStr.InnerText);
                        var wrkint = CInfo.NumberOfCases;
                        if (wrkint == 200)
                        {
                            StartDay.AddDays(AdicionarDias * -1);
                            StartDay.AddDays(-1);
                            EndDay = StartDay;
                            EndDay.AddDays(AdicionarDias);
                            AdicionarDias = AdicionarDias - 3;
                            MainBrowser.Navigate("https://applications.mypalmbeachclerk.com/eCaseView/search.aspx");
                            logclick("Main Page");
                            break;
                        }
                        else
                        {
                            var casosxdia = wrkint / AdicionarDias;
                            var amplitud  = casosxdia * 3;
                            var cabe      = (200 - amplitud);
                            if (wrkint > cabe)
                            {
                                AdicionarDias++;
                            }
                        }
                    }

                    var TablaCasos   = WPDoc.GetElementbyId("cphBody_gvResults");
                    var CasesInfoRow = TablaCasos.Descendants("tr").ToList();
                    foreach (var Crow in CasesInfoRow)
                    {
                        if (!Crow.InnerText.Contains("Arrest Date"))
                        {
                            var      CasesInfoColumn = Crow.Descendants("td").ToList();
                            int      Num             = 0;
                            string[] AColInfo        = new string[7];
                            foreach (var Ccol in CasesInfoColumn)
                            {
                                AColInfo[Num] = Ccol.InnerText;
                                Num++;
                            }
                            pbICases WC = new pbICases();
                            WC.CaseNumber = AColInfo[0];
                            WC.Courts     = AColInfo[1];
                            WC.CaseType   = AColInfo[2];
                            try
                            {
                                WC.FileDate = Convert.ToDateTime(AColInfo[4]);
                            }
                            catch
                            {
                                WC.FileDate = Convert.ToDateTime("2008-01-01");
                            }

                            if (!string.IsNullOrEmpty(AColInfo[5]))
                            {
                                if (AColInfo[5].IndexOf(" V ") > 0)
                                {
                                    WC.PrimaryParty   = AColInfo[5].Substring(0, AColInfo[5].IndexOf(" V "));
                                    WC.SecondaryParty = AColInfo[5].Substring(AColInfo[5].IndexOf(" V ") + 3);
                                }
                                else
                                {
                                    WC.PrimaryParty   = AColInfo[5];
                                    WC.SecondaryParty = AColInfo[5];
                                }
                            }

                            WC.CaseStatus = AColInfo[6];

                            CInfo.ListaCasos.Add(WC);
                            CInfo.FileDate = WC.FileDate;
                        }
                    }

                    // Salvar en Async y Threadding.
                    SaveCases(CInfo);
                    // Slow the speed
                    Thread.Sleep(24000);


                    // cphBody_lbSearch  // Volver a la pantalla de Busqueda
                    //var SearchLink = doc.GetElementById("ctl00$cphBody$cmdSearch");
                    //SearchBtn.InvokeMember("Click");
                    MainBrowser.Navigate("https://applications.mypalmbeachclerk.com/eCaseView/search.aspx");
                    logclick("Main Page");
                    break;
                }

                case 4:
                {
                    MainBrowser.Navigate("https://applications.mypalmbeachclerk.com/eCaseView/search.aspx");
                    logclick("Main Page");
                    break;
                }
                }
            }
        }