Example #1
0
        private async Task ExportData(IDataExporter dataExporter, ExportOptions exportOptions)
        {
            using (var cancellationTokenSource = new CancellationTokenSource())
            {
                var operationMonitor = new WindowOperationMonitor(cancellationTokenSource)
                {
                    IsIndeterminate = false
                };
                operationMonitor.Show();

                var exception = await App.SafeActionAsync(
                    async delegate
                {
                    using (var exportContext = await dataExporter.StartExportAsync(exportOptions, DataExportHelper.GetOrderedExportableColumns(ResultGrid), _outputViewer.DocumentPage.InfrastructureFactory.DataExportConverter, cancellationTokenSource.Token))
                    {
                        exportContext.SetProgress(_resultRows.Count, operationMonitor);
                        await exportContext.AppendRowsAsync(_resultRows);
                        await exportContext.FinalizeAsync();
                    }
                });

                operationMonitor.Close();

                var isOperationCanceledException = exception is OperationCanceledException;
                if (exception != null && !isOperationCanceledException)
                {
                    Messages.ShowError(exception.Message);
                }
            }
        }
Example #2
0
        private void btnSaveMatrix_Click(object sender, EventArgs e)
        {
            if (this.dlgSaveResults.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    OptModel.Properties[_result.Name] = _result;
                    string        filePath = dlgSaveResults.FileName;
                    IDataExporter exporter = null;
                    if (filePath.EndsWith(ExcelExporter.ExcelFileExtension, StringComparison.InvariantCultureIgnoreCase))
                    {
                        exporter = new ExcelExporter(new ExcelExporterSettings()
                        {
                            ExportWhat = ExportableData.Results, FilePath = filePath
                        });
                    }
                    else
                    {
                        exporter = new TextResultExporter(new TextResultExporterSettings()
                        {
                            ExportWhat = ExportableData.Results, FilePath = filePath
                        });
                    }

                    exporter.Export(OptModel);
                }
                catch (Exception ex)
                {
                    MessageBoxHelper.ShowError("Невозможно выполнить сохранение по указанному пути\nОригинальное сообщение: " + ex.Message);
                    return;
                }

                this.dlgSaveResults.FileName = string.Empty;
            }
        }
        public static void Register(string settingsFile, string costDataFile, string exportFile = "", EnExportType exportType = EnExportType.Console, IHtmlWrapper wrapper = null)
        {
            IMlogger          mLogger   = new Mlogger();
            IAppConfiguration appConfig = new ApplicationConfiguration(settingsFile, costDataFile);

            TinyIoCContainer.Current.Register <IMlogger>(mLogger);
            TinyIoCContainer.Current.Register <IAppConfiguration>(appConfig);
            IDataExporter exporter = null;

            switch (exportType)
            {
            case EnExportType.Console:
                exporter = new ConsoleWriter();
                break;

            case EnExportType.Csv:
                exporter = new CsvExporter(mLogger, exportFile);
                break;

            case EnExportType.Html:
                if (wrapper != null)
                {
                    exporter = new HtmlExporter(mLogger, exportFile, wrapper);
                }
                else
                {
                    // Fall back to Consolewriter - ideally we should log this failure...
                    exporter = new ConsoleWriter();
                }

                break;
            }
            TinyIoCContainer.Current.Register <IDataExporter>(exporter);
        }
 /// <inheritdoc />
 public ExportController(IServiceProvider provider,
                         ILogger <ExportController> logger,
                         IDataExporter exporter)
     : base(provider, logger)
 {
     _exporter = exporter;
 }
 public RenamingController(ILog log, IDataExporter <string> exporter, RenamingService service)
 {
     this._log         = log ?? new ConsoleHLog(); // Until we get DI working and find a way to call ctors from electron.
     this._exporter    = exporter;
     this._service     = service;
     this._service.Log = _log; // Until we have DI and some Singleton/Factory
 }
 public DataExportTask(
     IDataExporter exporter,
     IExportProfileService exportProfileService)
 {
     _exporter             = exporter;
     _exportProfileService = exportProfileService;
 }
Example #7
0
        private void mnuExportResults_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            IDataExporter  dataExporter   = null;

            try
            {
                // Ask user where they would like to save the file
                saveFileDialog.Filter = "CSV|*.csv|json|*.json|XML Document|*.xml";
                saveFileDialog.ShowDialog();

                if (String.IsNullOrEmpty(saveFileDialog.FileName))
                {
                    return;
                }

                // Delete existing file
                if (File.Exists(saveFileDialog.FileName))
                {
                    File.Delete(saveFileDialog.FileName);
                }

                dataExporter = DataExporterFactory.Create(saveFileDialog.FileName, dgvResults);
                dataExporter.Run();

                // Open when complete
                ProcessManager.OpenFile(saveFileDialog.FileName);
            }
            catch (Exception ex)
            {
                DisplayError(ex);
            }
        }
Example #8
0
 public HackerNewsScraper(IDataImporter <string, string> importer, IDataParser <string, IEnumerable <Post> > parser,
                          IDataFormatter <List <Post>, string> formatter, IDataExporter <string> exporter)
 {
     _importer  = importer;
     _parser    = parser;
     _formatter = formatter;
     _exporter  = exporter;
 }
 public AzureManagement(IMlogger logger, IAppConfiguration configuration, IDataExporter dataExporter)
 {
     Logger = logger;
     Configuration = configuration;
     var subscriptionId = configuration.SubscriptionId();
     var base64EncodedCertificate = configuration.Base64EncodedManagementCertificate();
     MyCloudCredentials = getCredentials(subscriptionId, base64EncodedCertificate);
     Exporter = dataExporter;
 }
Example #10
0
 public EntityController(IWebAppContext appContext
                         , IQueryViewFinder queryViewFinder
                         , IDataExporter dataExporter
                         )
     : base(appContext)
 {
     _queryViewFinder = queryViewFinder;
     _dataExporter    = dataExporter;
 }
Example #11
0
 private void ExportData(IDataExporter exporter, string fileName)
 {
     using (var resultSet = new EasyDbResultSet(EqManager.Query,
                                                ResultDS.Tables[0].CreateDataReader(),
                                                EqManager.ResultSetOptions))
         using (var fileStream = File.OpenWrite(fileName))
             exporter.Export(resultSet, fileStream);
     Process.Start(fileName);
 }
        public AzureManagement(IMlogger logger, IAppConfiguration configuration, IDataExporter dataExporter)
        {
            Logger        = logger;
            Configuration = configuration;
            var subscriptionId           = configuration.SubscriptionId();
            var base64EncodedCertificate = configuration.Base64EncodedManagementCertificate();

            MyCloudCredentials = getCredentials(subscriptionId, base64EncodedCertificate);
            Exporter           = dataExporter;
        }
Example #13
0
 private void ExportCategories(IDataExporter exporter, Category cat)
 {
     foreach (var category in cat.Categories)
     {
         exporter.AddCategory(category);
         if (category.Categories.Count > 0)
         {
             ExportCategories(exporter, category);
         }
     }
 }
Example #14
0
 public ExportJob(IDataExporter dataExporter,
                  IPushNotificationManager pushNotificationManager,
                  IExportProviderFactory exportProviderFactory,
                  IModuleInitializerOptions moduleInitializerOptions,
                  ISettingsManager settingsManager)
 {
     _dataExporter            = dataExporter;
     _pushNotificationManager = pushNotificationManager;
     _exportProviderFactory   = exportProviderFactory;
     _settingsManager         = settingsManager;
     _defaultExportFolder     = moduleInitializerOptions.VirtualRoot + "/App_Data/Export/";
 }
        public async Task ExportItem(IContent content, IDataExporter exporter, IContentLoader contentLoader)
        {
            var exportedFileLocation = Path.GetTempFileName();
            var stream   = new FileStream(exportedFileLocation, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
            var settings = new Dictionary <string, object>
            {
                [this._contentSyncOptions.SettingPageLink]    = content.ContentLink,
                [this._contentSyncOptions.SettingRecursively] = false,
                [this._contentSyncOptions.SettingPageFiles]   = true,
                [this._contentSyncOptions.SettingIncludeContentTypeDependencies] = true
            };

            var sourceRoots = new List <ExportSource>
            {
                new ExportSource(content.ContentLink, ExportSource.NonRecursive)
            };

            var options = ExportOptions.DefaultOptions;

            options.ExcludeFiles = false;
            options.IncludeReferencedContentTypes = true;

            contentLoader.TryGet(content.ParentLink, out IContent parent);

            var state = new ExportState
            {
                Stream       = stream,
                Exporter     = exporter,
                FileLocation = exportedFileLocation,
                Options      = options,
                SourceRoots  = sourceRoots,
                Settings     = settings,
                Parent       = parent?.ContentGuid ?? Guid.Empty
            };

            if (state.Parent == Guid.Empty)
            {
                return;
            }

            try
            {
                exporter.Export(state.Stream, state.SourceRoots, state.Options);
                exporter.Dispose();
                await SendContent(state.FileLocation, state.Parent);
            }
            catch (Exception ex)
            {
                exporter.Abort();
                exporter.Status.Log.Error("Can't export package because: {0}", ex, ex.Message);
            }
        }
Example #16
0
 public WdaqService(
     IWdaqFileService wdaqFileService,
     ILogService logService,
     IWdaqDataParser dataParser,
     IDataExporter dataExporter,
     IWdaqSettingService settingService)
 {
     _wdaqFileService = wdaqFileService;
     _logService      = logService;
     _dataParser      = dataParser;
     _dataExporter    = dataExporter;
     _settingService  = settingService;
 }
Example #17
0
        private void addAsAttachment(IDataExporter exporter, byte[] data)
        {
            if (string.IsNullOrEmpty(exporter.FileName))
                throw new InvalidOperationException("Please fill the exporter.FileName.");

            if (string.IsNullOrEmpty(exporter.Description))
                exporter.Description = "Exported data";

            var pdfDictionary = new PdfDictionary();
            pdfDictionary.Put(PdfName.MODDATE, new PdfDate(DateTime.Now));
            var fs = PdfFileSpecification.FileEmbedded(_sharedData.PdfWriter, null, exporter.FileName, data, true, null, pdfDictionary);
            _sharedData.PdfWriter.AddFileAttachment(exporter.Description, fs);
        }
Example #18
0
 public EventFinder(
     IDocumentUtilty documentUtility,
     IScraperService scraperService,
     IDataExporter <EventModel> eventExporter,
     Action <string> outputHandle,
     string document)
 {
     _scraperService = scraperService;
     _eventExporter  = eventExporter;
     _documentUtilty = documentUtility;
     _outputHandle   = outputHandle;
     _documentUtilty.LoadDocument(document);
 }
Example #19
0
        public ExportDataFilter(ExportType exportType, string exportFileName)
        {
            _exportType = exportType;
            _exporter   = _exporterFactory.CreateDataExporter(exportType);
            SetAcceptHeaderAndFileExtension();

            _exportFileName = exportFileName;

            if (string.IsNullOrEmpty(_acceptHeader) || string.IsNullOrEmpty(_exportFileName))
            {
                throw new ArgumentException();
            }
        }
Example #20
0
 public DataImporterController(IWebAppContext appContext
                               , IDataImporter dataImporter
                               , IDataExporter dataExporter
                               , IImportDataService importDataService
                               , IImportFileService importFileService
                               , IImportMapService importMapService)
     : base(appContext)
 {
     _dataImporter      = dataImporter;
     _dataExporter      = dataExporter;
     _importDataService = importDataService;
     _importFileService = importFileService;
     _importMapService  = importMapService;
 }
        private void ExportData(IDataExporter exporter, string fileName)
        {
            var resultDt = ((DataView)datGrid.ItemsSource).ToTable();

            using (var resultSet = new EasyDbResultSet(EqManager.Query, resultDt.CreateDataReader(), EqManager.ResultSetOptions))
                using (var fileStream = File.OpenWrite(fileName))
                    exporter.Export(resultSet, fileStream);

            new Process
            {
                StartInfo = new ProcessStartInfo(fileName)
                {
                    UseShellExecute = true
                }
            }.Start();
        }
Example #22
0
        private void ExportData(IDataExporter exporter, string fileName)
        {
            using (var resultSet = new EasyDbResultSet(EqManager.Query,
                                                       ResultDS.Tables[0].CreateDataReader(),
                                                       EqManager.ResultSetOptions))
                using (var fileStream = File.OpenWrite(fileName))
                    exporter.Export(resultSet, fileStream);

            new Process
            {
                StartInfo = new ProcessStartInfo(fileName)
                {
                    UseShellExecute = true
                }
            }.Start();
        }
 public ExportJob(IDataExporter dataExporter,
                  IPushNotificationManager pushNotificationManager,
                  IOptions <PlatformOptions> platformOptions,
                  IExportProviderFactory exportProviderFactory,
                  ISettingsManager settingsManager,
                  IBlobStorageProvider blobStorageProvider,
                  IBlobUrlResolver blobUrlResolver)
 {
     _dataExporter            = dataExporter;
     _pushNotificationManager = pushNotificationManager;
     _platformOptions         = platformOptions.Value;
     _exportProviderFactory   = exportProviderFactory;
     _settingsManager         = settingsManager;
     _blobStorageProvider     = blobStorageProvider;
     _blobUrlResolver         = blobUrlResolver;
 }
        private void addAsAttachment(IDataExporter exporter, byte[] data)
        {
            if (string.IsNullOrEmpty(exporter.FileName))
            {
                throw new InvalidOperationException("Please fill the exporter.FileName.");
            }

            if (string.IsNullOrEmpty(exporter.Description))
            {
                exporter.Description = "Exported data";
            }

            var pdfDictionary = new PdfDictionary();

            pdfDictionary.Put(PdfName.Moddate, new PdfDate(DateTime.Now));
            var fs = PdfFileSpecification.FileEmbedded(_sharedData.PdfWriter, null, exporter.FileName, data, true, null, pdfDictionary);

            _sharedData.PdfWriter.AddFileAttachment(exporter.Description, fs);
        }
        private static void InitDataExchangers()
        {
            dataExporters = new List <IDataExchanger> ();
            dataImporters = new List <IDataExchanger> ();

            foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/Warehouse/Business/Exchange"))
            {
                object        instance = node.CreateInstance();
                IDataExporter exporter = instance as IDataExporter;
                if (exporter != null)
                {
                    dataExporters.Add(exporter);
                }

                IDataImporter importer = instance as IDataImporter;
                if (importer != null)
                {
                    dataImporters.Add(importer);
                }
            }
        }
Example #26
0
 public ExportController(
     SmartDbContext db,
     IExportProfileService exportProfileService,
     ICategoryService categoryService,
     IDataExporter dataExporter,
     ITaskScheduler taskScheduler,
     IProviderManager providerManager,
     ITaskStore taskStore,
     DataExchangeSettings dataExchangeSettings,
     CustomerSettings customerSettings)
 {
     _db = db;
     _exportProfileService = exportProfileService;
     _categoryService      = categoryService;
     _dataExporter         = dataExporter;
     _taskScheduler        = taskScheduler;
     _providerManager      = providerManager;
     _taskStore            = taskStore;
     _dataExchangeSettings = dataExchangeSettings;
     _customerSettings     = customerSettings;
 }
Example #27
0
 public DefaultDataExporterInterceptor(IDataExporter defaultDataExporter
                                       , ITransferExportOptionsEx transferExportOptionsEx
                                       , IContentVersionRepository contentVersionRepository
                                       , IRawContentRetriever rawContentRetriever
                                       , IContentLoader contentLoader
                                       , IPropertyExporter propertyExporter
                                       , IDataExportEventsRaiser eventRegister
                                       , IDataExportEvents exportEvents
                                       , IContentCacheKeyCreator contentCacheKeyCreator
                                       , ISynchronizedObjectInstanceCache cacheInstance
                                       , IContentRepository contentRepository
                                       , IPermanentLinkMapper permanentLinkMapper
                                       , IContentTypeRepository contentTypeRepository
                                       , IContentProviderManager contentProviderManager
                                       , ContentTypeAvailabilityService contentTypeAvailabilityService
                                       , IAvailableSettingsRepository availableSettingsRepository
                                       , IContentExporter contentExporter
                                       , PropertyCategoryTransform categoryTransform
                                       , ContentRootRepository contentRootRepository
                                       , ISiteDefinitionRepository siteDefinitionRepository
                                       , IMimeTypeResolver mimeTypeResolver)
     : base(eventRegister, exportEvents, contentCacheKeyCreator
            , cacheInstance, contentRepository
            , permanentLinkMapper, contentTypeRepository
            , contentProviderManager, contentTypeAvailabilityService
            , availableSettingsRepository, contentExporter
            , categoryTransform, contentRootRepository
            , siteDefinitionRepository, mimeTypeResolver)
 {
     _defaultDataExporter      = defaultDataExporter;
     _transferExportOptionsEx  = transferExportOptionsEx;
     _contentVersionRepository = contentVersionRepository;
     _contentExporter          = contentExporter;
     _rawContentRetiever       = rawContentRetriever;
     _contentLoader            = contentLoader;
     _propertyExporter         = propertyExporter;
 }
Example #28
0
 public DataExportTask(SmartDbContext db, IDataExporter dataExporter, IProviderManager providerManager)
 {
     _db              = db;
     _dataExporter    = dataExporter;
     _providerManager = providerManager;
 }
Example #29
0
        public DataTransferController(IConfigurationDbContext configurationDatabaseContext, IDataExporter dataExporter, IDataImporter dataImporter, IFacade facade, IFeatureManager featureManager, IServiceProvider serviceProvider) : base(facade)
        {
            this.ConfigurationDatabaseContext = configurationDatabaseContext ?? throw new ArgumentNullException(nameof(configurationDatabaseContext));
            this.DataExporter   = dataExporter ?? throw new ArgumentNullException(nameof(dataExporter));
            this.DataImporter   = dataImporter ?? throw new ArgumentNullException(nameof(dataImporter));
            this.FeatureManager = featureManager ?? throw new ArgumentNullException(nameof(featureManager));

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (featureManager.IsEnabled(Feature.Saml))
            {
                this.SamlDatabaseContext = serviceProvider.GetRequiredService <ISamlConfigurationDbContext>();
            }

            if (featureManager.IsEnabled(Feature.WsFederation))
            {
                this.WsFederationDatabaseContext = serviceProvider.GetRequiredService <IWsFederationConfigurationDbContext>();
            }
        }
Example #30
0
 /// <summary>
 /// Sets the desired exporters such as ExportToExcel.
 /// </summary>
 /// <param name="exportSettings">export settings</param>
 public void ToCustomFormat(IDataExporter exportSettings)
 {
     _pdfReport.DataBuilder.CustomExportSettings.Add(exportSettings);
 }
Example #31
0
        private static async Task <string> GenerateExportFile(DataGridResultViewer resultViewer, IDataExporter dataExporter)
        {
            var tempFileName            = Path.GetTempFileName();
            var connectionConfiguration = ConfigurationProvider.GetConnectionConfiguration(ConfigurationProvider.ConnectionStrings[0].Name);

            Thread.CurrentThread.CurrentCulture = CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            using (var exportContext = await dataExporter.StartExportAsync(ExportOptions.ToFile(tempFileName, resultViewer.Title), DataExportHelper.GetOrderedExportableColumns(resultViewer.ResultGrid), connectionConfiguration.InfrastructureFactory.DataExportConverter, CancellationToken.None))
            {
                await exportContext.AppendRowsAsync(resultViewer.ResultGrid.Items.Cast <object[]>());

                await exportContext.FinalizeAsync();
            }

            return(tempFileName);
        }
Example #32
0
        private static async Task <string> GetExportContent(DataGridResultViewer resultViewer, IDataExporter dataExporter)
        {
            var tempFileName = await GenerateExportFile(resultViewer, dataExporter);

            var result = File.ReadAllText(tempFileName);

            File.Delete(tempFileName);
            return(result);
        }
Example #33
0
 public ExportController(IDataExporter service)
 {
     Service = service;
 }
Example #34
0
		private static async Task<string> GenerateExportFile(DataGridResultViewer resultViewer, IDataExporter dataExporter)
		{
			var tempFileName = Path.GetTempFileName();
			var connectionConfiguration = ConfigurationProvider.GetConnectionConfiguration(ConfigurationProvider.ConnectionStrings[0].Name);
			Thread.CurrentThread.CurrentCulture = CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

			using (var exportContext = await dataExporter.StartExportAsync(ExportOptions.ToFile(tempFileName, resultViewer.Title), DataExportHelper.GetOrderedExportableColumns(resultViewer.ResultGrid), connectionConfiguration.InfrastructureFactory.DataExportConverter, CancellationToken.None))
			{
				await exportContext.AppendRowsAsync(resultViewer.ResultGrid.Items.Cast<object[]>());
				await exportContext.FinalizeAsync();
			}

			return tempFileName;
		}
Example #35
0
		private static async Task<string> GetExportContent(DataGridResultViewer resultViewer, IDataExporter dataExporter)
		{
			var tempFileName = await GenerateExportFile(resultViewer, dataExporter);

			var result = File.ReadAllText(tempFileName);
			File.Delete(tempFileName);
			return result;
		}
 public AzureManagementDownloader(IMlogger logger, IAppConfiguration configuration, IDataExporter dataExporter)
     : base(logger, configuration, dataExporter)
 {
 }
Example #37
0
		private async Task ExportData(IDataExporter dataExporter, ExportOptions exportOptions)
		{
			using (var cancellationTokenSource = new CancellationTokenSource())
			{
				var operationMonitor = new WindowOperationMonitor(cancellationTokenSource) { IsIndeterminate = false };
				operationMonitor.Show();

				var exception = await App.SafeActionAsync(
					async delegate
					{
						using (var exportContext = await dataExporter.StartExportAsync(exportOptions, DataExportHelper.GetOrderedExportableColumns(ResultGrid), _outputViewer.DocumentPage.InfrastructureFactory.DataExportConverter, cancellationTokenSource.Token))
						{
							exportContext.SetProgress(_resultRows.Count, operationMonitor);
							await exportContext.AppendRowsAsync(_resultRows);
							await exportContext.FinalizeAsync();
						}
					});

				operationMonitor.Close();

				var isOperationCanceledException = exception is OperationCanceledException;
				if (exception != null && !isOperationCanceledException)
				{
					Messages.ShowError(exception.Message);
				}
			}
		}