/// <summary> /// Создаёт файл экспорта данных из ORM. /// </summary> /// <param name="dataService">Сервис данных ORM.</param> /// <param name="parameters">Параметры экпорта.</param> /// <param name="objs">Объекты для экспорта.</param> /// <param name="queryParams">Параметры в запросе HTTP.</param> /// <returns>Возвращает файл экспорта в виде MemoryStream.</returns> public MemoryStream CreateExportStream(IDataService dataService, IExportParams parameters, DataObject[] objs, NameValueCollection queryParams) { var exportService = new DataExportLimitedService(parameters, dataService); var dataExport = exportService.GetDataExport(objs); var excelService = new ExcelExportService(parameters, queryParams); excelService.SpreadsheetCustomizer = new SpreadsheetCustomizer(); MemoryStream result = excelService.GetExportStream(dataExport); return(result); }
/// <summary> /// Exports the T-SQL scripts to disk. /// </summary> public virtual void ExportUpgradeScripts(IExportParams exportParameters, IScriptWriter scriptWriter) { Throw.If(exportParameters).IsNull(); Throw.If(scriptWriter).IsNull(); exportParams = exportParameters; writer = scriptWriter; CalculateScriptObjectCount(); ScriptTableDataDifferences(); }
// USE CASE: Using a configured FlexiCapture project to recognize image files public static void Using_a_configured_FlexiCapture_project_to_recognize_image_files(IEngine engine) { trace("Open the sample project..."); IProject project = engine.OpenProject("D:\\Users\\seral\\Desktop\\SampleImages\\SampleProject\\DocScan1CProject\\DocScan1CProject.fcproj"); try { trace("Add a new batch..."); IBatch batch = project.Batches.AddNew("DocScan1C"); trace("Open the batch..."); batch.Open(); try { IStringsCollection filePaths = engine.CreateStringsCollection(); filePaths.Add(SamplesFolder + "1134.pdf"); filePaths.Add(SamplesFolder + "Scan_07_θη_06.bmp"); //filePaths.Add(SamplesFolder + "Scan_02_θη_06.jpg"); // filePaths.Add(SamplesFolder + "Scan_08_θη_06.jpg");*/ IStringsCollection badFiles = engine.CreateStringsCollection();; ILongsCollection docIds = engine.CreateLongsCollection(); trace("Add image files to the batch..."); batch.AddImages(filePaths, -1, null, null, badFiles, docIds); trace("Recognize all images in the batch..."); batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeMinimal, null); trace("Export the results..."); IExportParams exportParams = engine.CreateExportParams(ExportDestinationTypeEnum.EDT_File); exportParams.IgnoreRuleErrors = true; exportParams.FileExportParams.RootPath = "D:\\Users\\seral\\Desktop\\FCEExport"; exportParams.FileExportParams.FileFormat = FileExportFormatEnum.FEF_XML; exportParams.FileExportParams.FileNamePattern = "<DocumentDefinition>"; exportParams.FileExportParams.CreateSeparateFilesForRepeatableItems = true; exportParams.FileExportParams.FileOverwriteRule = FileOverwriteRuleEnum.FOR_Rename; batch.Export(null, exportParams); trace("Close and delete the batch..."); } finally { batch.Close(); // Before the batch could be deleted, it has to be closed project.Batches.DeleteAll(); } trace("Close the project..."); } finally { project.Close(); } }
/// <summary> /// Exports the T-SQL scripts to disk. /// </summary> public virtual void ExportScripts(IExportParams exportParameters, IScriptWriter scriptWriter) { Throw.If(exportParameters).IsNull(); Throw.If(scriptWriter).IsNull(); exportParams = exportParameters; writer = scriptWriter; CalculateScriptObjectCount(); ScriptSprocs(); ScriptViews(); ScriptTables(); ScriptTableData(); }
/// <summary> /// Exports the T-SQL scripts to disk. /// </summary> public virtual void ExportScripts(IExportParams exportParameters, IScriptWriter scriptWriter) { Throw.If(exportParameters).IsNull(); Throw.If(scriptWriter).IsNull(); exportParams = exportParameters; writer = scriptWriter; CalculateScriptObjectCount(); ScriptSprocs(); ScriptViews(); ScriptTables(); ScriptTableData(); }
public void Export(string exportDirectory, IExportParams exportParams) { ScriptEngine engine = null; try { engine = new ScriptEngine(database); engine.ProgressEvent += Engine_ProgressEvent; engine.ExportScripts(exportParams, new MultiFileScriptWriter(exportDirectory)); } finally { if (engine != null) { engine.ProgressEvent -= Engine_ProgressEvent; } } }
public void Export(IExportParams exportParams) { ScriptEngine engine = null; try { var scriptWriter = new ScriptWriterFactory().Create( exportParams.ExportDirectory, DatabaseName, exportParams.UseMultipleFiles); engine = new ScriptEngine(_database); engine.ProgressEvent += Engine_ProgressEvent; engine.ExportScripts(exportParams, scriptWriter); } finally { if (engine != null) { engine.ProgressEvent -= Engine_ProgressEvent; } } }
/// <summary> /// Обработка документа Excel. /// </summary> /// <param name="document">Документ Excel.</param> /// <param name="parameters">Параметры экпорта.</param> /// <param name="queryParams">Параметры в запросе HTTP.</param> public void Process(ref SpreadsheetDocument document, IExportParams parameters = null, NameValueCollection queryParams = null) { var worksheetPart = document.WorkbookPart.GetPartsOfType <WorksheetPart>().First(); var sheetData = worksheetPart.Worksheet.GetFirstChild <SheetData>(); var row = new Row(); string query = null; foreach (var key in queryParams.AllKeys) { if (query != null) { query += "&"; } query += $"{key}={queryParams[key]}"; } var excelDataType = new ExcelTypeDefinition(CellValues.String, CustomStylesheet.StyleIndexTextAllBordersWrapAlignment); var cell = CreateCell(query, excelDataType); row.AppendChild(cell); sheetData.AppendChild(row); return; }
/// <summary> /// Обработка документа Excel. /// </summary> /// <param name="document">Документ Excel.</param> public void Process(ref SpreadsheetDocument document, IExportParams parameters = null, NameValueCollection queryParams = null) { var workbookPart = document.WorkbookPart; if (workbookPart != null) { WorkbookStylesPart styles = workbookPart.WorkbookStylesPart; if (styles != null) { Stylesheet stylesheet = styles.Stylesheet; if (stylesheet != null) { CellFormats cellformats = stylesheet.CellFormats; Fonts fonts = stylesheet.Fonts; UInt32 fontIndex = fonts.Count; UInt32 formatIndex = cellformats.Count; var worksheetPart = workbookPart.GetPartsOfType <WorksheetPart>().First(); if (worksheetPart != null) { var sheetData = worksheetPart.Worksheet.GetFirstChild <SheetData>(); if (sheetData != null) { var headerRow = sheetData.GetFirstChild <Row>(); if (headerRow != null) { Cell cell = headerRow.GetFirstChild <Cell>(); CellFormat f = (CellFormat)cellformats.ElementAt((int)cell.StyleIndex.Value); var font = (Font)fonts.ElementAt((int)f.FontId.Value); var newfont = (Font)font.Clone(); newfont.Bold = new Bold(); fonts.Append(newfont); fonts.Count = UInt32Value.FromUInt32((uint)fonts.ChildElements.Count); CellFormat newformat = (CellFormat)f.Clone(); newformat.FontId = fontIndex; Fill fill = new Fill(); PatternFill patternFill = new PatternFill() { PatternType = PatternValues.Solid }; patternFill.ForegroundColor = new ForegroundColor() { Rgb = "FFD0D0D0" }; patternFill.BackgroundColor = new BackgroundColor() { Indexed = (UInt32Value)64U }; fill.PatternFill = patternFill; Fills fills = new Fills(); fills.Append(new Fill() { PatternFill = new PatternFill() }); fills.Append(new Fill() { PatternFill = new PatternFill() { PatternType = PatternValues.Gray125 } }); fills.Append(fill); stylesheet.Fills = fills; stylesheet.Fills.Count = UInt32Value.FromUInt32((uint)fills.ChildElements.Count); newformat.FillId = stylesheet.Fills.Count - 1; cellformats.Append(newformat); cellformats.Count = UInt32Value.FromUInt32((uint)cellformats.ChildElements.Count); stylesheet.Save(); foreach (OpenXmlElement el in headerRow.ChildElements) { (el as Cell).StyleIndex = formatIndex; } } } } } } } }