示例#1
0
 public JsonResult GetAllFunds()
 {
     FundRepository = new FundRepository(System.Web.HttpContext.Current.Server);
     var funds = FundRepository.GetFunds();
     var total = funds.Count;
     return Json(new { funds, total}, JsonRequestBehavior.AllowGet);
 }
示例#2
0
文件: FiltersTests.cs 项目: igiel/Etf
        public void ExportFilters()
        {
            var fundRepository = new FundRepository();
            var filterRepository = new BaseXmlRepository<Filter>();

            var funds = fundRepository.GetFunds();

            var filters = new List<Filter>();

            foreach (var prop in typeof(Fund).GetProperties())
            {
                var valuesList =
                funds.Select(f => prop.GetValue(f, null))
                    .Distinct()
                    .Where(a=> a != null)
                    .Select(f => new Filter { AttributeName = prop.Name, AttributeValue = f.ToString() })
                    .ToList();

                filters.AddRange(valuesList);
                //var a = string.Format("{0}={1}", prop.Name, prop.GetValue(funds.First(), null));
            }

            //var list =
            //    funds.Select(f => f.AssetClass)
            //        .Distinct()
            //        .Select(f => new Filter {AttributeName = nameof(Fund.AssetClass), AttributeValue = f})
            //        .ToList();

            filterRepository.Save(filters);
            Assert.AreNotEqual(0, filters.Count);
        }
示例#3
0
 public ActionResult Details(string fundId)
 {
     FundRepository = new FundRepository(System.Web.HttpContext.Current.Server);
     var model = FundRepository.GetFunds().FirstOrDefault(f => f.ExchangeBloombergCode.Equals(fundId));
     return View("Details/Details", model);
 }
示例#4
0
        public void GetFullFund()
        {
            var fundRepository = new FundRepository();
            var fundsLinks = this.etfsec.GetFundsLinks();
            foreach (var fundLink in fundsLinks)
            {
                try
                {
                    if(fundRepository.GetByFundUrl(fundLink)!=null)
                        continue;

                    //var etfConverter = new EtfConverter();
                    var etfConverter = this.etfsec.GetSingleFundByLink(fundLink);

                    var fund = etfConverter.Convert();
                    //fund.FundUrl = fundLink;

                    var sb = new StringBuilder();
                    sb.AppendLine("Not defined attributes: ");
                    EtfConverter.Attributes.Except(etfConverter.EtfFund.Keys).ForEach(x => sb.Append(x + "; "));
                    sb.AppendLine();
                    etfConverter.EtfFund.ForEach(x => sb.AppendLine(x.Key + " : " + x.Value));
                    sb.AppendLine("Fund url :" + etfConverter.FundUrl);
                    sb.AppendLine("Fund postdata :" + etfConverter.FundPostData);

                    var indexOfLastBackslash = fundLink.LastIndexOf('/');
                    var fileName = "Results/" + fundLink.Substring(indexOfLastBackslash + 1) + ".xml";
                    File.WriteAllText(fileName, sb.ToString());

                    fundRepository.AddOrUpdate(fund);
                }
                catch
                {

                }
            }

            //Assert.IsTrue(fundRepository.GetFunds().Count > 100, "Initial set is not parsed");
            Assert.IsTrue(fundRepository.GetFunds().Count > 200, "Full set is not parsed");
        }
示例#5
0
 public void ClearDuplicated()
 {
     var fundRepository = new FundRepository();
     var funds = fundRepository.GetFunds();
     var distinctFUnds = funds
         .GroupBy(f => f.ExchangeBloombergCode)
         .Select(g => g.First())
         .ToList();
     fundRepository.SaveFunds(distinctFUnds);
     Assert.IsTrue(distinctFUnds.Any());
 }