public bool GetBusy() { MarketTimeConverter date = new MarketTimeConverter(); var manila = date.ManilaTime; var withinTimeFrame = (manila.Ticks > date.MarketPreOpen.Ticks && manila.Ticks < date.MarketOpen.Ticks); return(withinTimeFrame); }
private async void RefreshPortfolioList(string param = "") { StockServices services = new StockServices(); IsBusy = false; ObservableCollection <Portfolio> port = new ObservableCollection <Portfolio>( await App._PortfolioData.GetPortfolioListAsync());; PortfolioList = port; NetTotal = PortfolioList.Sum(i => i.NetMarketValue); GainLoss = PortfolioList.Sum(i => i.NetGain); OriginalValue = PortfolioList.Sum(i => i.OriginalMarketValue); PercentGainLoss = Math.Round((GainLoss / OriginalValue) * 100, 2); AsOf = new MarketTimeConverter().ManilaTime; IsBusy = false; }
public async void RefreshListAsync() { MarketTimeConverter market = new MarketTimeConverter(); var active = await market.MarketActive(); if (!active || IsBusy) { return; } { try { lstView.BeginRefresh(); } catch (Exception e) { return; } } lstView.EndRefresh(); }
private async void RefreshListAsync() { MarketTimeConverter market = new MarketTimeConverter(); var active = await market.MarketActive(); if (!active || IsBusy) { return; } try { lstPortfolio.BeginRefresh(); } catch (Exception e) { return; } lstPortfolio.EndRefresh(); }
public async void Initialize() { MarketTimeConverter market = new MarketTimeConverter(); LocalStorageService storage = new LocalStorageService(); DateTime LastWrite = DateTime.UtcNow.AddHours(8); var exists = await storage.FileExists(); StockServices services = new StockServices(); string jsonStocks = ""; if (exists) { try { jsonStocks = await services.GetStringJson(); var root = JsonConvert.DeserializeObject <StockRoot>(jsonStocks); var LastServerUpdate = root.LastUpdate; LastWrite = await storage.GetLastWrite(); if (LastServerUpdate > LastWrite) //check if data server is updated { await storage.WriteText(jsonStocks); } } catch (Exception) { return; } } else //write the file automatically { jsonStocks = await services.GetStringJson(); var root = JsonConvert.DeserializeObject <StockRoot>(jsonStocks); await storage.WriteText(jsonStocks); } }
public async void CheckMarketActive() { MarketTimeConverter market = new MarketTimeConverter(); MarketActive = await market.MarketActive(); }
public override void OnReceive(Context context, Intent intent) { int counter = 0; MarketTimeConverter marketTime = new MarketTimeConverter(); ConnectionStatus conn = new ConnectionStatus(); var message = intent.GetStringExtra("message"); var title = intent.GetStringExtra("title"); var notIntent = new Intent(context, typeof(MainActivity)); var contentIntent = PendingIntent.GetActivity( context, ++counter, notIntent, PendingIntentFlags.UpdateCurrent); var manager = NotificationManagerCompat.From( context); var style = new NotificationCompat.BigTextStyle(); style.BigText(message); //generate notications var builder = new NotificationCompat.Builder(context) .SetContentIntent(contentIntent) .SetSmallIcon(Resource.Drawable.stocks) .SetContentTitle(title) .SetContentText(message) .SetStyle(style) .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()) .SetAutoCancel(true) .SetDefaults(1); var notification = builder.Build(); CheckMarketActive(); if (!MarketActive) { return; } var open = title.Contains("Open"); var close = title.Contains("Close"); var timeAhead = 7; var ahead = marketTime.SampleTime.AddMinutes(30); var t = marketTime.SampleTime > marketTime.ManilaTime; var withinTimeFrame = (marketTime.ManilaTime.Ticks > marketTime.MarketOpen.Ticks && marketTime.ManilaTime.Ticks < marketTime.MarketOpen.AddMinutes(timeAhead).Ticks); var withinTimeFrameClose = (marketTime.ManilaTime.Ticks > marketTime.MarketClose.Ticks && marketTime.ManilaTime.Ticks < marketTime.MarketClose.AddMinutes(timeAhead).Ticks); if (open && !withinTimeFrame) { return; } if (close && !withinTimeFrameClose) { return; } manager.Notify(++counter, notification); }