Beispiel #1
0
        public void test_parse()
        {
            var parser = new TransactionsParser();
            var parsed = parser.ParseFile(@"c:\ezbob\test-data\bank\NatWest.csv");

            Assert.NotNull(parsed);
            Assert.AreEqual(null, parsed.Error);
        }
        public JsonResult ParseYodlee(int customerId, int fileId)
        {
            var file         = m_oServiceClient.Instance.GetCompanyFile(_context.UserId, fileId);
            var fileMetaData = _companyFiles.Get(fileId);
            var parser       = new TransactionsParser();
            var parsed       = parser.ParseFile(fileMetaData.FileName, file);

            if (!string.IsNullOrEmpty(parsed.Error))
            {
                return(Json(new { error = parsed.Error }));
            }

            if (parsed.NumOfTransactions == 0)
            {
                return(Json(new { error = "File contains 0 transactions" }));
            }

            var customer = _customers.Get(customerId);
            var yodlee   = new YodleeServiceInfo();
            var yodleeMp = customer.CustomerMarketPlaces.FirstOrDefault(mp => mp.Marketplace.InternalId == yodlee.InternalId && mp.DisplayName == "ParsedBank");

            if (yodleeMp != null)
            {
                var data = Serialized.Deserialize <YodleeSecurityInfo>(yodleeMp.SecurityData);
                data.ItemId           = fileId;
                yodleeMp.SecurityData = new Serialized(data);
                _session.Flush();
                m_oServiceClient.Instance.UpdateMarketplace(customer.Id, yodleeMp.Id, false, _context.UserId);
            }
            else
            {
                int marketPlaceId = _mpTypes.GetAll().First(a => a.InternalId == yodlee.InternalId).Id;

                var securityData = new YodleeSecurityInfo {
                    ItemId        = fileId,
                    Name          = "",
                    Password      = "",
                    MarketplaceId = marketPlaceId,
                    CsId          = 0
                };

                var yodleeDatabaseMarketPlace = new YodleeDatabaseMarketPlace();
                var mp = _helper.SaveOrUpdateCustomerMarketplace("ParsedBank", yodleeDatabaseMarketPlace, securityData, customer);

                m_oServiceClient.Instance.UpdateMarketplace(customer.Id, mp.Id, false, _context.UserId);
            }     // if
            return(Json(new { }));
        }         // ParseYodlee
Beispiel #3
0
        static void Main(string[] args)
        {
            var parser = new TransactionsParser();

            parser.ParseFile(@"c:\ezbob\test-data\bank\bank2.csv");
            parser.ParseFile(@"c:\ezbob\test-data\bank\bank3.csv");
            parser.ParseFile(@"c:\ezbob\test-data\bank\bank4.csv");
            parser.ParseFile(@"c:\ezbob\test-data\bank\bank1_2.xls");
            parser.ParseFile(@"c:\ezbob\test-data\bank\bank1_1.xlsx");
            parser.ParseFile(@"c:\ezbob\test-data\bank\Current.July14.csv");
        }
Beispiel #4
0
        }         // ConvertData

        private ElapsedTimeInfo UpdateClientOrdersInfo(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, YodleeSecurityInfo securityInfo, MP_CustomerMarketplaceUpdatingHistory historyRecord)
        {
            Dictionary <BankData, List <BankTransactionData> > ordersList;

            if (databaseCustomerMarketPlace.DisplayName == "ParsedBank")
            {
                //retrieve data from file
                var fileInfo          = Helper.GetFileInfo((int)securityInfo.ItemId);
                var lastTransactionId = Helper.GetLastTransactionId();
                if (fileInfo == null)
                {
                    throw new Exception("file not found");
                }

                var parser     = new TransactionsParser();
                var parsedData = parser.ParseFile(fileInfo.FilePath);

                if (parsedData == null)
                {
                    throw new Exception(string.Format("failed to parse the file {0}", fileInfo.FileName));
                }
                if (!string.IsNullOrEmpty(parsedData.Error))
                {
                    throw new Exception(string.Format("failed to parse the file {0} \n {1}", fileInfo.FileName, parsedData.Error));
                }

                ordersList = ConvertData(parsedData, fileInfo.FileName, securityInfo.ItemId, lastTransactionId);
            }
            else
            {
                //retrieve data from Yodlee API
                ordersList = YodleeConnector.GetOrders(securityInfo.Name, Encrypted.Decrypt(securityInfo.Password),
                                                       securityInfo.ItemId);
            }

            var elapsedTimeInfo = new ElapsedTimeInfo();

            if (ordersList != null)
            {
                var newOrders = new YodleeOrderDictionary {
                    Data = ordersList
                };

                //save orders data
                ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(elapsedTimeInfo,
                                                                               databaseCustomerMarketPlace.Id,
                                                                               ElapsedDataMemberType.StoreDataToDatabase,
                                                                               () => Helper.StoreYodleeOrdersData(
                                                                                   databaseCustomerMarketPlace,
                                                                                   newOrders,
                                                                                   historyRecord)
                                                                               );
            }

            List <string> directors;

            ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(elapsedTimeInfo,
                                                                           databaseCustomerMarketPlace.Id,
                                                                           ElapsedDataMemberType.AggregateData,
                                                                           () => Helper.GetAllYodleeOrdersData(DateTime.Now, databaseCustomerMarketPlace, false, out directors));

            //Thread.Sleep(15000);
            return(elapsedTimeInfo);
        } // UpdateClientsOrderInfo