/// <summary> /// This will scan the newly filed Form 4's and return the ones that are new (have not been seen yet). Thus, this will mark the new ones as observed. /// </summary> public async Task <StatementOfBeneficialOwnership[]> ObserveNewForm4sAsync() { //Get the last observed filing URL string LastObservedFilingUrl = await DownloadLatestObservedForm4FilingUrlAsync(); //Search! EdgarLatestFilingsSearch elfs = await EdgarLatestFilingsSearch.SearchAsync("4", EdgarSearchOwnershipFilter.only, EdgarSearchResultsPerPage.Entries40); //Get a list of new filings List <EdgarLatestFilingResult> NewlyObservedFilings = new List <EdgarLatestFilingResult>(); if (LastObservedFilingUrl != null) { foreach (EdgarLatestFilingResult esr in elfs.Results) { if (LastObservedFilingUrl == esr.DocumentsUrl) { break; } else { NewlyObservedFilings.Add(esr); } } } else //If there isn't a latest received filings url in azure, just add all of them { foreach (EdgarLatestFilingResult esr in elfs.Results) { NewlyObservedFilings.Add(esr); } } //Get a list of statmenet of changes in beneficial ownership for each of them List <StatementOfBeneficialOwnership> ToReturn = new List <StatementOfBeneficialOwnership>(); foreach (EdgarLatestFilingResult esr in NewlyObservedFilings) { EdgarSearchResult esrt = new EdgarSearchResult(); esrt.DocumentsUrl = esr.DocumentsUrl; //Have to plug it into here because this is the only class has has the GetDocumentFormatFilesAsync method FilingDocument[] docs = await esrt.GetDocumentFormatFilesAsync(); foreach (FilingDocument fd in docs) { if (fd.DocumentName.ToLower().Contains(".xml") && fd.DocumentType == "4") { try { StatementOfBeneficialOwnership form4 = await StatementOfBeneficialOwnership.ParseXmlFromWebUrlAsync(fd.Url); ToReturn.Add(form4); } catch { } } } } //Log the most recent seen form 4 (it would just be the first one in the list of results) await UploadLatestObservedForm4FilingUrlAsync(elfs.Results[0].DocumentsUrl); //Return return(ToReturn.ToArray()); }
public static void IndividualTest(string[] args) { StatementOfBeneficialOwnership form4 = StatementOfBeneficialOwnership.ParseXmlFromWebUrlAsync(args[0]).Result; Console.WriteLine(JsonConvert.SerializeObject(form4)); }