public WeeklyDataDisplayer(Strategy vtrades, bool visIntraDay, DateTime startTime, DateTime endTime)
            : base(vtrades, visIntraDay, startTime, endTime)
        {
            DateTimeFormatInfo dtfInfo = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentCulture);

            _dateTimeFormat = "dd" + dtfInfo.DateSeparator.ToString() + "MM" + dtfInfo.DateSeparator.ToString() + "yyyy" +
                              " HH:mm:ss";
            _dayindexer = 0;
            _weekindexer = 0;
            _tradeindexer = 0;
            _isFullWeek = false;
            _tempDayOfYear = Trades[0].TimeOpen.DayOfYear;
            _currDayOfYear = _tempDayOfYear;
            _currentweek = Trades[0].TimeOpen.DayOfYear;
            _tempweek = Trades[0].TimeOpen.DayOfYear;

            _currWeek = Trades[0].TimeOpen;
            _startWeek = Trades[0].TimeOpen;
            _endWeek = Trades[0].TimeOpen;
            _tempTrades = Trades;

            _weeklyData = new WeeklyData();

            _weeklyData.Relations.Add("1", _weeklyData.Tables["tableWeek"].Columns["id"],
                                   _weeklyData.Tables["tableDays"].Columns["id_Week"], false);
            _weeklyData.Relations.Add("2", _weeklyData.Tables["tableDays"].Columns["id"],
                                   _weeklyData.Tables["tableTrades"].Columns["id_Day"], false);

            CreateDataTablesFromTrades();
        }
        private void UpdateData()
        {
            DateTime selectedWeek = FirstDayOfWeek(DateTime.Now - (TimeSpan.FromDays(7 * _day)));

            WeeklyData.Clear();

            for (int i = 0; i < 7; i++)
            {
                DailyRecord record;
                record = SelectedUser.FindRecord(selectedWeek + TimeSpan.FromDays(i), true);

                ChartData[i].value1 = (selectedWeek + TimeSpan.FromDays(i)).Day;
                ChartData[i].value2 = 0;

                if (record != null)
                {
                    Record sumRec = record.SummarizeRecord();
                    WeeklyData.Add(sumRec);
                    ChartData[i].value2 = sumRec.WalkingStepCount + sumRec.RunningStepCount;
                }
            }

            OnPropertyChanged(null);
            ChartData.UpdateCollection();
        }
示例#3
0
    public static void UploadWeeklyData(WeeklyData wdata)
    {
        string temp = string.Format("{3}/uploadweekly?t={4}&branch_id={0}&date_sent={1}&data_array={2}", wdata.BranchId, wdata.Date.ToString("yyyy-MM-dd"), wdata.Data, DbControllerUrl, token);

        //System.IO.File.Create(@"C:\Database\" + temp + ".txt");
        ServerCommunication.UploadDataGet(temp);
    }
        private void UpdateData()
        {
            DateTime selectedWeek = FirstDayOfWeek(DateTime.Now - (TimeSpan.FromDays(7 * _day)));

            WeeklyData.Clear();

            for (int i = 0; i < 7; i++)
            {
                DailyRecord record;
                record = SelectedUser.FindRecord(selectedWeek + TimeSpan.FromDays(i), true);

                ChartData[i].value1 = (selectedWeek + TimeSpan.FromDays(i)).Day;
                ChartData[i].value2 = 0;

                if (record != null)
                {
                    Record sumRec = record.SummarizeRecord();
                    WeeklyData.Add(sumRec);

                    DateTime startDate = new DateTime(record.Date.Year, record.Date.Month, record.Date.Day, 0, 0, 0);

                    //24 hrs a day
                    for (int a = 0; a < 24; a++)
                    {
                        var hrec    = record.GetHourlyRecord(a, true);
                        int walking = (hrec == null || hrec.ActivityType != 0 ? 0 : _counter.GetWalkingCalorieBurn(hrec));
                        int hourly  = (hrec == null ? ((startDate.Date == DateTime.Now.Date && a > DateTime.Now.Hour) ? 0 : _counter.CalcHourlyBMR(startDate)) : _counter.AdjustedBMR(hrec));

                        areaChartData[i].value2 += hourly + walking;

                        startDate += TimeSpan.FromHours(1);
                    }

                    foreach (Record hrec in record.Records)
                    {
                        int activity = (hrec == null || hrec.ActivityType == 0 ? 0 : (int)((double)_counter.RawBMR() * 1.157407407407407e-5 * (double)hrec.WalkTime
                                                                                           * hrec.RealActivity.metaEquivalent)); //BMR per second
                        areaChartData[i].value2 += activity;
                    }
                }
            }

            OnPropertyChanged(null);
            ChartData.UpdateCollection();
        }