Ejemplo n.º 1
0
        /// <summary>
        /// Update the data to monthly usage
        /// </summary>
        /// <param name="directionPeakType">One of the magic strings depicting download/upload and onpeak/offpeak/total</param>
        /// <returns>A Task, in case you wanna await for it</returns>
        public async Task UpdateMonthly(string directionPeakType)
        {
            _usages.Clear();
            var values = await TeksavvyDataSource.GetAllMonthlyUsageOperation();

            var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;

            await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                List <Usage> tmpList = values.Select(usageData => new Usage {
                    Name   = usageData.EndDate.Substring(0, 7),
                    Amount = getUsageData(usageData, directionPeakType)
                }).ToList();
                _usages.AddRange(tmpList);
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the data to daily usage
        /// </summary>
        /// <param name="directionPeakType">One of the magic strings depicting download/upload and onpeak/offpeak/total</param>
        /// <returns>A Task, in case you wanna await for it</returns>
        public async Task UpdateDaily(string directionPeakType)
        {
            _usages.Clear();
            var values = await TeksavvyDataSource.GetAllDailyUsageOperation();

            var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;

            await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                List <Usage> tmpList = new List <Usage>();
                for (int i = values.Count - 30; i < values.Count; i++)
                {
                    var usageData = values[i];
                    tmpList.Add(new Usage {
                        Name   = usageData.Date.Substring(0, 10),
                        Amount = getUsageData(usageData, directionPeakType)
                    });
                }
                _usages.AddRange(tmpList);
            });
        }