public void Add(AnimalComportamentoViewModel obj)
        {
            _uow.BeginTransaction();
            var caixa = _mapper.Map <AnimalComportamento>(obj);

            _animalComportamentoService.Add(caixa);
            Commit();
        }
Exemplo n.º 2
0
        private void FormVideoAnalyzerPlayerWmp_KeyDown(object sender, KeyEventArgs e)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            string empty  = string.Empty;
            Button button = sender as Button;

            if ((e == null ? true : e.KeyCode != Keys.Space))
            {
                try
                {
                    if (e == null)
                    {
                        empty = button.Text.Substring(0, 1);
                    }
                    this.lblComportamento.Text = string.Concat("Tecla: ", (string.IsNullOrEmpty(empty) ? (new KeysConverter()).ConvertToString(e.KeyCode) : empty.ToString()));
                    if ((this._comportamento == null ? true : this._comportamento.BotaoPressionado))
                    {
                        if (this._comportamento == null)
                        {
                            throw new CustomException("Erro ao inserir comportamento do animal!");
                        }
                        stopwatch.Stop();
                        this._transacoes.Add(stopwatch);
                        this._comportamento.Cronometro.Stop();
                        double totalSeconds = this._comportamento.Cronometro.Elapsed.TotalSeconds;
                        double num          = totalSeconds + this._transacoes.Sum <Stopwatch>((Stopwatch t) => t.Elapsed.TotalSeconds);
                        AnimalComportamentoViewModel animalComportamentoViewModel = new AnimalComportamentoViewModel()
                        {
                            Quantidade            = (long)1,
                            DataAnalise           = DateTime.Now,
                            IdUsuario             = Guid.Parse(Settings.Default.Logado),
                            Tempo                 = num,
                            IdAnimalComportamento = Guid.NewGuid(),
                            IdAnimal              = this.IdAnimalEmAnalise,
                            IdComportamento       = this._comportamento.IdComportamento
                        };
                        this._animalComportamentoAppService.Add(animalComportamentoViewModel);
                        this.lblComportamento.Text           = string.Empty;
                        this._comportamento.BotaoPressionado = false;
                    }
                    else
                    {
                        this._comportamento = this._comportamentos.FirstOrDefault <ComportamentoViewModel>((ComportamentoViewModel _) => (empty == null ? false : _.LetraTeclado.Equals((empty == string.Empty ? (new KeysConverter()).ConvertToString(e.KeyCode) : empty.ToString()), StringComparison.CurrentCultureIgnoreCase)));
                        if (this._comportamento != null)
                        {
                            stopwatch.Stop();
                            this._comportamento.Cronometro = new Stopwatch();
                            this._comportamento.Cronometro.Start();
                            this._transacoes.Add(stopwatch);
                            this._comportamento.BotaoPressionado = true;
                        }
                        else
                        {
                            this._comportamento = new ComportamentoViewModel();
                            return;
                        }
                    }
                }
                catch
                {
                }
            }
            else
            {
                base.FormBorderStyle  = System.Windows.Forms.FormBorderStyle.Sizable;
                base.WindowState      = FormWindowState.Normal;
                base.Size             = this._formSize;
                this.video.Owner      = this.painelVideo;
                this.painelVideo.Size = this._pnlSize;
            }
        }