Exemplo n.º 1
0
        public static DapperResult CommonSqlPage(string sqlid, IIdentity _identity, int startpage, int limit, string orderby)
        {
            var result = string.Empty;
            var dar    = new DapperResult();

            var _sql = $@"
                            SELECT sqlcontent
                FROM TBL_T_DataSql a
                LEFT JOIN tb_SQL b ON a.sqlid = b.NewSqlID
                WHERE 
                CAST(a.sqlid AS NVARCHAR(50)) = '{sqlid}' 
                OR b.sqlid = '{sqlid}'";


            List <Dictionary <string, object> > sqls = QueryNormal(_sql, false).rows;

            if (sqls.Count == 0)
            {
                dar.rows    = null;
                dar.total   = 0;
                dar.msg     = "Querynodata";
                dar.success = 0;
                return(dar);
            }


            string sql = sqls[0]["sqlcontent"].ToString();

            sql = sql.Replace("@RenYuanId", CharacterUtil.SQLEncode(ExtendIdentity.GetUserId(_identity))).Replace("@CompanyCode", CharacterUtil.SQLEncode(ExtendIdentity.GetOrganizationId(_identity)));


            return(QueryPage(sql, startpage, limit, orderby));
        }
Exemplo n.º 2
0
        public static DapperResult CommonSql(string sqlid, IIdentity _identity)
        {
            var result = string.Empty;
            var dar    = new DapperResult();

            var _sql = string.Format(@"
                            SELECT sqlcontent
                FROM TBL_T_DataSql a
                LEFT JOIN tb_SQL b ON a.sqlid = b.NewSqlID
                WHERE 
                CAST(a.sqlid AS NVARCHAR(50)) = '{0}' 
                OR b.sqlid = '{0}'", sqlid);

            var dr = QueryNormal(_sql, false);

            if (dr == null || dr.success == 0 || dr.rows == null)
            {
                dar.rows    = null;
                dar.total   = 0;
                dar.msg     = "Querynodata";
                dar.success = 0;
                return(dar);
            }
            List <Dictionary <string, object> > sqls = dr.rows;

            if (sqls.Count == 0)
            {
                dar.rows    = null;
                dar.total   = 0;
                dar.msg     = "Querynodata";
                dar.success = 0;
                return(dar);
            }


            string sql = sqls[0]["sqlcontent"].ToString();

            sql = sql.Replace("@RenYuanId", CharacterUtil.SQLEncode(ExtendIdentity.GetUserId(_identity))).Replace("@CompanyCode", CharacterUtil.SQLEncode(ExtendIdentity.GetOrganizationId(_identity)));
            //  sql = ControlNPrefix(sql);


            return(QueryNormal(sql, false));
        }