Beispiel #1
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);
                }
            }
        }
Beispiel #2
0
        //保存日常列表
        //public async void SaveToFile()
        //{
        //    if (_data != null)
        //    {
        //        await StorageFileHelper.WriteAsync(_data, "Daily.dat");
        //    }
        //    else
        //    {
        //        MessageDialog dialog = new MessageDialog("data is null!");
        //        await dialog.ShowAsync();
        //    }
        //}

        // 移除一条记录
        public void Remove(Daily item)
        {
            _data.Remove(item);
        }