public FlattenedDatasheet FlattenDatasheet(Datasheet.Dal.Ef.Datasheet datasheet) { FlattenedDatasheet flatDatasheet = new FlattenedDatasheet { DataSheetId = datasheet.DatasheetId, FlattenedSections = new List <FlattenedSection>(datasheet.Sections.Count) }; foreach (var section in datasheet.Sections) { flatDatasheet.FlattenedSections.Add(this.FlattenSection(section)); } return(flatDatasheet); }
private Task StartWordWithPdfAdProcess() { var pdfBytes = System.IO.File.ReadAllBytes(_filePath); using (NetOffice.WordApi.Application app = new NetOffice.WordApi.Application()) { #if DEBUG app.Visible = true; #endif var doc = app.Documents.Open(_filePath); var datasheet = new Datasheet.Dal.Ef.Datasheet { FilePath = _filePath, Pdf = pdfBytes, PdfProvider = GetInstanceName(_filePath), }; foreach (var section in doc.Paragraphs) { var newSection = new Section { }; datasheet.Sections.Add(newSection); if (!String.IsNullOrEmpty(section.Range.Text) && ! String.IsNullOrWhiteSpace(section.Range.Text)) { newSection.SectionText = section.Range.Text; } else { //Extract image! //newSection.SectionImage = section.Range. } } app.Quit(); _context.Datasheets.Add(datasheet); return _context.SaveChangesAsync(); } }
private Task StartWordWithPdfAdProcess() { var pdfBytes = System.IO.File.ReadAllBytes(_filePath); using (NetOffice.WordApi.Application app = new NetOffice.WordApi.Application()) { #if DEBUG app.Visible = true; #endif var doc = app.Documents.Open(_filePath); var datasheet = new Datasheet.Dal.Ef.Datasheet { FilePath = _filePath, Pdf = pdfBytes, PdfProvider = GetInstanceName(_filePath), }; foreach (var section in doc.Paragraphs) { var newSection = new Section { }; datasheet.Sections.Add(newSection); if (!String.IsNullOrEmpty(section.Range.Text) && !String.IsNullOrWhiteSpace(section.Range.Text)) { newSection.SectionText = section.Range.Text; } else { //Extract image! //newSection.SectionImage = section.Range. } } app.Quit(); _context.Datasheets.Add(datasheet); return(_context.SaveChangesAsync()); } }