Beispiel #1
0
        public void Map(ExcelFileDto dto, HttpPostedFileBase file)
        {
            if (string.IsNullOrEmpty(dto.Title))
            {
                dto.Title = Path.GetFileNameWithoutExtension(file.FileName);
            }

            dto.File = file.InputStream;
        }
Beispiel #2
0
        public ActionResult ParseExcelFile(ExcelFileDto dto)
        {
            if (Request.Files != null && Request.Files[0].InputStream.Length == 0)
            {
                return(View("ParseExcelFile"));
            }

            fileMapper.Map(dto, Request.Files[0]);

            parseExcelFileCommand.Execute(dto);

            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public SingleObjectModel GetExcelTrialBalance([FromBody] TrialBalanceCommand command)
        {
            base.RequireBody(command);

            using (var usecases = TrialBalanceUseCases.UseCaseInteractor()) {
                TrialBalanceDto trialBalance = usecases.BuildTrialBalance(command);

                var excelExporter = new ExcelExporter();

                ExcelFileDto excelFileDto = excelExporter.Export(trialBalance, command);

                return(new SingleObjectModel(this.Request, excelFileDto));
            }
        }
Beispiel #4
0
        public SingleObjectModel GetAccountsInExcelFile([FromUri] string accountsChartUID,
                                                        [FromBody] AccountsSearchCommand searchCommand)
        {
            base.RequireBody(searchCommand);

            using (var usecases = AccountsChartUseCases.UseCaseInteractor()) {
                AccountsChartDto accountsChart = usecases.SearchAccounts(accountsChartUID, searchCommand);

                var excelExporter = new ExcelExporter();

                ExcelFileDto excelFileDto = excelExporter.Export(accountsChart, searchCommand);

                return(new SingleObjectModel(base.Request, excelFileDto));
            }
        }
Beispiel #5
0
        public void Execute(ExcelFileDto dto)
        {
            DataSet data = null;

            using (var reader = ExcelReaderFactory.CreateReader(dto.File))
            {
                data = reader.AsDataSet();
            }

            var csvData = data.Tables[0].ToCsv();

            var csvFile = new CsvFile
            {
                Title       = dto.Title,
                Description = dto.Description,
                Contents    = csvData
            };

            csvFileRepository.Save(csvFile);
        }