Exemplo n.º 1
0
        /// <summary>
        /// 分页取指标结果集
        /// </summary>
        /// <param name="guideLineId"></param>
        /// <param name="param"></param>
        /// <param name="filterWord"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="sortBy"></param>
        /// <param name="sortDirection"></param>
        /// <param name="requestUser"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public static DataTable QueryGuideline(string guideLineId, Dictionary <string, object> param, string filterWord, decimal pageIndex, decimal pageSize, string sortBy, string sortDirection, SinoRequestUser requestUser, ref int recordCount)
        {
            int          getQueryStartTime = Environment.TickCount;
            int          count             = 0;
            DataTable    tb     = new DataTable("ResultTable");
            MD_GuideLine define = GetGuidelineDefine(guideLineId);

            if (define != null)
            {
                string queryStr = GetGuidelineMethod(guideLineId);

                List <MDQuery_GuideLineParameter> glPara = new List <MDQuery_GuideLineParameter>();
                if (param != null && define.Parameters != null)
                {
                    foreach (var p in param)
                    {
                        MD_GuideLineParameter md_pa = define.Parameters.Find(pa => pa.ParameterName == p.Key);
                        if (md_pa != null)
                        {
                            glPara.Add(new MDQuery_GuideLineParameter(md_pa, p.Value));
                        }
                    }
                }
                foreach (MDQuery_GuideLineParameter gp in glPara)
                {
                    queryStr = OraQueryBuilder.RebuildGuideLineQueryString(queryStr, gp);
                }
                if (requestUser != null)
                {
                    queryStr = OraQueryBuilder.ReplaceExtSecret(null, queryStr, requestUser);
                }
                if (!string.IsNullOrEmpty(filterWord))
                {
                    queryStr = string.Format("select * from (\n {0} \n) where {1}", queryStr, filterWord);
                }

                try
                {
                    recordCount = Convert.ToInt32(MysqlDBHelper.ExecuteScalar(MysqlDBHelper.conf, CommandType.Text, string.Format("select count(*) from (\n {0} \n) ", queryStr)));
                }
                catch (Exception e)
                {
                    //OracleLogWriter.WriteSystemLog("Exception :QueryGuideline310行异常,异常信息为" + e.Message, "ERROR");
                }

                queryStr = OraQueryBuilder.BuildPagingSQL(queryStr, pageIndex, pageSize, sortBy, sortDirection);
                tb       = OraQueryModelHelper.FillResultData(queryStr, "ResultTable", ref count);
                if (requestUser != null && requestUser.BaseInfo != null)
                {
                    //OracleLogWriter.WriteQueryLog(BuildQueryLogStr(guideLineId, param, requestUser), Environment.TickCount - getQueryStartTime, count.ToString(), requestUser.BaseInfo.UserId, "2");
                }
            }
            return(tb);
        }
 public MDQuery_GuideLineParameter(MD_GuideLineParameter pDefine, object data)
 {
     Paramter             = pDefine;
     Data                 = data;
     this.ParameterName   = pDefine.ParameterName;
     this.DisplayTitle    = pDefine.DisplayTitle;
     this.ParameterType   = pDefine.ParameterType;
     this.ParameterValue  = data;
     this.RefTableName    = pDefine.RefTableName;
     this.IncludeChildren = pDefine.IncludeChildren;
     this.SelectAllCode   = pDefine.SelectAllCode;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 取所有主键的值
        /// </summary>
        /// <param name="guideLineId"></param>
        /// <param name="param"></param>
        /// <param name="keyField"></param>
        /// <param name="requestUser"></param>
        /// <returns></returns>
        public static string GetAllKeyField(string guideLineId, Dictionary <string, object> param, string keyField, SinoRequestUser requestUser)
        {
            int          count  = 0;
            DataTable    tb     = new DataTable("ResultTable");
            MD_GuideLine define = GetGuidelineDefine(guideLineId);

            if (define != null)
            {
                string queryStr = GetGuidelineMethod(guideLineId);

                List <MDQuery_GuideLineParameter> glPara = new List <MDQuery_GuideLineParameter>();
                if (param != null && define.Parameters != null)
                {
                    foreach (var p in param)
                    {
                        MD_GuideLineParameter md_pa = define.Parameters.Find(pa => pa.ParameterName == p.Key);
                        if (md_pa != null)
                        {
                            glPara.Add(new MDQuery_GuideLineParameter(md_pa, p.Value));
                        }
                    }
                }
                foreach (MDQuery_GuideLineParameter gp in glPara)
                {
                    queryStr = OraQueryBuilder.RebuildGuideLineQueryString(queryStr, gp);
                }
                if (requestUser != null)
                {
                    queryStr = OraQueryBuilder.ReplaceExtSecret(null, queryStr, requestUser);
                }
                tb = OraQueryModelHelper.FillResultData(queryStr, "ResultTable", ref count);

                try
                {
                    tb.PrimaryKey = new DataColumn[] { tb.Columns[keyField] };
                }
                catch
                {
                    string errMsg = string.Format("取指标[zbid={0}]的结果集中所有主键[KeyField={1}]的值时设置主键出错,请检查主键是否唯一!", guideLineId, keyField);
                    //OracleLogWriter.WriteSystemLog(errMsg, "ERROR");
                    return("");
                }
            }

            List <string> listKeyField = new List <string>();

            foreach (DataRow row in tb.Rows)
            {
                listKeyField.Add(row[keyField].ToString());
            }
            return(string.Join(",", listKeyField));
        }
Exemplo n.º 4
0
        public static int GetQueryResultCount(string guideLineId, Dictionary <string, object> param, string filterWord, SinoRequestUser requestUser, MySqlConnection cn)
        {
            int          ret      = 0;
            string       queryStr = GetGuidelineMethod(guideLineId);
            MD_GuideLine define   = GetGuidelineDefine(guideLineId);

            if (define != null)
            {
                List <MDQuery_GuideLineParameter> glPara = new List <MDQuery_GuideLineParameter>();
                if (param != null && define.Parameters != null)
                {
                    foreach (var p in param)
                    {
                        MD_GuideLineParameter md_pa = define.Parameters.Find(pa => pa.ParameterName == p.Key);
                        if (md_pa != null)
                        {
                            glPara.Add(new MDQuery_GuideLineParameter(md_pa, p.Value));
                        }
                    }
                }
                foreach (MDQuery_GuideLineParameter gp in glPara)
                {
                    queryStr = OraQueryBuilder.RebuildGuideLineQueryString(queryStr, gp);
                }
                if (requestUser != null)
                {
                    queryStr = OraQueryBuilder.ReplaceExtSecret(null, queryStr, requestUser);
                }
                if (!string.IsNullOrEmpty(filterWord))
                {
                    queryStr = string.Format("select * from (\n {0} \n) where {1}", queryStr, filterWord);
                }
                try
                {
                    ret = Convert.ToInt32(MysqlDBHelper.ExecuteScalar(cn, CommandType.Text, string.Format("select count(*) from (\n {0} \n) ", queryStr)));
                }
                catch (Exception exception)
                {
                    string errorMessage = string.Format("取指标[{0}]的结果记录数出错,错误信息为{1}", guideLineId, exception.Message);
                    //OracleLogWriter.WriteSystemLog(errorMessage, "ERROR");
                }
            }
            return(ret);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 取指标结果集
        /// </summary>
        /// <param name="guideLineId"></param>
        /// <param name="param"></param>
        /// <param name="filterWord"></param>
        /// <param name="requestUser"></param>
        /// <returns></returns>
        public static DataTable QueryGuideline(string guideLineId, Dictionary <string, object> param, string filterWord, SinoRequestUser requestUser)
        {
            int          getQueryStartTime = Environment.TickCount;
            int          count             = 0;
            DataTable    tb     = new DataTable("ResultTable");
            MD_GuideLine define = GetGuidelineDefine(guideLineId);

            if (define != null)
            {
                string queryStr = GetGuidelineMethod(guideLineId);

                List <MDQuery_GuideLineParameter> glPara = new List <MDQuery_GuideLineParameter>();
                if (param != null && define.Parameters != null)
                {
                    foreach (var p in param)
                    {
                        MD_GuideLineParameter md_pa = define.Parameters.Find(pa => pa.ParameterName == p.Key);
                        if (md_pa != null)
                        {
                            glPara.Add(new MDQuery_GuideLineParameter(md_pa, p.Value));
                        }
                    }
                }
                foreach (MDQuery_GuideLineParameter gp in glPara)
                {
                    queryStr = OraQueryBuilder.RebuildGuideLineQueryString(queryStr, gp);
                }
                if (requestUser != null)
                {
                    queryStr = OraQueryBuilder.ReplaceExtSecret(null, queryStr, requestUser);
                }
                if (!string.IsNullOrEmpty(filterWord))
                {
                    queryStr = string.Format("select * from (\n {0} \n) where {1}", queryStr, filterWord);
                }
                tb = OraQueryModelHelper.FillResultData(queryStr, "ResultTable", ref count);
                if (requestUser != null && requestUser.BaseInfo != null)
                {
                    //OracleLogWriter.WriteQueryLog(BuildQueryLogStr(guideLineId, param, requestUser), Environment.TickCount - getQueryStartTime, count.ToString(), requestUser.BaseInfo.UserId, "2");
                }
            }
            return(tb);
        }