private void btnPrint_Click(object sender, EventArgs e) { try { string file = "Report.lst"; if (!File.Exists(file)) { file = ChooseFile(); } if (File.Exists(file)) { ExportConfiguration config = new ExportConfiguration(LlExportTarget.Pdf, Path.Combine(Path.GetTempPath(), "statistics.pdf"), file); config.ShowResult = true; config.BoxType = LlBoxType.NormalMeter; InitDataSource(); _lL.Export(config); } } catch (ListLabelException) { } catch (DbException ex) { MessageBox.Show(ex.Message); } }
// POST api/<controller> public async Task <IHttpActionResult> Post() { log.Log($"Exporting data using Post ..."); var configuration = await Request.Content.ReadAsStringAsync(); log.Log(new LogEntry($"'Post' body.", information: configuration)); if (string.IsNullOrEmpty(configuration)) { return(BadRequest("Configuration cannot be empty.")); } log.Log($"Converting from JSON to object ..."); var jsonObject = ExportConfiguration.FromJson(configuration); log.Log($"Finished creating JSON object."); log.Log($"Exporting ..."); var data = crmExporter.ExportRecords(jsonObject); log.Log($"Finished exporting data."); return(Ok(data)); }
public static void ExportAsPdf(string labelDefinition, IEnumerable <Object> data, string parentEntity, string targetFilePath) { using (var listLabel = new ListLabel()) { listLabel.LicensingInfo = ListLabelLicenseString; // Set up the dataset listLabel.DataSource = new ObjectDataProvider(data) { FlattenStructure = true, }; listLabel.DataMember = parentEntity; listLabel.AutoMasterMode = LlAutoMasterMode.AsVariables; // Configure the designer to read the report design from a memoryStream var memoryStream = new MemoryStream(); if (labelDefinition != null) { var stringBytes = Encoding.Unicode.GetBytes(labelDefinition); memoryStream.Write(stringBytes, 0, stringBytes.Length); } // Launch the designer var exportConfiguration = new ExportConfiguration( LlExportTarget.Pdf, targetFilePath, memoryStream) { ShowResult = false, }; listLabel.Export(exportConfiguration); } }
public static MemoryStream Export <TData>(ExportConfiguration <TData> exportConfiguration, List <TData> data) { using (var pck = new ExcelPackage()) { // Create the worksheet var sheet = pck.Workbook.Worksheets.Add(exportConfiguration.FileName); // Execute the func var headers = exportConfiguration.DataMapper.Keys.ToList(); // Set columns headers for (var i = 0; i < headers.Count; i++) { sheet.Cells[1, i + 1].Value = headers[i]; } // Fill the data if (data.Any()) { var loadedData = data.Select(x => exportConfiguration.DataMapper.Values.Select(y => y(x)).ToArray()).ToList(); sheet.Cells["A2"].LoadFromArrays(loadedData); } // Create the file stream var stream = new MemoryStream(EpplusCsvConverter.ConvertToCsv(pck)) { Position = 0 }; return(stream); } }
private static ReadOnlyCollection <string> GetEnabledWidgets() { using (var service = ServiceFactory.GetCallbackServiceWrapper <ISettingsService>(new SettingsServiceCallback())) { ExportConfiguration exports = service.Instance.GetSetting(SettingKeys.WidgetConfigurationKey).GetValue <ExportConfiguration>(); return(new ReadOnlyCollection <string>(exports.GetEnabledExports())); } }
public IExportedImage Export(IExporter exporter, Action <IExportConfiguration> configuration) { ExportConfiguration exportConfiguration; configuration(exportConfiguration = new ExportConfiguration(exporter)); _exportedImage = exportConfiguration.Export(_scanImage, exportConfiguration.Options); return(_exportedImage); }
private void ToolButtonExportClick(object sender, EventArgs e) { ExportConfiguration export = new ExportConfiguration(this.Database); this.exportFileDialog.Filter = export.FilterString; this.exportFileDialog.DefaultExt = export.ShortExtension; if (this.exportFileDialog.ShowDialog() == DialogResult.OK) { export.Execute(this.exportFileDialog.FileName); } }
public void HeaderRowShouldBeCreatedByDefault() { var metadata = MetadataReader.ReadMetadata(typeof(TestExportItem)); var enumerable = new List <TestExportItem>(); var configuration = new ExportConfiguration(); var valuesReader = new ValuesReader <TestExportItem>(metadata, configuration); var values = valuesReader.ReadValues(enumerable); Assert.Equal(1, values.Count); Assert.True(values[0].IsHeaderRow); }
public ExportController( IFhirRequestContextAccessor fhirRequestContextAccessor, IOptions<OperationsConfiguration> operationsConfig, ILogger<ExportController> logger) { EnsureArg.IsNotNull(fhirRequestContextAccessor, nameof(fhirRequestContextAccessor)); EnsureArg.IsNotNull(operationsConfig?.Value?.Export, nameof(operationsConfig)); EnsureArg.IsNotNull(logger, nameof(logger)); _fhirRequestContextAccessor = fhirRequestContextAccessor; _exportConfig = operationsConfig.Value.Export; _logger = logger; }
public void HeaderRowShouldNotBeCreatedByConfiguration() { var metadata = MetadataReader.ReadMetadata(typeof(TestExportItem)); var enumerable = new List <TestExportItem>(); var configuration = new ExportConfiguration { WriteHeaderRow = false }; var valuesReader = new ValuesReader <TestExportItem>(metadata, configuration); var values = valuesReader.ReadValues(enumerable); Assert.Equal(0, values.Count); }
protected override void LoadToMapCore() { if (ExportConfiguration.Count(tmpConfig => tmpConfig.NeedsToExport) > 0) { Collection <ShapeFileFeatureLayer> layers = GetShapeFileLayers(OutputShapeFileNames); GisEditor.ActiveMap.AddLayersBySettings(layers); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(this, RefreshArgsDescription.LoadToMapCoreDescription)); foreach (var overlay in OverlaysToRefresh) { overlay.Invalidate(); } } }
protected override TaskPlugin GetTaskPluginCore() { OutputShapeFileNames.Clear(); OverlaysToRefresh.Clear(); FeatureSource featureSource = null; if (UseSelectedFeaturesOnly) { SaveSelectedFeaturesToTempFile(); featureSource = new ShapeFileFeatureSource(tempFilePath); } else { featureSource = SelectedLayerToSplit.FeatureSource; } if (featureSource.IsOpen) { featureSource.Close(); if (featureSource.Projection != null) { featureSource.Projection.Close(); } } Dictionary <string, string> exportConfigs = new Dictionary <string, string>(); var plugin = GisEditor.TaskManager.GetActiveTaskPlugins <SplitTaskPlugin>().FirstOrDefault(); if (plugin != null) { InitializePlugin(plugin, featureSource, exportConfigs); } var configsNeedToExport = ExportConfiguration.Where(config => config.NeedsToExport); foreach (var item in configsNeedToExport) { string finalShapeFilePath = Path.Combine(OutputPath, item.OutputFileName + ".shp"); if (File.Exists(finalShapeFilePath) && overwriteOutputFiles) { CloseExistingLayersAndCollectOverlaysToRefresh(finalShapeFilePath); } OutputShapeFileNames.Add(finalShapeFilePath); exportConfigs.Add(item.ColumnValue, item.OutputFileName + ".shp"); } return(plugin); }
public void AllRowsShouldBeExported() { var metadata = MetadataReader.ReadMetadata(typeof(TestExportItem)); var enumerable = new List <TestExportItem> { new TestExportItem(), new TestExportItem() }; var configuration = new ExportConfiguration(); var valuesReader = new ValuesReader <TestExportItem>(metadata, configuration); var values = valuesReader.ReadValues(enumerable); Assert.Equal(3, values.Count); Assert.Equal(2, values.Count(v => !v.IsHeaderRow)); }
public void GenerateExportConfigAsync() { ExportConfiguration.Clear(); CurrentThread = new Thread(new ThreadStart(GenerateExportConfig)); IsBusy = true; BusyContent = "Analyzing..."; CurrentThread.Start(); while (IsBusy) { System.Windows.Forms.Application.DoEvents(); Thread.SpinWait(100); } }
private void Initialise() { log.Log("Initialising data import parameters ..."); recordsMap = data.EntityDefinition; if (recordsMap.Any(r => r.Key == Guid.Empty)) { throw new Exception("Exported records contains an invalid GUID."); } relationsMap = data.RelationDefinition; queries = data.Queries; config = data.Configuration; batchSize = (int?)options?.BulkSize ?? 500; log.Log("Initialised data import parameters."); }
private ExportController GetController(ExportConfiguration exportConfig) { var operationConfig = new OperationsConfiguration() { Export = exportConfig, }; IOptions <OperationsConfiguration> optionsOperationConfiguration = Substitute.For <IOptions <OperationsConfiguration> >(); optionsOperationConfiguration.Value.Returns(operationConfig); return(new ExportController( Substitute.For <IFhirRequestContextAccessor>(), optionsOperationConfiguration, NullLogger <ExportController> .Instance)); }
public void NullShouldBeNullByDefault() { var metadata = MetadataReader.ReadMetadata(typeof(TestExportItem)); var enumerable = new List <TestExportItem> { new TestExportItem() }; var configuration = new ExportConfiguration { WriteHeaderRow = false }; var valuesReader = new ValuesReader <TestExportItem>(metadata, configuration); var values = valuesReader.ReadValues(enumerable); var row = values.SingleOrDefault(); Assert.NotNull(row); Assert.True(row.Values.Any(v => v.Value == null)); Assert.False(row.Values.Any(v => v.Value != null && v.Value.ToString() == "NULL")); }
public void Save( ExportConfiguration exportConfiguration, ProjectExport projectExport, IExportDataWriter dataWriter) { // Only write the statistics file if the full model is exported. // We don't want to write the file for internal edit mode exports. if (exportConfiguration.Mode != ExportMode.FullModel) { return; } using (var stream = dataWriter.OpenStream("ExportStatistics.txt")) using (var writer = new StreamWriter(stream, Encoding.UTF8)) { WriteStatistics(projectExport, writer); writer.Flush(); } }
public void SimpleDisplayMemberPathShouldBeUsed() { var metadata = MetadataReader.ReadMetadata(typeof(TestExportItem)); var enumerable = new List <TestExportItem> { new TestExportItem { Timestamp = new DateTime(1961, 2, 25) } }; var configuration = new ExportConfiguration { WriteHeaderRow = false }; var valuesReader = new ValuesReader <TestExportItem>(metadata, configuration); var values = valuesReader.ReadValues(enumerable); var row = values.SingleOrDefault(); Assert.NotNull(row); Assert.True(row.Values.Any(v => v.Value is int && (int)v.Value == 1961)); }
/// <summary> /// Export the list of data in an excel file /// </summary> /// <returns></returns> public static MemoryStream Export <TData>(ExportConfiguration <TData> exportConfiguration, List <TData> data) { using (var pck = new ExcelPackage()) { // Create the worksheet var sheet = pck.Workbook.Worksheets.Add(exportConfiguration.FileName); sheet.Cells.Style.Numberformat.Format = "@"; // Execute the func var headers = exportConfiguration.DataMapper.Keys.ToList(); // Set columns headers for (var i = 0; i < headers.Count; i++) { sheet.Cells[1, i + 1].Value = headers[i]; } // Fill the data if (data.Any()) { var loadedData = data.Select(x => exportConfiguration.DataMapper.Values.Select(y => y(x)).ToArray()).ToList(); sheet.Cells["A2"].LoadFromArrays(loadedData); } // Apply header style using (var rng = sheet.Cells["A1:BZ1"]) { rng.Style.Font.Bold = true; rng.Style.ShrinkToFit = true; } sheet.Cells[sheet.Dimension.Address].AutoFitColumns(); // Create the file stream var stream = new MemoryStream(pck.GetAsByteArray()) { Position = 0 }; return(stream); } }
public void CorrectValuesShouldBeRead() { var metadata = MetadataReader.ReadMetadata(typeof(TestExportItem)); var enumerable = new List <TestExportItem> { new TestExportItem { Name = "Jann", Id = 15 } }; var configuration = new ExportConfiguration { WriteHeaderRow = false }; var valuesReader = new ValuesReader <TestExportItem>(metadata, configuration); var values = valuesReader.ReadValues(enumerable); var row = values.SingleOrDefault(); Assert.NotNull(row); Assert.True(row.Values.Any(v => v.Value.ToString().Equals("Jann"))); Assert.True(row.Values.Any(v => v.Value is int && (int)v.Value == 15)); }
private void MenuItemBackupClick(object sender, EventArgs e) { if (this.saveBackupDialog.ShowDialog() == DialogResult.OK) { XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", string.Empty)); XmlElement root = doc.CreateElement("database"); doc.AppendChild(root); XmlElement elem = doc.CreateElement(root, "configuration"); ExportConfiguration.CreateXmlTree(this.database, doc, elem); elem = doc.CreateElement(root, "folders"); this.ExportsFolders(doc, elem); elem = doc.CreateElement(root, "filters"); this.ExportFilters(doc, elem); elem = doc.CreateElement(root, "records"); ExportData.CreateXmlTree(this.database, doc, elem); doc.Save(this.saveBackupDialog.FileName); KryptonMessageBox.Show(Strings.DataBackuped, Strings.Backup, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
static void Main(string[] args) { var app = new CommandLineApplication(throwOnUnexpectedArg: true); app.FullName = "SQL to CSV"; app.Name = "sql2csv"; app.HelpOption("-?|-h|--help"); var verboseOption = app.Option("-v|--verbose", "Show verbose output", CommandOptionType.NoValue); var configOption = app.Option("-C|--config <file>", "Specify configuration file", CommandOptionType.SingleValue); app.Command("export", command => { command.HelpOption("-?|-h|--help"); var options = new ConfigurationOptions( verboseOption, configOption, command.Option("-c|--connection <connection>", "The connection string", CommandOptionType.SingleValue), command.Option("-i|--input <file>", "Input SQL script file", CommandOptionType.SingleValue), command.Option("-o|--output <file>", "The output file", CommandOptionType.SingleValue), command.Option("-q|--sql <query>", "Input SQL query", CommandOptionType.SingleValue), command.Option("-S|--separator <separator>", "Specify the separator to use, default to ;", CommandOptionType.SingleValue), command.Option("-e|--encoding <encoding>", "Specify the encoding of the output file, default utf-8", CommandOptionType.SingleValue), command.Option("-Q|--quoted", "Specify whether values should be quoted, default to true", CommandOptionType.NoValue), command.Option("-l|--limit <value>", "Specify record limit count", CommandOptionType.SingleValue), command.Option("-f|--filter <file>", "Specify filter file", CommandOptionType.SingleValue), command.Option("-i|--index <col>", "Specify the column index or name to filter by, default 1 (first column)", CommandOptionType.SingleValue)); command.OnExecute(() => { var configFile = configOption.LoadConfiguration(); var config = new ExportConfiguration(options, configFile); var task = new CsvDump(config); return(task.Execute()); }); }); app.Execute(args); }
bool IJob.Initialize() { // Get export configuration ExportConfiguration exports = SettingsManager.Instance.GetSetting("GrowlJob", "GrowlSender").GetValue <ExportConfiguration>(); // Add each export to the list, if initialization succeeded foreach (string exportAlias in exports.GetEnabledExports()) { try { IGrowlSender growlSender = ExportedTypeLibrary.Import <IGrowlSender>(exportAlias); // This one has passed! _growlSender.Add(growlSender); Logger.Instance.LogFormat(LogType.Info, this, "Added growl sender '{0}'.", exportAlias); } catch { Logger.Instance.LogFormat(LogType.Warning, this, "An error occurred while initialization plug-in '{0}'. Ignoring plug-in.", exportAlias); } } return(true); }
public CsvDump(ExportConfiguration config) { _config = config; }
/// <summary> /// Create new export configuration /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='properties'> /// Export configurations. /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ExportConfigurationResult> CreateAsync(this IExportConfigurations operations, ExportConfiguration properties, string ownerName, string appName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateWithHttpMessagesAsync(properties, ownerName, appName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public void Export(ExportConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrWhiteSpace(configuration.SourceFileNamePath)) { throw new ArgumentNullException("SourceFileNamePath"); } //See if the local file even exists.. Console.WriteLine("Opening Source File '{0}'...", configuration.SourceFileNamePath); using (var sourceFileStream = File.OpenRead(configuration.SourceFileNamePath)) { if (GLFReader.IsGLF(sourceFileStream) == false) { throw new InvalidOperationException("Specified source file is not a Loupe Log file (glf)"); } var sessionCollection = new SessionCollection(); var session = sessionCollection.Add(sourceFileStream); if (session == null) { throw new InvalidOperationException("Unable to find session data in source data file"); } Console.WriteLine("Initializing {0} Export...", configuration.LogMessageFormat); using (session) { //instance the correct exporter... LogMessageFormatter messageFormatter; switch (configuration.LogMessageFormat) { case LogMessageFormat.Default: messageFormatter = new DefaultLogMessageFormatter(configuration); break; case LogMessageFormat.Summary: messageFormatter = new SummaryLogMessageFormatter(configuration); break; case LogMessageFormat.Detailed: messageFormatter = new DetailedLogMessageFormatter(configuration); break; default: throw new ArgumentOutOfRangeException(); } ISession readOnlySession = new ReadOnlySession(session); var stopwatch = Stopwatch.StartNew(); Console.WriteLine("Exporting Session Data into '{0}'...", configuration.TargetFileNamePath); messageFormatter.Export(readOnlySession); stopwatch.Stop(); Console.WriteLine("Completed export in {0:T}.", stopwatch.Elapsed); } } }
/// <summary> /// Export a report using current instance of ListLabel and upload it directly to the Google Drive Cloud Storage. /// </summary> /// <param name="ll">current instance of List & Label</param> /// <param name="exportConfiguration">required export configuration for native ListLabel Export method</param> /// <param name="exportParameters">requied parameters for Google Drive OAuth 2.0 upload.</param> /// <param name="clientSecretFilePath">The full path of client secret file.</param> public static void Export(this Reporting.ListLabel ll, ExportConfiguration exportConfiguration, GoogleDriveExportParameter exportParameters, string clientSecretFilePath) { ll.AutoShowSelectFile = false; ll.AutoShowPrintOptions = false; ll.AutoDestination = LlPrintMode.Export; ll.AutoProjectType = LlProject.List; ll.AutoBoxType = LlBoxType.None; exportConfiguration.ExportOptions.Add("Export.Quiet", "1"); string mimeType = string.Empty; switch (exportConfiguration.ExportTarget) { case LlExportTarget.Pdf: exportParameters.CloudFileName += ".pdf"; mimeType = "application/pdf"; break; case LlExportTarget.Rtf: exportParameters.CloudFileName += ".rtf"; mimeType = "application/rtf"; break; case LlExportTarget.Xls: exportParameters.CloudFileName += ".xls"; mimeType = "application/vnd.ms-excel"; break; case LlExportTarget.Xlsx: exportParameters.CloudFileName += ".xlsx"; mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; case LlExportTarget.Docx: exportParameters.CloudFileName += ".docx"; mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; case LlExportTarget.Xps: exportParameters.CloudFileName += ".xps"; mimeType = "application/vnd.ms-xpsdocument"; break; case LlExportTarget.Mhtml: exportParameters.CloudFileName += ".mhtml"; mimeType = "message/rfc822"; break; case LlExportTarget.Text: exportParameters.CloudFileName += ".txt"; mimeType = "text/plain"; break; case LlExportTarget.Pptx: exportParameters.CloudFileName += ".pptx"; mimeType = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; break; default: exportParameters.CloudFileName += ".zip"; mimeType = "application/zip"; exportConfiguration.ExportOptions.Add(LlExportOption.ExportSaveAsZip, "1"); exportConfiguration.ExportOptions.Add(LlExportOption.ExportZipFile, exportParameters.CloudFileName); exportConfiguration.ExportOptions.Add(LlExportOption.ExportZipPath, Path.GetDirectoryName(exportConfiguration.Path)); break; } ll.Export(exportConfiguration); FileStream stream = System.IO.File.Open(string.Concat(Path.GetDirectoryName(exportConfiguration.Path), "\\", exportParameters.CloudFileName), FileMode.Open); Upload(ll, new GoogleDriveUploadParameter() { UploadStream = stream, CloudFileName = exportParameters.CloudFileName, CloudPath = exportParameters.CloudPath, ApplicationName = exportParameters.ApplicationName, MimeType = mimeType }, clientSecretFilePath); }
public DefaultLogMessageFormatter(ExportConfiguration config) : base(config) { }
public SummaryLogMessageFormatter(ExportConfiguration config) : base(config) { }