コード例 #1
0
        public void InitScenario()
        {
            _mockMarkOffFileProvider = new Mock <IMarkOffFileProvider>();
            _mockReconcileEngine     = new Mock <IReconcileEngine>();
            _csvReader = new CSVMarkOffFileParser();
            _sessionId = SessionIdGenerator.CreateNewId();
            _mockMarkOffFileProvider.Setup(x => x.SaveMarkOffFile(It.IsAny <Stream>(), _sessionId, ClientMarkoffFileName)).Returns(ClientMarkoffFileName);
            _mockMarkOffFileProvider.Setup(x => x.SaveMarkOffFile(It.IsAny <Stream>(), _sessionId, BankMarkoffFileName)).Returns(BankMarkoffFileName);

            _mockMarkOffFileProvider.Setup(x => x.GetMarkOffFile(_sessionId, ClientMarkoffFileName)).Returns(Resources.ClientMarkoffFile20140113);
            _mockMarkOffFileProvider.Setup(x => x.GetMarkOffFile(_sessionId, BankMarkoffFileName)).Returns(Resources.BankMarkoffFile20140113);
        }
コード例 #2
0
        public ActionResult Compare(CompareModel compareFiles)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string clientFileName = null, bankFileName = null, sessionId;
                    if (compareFiles.ClientMarkOffFile.ContentLength > 0 && compareFiles.BankMarkOfffile.ContentLength > 0)
                    {
                        clientFileName = Path.GetFileName(compareFiles.ClientMarkOffFile.FileName);
                        sessionId      = SessionIdGenerator.CreateNewId();


                        ParserResult result = _csvFileReader.Validate(compareFiles.ClientMarkOffFile.InputStream);
                        if (!result.IsValid)
                        {
                            ModelState.AddModelError("ClientMarkOffFile", result.Errors[1]);
                            return(View());
                        }
                        else
                        {
                            _markOffFileProvider.SaveMarkOffFile(compareFiles.ClientMarkOffFile.InputStream, sessionId, clientFileName);
                        }

                        result = _csvFileReader.Validate(compareFiles.BankMarkOfffile.InputStream);
                        if (!result.IsValid)
                        {
                            ModelState.AddModelError("BankMarkOfffile", result.Errors[1]);
                            return(View());
                        }
                        else
                        {
                            bankFileName = Path.GetFileName(compareFiles.BankMarkOfffile.FileName);
                            _markOffFileProvider.SaveMarkOffFile(compareFiles.BankMarkOfffile.InputStream, sessionId, bankFileName);
                        }
                        return(RedirectToAction("compareresult", new { sid = sessionId, cfn = clientFileName, tfn = bankFileName }));
                    }
                }

                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }