public RelatorioViewModel(IContextProvider repositorio)
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
                var batidas = new List<Batida>();
                batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 08, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 12, 0, 0), NaturezaBatida = NaturezaBatida.Saida });
                batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 13, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 18, 0, 0), NaturezaBatida = NaturezaBatida.Saida });

                batidas.Add(new Batida { Horario = new DateTime(2012, 2, 1, 08, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                batidas.Add(new Batida { Horario = new DateTime(2012, 2, 1, 12, 0, 0), NaturezaBatida = NaturezaBatida.Saida });
                batidas.Add(new Batida { Horario = new DateTime(2012, 2, 1, 13, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                batidas.Add(new Batida { Horario = new DateTime(2012, 2, 1, 17, 0, 0), NaturezaBatida = NaturezaBatida.Saida });

                var groups = batidas.ToKeyGroup(item => item.Horario.Date.ToString("dd/MM/yyyy"));

                Batidas = new ObservableCollection<KeyGroup<Batida>>(groups);
            }
            else
            {
                _cacheContext = repositorio.CacheContext;
                // Code runs in Blend --> create design time data.
                Batidas = new ObservableCollection<KeyGroup<Batida>>();

                PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName == "De" || args.PropertyName == "Ate")
                        AtualizaBatidas();
                };
            }
        }
        public LancamentoViewModel(IContextProvider repositorio)
        {
            _context = repositorio.CacheContext;
            Batidas = new ObservableCollection<Batida>();

            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.

                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 08, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 12, 0, 0), NaturezaBatida = NaturezaBatida.Saida });
                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 13, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 18, 0, 0), NaturezaBatida = NaturezaBatida.Saida });
            }
            else
            {
                // Code runs "for real"
                _configuracao = _context.Configuracoes.FirstOrDefault();

                AdicionarBatida = new RelayCommand(AddBatida);
                RemoverBatida = new RelayCommand<Batida>(RemoveBatida);

                Batidas.CollectionChanged += (sender, args) =>
                {
                    RaisePropertyChanged("HorarioTrabalhado");
                    RaisePropertyChanged("Resumo");
                };
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background
            // Launch a toast to show that the agent is running.
            // The toast will not be shown if the foreground application is running.
            var cache = new CacheContext();
            var batidasHoje = cache.Batidas.Where(b => b.Horario.Date == DateTime.Now.Date);

            var shellTileData = new StandardTileData
            {
                BackContent = string.Join("\n", batidasHoje.Select(x => x.Horario.ToShortTimeString())),
                BackTitle = "Batidas hoje"
            };

            ShellTile appTile = ShellTile.ActiveTiles.First();

            appTile.Update(shellTileData);

            // Call NotifyComplete to let the system know the agent is done working.

            NotifyComplete();
        }
Exemplo n.º 4
0
        public MainViewModel(IContextProvider repositorio)
        {
            context = repositorio.CacheContext;
            Batidas = new ObservableCollection<Batida>();

            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 08, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 12, 0, 0), NaturezaBatida = NaturezaBatida.Saida });
                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 13, 0, 0), NaturezaBatida = NaturezaBatida.Entrada });
                Batidas.Add(new Batida { Horario = new DateTime(2012, 1, 1, 18, 0, 0), NaturezaBatida = NaturezaBatida.Saida });
            }
            else
            {
                // Code runs "for real"

                context.Batidas
                    .Where(x => x.Horario.Date == DateTime.Now.Date)
                    .ToList()
                    .ForEach(Batidas.Add);

                CarregaConfiguracao();

                AdicionarBatida = new RelayCommand(AddBatida);
                RemoverBatida = new RelayCommand<Batida>(RemoveBatida);
                Batidas.CollectionChanged += (sender, args) =>
                {
                    RaiseChangedHorarioTrabalhado();
                    RegisterTasks();
                };

                if (AtualizaHorasTrabalhadas)
                    RaiseChangedHorarioTrabalhado();
            }
        }
 public BatidasToResumoConverter()
 {
     _cacheContext = new CacheContext();
 }