コード例 #1
0
ファイル: AppEngine.cs プロジェクト: macieja79/budget
        void ProceedImport()
        {
            List <string> paths = _iOutput.FilePathProvider.GetFilePaths();

            if (paths.IsNullObj())
            {
                return;
            }

            List <FileData>             fileDatas = new List <FileData>();
            FileTransactionDataProvider provider  = new FileTransactionDataProvider();

            foreach (string path in paths)
            {
                provider.FilePath = path;
                FileData fileData = provider.GetTransactionData();
                fileDatas.Add(fileData);
            }

            GetTransactionsAction.Data getTransactionData = new GetTransactionsAction.Data()
            {
                FileDatas = fileDatas,
                Parsers   = _import.GetParsers(),
            };
            GetTransactionsAction getTransaction = new GetTransactionsAction();

            GetTransactionsAction.Result getTransactionResult = getTransaction.Execute(getTransactionData);

            var transactions = getTransactionResult.Reports.SelectMany(r => r.Transactions).ToList();

            AttachRulesAction.Data attachRulesData = new AttachRulesAction.Data
            {
                Transactions = transactions,
                Categories   = _repository.Categories.Item
            };

            AttachRulesAction attachRulesAction = new AttachRulesAction();

            attachRulesAction.Execute(attachRulesData);

            TransactionManager       transactionManager = new TransactionManager();
            List <TransactionReport> reports            = transactionManager.GetMonthReports(transactions);

            transactionManager.RemoveInternalTransactions(reports);

            _repository.Reports.Item.Reports = reports;
            _iOutput.ShowReports(reports);
        }