Beispiel #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sqid"></param>
        /// <param name="dcs"></param>
        /// <param name="sqli"></param>
        /// <returns></returns>
        public bool get_ColumnSetting(int sqid, ref Dictionary<string, ColumnSetting> dcs, out SqlListItem sqli)
        {
            sqli = null;
            foreach (string k in _sqlKey.Keys )
            {
                if (_sqlKey[k].ContainsID(sqid, out sqli))
                {
                    dcs=_sqlKey[k].ColumnSetting;
                    return true;
                }
            }
            SqlCmd sqlc = null;
            if (!_sqlKey.ContainsKey("__BASE_SETTING_OTHER"))
            {
                sqlc = new SqlCmd();
                _sqlKey.Add("__BASE_SETTING_OTHER", sqlc);
            }
            else
            {
                 sqlc = _sqlKey["__BASE_SETTING_OTHER"];
            }
            DataTable dt = new DataTable();
            if (!_GDC.GetData(string.Format("SELECT [ID],[ActionName],[StepSQL],[paramnumber] from ActionStepSQLItem where id='{0}'", sqid), ref dt))
            {
                return false;
            }
            if (dt.Rows.Count < 1)
            {
                return false ;
            }

            int param_count = 0;

            foreach (DataRow dr in dt.Rows)
            {//增加了参数数量对比
                if (Convert.IsDBNull(dr["paramnumber"]) || !int.TryParse(dr["paramnumber"].ToString(), out param_count))
                {
                    continue;
                }
                //使用正则表达式,获取sql中的{}对数,与param_count作比较,不等下一条记录对比
                if (!CompParamCount(dr["stepsql"].ToString(), param_count))
                {
                    continue;
                }
                sqli = new SqlListItem()
                {
                    ActionName = dr["actionname"].ToString(),
                    SQLString = dr["stepsql"].ToString(),
                    ParamNumber = param_count,
                    ID = Convert.ToInt32(dr["id"])
                };
                sqlc.SQLList.Add(sqli    );
                break;
            }
            sqlc.CompleteParamItemCount();  //计算拥有参数的子项数量
            sqlc.Inistaled = true;
            dt = new DataTable();
            if (_GDC.GetData(string.Format ("select * from dbo.get_ActionSettingByASSID('{0}')",sqid), ref dt))  //获取数据列设置
            {
                 sqlc.SetColumnSettingDataByTable(dt);
                 getColumnSettingEx(sqlc);
            }
            dcs = sqlc.ColumnSetting;
            return true;
        }
Beispiel #2
0
 public bool ContainsID(int sqlid, out SqlListItem sqli)
 {
     foreach (SqlListItem sli in _sqlList)
     {
         if (sli.ID.Equals(sqlid))
         {
             sqli = sli;
             return true; }
     }
     sqli = null;
     return false;
 }