public IFilingParserResult Parse(IFilingParserParams parserParams) { ResetState(); SECParserParams secParams = parserParams as SECParserParams; SECParserResult result = new SECParserResult(); try { ValidateFile(secParams, result); if (result.Success) { var doc = OpenDocument(secParams); if (doc != null) { ExtractCompanyData(doc, result); ExtractFilingData(doc, result); ExtractReportingOwnerData(doc, result); ExtractNonDerivaties(doc, result, result.PeriodEnd); ExtractDerivaties(doc, result); } } } catch (Exception ex) { result.Success = false; result.AddError(EErrorCodes.ParserError, EErrorType.Error, ex.Message); } return(result); }
public IFilingParserResult Parse(IFilingParserParams parserParams) { SECParserParams secParams = parserParams as SECParserParams; SECParserResult result = new SECParserResult(); try { ValidateFiles(secParams, result); if (result.Success) { XmlDocument docPrimary = OpenDocument(secParams, "primary_doc.xml"); XmlDocument docInfoTable = OpenDocument(secParams, "form13fInfoTable.xml"); ExtractFilingData(docPrimary, result); ExtractGeneralData(docPrimary, result); ExtractManagersData(docPrimary, result); ExtractHoldingsData(docInfoTable, result); } } catch (Exception ex) { result.Success = false; result.AddError(EErrorCodes.ParserError, EErrorType.Error, ex.Message); } return(result); }
protected XmlDocument OpenDocument(SECParserParams secParams) { XmlDocument doc = new XmlDocument(); doc.Load(secParams.FileContent.Values.ElementAt(0)); return(doc); }
protected void ValidateFile(SECParserParams secParams, SECParserResult secResult) { if (secParams.FileContent == null || !secParams.FileContent.Values.ElementAt(0).CanRead) { secResult.Success = false; secResult.AddError(EErrorCodes.FileNotFound, EErrorType.Error, "Stream is unaccessable"); } }
protected XmlDocument OpenDocument(SECParserParams secParams, string name) { XmlDocument doc = new XmlDocument(); doc.Load(secParams.FileContent[name]); return(doc); }
private void ValidateFiles(SECParserParams secParams, SECParserResult secResult) { if (secParams.FileContent != null && secParams.FileContent.Count > 0) { foreach (var s in secParams.FileContent) { if (!s.Value.CanRead) { secResult.Success = false; secResult.AddError(EErrorCodes.FileNotFound, EErrorType.Error, string.Format("Stream {0} is unaccessable", s.Key)); } } } else { secResult.Success = false; secResult.AddError(EErrorCodes.FileNotFound, EErrorType.Error, "Streams were not provided"); } }