Exemple #1
0
        public void Run()
        {
            Global.UserRightProvider.CanDo(Right.RightItem.Select);

            if (Parameters.Count < 2)
            {
                throw new ArgumentException("Parameter 1 is select statement before where. Parameter 2 - n is docids.");
            }

            string sql = Parameters[0];

            SFQL.Parse.SFQLParse sfqlParse = new Hubble.Core.SFQL.Parse.SFQLParse();
            sfqlParse.SyntaxAnalyse(sql);


            SFQL.SyntaxAnalysis.Select.Select select = sfqlParse.SFQLSentenceList[0].SyntaxEntity as
                                                       SFQL.SyntaxAnalysis.Select.Select;

            string tableName = select.SelectFroms[0].Name;

            Data.DBProvider dbProvider = Data.DBProvider.GetDBProvider(tableName);

            if (dbProvider == null)
            {
                throw new Data.DataException(string.Format("Invalid table:{0}", tableName));
            }

            List <Data.Field> fields;
            int allFieldsCount;

            sfqlParse.GetSelectFields(select, dbProvider, out fields, out allFieldsCount);

            Query.DocumentResultForSort[] docs = new Hubble.Core.Query.DocumentResultForSort[Parameters.Count - 1];

            for (int i = 1; i < Parameters.Count; i++)
            {
                docs[i - 1] = new Hubble.Core.Query.DocumentResultForSort(int.Parse(Parameters[i]));
            }

            List <Data.Document> docResult = dbProvider.Query(fields, docs);

            Hubble.Framework.Data.DataSet ds = Data.Document.ToDataSet(fields, docResult);
            ds.Tables[0].TableName = "Select_" + select.SelectFroms[0].Alias;
            _QueryResult.DataSet   = ds;
        }