コード例 #1
0
        /// <summary>
        /// Executes the specified count only.
        /// </summary>
        /// <param name="countOnly">
        /// if set to <c>true</c> [count only].
        /// </param>
        /// <returns>
        /// The <see cref="GenericRecordSet"/>.
        /// </returns>
        public GenericRecordSet Execute(bool countOnly)
        {
            var recordSet = new DatabaseRecordSet(this.crmDatabase);
            var context   = new StatementCreationContext(this);

            var statementString = this.CreateStatement(context, countOnly);

            if (!string.IsNullOrEmpty(context.ErrorText))
            {
                // _crmDatabase.Trace(_crmDatabase, context.GetErrorText());
                return(null);
            }

            var parameterList  = context.ParameterValues;
            var parameterCount = parameterList?.Count ?? 0;

            if (parameterCount > 0)
            {
                recordSet.Execute(statementString, parameterList?.ToArray(), this.MaxResultRowCount);
            }
            else
            {
                recordSet.Execute(statementString, this.MaxResultRowCount);
            }

            if (recordSet.GetRowCount() > 0 && this.RootTreeItem.HasSubQueries())
            {
                var joinedRecordSet = this.RootTreeItem.ExecuteSubQueries(recordSet);
                return(joinedRecordSet);
            }

            return(recordSet);
        }
コード例 #2
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int Load()
        {
            var tableRecordSet = new DatabaseRecordSet(this.Database);

            tableRecordSet.Query.Prepare("SELECT infoareaid, rootinfoareaid, name, haslookup FROM tableinfo");

            TableInfo   tableinfo;
            DatabaseRow row;
            var         ret            = tableRecordSet.Execute();
            var         tableInfoCount = tableRecordSet.GetRowCount();

            for (var i = 0; i < tableInfoCount; i++)
            {
                row       = tableRecordSet.GetRow(i);
                tableinfo = this.AddTableInfo(
                    row.GetColumn(0),
                    row.GetColumn(1),
                    row.GetColumn(2),
                    row.GetColumnInt(3, 0));
                tableinfo.Load(this.Database);
            }

            for (var i = 0; i < tableInfoCount; i++)
            {
                tableinfo = this.TableInfos[i];
                if (!string.IsNullOrEmpty(tableinfo.RootInfoAreaId))
                {
                    var parent = this.Database.GetTableInfoByInfoArea(tableinfo.RootInfoAreaId);
                    parent?.AddSpecialInfoArea(tableinfo);
                }
            }

            var catalogRecordSet = new DatabaseRecordSet(this.Database);

            catalogRecordSet.Query.Prepare("SELECT catnr FROM fixcatinfo");
            catalogRecordSet.Execute();

            var catalogInfoCount = catalogRecordSet.GetRowCount();

            for (var i = 0; i < catalogInfoCount; i++)
            {
                row = catalogRecordSet.GetRow(i);
                this.AddFixedCatalog(row.GetColumnInt(0));
            }

            catalogRecordSet = new DatabaseRecordSet(this.Database);
            catalogRecordSet.Query.Prepare("SELECT catnr, parentcatnr FROM varcatinfo");
            if (ret == 0)
            {
                ret = catalogRecordSet.Execute();
            }

            catalogInfoCount = catalogRecordSet.GetRowCount();
            for (var i = 0; i < catalogInfoCount; i++)
            {
                row = catalogRecordSet.GetRow(i);
                if (row.IsNull(1))
                {
                    this.AddVariableCatalog(row.GetColumnInt(0));
                }
                else
                {
                    this.AddVariableCatalog(row.GetColumnInt(0), row.GetColumnInt(1));
                }
            }

            this.Sort(true);

            return(ret);
        }