Пример #1
0
        public async Task <HttpResponseMessage> UploadPdf()
        {
            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            string root     = HttpContext.Current.Server.MapPath("~/App_Data");
            var    provider = new MultipartFormDataStreamProvider(root);

            try
            {
                // Read the form data.
                await Request.Content.ReadAsMultipartAsync(provider);

                string fileName = string.Empty;
                // This illustrates how to get the file names.
                foreach (MultipartFileData file in provider.FileData)
                {
                    Trace.WriteLine(file.Headers.ContentDisposition.FileName);
                    Trace.WriteLine("Server file path: " + file.LocalFileName);
                    fileName = file.LocalFileName;
                }

                var pdfContent = PdfLogic.ReadPdfFile(fileName);
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (System.Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
Пример #2
0
        public void Execute()
        {
            _validationLogic.ValidateInput();
            var rateCsvLogic = new RateCsvLogic <Rate>();
            var rateList     = rateCsvLogic.CreateRateList(new [] {
                _fiatRatesPath,
                _ratesPath
            }).OrderBy(r => r.DestinationCurrency).ThenBy(r => r.OriginCurrency).ThenByDescending(r => r.Date).ToList();
            var transactionCsvLogic = new TransactionCsvLogic <Transaction>(_transactionsPath, rateList);
            var transactionList     = transactionCsvLogic.CreateTransactionList();
            var transactionLogic    = new TransactionLogic <Transaction, DetailedTransaction, K4TransactionModel>(rateList);

            transactionLogic.ParseTransactions(transactionList);
            var detailedTransactionCsvLogic = new DetailedTransactionCsvLogic <DetailedTransaction>(_outputPath + @"\Detailed transactions.csv");

            detailedTransactionCsvLogic.CreateDetailedTransactionsCsv(transactionLogic.DetailedTransactions);

            var reportLogic           = new ReportLogic <ReportYearlySummary>(transactionLogic.DetailedTransactions);
            var reportYearlySummaries = reportLogic.CreateReportYearlySummaryList();
            var reportCsvLogic        = new ReportCsvLogic <ReportYearlySummary>(_outputPath + @"\Yearly reports.csv");

            reportCsvLogic.CreateReportCsv(reportYearlySummaries);

            var k4FormModel = new K4FormModel
            {
                FullName = _fullName,
                PersonalIdentificatonNumber = _personalIdentificationNumber,
                Years = _years,
                CryptoTransactions = transactionLogic.K4CryptoCurrencyTransactions,
                FiatTransactions   = transactionLogic.K4FiatCurrencyTransactions
            };
            var k4FormLogic  = new K4FormLogic <K4FillModel, K4TabIndexModel>(k4FormModel);
            var k4FillModels = k4FormLogic.GetK4FillModelList();
            var pdfLogic     = new PdfLogic(_outputPath, _processName);

            k4FillModels.ForEach(k4FillModel =>
            {
                var k4FillLogic = new K4FillLogic(pdfLogic, k4FillModel);
                k4FillLogic.FillAndSaveForms();
            });
        }