void ProcessTask(Task task) { Step = String.Concat("Retrieving Funds List for Product ", task.product.Name, " ..."); StepType = false; ProgressPct = 0; serviceadapter.GetFundsByProductCode(task.product.Code, (result) => { OLife olife = result.Result; Total = olife.Items.Count(); task.Total = Total; foreach (InvestmentProduct investproduct in olife.Items) { SourceLookup lookup = new SourceLookup() { SourceType = SourceTypes.Silica_FundCode, SourceId = investproduct.InvestProductSysKey[0].Replace("Compass_FundCode{", "").Replace("}", ""), }; //Only for dev purposes until the live feed is up lookup.ProductCode = investproduct.ProductCode; serviceadapter.AddRequest(lookup); } }); }
public void AddRequest(SourceLookup lookup) { lock (_Queue) { _Queue.Enqueue(lookup); } }
private void DoWork(object sender, DoWorkEventArgs e) { while (!_Worker.CancellationPending) { if (_Queue.Count > 0) { int _NumRequests = 0; lock (_ActiveRequests) { _NumRequests = _ActiveRequests.Count; } if (_NumRequests >= _MaxRequests) { continue; } // Check the queue for new request items SourceLookup lookup = null; lock (_Queue) { lookup = _Queue.Dequeue(); } if (lookup == null) { continue; } // We found a new request item! lock (_ActiveRequests) { _ActiveRequests.Add(lookup); } // TBD: Initiate an async service request, // something like the following: try { proxy.GetFundAsync(lookup, lookup); } catch (Exception Ex) { } } } }
void proxy_GetFundCompleted(object sender, GetFundCompletedEventArgs e) { try { if (e.Error != null || e.Cancelled) { if (OnFundProcessError != null) { OnFundProcessError(this, new SourceLookupEventArgs(e.UserState as SourceLookup)); } } OLife obj = e.Result; InvestmentProduct investmentproduct = (InvestmentProduct)obj.Items[0]; string code = investmentproduct.InvestProductSysKey[0].Replace("Silica_FundCode{", "").Replace("}", ""); SourceLookup lookup = e.UserState as SourceLookup; //_ActiveRequests.SingleOrDefault(t => t.SourceId == code); lock (_ActiveRequests) { if (lookup != null) { _ActiveRequests.Remove(lookup); } Fund fund = new Fund(investmentproduct); FundController.CreateFundWithPerformance(fund); if (OnFundProcessed != null) { OnFundProcessed(this, new InvestProductEventArgs(investmentproduct)); } } } catch (Exception ex) { throw ex; } }
OLife IFundService.GetFund(SourceLookup sourceLookup) { return(OLifeLoader.LoadBySourceLookup(sourceLookup)); #region XML //Serializable.OLifE obj = OLifeLoader.LoadBySourceLookup(sourceLookup); //var sfund = obj.InvestProduct.FirstOrDefault(); //InvestmentProduct fund = new InvestmentProduct() //{ // CarrierName = sfund.CarrierName, // InvestProductSysKey = new String[] { sfund.InvestProductSysKey }, // ProductSymbol = sfund.ProductSymbol, // FundFamilyName = sfund.FundFamilyName, // FullName = sfund.FullName, // SaleEffectiveDate = sfund.SaleEffectiveDate //}; //List<OLifEExtension> extlst = new List<OLifEExtension>(); //foreach (var itm in sfund.OLifEExtension) //{ // OLifEExtension ext = new OLifEExtension(); // ext.VendorCode = itm.VendorCode; // if (itm.SectorAllocation != null && itm.SectorAllocation.Count() > 0) // { // List<SectorAllocation> marketsectors = new List<SectorAllocation>(); // foreach (var sec in itm.SectorAllocation) // { // marketsectors.Add(new SectorAllocation() // { // JSECode = sec.JSECode, // Local = Convert.ToDouble(sec.Local), // MarketSector = sec.MarketSector, // Total = sec.Total, // }); // } // ext.Items = (object[])marketsectors.ToArray(); // extlst.Add(ext); // } // if (itm.FundPrice != null && itm.FundPrice.Count() > 0) // { // List<FundPrice> fundprices = new List<FundPrice>(); // foreach (var pr in itm.FundPrice) // { // fundprices.Add(new FundPrice() // { // Date = pr.Date, // Name = pr.Name, // Performance = Convert.ToDouble(pr.Performance) // }); // } // ext.Items = (object[])fundprices.ToArray(); // extlst.Add(ext); // } //} //OLife olife = new OLife(); //fund.OLifEExtension = extlst.ToArray(); //List<OLifeBase> lst = new List<OLifeBase>(); //lst.Add(fund); //olife.Items = lst.ToArray(); //return olife; #endregion }
public static OLife LoadBySourceLookup(SourceLookup sourceLookup) { FileHelperEngine engine = new FileHelperEngine(typeof(Funds)); Funds[] fundsexport = (Funds[])engine.ReadFile(HttpContext.Current.Server.MapPath("~/App_Data/Funds.csv")); engine = new FileHelperEngine(typeof(FundPerformance)); FundPerformance[] fundPerformance = (FundPerformance[])engine.ReadFile(HttpContext.Current.Server.MapPath("~/App_Data/FundPerformance.csv")); OLife olife = new OLife(); List <OLifeBase> lstProduct = new List <OLifeBase>(); //THIS WILL CHANGE ON LIVE //int SourceId = int.Parse(sourceLookup.SourceId); // var funds = fundsexport.Where(t => t.TrustNo == SourceId).ToList(); //var sfund = fundsexport.FirstOrDefault(t => t.TrustNo == SourceId); var sfund = fundsexport.SingleOrDefault(t => t.JSECode == sourceLookup.SourceId); //foreach (var sfund in funds) //{ if (sfund != null) { InvestmentProduct fund = new InvestmentProduct() { id = String.Concat("STLB_InvestmentProduct_", sfund.TrustNo), //InvestProductSysKey = new String[] { String.Concat("Silica_FundCode{", sfund.TrustNo.ToString(), "}") }, InvestProductSysKey = new String[] { String.Concat("Silica_FundCode{", sfund.JSECode.ToString(), "}") }, ProductCode = sourceLookup.ProductCode, FullName = sfund.FundName, SaleEffectiveDate = sfund.QuarterEnd }; OLifEExtension ext = new OLifEExtension(); List <OLifEExtension> extlst = new List <OLifEExtension>(); List <FundPrice> fundprices = new List <FundPrice>(); List <SectorAllocation> sectors = new List <SectorAllocation>(); ext.VendorCode = "STANLIB"; sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Resources", Local = sfund.Resources, LocalSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Financials", Local = sfund.Financials, LocalSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Industrials", Local = sfund.Industrials, LocalSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Alt X", Local = sfund.AltX, LocalSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Property", Local = sfund.Property, LocalSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Bonds", Local = sfund.Bonds, LocalSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Cash", Local = sfund.Cash, LocalSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Foreign Equity", Foreign = sfund.ForeignEquity, ForeignSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Foreign Bonds", Foreign = sfund.ForeignBonds, ForeignSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Foreign Property", Foreign = sfund.ForeignProperty, ForeignSpecified = true }); sectors.Add(new SectorAllocation { JSECode = sfund.JSECode, MarketSector = "Foreign Cash", Foreign = sfund.ForeignCash, ForeignSpecified = true }); ext.Items = (object[])sectors.ToArray(); extlst.Add(ext); ext = new OLifEExtension(); var fundprice = fundPerformance.FirstOrDefault(t => t.JSECode.Trim() == sfund.JSECode.ToString()); if (fundprice != null) { fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M1"), Performance = fundprice.M1, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M2"), Performance = fundprice.M2, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M3"), Performance = fundprice.M3, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M4"), Performance = fundprice.M4, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M5"), Performance = fundprice.M5 }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M6"), Performance = fundprice.M6, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M7"), Performance = fundprice.M7 }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M8"), Performance = fundprice.M8, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M9"), Performance = fundprice.M9 }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M10"), Performance = fundprice.M10, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M11"), Performance = fundprice.M11 }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M12"), Performance = fundprice.M12, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M13"), Performance = fundprice.M13, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M14"), Performance = fundprice.M14, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M15"), Performance = fundprice.M15 }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M16"), Performance = fundprice.M16, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M17"), Performance = fundprice.M17, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M18"), Performance = fundprice.M18, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M19"), Performance = fundprice.M19, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M20"), Performance = fundprice.M20, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M21"), Performance = fundprice.M21, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M22"), Performance = fundprice.M22, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M23"), Performance = fundprice.M23, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M24"), Performance = fundprice.M24, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M25"), Performance = fundprice.M25, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M26"), Performance = fundprice.M26 }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M26"), Performance = fundprice.M27, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M28"), Performance = fundprice.M28, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M29"), Performance = fundprice.M29, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M30"), Performance = fundprice.M30, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M31"), Performance = fundprice.M31, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M32"), Performance = fundprice.M32, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M33"), Performance = fundprice.M33, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M34"), Performance = fundprice.M34, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M35"), Performance = fundprice.M35, Name = sfund.FundName, Type = PriceType.Price }); fundprices.Add(new FundPrice() { JSECode = fundprice.JSECode, Date = LookupDate("M36"), Performance = fundprice.M36 }); ext.Items = (object[])fundprices.ToArray(); extlst.Add(ext); } fund.OLifEExtension = extlst.ToArray(); lstProduct.Add(fund); } //} olife.Items = lstProduct.ToArray(); return(olife); }
private void Load(string folder, IEnumerable <EntityDefinition> definitions) { if (definitions == null) { return; } foreach (var ed in definitions) { ed.Vocabulary = this; if (ed.Concepts == null) { continue; } foreach (var c in ed.Concepts) { if (!string.IsNullOrEmpty(c.SourceLookup)) { if (!sourceLookups.ContainsKey(c.SourceLookup)) { var lookupFolder = c.SourceLookup; if (!string.IsNullOrEmpty(folder)) { lookupFolder = Path.Combine(folder, c.SourceLookup); } var lookup = new SourceLookup(Settings.Current.Building.VocabularyConnectionString, lookupFolder, Settings.Current.Building.VocabularySchemaName); lookup.Load(); sourceLookups.Add(c.SourceLookup, lookup); } } if (c.ConceptIdMappers == null) { continue; } foreach (var conceptIdMapper in c.ConceptIdMappers) { if (!string.IsNullOrEmpty(conceptIdMapper.Lookup)) { if (!lookups.ContainsKey(conceptIdMapper.Lookup)) { var lookupFolder = conceptIdMapper.Lookup; if (!string.IsNullOrEmpty(folder)) { lookupFolder = Path.Combine(folder, conceptIdMapper.Lookup); } var lookup = new MultiLookup(GetConnectionString(lookupFolder), lookupFolder, GetSchemaName(lookupFolder)); lookup.Load(); lookups.Add(conceptIdMapper.Lookup, lookup); } } if (string.IsNullOrEmpty(conceptIdMapper.File)) { continue; } if (lookups.ContainsKey(conceptIdMapper.File)) { continue; } var lookupFileLocation = conceptIdMapper.File; if (!string.IsNullOrEmpty(folder)) { lookupFileLocation = Path.Combine(folder, conceptIdMapper.File); } if (!rfLookups.ContainsKey(conceptIdMapper.File)) { var rfLookup = new ReferenceFileLookup(lookupFileLocation); rfLookup.Load(); rfLookups.Add(conceptIdMapper.File, rfLookup); } } if (c.SourceConceptIdMappers != null) { foreach (var conceptIdMapper in c.SourceConceptIdMappers) { if (!string.IsNullOrEmpty(conceptIdMapper.Lookup)) { if (!lookups.ContainsKey(conceptIdMapper.Lookup)) { var lookupFolder = conceptIdMapper.Lookup; if (!string.IsNullOrEmpty(folder)) { lookupFolder = Path.Combine(folder, conceptIdMapper.Lookup); } var lookup = new MultiLookup(GetConnectionString(lookupFolder), lookupFolder, GetSchemaName(lookupFolder)); lookup.Load(); lookups.Add(conceptIdMapper.Lookup, lookup); } } } } } } }
public SourceLookupEventArgs(SourceLookup lookup) { this.sourcelookup = lookup; }