Example #1
0
        private void LoadCounter()
        {
            //ReportItemDatabase.GetDatabase().DeleteAll<CounterTimestamp>();
            CounterTimestamp = ReportItemDatabase.GetDatabase().Table <CounterTimestamp>().FirstOrDefault();
            var a = ReportItemDatabase.GetDatabase().Table <CounterTimestamp>().ToList();

            if (CounterTimestamp != null)
            {
                CounterStarted = CounterTimestamp.Started;
                CounterText    = ReportUtils.FormatHourToCounter(new TimeSpan(CounterTimestamp.InitialTimestamp));
            }
            else
            {
                CounterStarted = false;
            }
            HandleCounterIcon();
        }
Example #2
0
        private void StartCounterCommandExecute()
        {
            CounterStarted = !CounterStarted;
            HandleCounterIcon();
            if (CounterStarted)
            {
                if (CounterTimestamp == null)
                {
                    CounterTimestamp = new CounterTimestamp {
                        InitialTimestamp = DateTime.Now.Ticks, Started = true
                    };
                    ReportItemDatabase.Save(CounterTimestamp);
                }
                else
                {
                    CounterTimestamp.InitialTimestamp = DateTime.Now.Ticks;
                    CounterTimestamp.Started          = true;
                    ReportItemDatabase.GetDatabase().Update(CounterTimestamp);
                }

                CounterText = ReportUtils.FormatHourToCounter(new TimeSpan(CounterTimestamp.InitialTimestamp));
            }
            else
            {
                if (CounterTimestamp != null)
                {
                    var      now         = DateTime.Now;
                    long     inicialDate = CounterTimestamp.InitialTimestamp;
                    long     finalDate   = now.Ticks;
                    TimeSpan totalTime   = new TimeSpan(finalDate - inicialDate).Duration();

                    CounterTimestamp.Started = false;
                    ReportItemDatabase.Update(CounterTimestamp);

                    var reportItem       = new ReportItem(now.Month, now.Day, now.Year, totalTime.Hours, totalTime.Minutes);
                    var navigationParams = new NavigationParameters();
                    navigationParams.Add(EzraConstants.REPORT_ITEM_NAV_PARAM, (ReportItem)reportItem);
                    navigationParams.Add(EzraConstants.IS_EDITING_NAV_PARAM, false);
                    NavigationService.NavigateAsync(EzraConstants.REPORT_EDITION_PAGE, navigationParams);
                }
            }
        }