예제 #1
0
        private async void initDailyPieChartData()
        {
            try
            {
                //设置日期控件日期
                MainPage.notification.Date_DP = LocalSettingsHelper.GetDPDate();

                // 获取饼图记录
                IEnumerable <PieChartDataItem> allRecords = await Common.GetPieRecords();

                if (allRecords != null)
                {
                    foreach (var record in allRecords)
                    {
                        PieChartDataItem data = new PieChartDataItem
                        {
                            title = record.title,
                            value = record.value
                        };
                        MainPage.notification.Data_pie_daily.Add(data);
                        switch (record.title)
                        {
                        case "dining":
                            MainPage.notification.Text_dining = record.value.ToString();
                            break;

                        case "sleep":
                            MainPage.notification.Text_sleep = record.value.ToString();
                            break;

                        case "toilet":
                            MainPage.notification.Text_toilet = record.value.ToString();
                            break;

                        case "parlour":
                            MainPage.notification.Text_parlour = record.value.ToString();
                            break;

                        case "outdoor":
                            MainPage.notification.Text_outdoor = record.value.ToString();
                            break;
                        }
                    }
                }
            } catch (Exception e)
            {
                Debug.WriteLine("InitDaily: " + e.Message);
            }
        }
예제 #2
0
        // 添加一条饼图记录
        public async void AddNew(PieChartDataItem item)
        {
            await Getdata();

            this.data.Add(item);
        }
예제 #3
0
        private void OnDailyReceived()
        {
            try
            {
                isReceiveDaily = true;

                Daily daily = Util.DataContractJsonDeSerializer <Daily>(message);
                //将日常数据加入到本地存储中
                dailyDataHelper.AddNew(daily);
                //  dailyDataHelper.SaveToFile();
                LocalSettingsHelper.SetDPDate(Util.StringToDateOffset(daily.date));
                Date_DP = LocalSettingsHelper.GetDPDate();

                PieChartDataItem item_dining = new PieChartDataItem();
                item_dining.title = "dining";
                item_dining.value = daily.dining;
                Text_dining       = daily.dining.ToString();

                PieChartDataItem item_sleep = new PieChartDataItem();
                item_sleep.title = "sleep";
                item_sleep.value = daily.sleep;
                Text_sleep       = daily.sleep.ToString();

                PieChartDataItem item_parlour = new PieChartDataItem();
                item_parlour.title = "parlour";
                item_parlour.value = daily.parlour;
                Text_parlour       = daily.parlour.ToString();

                PieChartDataItem item_toilet = new PieChartDataItem();
                item_toilet.title = "toilet";
                item_toilet.value = daily.toilet;
                Text_toilet       = daily.toilet.ToString();

                PieChartDataItem item_outdoor = new PieChartDataItem();
                item_outdoor.title = "outdoor";
                item_outdoor.value = daily.outdoor;
                Text_outdoor       = daily.outdoor.ToString();

                if (Data_pie_daily.Count > 0)
                {
                    int count = int.MaxValue;
                    while (count > 0)
                    {
                        try
                        {
                            Data_pie_daily.Clear();
                            pieChartDataHelper.Clear();
                            count = Data_pie_daily.Count;
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine(e.Message);
                        }
                    }
                }

                Data_pie_daily.Add(item_dining);
                Data_pie_daily.Add(item_sleep);
                Data_pie_daily.Add(item_toilet);
                Data_pie_daily.Add(item_parlour);
                Data_pie_daily.Add(item_outdoor);

                pieChartDataHelper.AddNew(item_dining);
                pieChartDataHelper.AddNew(item_sleep);
                pieChartDataHelper.AddNew(item_toilet);
                pieChartDataHelper.AddNew(item_parlour);
                pieChartDataHelper.AddNew(item_outdoor);
                pieChartDataHelper.SaveToFile();
            }
            catch (Exception e)
            {
                if (e.Message != "")
                {
                    Debug.WriteLine("OnDailyReceived: " + e.Message);
                }
            }
        }
예제 #4
0
        private async void DP_onDateChanged(object sender, DatePickerValueChangedEventArgs e)
        {
            try
            {
                bool isNull = true;
                if (dp_date.Date != DateTime.Now.Date)
                {
                    IEnumerable <Daily> allRecords = await Common.GetThisDayDailyRecords(dp_date.Date.ToString("yyyy/MM/dd"));

                    if (allRecords != null)
                    {
                        foreach (var record in allRecords)
                        {
                            isNull = false;
                            if (MainPage.notification.Data_pie_daily != null && MainPage.notification.Data_pie_daily.Count > 0)
                            {
                                int count = int.MaxValue;
                                while (count > 0)
                                {
                                    try
                                    {
                                        MainPage.notification.Data_pie_daily.Clear();
                                        count = MainPage.notification.Data_pie_daily.Count;
                                    }
                                    catch (Exception exc)
                                    {
                                        Debug.WriteLine(exc.Message);
                                    }
                                }
                            }
                            PieChartDataItem item_dining = new PieChartDataItem();
                            item_dining.title = "dining";
                            item_dining.value = record.dining;
                            MainPage.notification.Data_pie_daily.Add(item_dining);
                            MainPage.notification.Text_dining = record.dining.ToString();

                            PieChartDataItem item_sleep = new PieChartDataItem();
                            item_sleep.title = "sleep";
                            item_sleep.value = record.sleep;
                            MainPage.notification.Data_pie_daily.Add(item_sleep);
                            MainPage.notification.Text_sleep = record.sleep.ToString();

                            PieChartDataItem item_toilet = new PieChartDataItem();
                            item_toilet.title = "toilet";
                            item_toilet.value = record.toilet;
                            MainPage.notification.Data_pie_daily.Add(item_toilet);
                            MainPage.notification.Text_toilet = record.toilet.ToString();

                            PieChartDataItem item_parlour = new PieChartDataItem();
                            item_parlour.title = "parlour";
                            item_parlour.value = record.parlour;
                            MainPage.notification.Data_pie_daily.Add(item_parlour);
                            MainPage.notification.Text_parlour = record.parlour.ToString();

                            PieChartDataItem item_outdoor = new PieChartDataItem();
                            item_outdoor.title = "outdoor";
                            item_outdoor.value = record.outdoor;
                            MainPage.notification.Data_pie_daily.Add(item_outdoor);
                            MainPage.notification.Text_outdoor = record.outdoor.ToString();
                        }
                    }
                }
                if (isNull)
                {
                    dp_date.Date = LocalSettingsHelper.GetDPDate();
                    string        message = "No records in the day";
                    MessageDialog dialog  = new MessageDialog(message);
                    await dialog.ShowAsync();
                }
            }
            catch (Exception exc)
            {
                Debug.WriteLine("PivotPage DP_Changed: " + exc.Message);
            }
        }