Ejemplo n.º 1
0
        protected override DTO.ServiceResponse ProcessScrape(string outputPath, string debugID)
        {
            DTO.ServiceResponse response = null;
            string statementFilePath     = Path.Combine(outputPath, "statement.qfx");
            string noStatementFilePath   = Path.Combine(outputPath, "empty_statement.txt");

            if (File.Exists(statementFilePath))
            {
                string statementOfx            = File.ReadAllText(statementFilePath);
                Parse.OfxToXmlParser parser    = new Parse.OfxToXmlParser(statementOfx);
                XElement             parsedOfx = parser.Parse();

                Parse.OfxResponseBuilder responseBuilder = new Parse.OfxResponseBuilder();
                response = responseBuilder.BuildStatementResponse(parsedOfx, m_statementParameters.DateStart, m_statementParameters.DateEnd);
            }
            else if (File.Exists(noStatementFilePath))
            {
                response = new DTO.StatementResponse(HttpStatusCode.OK);
            }
            else
            {
                response = new DTO.ResponseError(HttpStatusCode.BadRequest)
                {
                    friendly_error = "An error occured when atempting to get account statement.",
                    detailed_error = "statement file missing"
                };
            }

            return(response);
        }
Ejemplo n.º 2
0
        protected override DTO.ServiceResponse ProcessScrape(string outputPath, string debugID)
        {
            DTO.ServiceResponse response = null;
            string accountsFilePath      = Path.Combine(outputPath, "accounts.json");

            if (File.Exists(accountsFilePath))
            {
                string accountJson = File.ReadAllText(accountsFilePath);
                response = new DTO.AccountsResponse();
                var accounts = JsonConvert.DeserializeObject <List <DTO.Account> > (accountJson);
                if (accounts != null && accounts.Count() > 0)
                {
                    ((DTO.AccountsResponse)response).accounts = accounts;
                }
                else
                {
                    throw new Exception("No accounts found.");
                }
            }
            else
            {
                response = new DTO.ResponseError(HttpStatusCode.BadRequest)
                {
                    friendly_error = "An error occured when atempting to get list of accounts.",
                    detailed_error = string.Format("accounts file missing ({0})", debugID)
                };
            }

            return(response);
        }