Example #1
0
        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);
                }
            });
        }
Example #2
0
        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;
            }
        }
Example #3
0
        public static OLife LoadByProductCode(ProductCode productCode)
        {
            FileHelperEngine engine = new FileHelperEngine(typeof(Funds));

            Funds[] funds = (Funds[])engine.ReadFile(HttpContext.Current.Server.MapPath("~/App_Data/Funds.csv"));

            OLife obj = new OLife();

            var lst = from x in funds
                      select new InvestmentProduct
            {
                id = String.Concat("STLB_InvestmentProduct_", x.TrustNo),
                InvestProductSysKey = new String[] { String.Concat("Compass_FundCode{", x.JSECode.ToString(), "}") },
                ProductCode         = productCode.ToString("F"),
                FullName            = x.FundName,
                SaleEffectiveDate   = x.QuarterEnd
            };

            OLife olife = new OLife();

            olife.Items = lst.ToArray();

            return(olife);
        }
Example #4
0
        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);
        }