public ISourceExtractResult ExtractFilingItems(ISourceExtractFilingItemsParams extractItemsParams) { SECSourceExtractResult result = new SECSourceExtractResult(); SECSourceExtractFilingItemsParams extractSECItemsParams = extractItemsParams as SECSourceExtractFilingItemsParams; if (extractSECItemsParams != null) { string cik = _dictionary.LookupRegulatorCompanyCode(extractSECItemsParams.RegulatorCode, extractSECItemsParams.CompanyCode); // TODO: lookup in dictionary if (!string.IsNullOrEmpty(cik)) { foreach (var item in extractSECItemsParams.Items) { SubmissionFile file = null; if (!_extractFromStorage) { file = _secApi.ArchivesEdgarDataCIKSubmissionFile(cik, extractSECItemsParams.Filing.Name, item.Name); } else { file = LoadFromStorage(extractSECItemsParams.RegulatorCode, extractSECItemsParams.CompanyCode, extractSECItemsParams.Filing.Name, item.Name); } if (file != null) { SECSourceItem sourceItem = ToSourceItem(extractItemsParams.RegulatorCode, extractItemsParams.CompanyCode, extractSECItemsParams.Filing.Name, file); result.Items.Add(sourceItem); } } if (!_extractFromStorage) { PutToStorage(result.Items); } } } return(result); }
public ISourceExtractResult ExtractReports(ISourceExtractParams extractParams) { SECSourceExtractResult result = new SECSourceExtractResult(); SECSourceExtractParams extractSECParams = extractParams as SECSourceExtractParams; if (extractSECParams != null) { string cik = _dictionary.LookupRegulatorCompanyCode(extractSECParams.RegulatorCode, extractSECParams.CompanyCode); // TODO: lookup in dictionary if (!string.IsNullOrEmpty(cik)) { foreach (var filing in extractSECParams.Items) { // getting list of files for each filing Submission submission = _secApi.ArchivesEdgarDataCIKSubmission(cik, filing.Name); if (submission != null) { foreach (var fileInfo in submission.Files) { // to speed up we need to extract only xml files and index headers file if (Path.GetExtension(fileInfo.Name) == ".xml" || fileInfo.Name.Contains(".txt")) { SubmissionFile file = _secApi.ArchivesEdgarDataCIKSubmissionFile(cik, filing.Name, fileInfo.Name); if (file != null) { SECSourceItem sourceItem = new SECSourceItem(); sourceItem.Name = fileInfo.Name; sourceItem.FilingName = filing.Name; sourceItem.CompanyCode = extractSECParams.CompanyCode; sourceItem.RegulatorCode = extractSECParams.RegulatorCode; sourceItem.Content = file.Content; result.Items.Add(sourceItem); } } } // saving all uploaded items to storage PutToStorage(result.Items); } else { result.AddError(EErrorCodes.ImporterError, EErrorType.Warning, string.Format("Failed to import filing {0}", filing.Name)); } } result.Success = true; } else { result.Success = false; result.AddError(EErrorCodes.InvalidParserParams, EErrorType.Error, string.Format("Cannot find the SEC CIK for company with code {0}", extractSECParams.CompanyCode)); } } else { result.Success = false; result.AddError(EErrorCodes.InvalidParserParams, EErrorType.Error, "Parameters of invalid type were provided"); } return(result); }