Example #1
0
        public override RFProcessingResult Process()
        {
            var         inputFile = Context.LoadDocumentContent <RFFile>(InstanceParams.Key);
            RFRawReport rawReport = null;

            using (var ms = new MemoryStream(inputFile.Data))
            {
                rawReport = LoadFromStream(ms, inputFile.Attributes, inputFile.ValueDate, _config, _builder);
            }

            if (rawReport != null)
            {
                rawReport.SourceUniqueKey = inputFile.UniqueKey;
                rawReport.SourceFilename  = inputFile.Attributes.FileName;

                Context.SaveEntry(RFDocument.Create(RFRawReportKey.Create(KeyDomain, _config.ReportCode, new RFGraphInstance {
                    ValueDate = rawReport.ValueDate, Name = _config.GraphInstance
                }),
                                                    rawReport));
            }

            return(new RFProcessingResult {
                WorkDone = true
            });
        }
Example #2
0
        public RFRawReport BuildReport(List <DataTable> tables, IRFReportBuilder builder, RFReportParserConfig config)
        {
            _report         = new RFRawReport();
            _currentSection = null;
            _parentSection  = null;
            _builder        = builder;

            foreach (var table in tables)
            {
                _parentSection  = table.TableName;
                _currentSection = new RFRawReportSection
                {
                    Name    = String.Format("{0}.{1}", _parentSection, HEADER_SECTION_NAME),
                    Columns = new List <string>()
                };
                _report.Sections.Add(_currentSection);
                bool isFirstRow = true;
                foreach (DataRow row in table.Rows)
                {
                    ProcessRow(row, isFirstRow, config.HasHeaders);
                    isFirstRow = false;
                }
            }

            return(_report);
        }
        public (MirroredFile mirroredFile, RFRawReport report) GetPreview(int mirroredFileID)
        {
            var         file   = GetFile(mirroredFileID);
            RFRawReport report = null;

            if (file.content != null && file.content.Length > 0)
            {
                try
                {
                    report = RFReportParserProcessor.LoadFromStream(new MemoryStream(file.content), null, null, null, null);
                    file.mirroredFile.Processed = true;
                    file.mirroredFile.NumRows   = report.Sections.Sum(s => s.Rows.Count);
                }
                catch (Exception ex)
                {
                    file.mirroredFile.Processed = false;
                    file.mirroredFile.NumRows   = null;
                    file.mirroredFile.Message   = ex.Message;
                }
            }
            return(file.mirroredFile, report);
        }
 public virtual RFDate ExtractValueDate(RFFileTrackedAttributes fileAttributes, RFRawReport content)
 {
     if (!string.IsNullOrWhiteSpace(Format))
     {
         try
         {
             if (fileAttributes != null && !string.IsNullOrWhiteSpace(fileAttributes.FileName) && fileAttributes.FileName.Length >= (Start + Format.Length))
             {
                 return(new RFDate(DateTime.ParseExact(fileAttributes.FileName.Substring(Start, Format.Length), Format, CultureInfo.InvariantCulture)).OffsetWeekdays(Offset));
             }
         }
         catch (Exception)
         {
             throw new RFLogicException(this, "Unable to extract date from file name {0} - has the format changed?", fileAttributes.FileName);
         }
     }
     if (DefaultDate != null)
     {
         return(DefaultDate());
     }
     return(RFDate.NullDate);
 }