Ejemplo n.º 1
0
        public JsonResult AddSql(ViewModel model)
        {
            if (SysUser != null)
            {
                model.INPUTER = SysUser.UserCode;
            }
            else
            {
                return(FailResult("未登录状态"));
            }
            var verifymodel = ModelVerify.First(model);

            if (verifymodel != null)
            {
                return(FailResult(verifymodel.ErrorMessage));
            }
            if (model.COMMAND_TEXT.Length > 2000)
            {
                return(FailResult("该SQL超出长度"));
            }
            if (!string.IsNullOrEmpty(model.VIEW_NAME))
            {
                if (sqlManager.IsExists(model.VIEW_NAME))
                {
                    return(FailResult("标题已存在,不可用"));
                }
            }
            if (!sqlManager.IsCorrect(model.COMMAND_TEXT))
            {
                return(FailResult(sqlManager.PromptInfo.Message));
            }

            Tsql_View daView = new Tsql_View()
            {
                ViewName     = model.VIEW_NAME,
                ClassifyId   = model.CLASSIFY_ID,
                CommandText  = model.COMMAND_TEXT,
                ViewTemplate = model.VIEW_TEMPLATE,
                CacheStatus  = model.CACHE_STATUS,
                PageRow      = model.PAGE_ROW,
                Status       = 1,
                Inputer      = model.INPUTER,
                Remarks      = model.REMARKS,
            };

            if (!daView.Insert())
            {
                return(FailResult(daView.PromptInfo.Message));
            }
            else
            {
                //添加删除缓存数据
                ViewFacade viewfacade = new ViewFacade();
                viewfacade.AddOrUpdateCache(daView.ViewId, Convert.ToInt32(daView.CacheStatus), Isparameter(daView.CommandText));
            }
            return(SuccessResult());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 验证表单提交数据合法性
        /// </summary>
        /// <returns></returns>
        private bool SaveVerify(string groupName)
        {
            var verifyResult = ModelVerify.First(this, groupName);

            if (verifyResult != null)
            {
                Alert(ResultType.非法数值, verifyResult.ErrorMessage);
                return(false);
            }
            //TODO:其他的检查
            return(true);
        }