Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Show(int id)
        {
            if (id < 1)
            {
                return(ShowAlert("请选择正确的报表"));
            }

            try
            {
                BF_CHART_REPORT.Entity entity = BF_CHART_REPORT.Instance.GetEntityByKey <BF_CHART_REPORT.Entity>(id);
                if (entity == null)
                {
                    return(ShowAlert("报表不存在"));
                }
                if (entity.IS_ENABLE != 1)
                {
                    return(ShowAlert("报表已被禁用"));
                }
                ViewBag.DB_ID       = entity.DB_ID;
                ViewBag.SQL_CODE    = Base.Encrypt.BAES.Encrypt(entity.SQL_CODE);
                ViewBag.CHART_CODE  = Base.Encrypt.BAES.Encrypt(entity.CHART_CODE);
                ViewBag.TOP_CODE    = entity.TOP_CODE;
                ViewBag.BOTTOM_CODE = entity.BOTTOM_CODE;
                return(View());
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.WARN, "查询报表[" + id + "]出现未知错误:" + ex.Message);
                return(ShowAlert("查询报表出现未知错误:" + ex.Message));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 以json串返回sql查询结果集(含内置参数的替换)
        /// </summary>
        /// <param name="sqlE"></param>
        /// <returns></returns>
        public ActionResult GetDataBySql(Models.FW.SqlExcute sqlE)
        {
            BF_CHART_REPORT.Entity entity = new BF_CHART_REPORT.Entity();
            entity.ID       = 0;
            entity.DB_ID    = sqlE.DB_ID;
            entity.SQL_CODE = sqlE.SQL_CODE;

            List <object> paraList = new List <object>();

            string    sql = BF_CHART_REPORT.GenerateSQL(entity, null, out paraList);
            DataTable dt  = BF_CHART_REPORT.QueryTable(entity, sql, null, 0, 1);

            return(Content(JSON.DecodeToStr(dt)));
        }
Beispiel #3
0
        /// <summary>
        /// 新增或编辑图表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id = 0)
        {
            ViewBag.Result  = false;
            ViewBag.Message = string.Empty;
            ViewBag.DIC_DBS = BF_DATABASE.Instance.GetDictionary();

            BF_CHART_REPORT.Entity entity = new BF_CHART_REPORT.Entity();
            entity.IS_SHOW_EXPORT = 1;
            entity.IS_SHOW_DEBUG  = 1;

            if (id > 0)
            {
                entity = BF_CHART_REPORT.Instance.GetEntityByKey <BF_CHART_REPORT.Entity>(id);
                if (entity == null)
                {
                    ViewBag.Message = "报表不存在";
                    entity          = new BF_CHART_REPORT.Entity();
                    entity.ID       = -1;
                }
            }

            ModelState.Clear();
            return(View(entity));
        }
Beispiel #4
0
        /// <summary>
        /// 验证输入
        /// </summary>
        /// <param name="entity"></param>
        private void CheckInput(BF_CHART_REPORT.Entity entity)
        {
            if (entity == null)
            {
                throw new Exception("对象为空");
            }
            if (string.IsNullOrWhiteSpace(entity.NAME))
            {
                throw new Exception("图表名称不可为空");
            }
            if (string.IsNullOrWhiteSpace(entity.SQL_CODE))
            {
                throw new Exception("SQL语句不可为空");
            }
            if (string.IsNullOrWhiteSpace(entity.CHART_CODE))
            {
                throw new Exception("CHART代码不可为空");
            }

            if (BF_CHART_REPORT.Instance.IsDuplicate(entity.ID, "NAME", entity.NAME))
            {
                throw new Exception("图表名称 " + entity.NAME + " 已经存在");
            }
        }
Beispiel #5
0
        public ActionResult Edit(BF_CHART_REPORT.Entity entity)
        {
            if (!string.IsNullOrEmpty(entity.CHART_CODE))
            {
                string chartCode = Base.Encrypt.BAES.Decrypt(entity.CHART_CODE);
                entity.CHART_CODE = string.IsNullOrEmpty(chartCode) ? " " : chartCode;
            }
            if (!string.IsNullOrEmpty(entity.TOP_CODE))
            {
                string topCode = Base.Encrypt.BAES.Decrypt(entity.TOP_CODE);
                entity.TOP_CODE = string.IsNullOrEmpty(topCode) ? " " : topCode;
            }
            if (!string.IsNullOrEmpty(entity.BOTTOM_CODE))
            {
                string bottomCode = Base.Encrypt.BAES.Decrypt(entity.BOTTOM_CODE);
                entity.BOTTOM_CODE = string.IsNullOrEmpty(bottomCode) ? " " : bottomCode;
            }

            JsonResultData result = new JsonResultData();
            int            i      = 0;

            try
            {
                CheckInput(entity);

                if (entity.ID < 0)
                {
                    result.Message = "图表不存在,不可编辑";
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }

                if (entity.ID == 0)
                {
                    entity.IS_ENABLE   = 1;
                    entity.CREATE_UID  = SystemSession.UserID;
                    entity.CREATE_TIME = DateTime.Now;
                    entity.UPDATE_UID  = SystemSession.UserID;
                    entity.UPDATE_TIME = DateTime.Now;
                    i = BF_CHART_REPORT.Instance.Add(entity);
                }
                else
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("NAME", entity.NAME.Trim());
                    dic.Add("DB_ID", entity.DB_ID);
                    dic.Add("IS_SHOW_EXPORT", entity.IS_SHOW_EXPORT);
                    dic.Add("IS_SHOW_DEBUG", entity.IS_SHOW_DEBUG);
                    //dic.Add("IS_SHOW_CHECKBOX", entity.IS_SHOW_CHECKBOX);
                    dic.Add("SQL_CODE", entity.SQL_CODE);
                    dic.Add("REMARK", entity.REMARK);
                    dic.Add("TOP_CODE", entity.TOP_CODE);
                    dic.Add("BOTTOM_CODE", entity.BOTTOM_CODE);
                    dic.Add("UPDATE_UID", SystemSession.UserID);
                    dic.Add("UPDATE_TIME", DateTime.Now);

                    dic.Add("CHART_CODE", entity.CHART_CODE);//CHART代码体
                    i = BF_CHART_REPORT.Instance.UpdateByKey(dic, entity.ID);
                }

                if (i < 1)
                {
                    result.Message = "提交失败!出现了未知错误";
                }
                else
                {
                    result.IsSuccess = true;
                    result.Message   = "提交成功!";
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
                BLog.Write(BLog.LogLevel.WARN, "编辑图表出错:" + ex.ToString());
            }

            ViewBag.Result  = result.IsSuccess;
            ViewBag.Message = result.Message;

            ViewBag.DIC_DBS = BF_DATABASE.Instance.GetDictionary();
            ModelState.Clear();
            return(View(entity));
        }