static void Main(string[] args)
        {
            List <Batch> batches = new List <Batch>();
            string       root    = Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).Parent.Parent.FullName;


            ImportService importService = new ImportService(new BatchDirector());

            batches.Add(importService.Import("BPS", Path.Combine(root, "Inbound", "BPS", "BPSBatchFile.txt")));
            batches.Add(importService.Import("CS", Path.Combine(root, "Inbound", "CS", "CSBatchFile.txt")));
            batches.Add(importService.Import("FDMR", Path.Combine(root, "Inbound", "FDMR", "FDMRBatchFile.txt")));
            batches.Add(importService.Import("DEL", Path.Combine(root, "Inbound", "Delinking", "DelinkingBatchFile.txt")));

            Console.WriteLine("All batches imported");
        }
Пример #2
0
        public async Task <IActionResult> Import([FromBody] ResourceImport model)
        {
            if (!_env.IsDevelopment())
            {
                return(Forbid());
            }

            await _importSvc.Import(model);

            return(Ok());
        }
Пример #3
0
        public override void HandleInternal(BackgroundTask task, District district, BackgroundTaskService.BackgroundTaskLog log)
        {
            var info = new SisConnectionInfo
            {
                SisPassword = district.SisPassword,
                SisUrl      = district.SisUrl,
                SisUserName = district.SisUserName
            };
            var importService = new ImportService(district.Id, info, log, task.Id);

            importService.Import();
        }
Пример #4
0
        public async Task ShouldPersistsDataWithImportData()
        {
            //ARRANGE
            const string leaguecode = "Dummy League Code";
            var          sut        = new ImportService(_persistenceService.Object, _mockHttpClient.Object);

            //ACT
            await sut.Import(leaguecode);

            //ASSERT
            _persistenceService.Verify(p => p.SaveData(It.IsAny <List <CompetitionRootObject> >(), It.IsAny <List <TeamRootObject> >(), It.IsAny <List <PlayerRootObject> >(), leaguecode), Times.Once);
        }
Пример #5
0
        static void Main(string[] args)
        {
            string json     = File.ReadAllText("importSettings.json");
            var    settings = JsonConvert.DeserializeObject <ImportSettings>(json);

            decimal total = 0;

            foreach (var file in settings.Files)
            {
                System.Console.WriteLine($"File {file}");
                System.Console.WriteLine("--------------------------------------------");
                using (var stream = File.OpenRead(file))
                {
                    IImportService importService = new ImportService();
                    var            result        = importService.Import(stream, "csv", "ANZ");

                    IClassificationService classificationService = new ClassificationService();
                    classificationService.Classify(result.Transactions, settings.Categories, settings.Tags);

                    decimal subtotal = 0;
                    foreach (var t in result.Transactions.Where(t => t.Category != null || t.Tags.Any()))
                    {
                        System.Console.WriteLine($"{t.Date.ToString("dd/MM/yyyy")}\t${t.Amount.ToString()}\t{t.Description}");
                        System.Console.WriteLine($"\tCategory: { t.Category?.Name ?? "No category" }");

                        if (t.Tags.Any())
                        {
                            System.Console.WriteLine($"\tTags: {t.Tags?.Select(x => x.Name).Aggregate((a, b) => $"{a}, {b}") ?? "No tags"}");
                        }
                        else
                        {
                            System.Console.WriteLine("\tTags: No tags");
                        }

                        subtotal += t.Amount;
                    }

                    total += subtotal;

                    System.Console.WriteLine("-------------------");
                    System.Console.WriteLine("Total: ${0}", subtotal);
                    System.Console.WriteLine();
                }
            }

            System.Console.WriteLine("Full total: ${0}", total);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Console.WriteLine("Press any key to continue...");
                System.Console.ReadLine();
            }
        }
Пример #6
0
        public async Task ShouldThrowAnExceptionIfClientFails()
        {
            //ARRANGE
            const string leaguecode = "Dummy League Code";

            _mockHttpClient.Setup(c => c.GetCompetitionsAsync(leaguecode)).Throws <InvalidOperationException>();

            var sut = new ImportService(_persistenceService.Object, _mockHttpClient.Object);

            //ACT
            await sut.Import(leaguecode);

            //ASSERT
        }
Пример #7
0
        private void Import(string fileName)
        {
            lvwResult.Items.Clear();

            var importService = new ImportService();
            var projects      = importService.Import(fileName);

            var organizeService = new ResultsOrganizerService(projects);
            var results         = organizeService.Organize();

            foreach (var result in results)
            {
                AddLine(result);
            }
        }
Пример #8
0
        public void ShouldCreateVulnerabilities()
        {
            var import = new Import {
                File = Stream.Null
            };

            var result = _importService.Import(import);

            Assert.AreEqual(1, result.VulnerabilityCount);
            Assert.AreEqual(0, result.UpdatedVulnerabilityCount);
            _mockImportVulnerabilityMapper.Verify(x => x.Map(_importRecords[0], import, It.IsAny <VulnerabilityEntity>()), Times.Once);
            _mockHostVulnerabilityRepository.Verify(x => x.AddRange(It.Is <IEnumerable <HostVulnerabilityEntity> >(z => z.Count() == 1)), Times.Once);
            _mockHostVulnerabilityRepository.Verify(r => r.Save(), Times.Once);
        }
 public void ProcessFiles(IEnumerable <FileParserInput> filesToParse)
 {
     foreach (var downloadResult in filesToParse)
     {
         ImportService.Import(downloadResult);
         //TODO some kind of unit of work autocommit
         if (downloadResult.BalanceSelectorFunc != null)
         {
             //TODO is this fixed now with proper EF implementation? Unfortunately Sqlite doesn't handle decimal, so we have to deal with double comparison issues
             var actualBalance = Math.Round(downloadResult.BalanceSelectorFunc(), 2);
             if (Math.Abs(actualBalance - downloadResult.Balance) >= 0.01m)
             {
                 throw new BalanceCheckException(downloadResult.Balance, actualBalance, "Balance check failed");
             }
         }
     }
 }
Пример #10
0
        public void ImportData()
        {
            IImportService service = new ImportService();

            using (Stream stream = File.OpenRead("./TestData/ANZ.csv"))
            {
                Assert.IsTrue(stream.Length > 0);

                var result = service.Import(stream, "csv", "ANZ");

                Assert.IsTrue(result.Success);
                Assert.IsNotNull(result.Transactions);

                var transactions = result.Transactions.ToArray();
                Assert.AreEqual(3, transactions.Length);
                Assert.AreEqual(7777.77m, transactions[0].Amount);
                Assert.AreEqual("PAY/SALARY FROM SUPERIOR SOFTWAR FORTNIGHTLY SALARY", transactions[0].Description);
                Assert.AreEqual(new DateTime(2017, 4, 7), transactions[0].Date);
            }
        }
Пример #11
0
        private async void btnImport_Click(object sender, RoutedEventArgs e)
        {
            string       dir    = tbGameDir.Text;
            ImportStatus result = _importService.CanImport(dir);

            if (result == ImportStatus.ALREADY_EXISTS)
            {
                MessageWindow updateWindow = new MessageWindow("Update", "This version is already imported. Are you sure you want to overwrite it?\nUse this feature only if you want to save a newer build of the same version.", MessageWindowButtons.YesNo);
                updateWindow.ShowDialog();
                if (updateWindow.Result != MessageWindowResult.Yes)
                {
                    return;
                }
            }

            btnImport.IsEnabled     = false;
            tbGameDir.IsEnabled     = false;
            btnBrowse.IsEnabled     = false;
            chbImportMods.IsEnabled = false;
            _isImportInProgress     = true;
            btnImportText.Text      = "Importing...";
            Taskbar.ProgressState   = TaskbarItemProgressState.Normal;
            Taskbar.ProgressValue   = 0;
            Progress <int> progress = new Progress <int>(percent =>
            {
                ProgressBarData.Progress = percent;
                Taskbar.ProgressValue    = percent / 100.0;
            });

            bool importMods = chbImportMods.IsChecked.GetValueOrDefault(false);
            await Task.Run(() => _importService.Import(dir, importMods, progress));

            tbGameDir.IsEnabled     = true;
            btnBrowse.IsEnabled     = true;
            chbImportMods.IsEnabled = true;
            btnImportText.Text      = "Import";
            new MessageWindow("Finished", "Import successfully finished!\nYou can now play replays from this version through the Replays tab.\nAfter you make sure everything works, you can delete the original game directory.", MessageWindowButtons.OK).ShowDialog();
            _isImportInProgress = false;
            OnPathChanged();
            Taskbar.ProgressState = TaskbarItemProgressState.None;
        }
Пример #12
0
        private async void btnImport_Click(object sender, RoutedEventArgs e)
        {
            btnImport.IsEnabled     = false;
            tbGameDir.IsEnabled     = false;
            btnBrowse.IsEnabled     = false;
            chbImportMods.IsEnabled = false;
            btnImportText.Text      = "Importing...";
            Progress <int> progress = new Progress <int>(percent =>
            {
                ProgressBarData.Progress = percent;
            });
            string dir        = tbGameDir.Text;
            bool   importMods = chbImportMods.IsChecked.GetValueOrDefault(false);
            await Task.Run(() => _importService.Import(dir, importMods, progress));

            tbGameDir.IsEnabled     = true;
            btnBrowse.IsEnabled     = true;
            chbImportMods.IsEnabled = true;
            btnImportText.Text      = "Import";
            new MessageWindow("Finished", "Import successfully finished!\nYou can now play replays from this version through the Replays tab.\nAfter you make sure everything works, you can delete the original game directory.", MessageWindowButtons.OK).ShowDialog();
            OnPathChanged();
        }
 public IActionResult OnPostImportDocs()
 {
     iSvc.Import("files/sdscom.xml", UserProfile_UserID);
     return(RedirectToPage("AuthorIndex"));
 }
Пример #14
0
 public IActionResult Run([FromBody] ImportServiceRunModel runModel)
 {
     ImportService.Import(runModel);
     return(Json(true));
 }
        public void Import(IFormFile file)
        {
            var fileContent = ReadAsList(file);

            _importService.Import(fileContent);
        }
Пример #16
0
        private static int Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture   = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

            var app = new CommandLineApplication();

            app.HelpOption("-h | --help");

            app.Command("template", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Create mapping file template from the Source Tenant model.";

                var tenantOption           = command.Option("-t | --tenant", "Export template tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Export template connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new TemplateService(tenantOption.Value(), connectionStringOption.Value());
                    service.GenerateTemplate().GetAwaiter().GetResult();
                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("export", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export data from source system.";

                var tenantOption           = command.Option("-t | --tenant", "Tenant to export", CommandOptionType.SingleValue);
                var mappingOption          = command.Option("-m | --mapping", "Mapping file", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var tenant       = tenantOption.Value();
                    var jsonSettings = new JsonSerializerSettings {
                        ContractResolver = new CamelCasePropertyNamesContractResolver()
                    };
                    var mappings        = JsonConvert.DeserializeObject <List <EntityMapDefinition> >(File.ReadAllText(mappingOption.Value()), jsonSettings);
                    var seriesProcessor = new SeriesProcessor(mappings, tenant, jsonSettings, _correlationId, _eventMetadata);
                    var service         = new ExportService(tenant, connectionStringOption.Value(), _correlationId, _eventMetadata, mappings, seriesProcessor, jsonSettings);
                    service.Export().GetAwaiter().GetResult();
                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("import", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Import data to destination system.";

                var folderOption           = command.Option("-f | --folder", "Import folder path", CommandOptionType.SingleValue);
                var tenantOption           = command.Option("-t | --tenant", "Import to tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ImportService(folderOption.Value(), tenantOption.Value(), connectionStringOption.Value());
                    service.Import().GetAwaiter().GetResult();
                    Console.WriteLine("Import finished successfully.");
                    Console.ReadKey();
                    return(0);
                });
            });


            app.Command("export-files", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export files from source system.";

                var tenantOption           = command.Option("-t | --tenant", "Tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Blob storage Connection string", CommandOptionType.SingleValue);
                var encryptionKeyOption    = command.Option("-ek | --encryption-key", "Export storage Encryption Key", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ExportBlobsService(tenantOption.Value(), connectionStringOption.Value(), encryptionKeyOption.Value());
                    service.Export().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("export-users", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export users data from source system.";

                var tenantOption           = command.Option("-t | --tenant", "Tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ExportUsersService(tenantOption.Value(), connectionStringOption.Value());
                    service.Export().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("import-users", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Import users data from source system.";

                var folderOption       = command.Option("-f | --folder", "Import folder path", CommandOptionType.SingleValue);
                var tenantOption       = command.Option("-t | --tenant", "Import to tenant", CommandOptionType.SingleValue);
                var apiAddressOption   = command.Option("-e | --endpoint", "Import API endpoint", CommandOptionType.SingleValue);
                var clientIdOption     = command.Option("-ci | --client-id", "API Client's ID", CommandOptionType.SingleValue);
                var clientSecretOption = command.Option("-cs | --client-secret ", "API Client's Secret", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ImportUsersService(folderOption.Value(), tenantOption.Value(), apiAddressOption.Value(), clientIdOption.Value(), clientSecretOption.Value());
                    service.Import().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });

            app.Command("import-files", (command) =>
            {
                command.HelpOption("-h | --help");
                command.Description = "Export files from source system.";

                var mappingsFolderOption   = command.Option("-m | --mappings", "Mappings folder where the file_mapping.csv was stored", CommandOptionType.SingleValue);
                var filesFolderOption      = command.Option("-f | --folder", "Files folder", CommandOptionType.SingleValue);
                var tenantOption           = command.Option("-t | --tenant", "Import to tenant", CommandOptionType.SingleValue);
                var connectionStringOption = command.Option("-c | --connection-string", "Blob storage connection string", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    var service = new ImportBlobsService(mappingsFolderOption.Value(), filesFolderOption.Value(), tenantOption.Value(), connectionStringOption.Value());
                    service.Import().GetAwaiter().GetResult();

                    Console.ReadKey();
                    return(0);
                });
            });



            return(app.Execute(args));
        }