public TopSecuritiesViewModel GetTopSecurities(string currency, List <int> exchanges, List <int> ranks) { TopSecuritiesViewModel securitiesVM = new TopSecuritiesViewModel(); securitiesVM.Securities = SecuritiesBL.GetTopSecurities(exchanges, ranks); return(securitiesVM); }
public void addMissingSecurities(ISecurities newColl, List <string> missingSecs) { securityRepository.Execute(session => { var securities = newColl.GetTopSecurities(new List <int>() { 1 }, new List <int>() { 1 }, string.Join(",", missingSecs)); List <Models.dbo.Price> ALLprices = getFullPrices(string.Join(",", missingSecs)); Parallel.ForEach(securities, s => { try { var CurrentSec = getCurrSecurity(s, m_objPortfolio); CurrentSec.PriceTable = AutoMapper.Mapper.Map <List <Price>, List <Entities.dbo.Price> >(ALLprices.Where(x => x.idSecurity == CurrentSec.Properties.PortSecurityId).OrderByDescending(x => x.dDate).ToList()); if (CurrentSec != null) { newColl.Add(CurrentSec); } } catch (Exception ex) { if (m_objErrorHandler != null) { m_objErrorHandler.LogInfo(ex); } } }); m_objPortfolio.Classes.RatesHandler.setSecuritiesPriceReturns(newColl, DateTime.Today.AddYears(-3).AddDays(-1), DateTime.Today.AddDays(-1), m_objPortfolio.Details.CalcCurrency); }); }
}//SetSecurites public void AddSecuritiesToMemory(int exchange) //, List<Models.dbo.Price> ALLprices) { securityRepository.Execute(session => { //List<cSecurity> lst; if (StaticData <cSecurity, ISecurities> .lst == null) { StaticData <cSecurity, ISecurities> .lst = new List <cSecurity>(); } else { //lst = StaticData<cSecurity, ISecurities>.lst; var secs = StaticData <cSecurity, ISecurities> .lst.Where(x => x.Properties.Market.ID == exchange).ToList(); int i = 0; while (secs.Count() > 0) { StaticData <cSecurity, ISecurities> .lst.Remove(secs[i]); secs.Remove(secs[i]); } } var securities = m_colSecurities.GetTopSecurities(new List <int>() { exchange }, new List <int>() { 1 }); m_colSecurities.Clear(); m_colFullCollection.Clear(); string securityID_list = getSecIDsString(securities); List <Models.dbo.Price> ALLprices = getFullPrices(securityID_list); var parallelList = new ConcurrentBag <cSecurity>(); Parallel.ForEach(securities, s => { try { if (StaticData <cSecurity, ISecurities> .lst.Where(x => x.Properties.PortSecurityId == s.idSecurity).Count() == 0) { var CurrentSec = getCurrSecurity(s, m_objPortfolio); CurrentSec.PriceTable = AutoMapper.Mapper.Map <List <Price>, List <Entities.dbo.Price> >(ALLprices.Where(x => x.idSecurity == CurrentSec.Properties.PortSecurityId).OrderByDescending(x => x.dDate).ToList()); if (CurrentSec != null) { parallelList.Add(CurrentSec); } } } catch (Exception ex) { if (m_objErrorHandler != null) { m_objErrorHandler.LogInfo(ex); } } }); StaticData <cSecurity, ISecurities> .lst.AddRange(parallelList); }); }