コード例 #1
0
        public void ProcessMailForExpenses(string subjectName)
        {
            List <MailMessage> claims = mailHelper.getStringMessages(subjectName);

            foreach (MailMessage claim in claims)
            {
                //store the request....
                RequestDAO request = new RequestDAO();
                if (request.shouldProcess(claim.id))
                {
                    Request req = request.createRequestOrGetRequest(claim.from, claim.body, DateTime.Now, claim.id);
                    //call the rest service.
                    XmlDocument xdoc              = RestHelper.callRestService(restEndPoint, claim.body);
                    ExpenseDTO  expenseDTO        = Deserialiser.deserialiseContent <ExpenseDTO>(xdoc);
                    ExpenseDAO  expenseDAO        = new ExpenseDAO();
                    Expense     expenseToValidate = expenseDAO.CreateExpense(expenseDTO, req);

                    ExpenseValidator validator = new ExpenseValidator(expenseToValidate);

                    mailHelper.sendMessage(claim.from, validator.getMessage(), claim.id, string.Format("response to claim dated {0}", claim.date));
                    //deserialise the content
                    //validate the request
                    //store - valid request or failure and respond to user
                }
            }
        }