private void CheckDataIntegrity(string path, CourtCase case1)
 {
     foreach (var c_doc in case1.Documents)
     {
         if (c_doc.downloaded == false)
         {
             retryDownloadFile(path, c_doc);
             if (c_doc.downloaded == false)
             {
                 logFileUnableToDownload(c_doc);
             }
         }
         else
         {
             if (!checkFileExist(path, c_doc))
             {
                 c_doc.downloaded = false;
                 retryDownloadFile(path, c_doc);
                 if (c_doc.downloaded == false)
                 {
                     logFileUnableToDownload(c_doc);
                 }
             }
         }
     }
 }
        private void downloadDocuments(string path, CourtCase case1)
        {
            try
            {
                string documents_tables_sel = "#divDocumentsInformation_body";
                var    documents_tables     = FindElementIfExists(By.CssSelector(documents_tables_sel));
                if (documents_tables == null)
                {
                    logNoDocumentsFound(case1);
                    return;
                }
                var docs_p = documents_tables.FindElements(By.TagName("p"));

                foreach (var doc_p in docs_p)
                {
                    CaseDocument casedoc = new CaseDocument();
                    casedoc.inCase = case1;
                    var doc_a = doc_p.FindElement(By.TagName("a"));
                    casedoc.URL         = doc_a.GetAttribute("href");
                    casedoc.description = doc_p.Text;
                    var doc_filename_span = doc_p.FindElement(By.TagName("span"));
                    casedoc.fileName = RemoveIllegalChars(doc_filename_span.Text);
                    case1.Documents.Add(casedoc);
                }

                for (int i = 0; i < case1.Documents.Count; i += 20)
                {
                    int      th_count = case1.Documents.Count - i < 20 ? case1.Documents.Count - i : 20;
                    Thread[] ths      = new Thread[th_count];
                    for (int j = 0; j < th_count; j++)
                    {
                        var docs = case1.Documents[i + j];
                        Console.WriteLine(docs.URL);
                        docs.fileNumber = i + j + 1;
                        var file_num_str = docs.fileNumber.ToString().PadLeft(4, '0');
                        docs.fileName = path + "/" + file_num_str + "-" + docs.fileName;
                        downloadDocument(docs, path, ths[j]);
                    }
                    for (int j = 0; j < th_count; j++)
                    {
                        if (ths[j] != null)
                        {
                            try
                            {
                                ths[j].Join();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(driver.Url);
            }
        }
        public static void TestStatistic(CourtCase courtCase, DateTime statisticDate, int expectedValue, StatisticType statisticType)
        {
            var courtCaseRepertory  = new CourtCaseRepertory();
            var repertoryStatistics = new RepertoryStatistics(statisticDate, statisticType);

            CheckStatistics(0, repertoryStatistics, courtCaseRepertory);
            courtCaseRepertory.Add(courtCase);
            CheckStatistics(expectedValue, repertoryStatistics, courtCaseRepertory);
        }
 public NewCourtCaseCreatedEvent(CourtCase courtCase, CourtCaseHeading heading)
 {
     if (courtCase == null)
     {
         throw new ArgumentNullException("courtCase");
     }
     if (heading == null)
     {
         throw new ArgumentNullException("heading");
     }
     CourtCase = courtCase;
     CourtCaseHeading = heading;
 }
Example #5
0
        //public async Task<CourtCasesViewModel> EditAsync(int? id)
        //{
        //    return await this.dbContext.CourtCases.Where(x => x.Id == id).Select(c => new CourtCasesViewModel
        //    {
        //        Id = c.Id,
        //        CaseNumber = c.CaseNumber,
        //        CaseYear = c.CaseYear,
        //        CaseType = c.CaseType.ToString(),
        //        CourtChamber = c.CourtChamber,
        //        CourtId = c.CourtId,
        //        LawCaseId = c.LawCaseId,
        //    }).FirstOrDefaultAsync();
        //}

        public async Task EditAsync(CourtCasesViewModel model)
        {
            var courtCase = new CourtCase
            {
                Id           = model.Id,
                CaseNumber   = model.CaseNumber,
                CaseYear     = model.CaseYear,
                CaseType     = Enum.Parse <CaseType>(model.CaseType, true),
                CourtChamber = model.CourtChamber,
                CourtId      = model.CourtId,
                LawCaseId    = model.LawCaseId,
            };

            this.dbContext.CourtCases.Update(courtCase);
            await this.dbContext.SaveChangesAsync();
        }
Example #6
0
        public async Task CreateAsync(CourtCasesInputModel model)
        {
            var courtCase = new CourtCase
            {
                CaseNumber   = model.CaseNumber,
                CaseYear     = model.CaseYear,
                CourtId      = model.CourtId,
                CaseType     = (CaseType)Enum.Parse(typeof(CaseType), model.CaseType, true),
                CourtChamber = model.CourtChamber,
                LawCaseId    = model.LawCaseId,
            };

            await this.dbContext.CourtCases.AddAsync(courtCase);

            await this.dbContext.SaveChangesAsync();
        }
 private bool process_case(string path, CourtCase case1)
 {
     try
     {
         Thread.Sleep(1000);
         Directory.CreateDirectory(path + "/" + case1.caseNum);
         savePageInfo(path + "/" + case1.caseNum, case1);
         downloadDocuments(path + "/" + case1.caseNum, case1);
         CheckDataIntegrity(path + "/" + case1.caseNum, case1);
         Thread.Sleep(500);
         return(true);
     }
     catch (Exception es)
     {
         Console.WriteLine(es.Message);
         Console.WriteLine(driver.Url);
         return(false);
     }
 }
 public CurrentCourtCaseChangedEvent(CourtCase courtCase)
 {
     CourtCase = courtCase;
 }
 private void logNoDocumentsFound(CourtCase case1)
 {
     Console.WriteLine("No Documents Found For Case " + case1.caseNum.ToString());
 }
        private bool savePageInfo(string path, CourtCase case1)
        {
            DocumentWriter doc = null;

            try
            {
                doc = new DocumentWriter(path + "/" + case1.caseNum);

                doc.addHeading(case1.caseNum);

                #region Div Case Information
                string caseInfoSel = "#divCaseInformation_body";
                var    caseInfoDiv = FindElementIfExists(By.CssSelector(caseInfoSel));
                if (caseInfoDiv != null)
                {
                    var caseInfochildDivs = driver.FindElementsByCssSelector(caseInfoSel + " > div");
                    doc.addHeading("Case Information");

                    foreach (var cicd in caseInfochildDivs)
                    {
                        var attr = cicd.GetAttribute("class");
                        doc.addText(cicd.Text);
                    }
                }
                #endregion

                #region Case Parties
                string casePartiessel = "#partyInformationDiv";
                var    casepartiesDiv = FindElementIfExists(By.CssSelector(caseInfoSel));
                if (casepartiesDiv != null)
                {
                    var caseInfohead = FindElementIfExists(By.CssSelector("#divPartyInformation_header"));
                    if (caseInfohead != null)
                    {
                        doc.addHeading(caseInfohead.Text);
                    }

                    var casePartiesBody = FindElementIfExists(By.CssSelector("#divPartyInformation_body"));

                    if (casePartiesBody != null)
                    {
                        var casepartieschildDivs = driver.FindElementsByCssSelector("#divPartyInformation_body > div");
                        foreach (var cicd in casepartieschildDivs)
                        {
                            doc.addText(cicd.Text);
                        }
                    }
                }
                #endregion

                #region Disposition Events
                string dispositionEventsSel = "#dispositionInformationDiv";
                var    dispositionEventDiv  = FindElementIfExists(By.CssSelector(dispositionEventsSel));
                if (dispositionEventDiv != null)
                {
                    doc.addHeading("Disposotion Events");
                    var dispositionEventBody = FindElementIfExists(By.CssSelector("#dispositionInformationDiv > div:nth-child(2)"));
                    if (dispositionEventBody != null)
                    {
                        var childDivs = dispositionEventBody.FindElements(By.CssSelector("div > div > div"));
                        foreach (var div in childDivs)
                        {
                            doc.addText(div.Text);
                        }
                    }
                }
                #endregion

                #region Events and Hearings
                string eventInfoSel = "#eventsInformationDiv";
                var    eventInfoDiv = FindElementIfExists(By.CssSelector(eventInfoSel));
                if (eventInfoSel != null)
                {
                    doc.addHeading("Events and Hearings");

                    var eventInfoBody = FindElementIfExists(By.CssSelector(".list-group"));
                    if (eventInfoBody != null)
                    {
                        var childLi = eventInfoBody.FindElements(By.TagName("li"));
                        foreach (var ch in childLi)
                        {
                            doc.addText(ch.Text);
                        }
                    }
                }
                #endregion

                #region Financial
                string financialSel = "#financialSlider";
                var    financialDiv = FindElementIfExists(By.CssSelector(financialSel));
                if (financialDiv != null)
                {
                    doc.addHeading("Financial");
                    var financialBody = FindElementIfExists(By.CssSelector("#financialSlider > div:nth-child(1)"));
                    var childs        = driver.FindElementsByCssSelector("#financialSlider > div:nth-child(1) > div");
                    foreach (var ch in childs)
                    {
                        var attr = ch.GetAttribute("class");
                        doc.addText(ch.Text);
                    }
                }
                #endregion

                doc.Save();

                return(true);
            }
            catch (Exception ex)
            {
                if (doc != null)
                {
                    doc.Save();
                }
                return(false);
            }
        }
        private bool findCases(string path, CrossRefNumber crossRef)
        {
            try
            {
                takescreenshot("before finding cases");
                var resFoundSel = "#SmartSearchResults";
                var resFound    = FindElementIfExists(By.CssSelector(resFoundSel));
                if (resFound == null)
                {
                    logCaseNotFound(crossRef);
                    return(true);
                }
                string tbodysel = "#CasesGrid > table:nth-child(1) > tbody:nth-child(3)";
                var    tbody    = driver.FindElementByCssSelector(tbodysel);
                var    trs      = tbody.FindElements(By.TagName("tr"));
                Console.WriteLine(trs.Count);
                string allcasesUrl = driver.Url;
                foreach (var tr1 in trs)
                {
                    CourtCase case1    = new CourtCase();
                    var       caseLink = tr1.FindElement(By.CssSelector(".caseLink"));
                    case1.URL     = caseLink.GetAttribute("data-url");
                    case1.caseNum = crossRef.refNum;
                    case_ref_num.cases.Add(case1);
                    new Actions(driver).Click(caseLink).Perform();
                    Thread.Sleep(1000);
                    string case_info_div_sel = "#divCaseInformation_body";
                    try
                    {
                        var body = new WebDriverWait(driver, TimeSpan.FromSeconds(submit_wait)).Until(ExpectedConditions.ElementExists(By.CssSelector(case_info_div_sel)));
                    }
                    catch (Exception ex)
                    {
                        Thread.Sleep(1000);
                        try
                        {
                            var body = new WebDriverWait(driver, TimeSpan.FromSeconds(submit_wait)).Until(ExpectedConditions.ElementExists(By.CssSelector(case_info_div_sel)));
                        }
                        catch (Exception ex1)
                        {
                            Console.WriteLine(driver.Url);
                            Console.WriteLine(ex1.Message);
                            return(false);
                        }
                    }

                    Console.WriteLine("case found" + caseLink.Text);
                    Thread.Sleep(1000);
                    bool flg = process_case(path, case1);
                    if (!flg)
                    {
                        return(flg);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                takescreenshot("exception findcases");
                Console.WriteLine(driver.Url);
                return(false);
            }
        }