static void Main(string[] args) { DataExporter exporter = null; // Lets export the data to Excel file exporter = new ExcelExporter(); exporter.ExportFormattedData(); System.Console.WriteLine(); // Lets export the data to PDF file exporter = new PDFExporter(); exporter.ExportFormattedData(); }
private void ExportFile(DataExporter dataExporter) { try { var msg = PluginLoader.ExportFile <Customer>(Customers, FileName, dataExporter) ? "Export Success" : "Export faild"; MessageBox.Show(msg); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Starts this instance. /// </summary> /// <exception cref="System.NotImplementedException"></exception> public void Start() { if (IsDisposed) { Logger.Warn("Cannot Start DataReporter - it has been Disposed."); return; } if (IsStarted) { Logger.Info("Cannot Start DataReporter - it has already been started."); return; } Logger.Debug($"Starting DataReporter - DataExporter is a {DataExporter.GetType()}"); lock (_locker) { IsStarted = true; // Set up timers for triggering push of data to HMS Cloud service. CasinoDataReportTimer = new CHGTimer(); CasinoDataReportTimer.TimerEvent += GetEgmDataForReport; CasinoDataReportTimer.Start(TimeSpan.FromMinutes(Settings.Default.CloudReportStartupDelay), TimeSpan.FromMinutes(Settings.Default.CloudReportInterval)); // Note that if DoReportToCloud configuration parameter is set to False, // we set the DataBackup timers such that they never trigger DataBackupTimer = new CHGTimer(); DataBackupTimer.TimerEvent += GetWeeklyDataBackupFiles; DataBackupTimer.Start(Settings.Default.DoReportToCloud ? TimeSpan.FromMinutes(Settings.Default.DataBackupStartupDelay) : CHGTimer.DisableTimer, Settings.Default.DoReportToCloud ? TimeSpan.FromMinutes(Settings.Default.DataBackupInterval) : CHGTimer.DisableTimer); // Note that if DoReportToCloud configuration parameter is set to False, // we set the DiagnosticFile timers such that they never trigger DiagnosticsTimer = new CHGTimer(); DiagnosticsTimer.TimerEvent += GetDiagnosticsFiles; DiagnosticsTimer.Start(Settings.Default.DoReportToCloud ? TimeSpan.FromMinutes(Settings.Default.DiagnosticsStartupDelay) : CHGTimer.DisableTimer, Settings.Default.DoReportToCloud ? TimeSpan.FromMinutes(Settings.Default.DiagnosticsInterval) : CHGTimer.DisableTimer); } }
public void Diff() { var dataTableFromLeftSource = ReaderOfLeftDataSource.Read(ReadOptionsOfLeftSource); var dataTableFromRightSource = ReaderOfRightDataSource.Read(ReadOptionsOfRightSource); DataMerger = new DataMerger(dataTableFromLeftSource, dataTableFromRightSource , MergeOptions , ColumnNameBuilder); var mergeResult = DataMerger.Merge(); lock (ExportLockObject) { DataExporter.Export(mergeResult, ExportOptions, ExcelHighlighter); } }
private IEnumerator ExportModels() { while (this.modelsToExport.Count > 0) { this.helpMessage.text = string.Format("Exporting models... ({0} remaining)", this.modelsToExport.Count); // Export the next model string model = this.modelsToExport.Dequeue() as string; GameObject go = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("ComponentPrefabs/" + model)); DataExporter.ExportModel(go, model); GameObject.Destroy(go); // Free up the UI for a bit yield return(new WaitForSeconds(0.25f)); } }
private void exportarVendaPorPJ_Click(object sender, RoutedEventArgs e) { //Verifica se tem algum sapato delecionado if (PessoaJuridicaSelecionada.ID == 0) { //Menssagem de aviso MessageBox.Show("Selecione uma pessoa para gerar o relatório", "Aviso", MessageBoxButton.OK); } else { //Instancia a classe de exportação e o contexto DataExporter exportador = new DataExporter(); ModelSapatos ctx = new ModelSapatos(); //Instancia um explorador de arquivos Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); //Filtro do dialogo dlg.Filter = "Excel (.xlsx)|*.xlsx"; //Define atributos para o arquivo dlg.FileName = "Relatório de vendas do cliente " + PessoaJuridicaSelecionada.Nome; // Nome padrão dlg.DefaultExt = ".xlsx"; // Extensão do arquivo //Pega o resultado, se o usuário apertou cancel ou deu continuidade Nullable <bool> result = dlg.ShowDialog(); //Se o usuário selecionou um local ele execulta o metodo if (result == true) { //Busca lista de vendas var vendas = ctx.vendas.Where(t => t.pessoaId == PessoaJuridicaSelecionada.ID).Select(t => t).ToList(); //Chama o metodo para gerar a lista if (exportador.CriarPlanilhaVendaPorPJ(vendas, PessoaJuridicaSelecionada, dlg.FileName) == true) { //Mostra mensagem MessageBox.Show("Planilha gerada com sucesso", "Sucesso", MessageBoxButton.OK); } else { //Mostra mensagem MessageBox.Show("Erro ao gerar planilha", "Erro", MessageBoxButton.OK); } } } }
void OnMenuItemExportClick(object sender, EventArgs e) { var saveWindow = new SaveFileDialog { FileName = $"Personal Activity Monitor ({DateTime.Now.ToShortDateString()}).xml", Filter = "Xml file (.xml)|*.xml" }; //saveWindow.FileName = "pamResult.xml"; if (saveWindow.ShowDialog() != true) { return; } var exporter = new DataExporter(monitor.Data); exporter.SaveToXml(saveWindow.OpenFile()); }
protected override void Extract(DataReader uimf, FileInfo originFile, int frameNumber) { foreach (var xicTarget in Options.XicTargetList) { var xicData = GetXicInfo(uimf, frameNumber, xicTarget.TargetMz, xicTarget.Tolerance, this.Options.Getmsms); var xicOutputFile = DataExporter.GetOutputLocation( originFile, "XiC_mz_" + xicTarget.TargetMz + "_tolerance_" + xicTarget.Tolerance + "_Frame", frameNumber); if (xicData == null) { return; } DataExporter.OutputXiCbyTime(xicData, xicOutputFile, this.Options.Verbose); } }
public void Debug() { string query = @" select top 100 * from[Database].[Schema].[Table] inner join[Database].[Schema].[Table] on[Database].[Schema].[Table].[Field] = [Database].[Schema].[Table].[Field] where[Database].[Schema].[Table].[Field] = 'Value' "; string scriptsDir = @"C:\Users\user\Desktop\localdb\Database\_Data"; string server = "someServer"; string database = "database"; string configServer = "configServer"; DataExporter dataExporter = new DataExporter(server, database, configServer, "localdatabase"); dataExporter.ExportDataToScripts(query, scriptsDir, DatabaseDevelopment.Enums.DataScriptType.Test, DatabaseDevelopment.Enums.SqlScriptType.Merge, true, true, true, "Test"); }
internal static void Process(SpawnNpcServerMessage message) { PacketProcessor.Instance.EntityTracker.Update(message); DamageTracker.Instance.UpdateEntities(message); if (message.NpcArea == 950 && message.NpcId == 9501) { var bosses = Database.Database.Instance.AllEntity().Select(x => PacketProcessor.Instance.EntityTracker.GetOrNull(x)).OfType <NpcEntity>().ToList(); var vergosPhase2Part1 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 1000); var vergosPhase2Part2 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 2000); DataExporter.AutomatedExport(vergosPhase2Part1, PacketProcessor.Instance.AbnormalityStorage); DataExporter.AutomatedExport(vergosPhase2Part2, PacketProcessor.Instance.AbnormalityStorage); } if (message.NpcArea == 950 && message.NpcId == 9502) { var bosses = Database.Database.Instance.AllEntity().Select(x => PacketProcessor.Instance.EntityTracker.GetOrNull(x)).OfType <NpcEntity>(); var vergosPhase3 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 3000); DataExporter.AutomatedExport(vergosPhase3, PacketProcessor.Instance.AbnormalityStorage); } }
protected override IEnumerable<PeakSet> BulkPeakFind(DataReader uimf, FileInfo originFile, int frameNumber) { var mzData = GetFullMzInfo(uimf, frameNumber); var doubleMzData = mzData.Select( keyValuePair => new KeyValuePair<double, double>(keyValuePair.Key, keyValuePair.Value)) .ToList(); var mzpeaks = PeakFinder.FindPeaks(doubleMzData); var mzPeakOutputLocation = DataExporter.GetOutputLocation( originFile, "Mz_Peaks", frameNumber, "xml"); DataExporter.OutputPeaks(mzpeaks, mzPeakOutputLocation); var peakSet = new List<PeakSet>(); peakSet.Add(mzpeaks); return peakSet; }
public void OnExportHistory() { if (currentSet.ArrowCount < 1) { MessageBox.Show(GlobalStrings.NoDataToExport); return; } save.InitialDirectory = DataExporter.ExportDirectory; save.Title = GlobalStrings.SerializerExportToFile; save.FileName = ""; save.Filter = DataExporter.AvailableExportFormats; if (save.ShowDialog() != DialogResult.Cancel) { var dataConverter = new DataConverter(currentSet, historyView); var dataExporter = new DataExporter(save.FilterIndex); dataExporter.ExportFailed += OnFailed; dataExporter.ExportSuccessful += OnExportSuccessful; dataExporter.ExportToFile(dataConverter.ConvertToArray(true), save.FileName); } }
protected override IEnumerable <PeakSet> BulkPeakFind(DataReader uimf, FileInfo originFile, int frameNumber) { var ticData = GetFullScanInfo(uimf, frameNumber); var doubleTicData = ticData.Select(scanInfo => new KeyValuePair <double, double>(scanInfo.DriftTime, scanInfo.TIC)) .ToList(); var ticPeaks = PeakFinder.FindPeaks(doubleTicData); var mzPeakOutputLocation = DataExporter.GetOutputLocation( originFile, "TiC_Peaks", frameNumber, "xml"); DataExporter.OutputPeaks(ticPeaks, mzPeakOutputLocation); var peakSets = new List <PeakSet>(); peakSets.Add(ticPeaks); return(peakSets); }
protected override IEnumerable <PeakSet> BulkPeakFind(DataReader uimf, FileInfo originFile, int frameNumber) { var peakSets = new List <PeakSet>(); foreach (var xicTarget in Options.XicTargetList) { var xicData = GetXicInfo(uimf, frameNumber, xicTarget.TargetMz, xicTarget.Tolerance, this.Options.Getmsms); var xicPeaks = PeakFinder.FindPeaks(xicData); var xicPeakOutputLocation = DataExporter.GetOutputLocation( originFile, "XiC_Peaks_mz_" + xicTarget.TargetMz + "_tolerance_" + xicTarget.Tolerance + "_Frame", frameNumber, "xml"); DataExporter.OutputPeaks(xicPeaks, xicPeakOutputLocation); peakSets.Add(xicPeaks); } return(peakSets); }
public void Test_MoveToImported() { TestUser user = new TestUser(); user.ID = Guid.NewGuid(); user.FirstName = "Test"; user.LastName = "Test"; DataExporter exporter = (DataExporter)DataAccess.Data.InitializeDataExporter(); exporter.ExportDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Exported"; // Export the user to XML exporter.ExportEntity(user); DataImporter importer = (DataImporter)DataAccess.Data.InitializeDataImporter(); importer.ImportableDirectoryPath = exporter.ExportDirectoryPath; importer.ImportedDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Imported"; // Test the move to imported function importer.MoveToImported(user, importer.CreateImportableEntityPath(user)); string importedPath = importer.CreateImportedEntityPath(user); int importableCount = 0; foreach (string dir in Directory.GetDirectories(importer.ImportableDirectoryPath)) { importableCount += Directory.GetFiles(dir, "*.xml").Length; } Assert.AreEqual(0, importableCount, "Incorrect number of files found in importable folder."); bool foundImported = File.Exists(importedPath); Assert.IsTrue(foundImported, "Imported file not found."); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (storage_lay != null && storage_stay != null) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Word файл (*.docx)|*.docx"; dialog.FilterIndex = 1; dialog.RestoreDirectory = true; bool success = true; if (dialog.ShowDialog() == true) { try { var filename = dialog.FileName; DataExporter.ExportToDOCCompare(filename, patient, studyDate.ToShortDateString(), storage_lay, storage_stay); } catch (Exception) { success = false; } if (!success) { MessageBox.Show("Не удалось сохранить файл", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show("Файл успешно сохранен", "Информация", MessageBoxButton.OK, MessageBoxImage.Information); } } } }
public Plotter(PlotView forcesPlot, PlotView xxtxttPlot, PlotView statePlot) { _forcesPlot = forcesPlot; _xxtxttPlot = xxtxttPlot; _statePlot = statePlot; _plots = new PlotView[] { _forcesPlot, _xxtxttPlot, _statePlot }; _forcesModel = DataExporter.CreateModel("Forces Graph", "f(t)", "g(t)", "h(t)", "w(t)"); _xxtxttModel = DataExporter.CreateModel("Motion Graph", "x(t)", "x_t(t)", "x_tt(t)"); _stateModel = DataExporter.CreateModel("State Graph", "State Vector"); _forcesPlot.Model = _forcesModel; _xxtxttPlot.Model = _xxtxttModel; _statePlot.Model = _stateModel; SetGridlines(_forcesModel); SetGridlines(_xxtxttModel); SetGridlines(_stateModel); SetAxesLabels(_forcesModel, "Time", "Force"); SetAxesLabels(_xxtxttModel, "Time", "Value"); SetAxesLabels(_stateModel, "Position", "Velocity"); }
public void OnExportJson() { Debug.Log("Clicked OnExportJson"); DataExporter.ExportJson(); }
public Task PriceJsonExport() { //Arrange IKnownExportTypesRegistrar registrar = new KnownExportTypesService(); var searchServiceMock = new Mock <IPricingSearchService>(); searchServiceMock.Setup(x => x.SearchPrices(It.Is <PricesSearchCriteria>(y => y.Skip == 0))).Returns(GetTestPriceResult <Price>()); searchServiceMock.Setup(x => x.SearchPrices(It.Is <PricesSearchCriteria>(y => y.Skip > 0))).Returns(new PricingSearchResult <Price>()); var priceServiceMock = new Mock <IPricingService>(); var itemServiceMock = new Mock <IItemService>(); var metadata = typeof(ExportablePrice).GetPropertyNames(); var resolver = (IKnownExportTypesResolver)registrar; registrar.RegisterType(ExportedTypeDefinitionBuilder.Build <ExportablePrice, PriceExportDataQuery>() .WithDataSourceFactory(new PriceExportPagedDataSourceFactory(searchServiceMock.Object, priceServiceMock.Object, itemServiceMock.Object, null)) .WithMetadata(metadata)); var includedPropertyNames = new string[] { "Currency", "ProductId", "Sale", "List", "MinQuantity", "StartDate", "EndDate", "EffectiveValue" }; var IncludedProperties = metadata.PropertyInfos.Where(x => includedPropertyNames.Contains(x.FullName, StringComparer.OrdinalIgnoreCase)).ToArray(); var exportProviderFactories = new[] { new Func <ExportDataRequest, IExportProvider>((request) => new JsonExportProvider(request)), }; var dataExporter = new DataExporter(resolver, new ExportProviderFactory(exportProviderFactories)); //Act var result = string.Empty; using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream, Encoding.UTF8) { AutoFlush = true }) { dataExporter.Export( stream, new ExportDataRequest() { DataQuery = new PriceExportDataQuery() { IncludedProperties = IncludedProperties }, ExportTypeName = typeof(ExportablePrice).FullName, ProviderName = nameof(JsonExportProvider) }, new Action <ExportProgressInfo>(x => Console.WriteLine(x.Description)), new CancellationTokenWrapper(CancellationToken.None)); stream.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(stream); result = reader.ReadToEnd(); } //Assert var prices = JsonConvert.DeserializeObject <ExportablePrice[]>(result); Assert.NotNull(prices); Assert.Equal(3, prices.Length); Assert.Equal(2, prices.Count(x => x.List == 3.99m)); Assert.Equal(1, prices.Count(x => x.ProductId == "d029526eab5948b189694f1bddba8e68")); return(Task.CompletedTask); }
public Task PriceCsvExport() { IKnownExportTypesRegistrar registrar = new KnownExportTypesService(); var resolver = (IKnownExportTypesResolver)registrar; var searchServiceMock = new Mock <IPricingSearchService>(); searchServiceMock.Setup(x => x.SearchPrices(It.Is <PricesSearchCriteria>(y => y.Skip == 0))).Returns(GetTestPriceResult <Price>()); searchServiceMock.Setup(x => x.SearchPrices(It.Is <PricesSearchCriteria>(y => y.Skip > 0))).Returns(new PricingSearchResult <Price>()); var priceServiceMock = new Mock <IPricingService>(); var itemServiceMock = new Mock <IItemService>(); var metadata = typeof(ExportablePrice).GetPropertyNames(); registrar.RegisterType(ExportedTypeDefinitionBuilder.Build <ExportablePrice, PriceExportDataQuery>() .WithDataSourceFactory(new PriceExportPagedDataSourceFactory(searchServiceMock.Object, priceServiceMock.Object, itemServiceMock.Object, null)) .WithMetadata(metadata) .WithTabularMetadata(typeof(TabularPrice).GetPropertyNames())); var exportProviderFactories = new[] { new Func <ExportDataRequest, IExportProvider>((request) => new JsonExportProvider(request)), new Func <ExportDataRequest, IExportProvider>((request) => new CsvExportProvider(request)), }; var includedPropertyNames = new string[] { "Currency", "ProductId" }; var IncludedProperties = metadata.PropertyInfos.Where(x => includedPropertyNames.Contains(x.FullName, StringComparer.OrdinalIgnoreCase)).ToArray(); var dataExporter = new DataExporter(resolver, new ExportProviderFactory(exportProviderFactories)); var result = string.Empty; using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream, Encoding.UTF8) { AutoFlush = true }) { dataExporter.Export( stream, new ExportDataRequest() { DataQuery = new PriceExportDataQuery() { IncludedProperties = IncludedProperties, }, ExportTypeName = typeof(ExportablePrice).FullName, ProviderName = nameof(CsvExportProvider) }, new Action <ExportProgressInfo>(x => Console.WriteLine(x.Description)), new CancellationTokenWrapper(CancellationToken.None)); stream.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(stream); result = reader.ReadToEnd(); } Assert.Equal("Currency,ProductId\r\nUSD,d029526eab5948b189694f1bddba8e68\r\nEUR,85e7aa089a4e4a97a4394d668e37e3f8\r\nEUR,f427108e75ed4676923ddc47632111e3\r\n", result); return(Task.CompletedTask); }
public Task PricelistAssignmentJsonExport() { IKnownExportTypesRegistrar registrar = new KnownExportTypesService(); var searchServiceMock = new Mock <IPricingSearchService>(); searchServiceMock.Setup(x => x.SearchPricelistAssignments(It.Is <PricelistAssignmentsSearchCriteria>(y => y.Skip == 0))).Returns(GetPricelistAssignmentSearchResult <PricelistAssignment>()); searchServiceMock.Setup(x => x.SearchPricelistAssignments(It.Is <PricelistAssignmentsSearchCriteria>(y => y.Skip > 0))).Returns(new PricingSearchResult <PricelistAssignment>()); var priceServiceMock = new Mock <IPricingService>(); var catalogServiceMock = new Mock <ICatalogService>(); var metadata = typeof(ExportablePricelistAssignment).GetPropertyNames(); var resolver = (IKnownExportTypesResolver)registrar; registrar.RegisterType(ExportedTypeDefinitionBuilder.Build <ExportablePricelistAssignment, PricelistAssignmentExportDataQuery>() .WithDataSourceFactory(new PricelistAssignmentExportPagedDataSourceFactory(searchServiceMock.Object, priceServiceMock.Object, catalogServiceMock.Object)) .WithMetadata(metadata)); var exportProviderFactories = new[] { new Func <ExportDataRequest, IExportProvider>((request) => new JsonExportProvider(request)), }; var dataExporter = new DataExporter(resolver, new ExportProviderFactory(exportProviderFactories)); var includedPropertyNames = new string[] { "CatalogId", "PricelistId", "Priority", "Id" }; var IncludedProperties = metadata.PropertyInfos.Where(x => includedPropertyNames.Contains(x.FullName, StringComparer.OrdinalIgnoreCase)).ToArray(); //Act var result = string.Empty; using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream, Encoding.UTF8) { AutoFlush = true }) { dataExporter.Export( stream, new ExportDataRequest() { DataQuery = new PricelistAssignmentExportDataQuery() { IncludedProperties = IncludedProperties }, ExportTypeName = typeof(ExportablePricelistAssignment).FullName, ProviderName = nameof(JsonExportProvider) }, new Action <ExportProgressInfo>(x => Console.WriteLine(x.Description)), new CancellationTokenWrapper(CancellationToken.None)); stream.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(stream); result = reader.ReadToEnd(); } //Assert var pricelistsAssigments = JsonConvert.DeserializeObject <ExportablePricelistAssignment[]>(result); Assert.NotNull(pricelistsAssigments); Assert.NotEmpty(pricelistsAssigments); var assigment = pricelistsAssigments.FirstOrDefault(x => x.Id == "d4a4e5271046497eaef61ee47efe6215"); Assert.NotNull(assigment); Assert.Null(assigment.Name); Assert.Equal("80873a35a34a4cf8997ac87e69cac6d6", assigment.PricelistId); Assert.Equal("4974648a41df4e6ea67ef2ad76d7bbd4", assigment.CatalogId); Assert.Equal(10, assigment.Priority); return(Task.CompletedTask); }
public Task PricelistJsonExport() { //Arrange IKnownExportTypesRegistrar registrar = new KnownExportTypesService(); var searchServiceMock = new Mock <IPricingSearchService>(); searchServiceMock.Setup(x => x.SearchPricelists(It.Is <PricelistSearchCriteria>(y => y.Skip == 0))).Returns(GetTestPricelistResult <Pricelist>()); searchServiceMock.Setup(x => x.SearchPricelists(It.Is <PricelistSearchCriteria>(y => y.Skip > 0))).Returns(new PricingSearchResult <Pricelist>()); searchServiceMock.Setup(x => x.SearchPrices(It.IsAny <PricesSearchCriteria>())).Returns(new PricingSearchResult <Price>() { TotalCount = 0, Results = new List <Price>(), }); var priceServiceMock = new Mock <IPricingService>(); var metadata = typeof(ExportablePricelist).GetPropertyNames(); var resolver = (IKnownExportTypesResolver)registrar; registrar.RegisterType(ExportedTypeDefinitionBuilder.Build <ExportablePricelist, PricelistExportDataQuery>() .WithDataSourceFactory(new PricelistExportPagedDataSourceFactory(searchServiceMock.Object, priceServiceMock.Object)) .WithMetadata(metadata)); var exportProviderFactories = new[] { new Func <ExportDataRequest, IExportProvider>((request) => new JsonExportProvider(request)), }; var dataExporter = new DataExporter(resolver, new ExportProviderFactory(exportProviderFactories)); var includedPropertyNames = new string[] { "Currency", "Id", "Name" }; var IncludedProperties = metadata.PropertyInfos.Where(x => includedPropertyNames.Contains(x.FullName, StringComparer.OrdinalIgnoreCase)).ToArray(); //Act var result = string.Empty; using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream, Encoding.UTF8) { AutoFlush = true }) { dataExporter.Export( stream, new ExportDataRequest() { DataQuery = new PricelistExportDataQuery() { IncludedProperties = IncludedProperties }, ExportTypeName = typeof(ExportablePricelist).FullName, ProviderName = nameof(JsonExportProvider) }, new Action <ExportProgressInfo>(x => Console.WriteLine(x.Description)), new CancellationTokenWrapper(CancellationToken.None)); stream.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(stream); result = reader.ReadToEnd(); } //Assert var pricelists = JsonConvert.DeserializeObject <ExportablePricelist[]>(result); Assert.NotNull(pricelists); Assert.NotEmpty(pricelists); var pricelist = pricelists.FirstOrDefault(x => x.Name.Equals("BoltsUSD", StringComparison.InvariantCultureIgnoreCase)); Assert.NotNull(pricelist); Assert.Equal("0456b3ebc0a24c0ab7054ec9a5cea78e", pricelist.Id); Assert.Equal("USD", pricelist.Currency); return(Task.CompletedTask); }
public void Setup() { _serializer = Substitute.For <ISerializer>(); _writableDestination = Substitute.For <IWritable>(); _dataExporter = new DataExporter(_serializer); }
public void Test_ZipToFile() { TestUser user = new TestUser(); user.ID = Guid.NewGuid(); user.FirstName = "Test"; user.LastName = "Test"; DataAccess.Data.Saver.Save(user); TestRole role = new TestRole(); role.ID = Guid.NewGuid(); role.Name = "Test Role"; DataAccess.Data.Saver.Save(role); TestArticle article = new TestArticle(); article.ID = Guid.NewGuid(); article.Title = "Test"; DataAccess.Data.Saver.Save(article); TestCategory category = new TestCategory(); category.Name = "Test"; DataAccess.Data.Saver.Save(category); string outputDirectory = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Exported"; int expectedCount = 0; foreach (string dataStoreName in DataAccess.Data.GetDataStoreNames()) { foreach (IEntity entity in DataAccess.Data.Stores[dataStoreName].Indexer.GetEntities()) { expectedCount++; } } DataExporter exporter = (DataExporter)DataAccess.Data.InitializeDataExporter(); exporter.ExportDirectoryPath = outputDirectory; exporter.ExportToXml(); int fileCount = 0; foreach (string directory in Directory.GetDirectories(outputDirectory)) { foreach (String file in Directory.GetFiles(directory)) { fileCount++; } } Assert.AreEqual(expectedCount, fileCount, "Incorrect number of files found."); DirectoryZipper zipper = new DirectoryZipper(exporter.ExportDirectoryPath); string zipFileName = @"Backup--" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "--" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + ".zip"; string zipFilePath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Backups" + Path.DirectorySeparatorChar + zipFileName; //zipShortPath;//Config.Application.PhysicalApplicationPath + zipShortPath; zipper.ZipToFile(zipFilePath); Assert.IsTrue(File.Exists(zipFilePath), "The zip file wasn't created."); // TODO: Open the zip file and check the contents }
public void SetUp() { _directory = AppDomain.CurrentDomain.BaseDirectory; _objectToTest = new DataExporter(_directory); }
private void HandleMessageReceived(Message obj) { var message = _messageFactory.Create(obj); if (DamageTracker.IsArchived) { var npcOccupier = message as SNpcOccupierInfo; if (npcOccupier != null) { Entity ent = _entityTracker.GetOrPlaceholder(npcOccupier.NPC); if (ent is NpcEntity) { var npce = ent as NpcEntity; if (npce.Info.Boss && npcOccupier.Target != EntityId.Empty) { CasualMessenger.Instance.ResetPlayerStats(true); //Stop viewing saved encounter on boss aggro } } return; } } _entityTracker?.Update(message); var skillResultMessage = message as EachSkillResultServerMessage; if (skillResultMessage != null) { if (skillResultMessage.IsValid(DamageTracker)) { var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase, null, _abnormalityTracker); CheckUpdate(skillResult); } return; } _playerTracker?.UpdateParty(message); _abnormalityTracker?.Update(message); var despawnNpc = message as SDespawnNpc; if (despawnNpc != null) { Entity ent = _entityTracker.GetOrPlaceholder(despawnNpc.Npc); if (ent is NpcEntity) { var npce = ent as NpcEntity; if (npce.Info.Boss && despawnNpc.Dead && !DamageTracker.IsArchived) { //no need to do something if we didn't count any skill against this boss if (DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Any(x => x.Target == npce)) { DamageTracker.PrimaryTarget = npce; //Name encounter with the last dead boss DamageTracker.IsPrimaryTargetDead = despawnNpc.Dead; //determine type ExportType exportType = ExportType.None; if (SettingsHelper.Instance.Settings.ExcelExport) { exportType = exportType | ExportType.Excel; } if (SettingsHelper.Instance.Settings.SiteExport) { exportType = exportType | ExportType.Upload; } if (exportType != ExportType.None) { DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData); } if (AutosaveEncounters) { ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true }); } } } } return; } var spawnNpc = message as SpawnNpcServerMessage; if (spawnNpc != null) { if (spawnNpc.NpcArea == 950 && spawnNpc.NpcId == 9501) { var bosses = DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Select(x => x.Target).OfType <NpcEntity>().ToList(); var vergosPhase2Part1 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 1000); var vergosPhase2Part2 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 2000); //determine type ExportType exportType = ExportType.None; if (SettingsHelper.Instance.Settings.ExcelExport) { exportType = exportType | ExportType.Excel; } if (SettingsHelper.Instance.Settings.SiteExport) { exportType = exportType | ExportType.Upload; } if (exportType != ExportType.None) { DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData, vergosPhase2Part1); } DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData, vergosPhase2Part2); if (AutosaveEncounters) { ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true }); } } if (spawnNpc.NpcArea == 950 && spawnNpc.NpcId == 9502) { var bosses = DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Select(x => x.Target).OfType <NpcEntity>().ToList(); var vergosPhase3 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 3000); //determine type ExportType exportType = ExportType.None; if (SettingsHelper.Instance.Settings.ExcelExport) { exportType = exportType | ExportType.Excel; } if (SettingsHelper.Instance.Settings.SiteExport) { exportType = exportType | ExportType.Upload; } if (exportType != ExportType.None) { DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData, vergosPhase3); } if (AutosaveEncounters) { ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true }); } } return; } var sLogin = message as LoginServerMessage; if (sLogin != null) { if (_needInit) { Server = BasicTeraData.Servers.GetServer(sLogin.ServerId, Server); _messageFactory.Region = Server.Region; Logger.Info($"Logged in to server {Server.Name}."); _teraData = BasicTeraData.DataForRegion(Server.Region); _entityTracker = new EntityTracker(_teraData.NpcDatabase, _userLogoTracker); _playerTracker = new PlayerTracker(_entityTracker, BasicTeraData.Servers); _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate); _entityTracker.Update(message); if (!DamageTracker.IsArchived) { DamageTracker.MeterPlayer = _playerTracker.Me(); } _needInit = false; } _abnormalityStorage.EndAll(message.Time.Ticks); _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate); return; } var cVersion = message as C_CHECK_VERSION; if (cVersion != null) { var opCodeNamer = new OpCodeNamer(Path.Combine(BasicTeraData.ResourceDirectory, $"opcodes/{cVersion.Versions[0]}.txt")); _messageFactory = new MessageFactory(opCodeNamer, Server.Region, cVersion.Versions[0]); return; } var sGetUserList = message as S_GET_USER_LIST; if (sGetUserList != null) { _userLogoTracker.SetUserList(sGetUserList); return; } }
private void ClickUploadGlyphAction(object sender, RoutedEventArgs e) { DataExporter.ExportGlyph(); }
public void Test_ImportFromXml_RenewSchema_TypeAndProperty() { Version currentVersion = new Version(1, 0, 0, 0); Version legacyVersion = new Version(0, 9, 0, 0); TestUser user = new TestUser(); user.ID = Guid.NewGuid(); user.FirstName = "Test"; user.LastName = "Test"; TestRole role = new TestRole(); role.ID = Guid.NewGuid(); role.Name = "Test Role"; user.Roles = new TestRole[] { role }; DataExporter exporter = (DataExporter)DataAccess.Data.InitializeDataExporter(); exporter.ExportDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Exported"; // IMPORTANT: Export the references before the entities, because the references are stripped from the entities upon export // Alternative is to reactivate the entities and their references using DataAccess.Data.Activator. EntityReferenceCollection references = DataAccess.Data.Referencer.GetActiveReferences(user); exporter.ExportEntity(references[0]); exporter.ExportEntity(user); exporter.ExportEntity(role); DataSchema schema = (DataSchema)DataAccess.Data.Schema; schema.LegacyVersion = legacyVersion; schema.ApplicationVersion = currentVersion; schema.SchemaCommandDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Schema"; RenamePropertyCommand command1 = new RenamePropertyCommand(); command1.TypeName = user.ShortTypeName; command1.PropertyName = "Roles"; command1.NewPropertyName = "GrantedRoles"; RenameTypeCommand command2 = new RenameTypeCommand(); command2.TypeName = user.ShortTypeName; command2.NewTypeName = typeof(TestAccount).Name; RenamePropertyCommand command3 = new RenamePropertyCommand(); command3.TypeName = role.ShortTypeName; command3.PropertyName = "Users"; command3.NewPropertyName = "Accounts"; DataSchemaCommandCollection commands = new DataSchemaCommandCollection(); commands.Add(command1); commands.Add(command2); commands.Add(command3); schema.SchemaCommands = commands; DataImporter importer = (DataImporter)DataAccess.Data.Importer; importer.ImportableDirectoryPath = exporter.ExportDirectoryPath; importer.ImportedDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Imported"; importer.ImportFromXml(); TestAccount foundAccount = DataAccess.Data.Reader.GetEntity <TestAccount>("ID", user.ID); Assert.IsNotNull(foundAccount, "foundAccount == null"); Assert.AreEqual(user.ID.ToString(), foundAccount.ID.ToString(), "The ID of the found account doesn't match the ID of the original user."); DataAccess.Data.Activator.Activate(foundAccount, "GrantedRoles"); Assert.IsNotNull(foundAccount.GrantedRoles, "user.GrantedRoles == null"); Assert.AreEqual(1, foundAccount.GrantedRoles.Length, "Invalid number of roles found."); TestRole foundRole = DataAccess.Data.Reader.GetEntity <TestRole>("ID", role.ID); Assert.IsNotNull(foundRole, "foundRole == null"); Assert.AreEqual(role.ID.ToString(), foundRole.ID.ToString(), "The ID of the found role doesn't match the ID of the original role."); }
public HistoryExportImport(DataExporter exporter) : this() { this.exporter = exporter; }
public virtual void Test_ImportFromXml() { Version currentVersion = new Version(1, 0, 0, 0); Version legacyVersion = new Version(0, 9, 0, 0); TestUser user = new TestUser(); user.ID = Guid.NewGuid(); user.FirstName = "Test"; user.LastName = "Test"; TestRole role = new TestRole(); role.ID = Guid.NewGuid(); role.Name = "Test Role"; TestArticle article = new TestArticle(); article.ID = Guid.NewGuid(); article.Title = "Test"; TestCategory category = new TestCategory(); category.ID = Guid.NewGuid(); category.Name = "Test"; user.Roles = new TestRole[] { role }; // IMPORTANT: Export the references before the entities, because the references are stripped from the entities upon export // Alternative is to reactivate the entities and their references using DataAccess.Data.Activator. EntityReferenceCollection references = DataAccess.Data.Referencer.GetActiveReferences(user); if (references.Count <= 0) { Assert.Fail("No active references found."); } DataExporter exporter = (DataExporter)DataAccess.Data.InitializeDataExporter(); exporter.ExportDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Exported"; exporter.ExportEntity(references[0]); exporter.ExportEntity(user); exporter.ExportEntity(role); exporter.ExportEntity(article); exporter.ExportEntity(category); DataAccess.Data.Schema.LegacyVersion = legacyVersion; DataAccess.Data.Schema.ApplicationVersion = currentVersion; DataImporter importer = (DataImporter)DataAccess.Data.InitializeDataImporter(); importer.ImportableDirectoryPath = exporter.ExportDirectoryPath; importer.ImportedDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Imported"; importer.ImportFromXml(); TestUser foundUser = DataAccess.Data.Reader.GetEntity <TestUser>("ID", user.ID); Assert.IsNotNull(foundUser, "foundUser == null"); Assert.AreEqual(user.ID.ToString(), foundUser.ID.ToString(), "The ID of the found user doesn't match the ID of the original user."); DataAccess.Data.Activator.Activate(foundUser, "Roles"); Assert.IsNotNull(foundUser.Roles, "user.Roles == null"); Assert.AreEqual(1, foundUser.Roles.Length, "Invalid number of roles found."); TestRole foundRole = DataAccess.Data.Reader.GetEntity <TestRole>("ID", role.ID); Assert.IsNotNull(foundRole, "foundRole == null"); Assert.AreEqual(role.ID.ToString(), foundRole.ID.ToString(), "The ID of the found role doesn't match the ID of the original role."); TestCategory foundCategory = DataAccess.Data.Reader.GetEntity <TestCategory>("ID", category.ID); Assert.IsNotNull(foundCategory, "foundCategory == null"); Assert.AreEqual(category.ID.ToString(), foundCategory.ID.ToString(), "The ID of the found category doesn't match the ID of the original category."); TestArticle foundArticle = DataAccess.Data.Reader.GetEntity <TestArticle>("ID", article.ID); Assert.IsNotNull(foundArticle, "foundArticle == null"); Assert.AreEqual(article.ID.ToString(), foundArticle.ID.ToString(), "The ID of the found article doesn't match the ID of the original article."); }