/// <summary>
        /// 视频管理界面
        /// 查询导入的所有视频
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public ObservableCollection <MetaViewModel> SelectAll(int count)
        {
            ObservableCollection <MetaViewModel> mvms = new ObservableCollection <MetaViewModel>();

            using (IDbConnection conn = SqlHelper.GetConnection())
            {
                conn.Open();
                var sql = @"SELECT * FROM TB_METADATA ORDER BY ID DESC LIMIT @count;";
                IEnumerable <dynamic> dynamics = conn.Query(sql, new { count });
                foreach (var item in dynamics)
                {
                    MetaViewModel mvm = new MetaViewModel
                    {
                        Id = Convert.ToInt32(item.ID)
                    };
                    MetaModel mm = new MetaModel
                    {
                        TaskCode  = item.TASKCODE,
                        Addr      = item.ADDR,
                        PipeCode  = item.PIPECODE,
                        VideoPath = item.VIDEOPATH,
                        StartTime = item.STARTTIME,
                        PipeType  = Convert.ToInt32(item.PIPETYPE),
                        GC        = item.GC,
                        FramePath = item.FRAMEPATH
                    };
                    mvm.Meta = mm;
                    mvms.Add(mvm);
                }

                return(mvms);
            }
        }
        /// <summary>
        /// 检测文件选择界面
        /// 获取所有分帧的视频列表
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <MetaViewModel> SelectAllFramed()
        {
            ObservableCollection <MetaViewModel> mvms = new ObservableCollection <MetaViewModel>();

            using (IDbConnection conn = SqlHelper.GetConnection())
            {
                conn.Open();
                var sql = @"SELECT * FROM TB_METADATA WHERE FRAMEPATH IS NOT NULL AND FRAMEPATH != '' ORDER BY ID DESC LIMIT 500;";
                IEnumerable <dynamic> dynamics = conn.Query(sql);
                foreach (var item in dynamics)
                {
                    MetaViewModel mvm = new MetaViewModel
                    {
                        Id = (int)item.ID
                    };
                    MetaModel mm = new MetaModel
                    {
                        VideoPath = item.VIDEOPATH,
                        Addr      = item.ADDR,
                        TaskCode  = item.TASKCODE,
                        StartTime = item.STARTTIME,
                        FramePath = item.FRAMEPATH,
                        HeadTime  = item.HEADTIME,
                        TailTime  = item.TAILTIME
                    };
                    mvm.Meta = mm;
                    mvms.Add(mvm);
                }
                return(mvms);
            }
        }
 /// <summary>
 /// 视频管理界面
 /// 根据id更新数据库
 /// </summary>
 /// <param name="meta"></param>
 /// <returns></returns>
 public int UpdateMeta(MetaViewModel meta)
 {
     using (IDbConnection conn = SqlHelper.GetConnection())
     {
         conn.Open();
         var sql = @"UPDATE TB_METADATA 
                     SET TASKCODE=@TaskCode,
                         ADDR=@Addr,
                         PIPECODE=@PipeCode,
                         VIDEOPATH=@VideoPath,
                         PIPETYPE=@PipeType,
                         GC=@GC,
                         FRAMEPATH=@FramePath 
                     WHERE ID = @Id";
         return(conn.Execute(sql, new
         {
             meta.Meta.TaskCode,
             meta.Meta.Addr,
             meta.Meta.PipeCode,
             meta.Meta.VideoPath,
             meta.Meta.PipeType,
             meta.Meta.GC,
             meta.Meta.FramePath,
             Id = Convert.ToInt32(meta.Id)
         }));
     }
 }
Exemple #4
0
        private bool MetasDiferentes(Meta metaOriginal, MetaViewModel metaCargada)
        {
            if ((metaOriginal.Valor1 == null && !string.IsNullOrEmpty(metaCargada.Valor1)) ||
                (metaOriginal.Valor1 != null && string.IsNullOrEmpty(metaCargada.Valor1)) ||
                (metaOriginal.Valor1 != null && !metaOriginal.Valor1.Value.ToString().Replace(",", ".").TrimEnd('0').TrimEnd('.').Equals(metaCargada.Valor1)))
            {
                return(true);
            }
            if ((metaOriginal.Valor2 == null && !string.IsNullOrEmpty(metaCargada.Valor2)) ||
                (metaOriginal.Valor2 != null && string.IsNullOrEmpty(metaCargada.Valor2)) ||
                (metaOriginal.Valor2 != null && !metaOriginal.Valor2.Value.ToString().Replace(",", ".").TrimEnd('0').TrimEnd('.').Equals(metaCargada.Valor2)))
            {
                return(true);
            }
            if (!metaOriginal.Signo1.ToString().Trim().Equals(metaCargada.Signo1.ToString().Trim()))
            {
                return(true);
            }
            if (!metaOriginal.Signo2.ToString().Trim().Equals(metaCargada.Signo2.ToString().Trim()))
            {
                return(true);
            }

            return(false);
        }
        public ActionResult RenderMeta()
        {
            var absUrl     = CurrentPage.UrlAbsolute();
            var isHomepage = CurrentPage.IsDocumentType(Alias.HomeDocType);

            var meta = new MetaViewModel
            {
                IsHomepage      = isHomepage,
                Author          = CurrentPage.WriterName,
                Canonical       = CurrentPage.GetCanonicalUrl(),
                Description     = CurrentPage.GetPropertyValue <string>(Alias.Description),
                Keywords        = CurrentPage.GetPropertyValue <string>(Alias.Keywords),
                OriginalSource  = absUrl,
                PageDescription = isHomepage ? "Simple man. Simple code. Simple life." : CurrentPage.GetPropertyValue <string>(Alias.PageDescription),
                PageTitle       = CurrentPage.GetPropertyValue <string>(Alias.PageTitle),
                ModifiedTime    = new DateTimeOffset(CurrentPage.UpdateDate),
                PublishedTime   = new DateTimeOffset(CurrentPage.CreateDate),
                ShortLink       = absUrl, // todo: generate short link
                Url             = absUrl,
                UrlFeed         = absUrl, // todo: generate feed
                UrlNext         = null    // todo: get next page
            };

            return(PartialView(PARTIALS_DIR + "_Meta.cshtml", meta));
        }
Exemple #6
0
        /// <summary>
        /// Get home page meta content
        /// </summary>
        /// <returns>MetaViewModel</returns>
        public static MetaViewModel getHomeMetaContent()
        {
            MetaViewModel _meta = new MetaViewModel();

            try
            {
                using (var _context = new TDHEntities())
                {
                    var _md = _context.PROC_WEB_VIEW_HOME_META().FirstOrDefault();
                    if (_md != null)
                    {
                        _meta.MetaTitle        = _md.title;
                        _meta.MetaDescription  = _md.description;
                        _meta.MetaKeywords     = _md.keyword;
                        _meta.MetaImage        = _md.image;
                        _meta.MetaOgImage      = _md.google_image;
                        _meta.MetaTwitterImage = _md.twitter_image;
                    }
                    return(_meta);
                }
            }
            catch (Exception ex)
            {
                throw new UserException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, 500, ErrorMessage.ErrorService, ex);
            }
        }
Exemple #7
0
 private void Validate(DBEntities context, MetaViewModel model)
 {
     if (model.MasterEntityId == Guid.Empty)
     {
         ModelState.AddModelError("MasterEntityId", "Поле Модель обязательно для заполнения");
     }
     //string res = MetaViewValidator.CheckTableName(context, model.Id, model.TableName);
     //if (res.Length > 0)
     //    ModelState.AddModelError("TableName", res);
 }
Exemple #8
0
        public MetaViewModel Atualizar(MetaViewModel meta)
        {
            var metaRetorno = Mapper.Map <MetaViewModel>(_metaService.Atualizar(Mapper.Map <Meta>(meta)));

            if (metaRetorno.EhValido())
            {
                Commit();
            }

            return(metaRetorno);
        }
Exemple #9
0
        private bool ValidaSignos(MetaViewModel meta)
        {
            if (!string.IsNullOrEmpty(meta.Valor1) && !string.IsNullOrEmpty(meta.Valor2))
            {
                decimal valor1 = Decimal.Parse(meta.Valor1.Replace(".", ","));
                decimal valor2 = Decimal.Parse(meta.Valor2.Replace(".", ","));

                Signo signo1 = meta.Signo1;
                Signo signo2 = meta.Signo2;

                if (valor1 == valor2)
                {
                    return((signo1 == Signo.Igual && signo2 == Signo.Igual) ||
                           (signo1 == Signo.Igual && signo2 == Signo.MayorOIgual) ||
                           (signo1 == Signo.Igual && signo2 == Signo.MenorOIgual) ||
                           (signo1 == Signo.MayorOIgual && signo2 == Signo.Igual) ||
                           (signo1 == Signo.MenorOIgual && signo2 == Signo.Igual) ||
                           (signo1 == Signo.MayorOIgual && signo2 == Signo.MayorOIgual) ||
                           (signo1 == Signo.MayorOIgual && signo2 == Signo.MenorOIgual) ||
                           (signo1 == Signo.MenorOIgual && signo2 == Signo.MenorOIgual) ||
                           (signo1 == Signo.MenorOIgual && signo2 == Signo.MayorOIgual));
                }
                else if (valor1 < valor2)
                {
                    return((signo1 == Signo.Menor && signo2 == Signo.Igual) ||
                           (signo1 == Signo.Menor && signo2 == Signo.Menor) ||
                           (signo1 == Signo.Menor && signo2 == Signo.MenorOIgual) ||
                           (signo1 == Signo.MenorOIgual && signo2 == Signo.MenorOIgual) ||
                           (signo1 == Signo.MenorOIgual && signo2 == Signo.Igual) ||
                           (signo1 == Signo.MenorOIgual && signo2 == Signo.Menor) ||
                           (signo1 == Signo.Igual && signo2 == Signo.Menor) ||
                           (signo1 == Signo.Igual && signo2 == Signo.MenorOIgual));
                }
                else if (valor1 > valor2)
                {
                    return((signo1 == Signo.Mayor && signo2 == Signo.Igual) ||
                           (signo1 == Signo.Mayor && signo2 == Signo.Mayor) ||
                           (signo1 == Signo.Mayor && signo2 == Signo.MayorOIgual) ||
                           (signo1 == Signo.MayorOIgual && signo2 == Signo.MayorOIgual) ||
                           (signo1 == Signo.MayorOIgual && signo2 == Signo.Igual) ||
                           (signo1 == Signo.MayorOIgual && signo2 == Signo.Mayor) ||
                           (signo1 == Signo.Igual && signo2 == Signo.Mayor) ||
                           (signo1 == Signo.Igual && signo2 == Signo.MayorOIgual));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Exemple #10
0
        public ActionResult Index()
        {
            var vm = new MetaViewModel()
            {
                Meta = metaProvider.GetMetadataForType(typeof(DishDto))
            };

            vm.ModelExplorer = new ModelExplorer(metaProvider, vm.Meta, new DishDto());

            return(View(vm));
        }
Exemple #11
0
        public ActionResult Alterar(MetaViewModel model)
        {
            if (ModelState.IsValid)
            {
                var meta = new Meta(model.Id, model.Destino, model.Porcentagem, model.TipoMeta);
                _repositorio.Alterar(meta);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemple #12
0
        private MetaViewModel Buscar(int id)
        {
            var meta = _repositorio.Buscar(id);

            var model = new MetaViewModel()
            {
                Id          = meta.Id,
                Destino     = meta.Destino,
                Porcentagem = meta.Porcentagem,
                TipoMeta    = meta.Tipo
            };

            return(model);
        }
Exemple #13
0
        public ActionResult Alterar(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            MetaViewModel metaViewModel = _metaAppService.ObterPorId((Guid)id);

            if (metaViewModel == null)
            {
                return(HttpNotFound());
            }

            return(View(metaViewModel));
        }
Exemple #14
0
        public ActionResult Alterar(MetaViewModel metaViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _metaAppService.Atualizar(metaViewModel);
                    TempData["AtualizadoSucesso"] = "Meta alterada com sucesso";
                    return(RedirectToAction("Index", "PainelAdministrativo"));
                }

                return(View(metaViewModel));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #15
0
        /// <summary>
        /// Get short introduction about me
        /// </summary>
        /// <returns>MetaViewModel</returns>
        public static MetaViewModel GetShortIntroAboutMe()
        {
            MetaViewModel _meta = new MetaViewModel();

            try
            {
                using (var _context = new TDHEntities())
                {
                    var _list = _context.PROC_WEB_VIEW_INTRO_META().FirstOrDefault();
                    _meta.MetaDescription = _list.description;
                    _meta.MetaImage       = _list.image;
                    return(_meta);
                }
            }
            catch (Exception ex)
            {
                throw new UserException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, 500, ErrorMessage.ErrorService, ex);
            }
        }
Exemple #16
0
        public ActionResult Edit(Guid?id)
        {
            if (id.HasValue)
            {
                MetaView obj = MetaViewHelper.Get(id.Value);
                if (obj == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                MetaViewModel.CreateMap();
                MetaViewModel model = Mapper.Map <MetaView, MetaViewModel>(obj);
                return(View(model));
            }
            else
            {
                return(View(new MetaViewModel()));
            }
        }
        public ActionResult Create(MetaViewModel model)
        {
            if (ModelState.IsValid)
            {
                var meta = new Metas();
                meta.MetaMensal = model.MetaMensal;
                meta.Inicio     = model.Inicio;
                meta.Fim        = model.Fim;
                meta.MetaDiaria = model.MetaDiaria;

                // Salvar a imagem para a pasta e pega o caminho

                db.Metas.Add(meta);
                db.SaveChanges();
                //return RedirectToAction("Create", "Contrato", new { id=cliente.ClienteId});
                return(RedirectToAction("Index"));
            }
            // Se ocorrer um erro retorna para pagina

            return(View(model));
        }
Exemple #18
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            MetaViewModel metaViewModel = (MetaViewModel)value;

            if (metaViewModel != null &&
                (
                    ((metaViewModel.Signo1 > 0 && !string.IsNullOrEmpty(metaViewModel.Valor1)) && (metaViewModel.Signo2 > 0 && !string.IsNullOrEmpty(metaViewModel.Valor2)))
                    ||
                    (!ValidarValor1 && metaViewModel.Signo1 == 0 && string.IsNullOrEmpty(metaViewModel.Valor1) && metaViewModel.Signo2 > 0 && !string.IsNullOrEmpty(metaViewModel.Valor2))
                    ||
                    (!ValidarValor2 && metaViewModel.Signo2 == 0 && string.IsNullOrEmpty(metaViewModel.Valor2) && metaViewModel.Signo1 > 0 && !string.IsNullOrEmpty(metaViewModel.Valor1))
                )
                )

            {
                if (ValidaSignos(metaViewModel))
                {
                    return(null);
                }
                else
                {
                    return(new ValidationResult("El campo Meta " + validationContext.DisplayName + " es incorrecto."));
                }
            }
            else
            {
                if (metaViewModel != null && (
                        (!ValidarValor1 && ((metaViewModel.Signo1 == 0 && !string.IsNullOrEmpty(metaViewModel.Valor1)) || (metaViewModel.Signo1 > 0 && string.IsNullOrEmpty(metaViewModel.Valor1))))
                        ||
                        (!ValidarValor2 && ((metaViewModel.Signo2 == 0 && !string.IsNullOrEmpty(metaViewModel.Valor2)) || (metaViewModel.Signo2 > 0 && string.IsNullOrEmpty(metaViewModel.Valor2))))
                        ))
                {
                    return(new ValidationResult("El campo Meta " + validationContext.DisplayName + " es incorrecto."));
                }
                else
                {
                    return(new ValidationResult("El campo Meta " + validationContext.DisplayName + " es obligatorio."));
                }
            }
        }
Exemple #19
0
        private decimal ObtenerValorEscala(MetaViewModel meta1, MetaViewModel meta2)
        {
            decimal valor = 0;

            if (!string.IsNullOrEmpty(meta1.Valor1) && !string.IsNullOrEmpty(meta2.Valor1))
            {
                if (decimal.Parse(meta1.Valor1.Replace(".", ",")) == decimal.Parse(meta2.Valor1.Replace(".", ",")))
                {
                    valor = decimal.Parse(meta1.Valor1.Replace(".", ","));
                }
            }

            if (!string.IsNullOrEmpty(meta1.Valor2) && !string.IsNullOrEmpty(meta2.Valor2))
            {
                if (decimal.Parse(meta1.Valor2.Replace(".", ",")) == decimal.Parse(meta2.Valor2.Replace(".", ",")))
                {
                    valor = decimal.Parse(meta1.Valor2.Replace(".", ","));
                }
            }

            if (!string.IsNullOrEmpty(meta1.Valor1) && !string.IsNullOrEmpty(meta2.Valor2))
            {
                if (decimal.Parse(meta1.Valor1.Replace(".", ",")) == decimal.Parse(meta2.Valor2.Replace(".", ",")))
                {
                    valor = decimal.Parse(meta1.Valor1.Replace(".", ","));
                }
            }

            if (!string.IsNullOrEmpty(meta1.Valor2) && !string.IsNullOrEmpty(meta2.Valor1))
            {
                if (decimal.Parse(meta1.Valor2.Replace(".", ",")) == decimal.Parse(meta2.Valor1.Replace(".", ",")))
                {
                    valor = decimal.Parse(meta1.Valor2.Replace(".", ","));
                }
            }

            return(valor);
        }
Exemple #20
0
 public ActionResult Novo(MetaViewModel metaViewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var metaRetorno = _metaAppService.Adicionar(metaViewModel);
             if (metaRetorno.EhValido())
             {
                 TempData["CadastradoSucesso"] = "Meta cadastrada com sucesso";
                 return(RedirectToAction("Index", "PainelAdministrativo"));
             }
             else
             {
                 return(View(metaRetorno));
             }
         }
         return(View(metaViewModel));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public ActionResult Create()
        {
            var model = new MetaViewModel();

            return(View(model));
        }
Exemple #22
0
        public ActionResult Edit(Guid id, MetaViewModel model, List <MetaViewColumnModel> columns, string button)
        {
            using (DBEntities context = Settings.CreateDataContext())
            {
                Validate(context, model);

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                MetaView target = null;
                if (model.Id != Guid.Empty)
                {
                    target = MetaViewHelper.Get(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return(View(model));
                    }
                }
                else
                {
                    target = new MetaView {
                        Id = Guid.NewGuid()
                    };
                    context.AddToMetaView(target);
                }

                MetaViewModel.CreateMap();

                Mapper.Map(model, target);
                if (columns != null)
                {
                    SyncViewColumns(target, columns, context);
                }

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message);
                    if (ex.InnerException != null)
                    {
                        sb.AppendLine(ex.InnerException.Message);
                    }
                    ModelState.AddModelError("", sb.ToString());
                    return(View(model));
                }

                if (button == "SaveAndExit")
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Edit", new { target.Id }));
                }
            }
        }
Exemple #23
0
 public static List <MetaViewColumnModel> GetColumnsForView(MetaViewModel model)
 {
     return(GetColumnsForView(model.Id, model.MasterEntityId, null));
 }
Exemple #24
0
        private async Task <int> GuardarMeta(MetaViewModel metaViewModel)
        {
            Meta meta = AutoMapper.Mapper.Map <Meta>(metaViewModel);

            return(await MetaRepository.Guardar(meta));
        }