Exemplo n.º 1
0
        /// <summary>
        /// Adds the with ownership.
        /// </summary>
        /// <param name="catalogValue">
        /// The catalog value.
        /// </param>
        /// <returns>
        /// The <see cref="CatalogValue"/>.
        /// </returns>
        protected virtual CatalogValue AddWithOwnership(CatalogValue catalogValue)
        {
            if (this.Values == null)
            {
                this.Values = new CatalogValueSet();
            }

            return(this.Values.AddWithOwnership(catalogValue));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the value set.
        /// </summary>
        /// <returns>
        /// The <see cref="CatalogValueSet"/>.
        /// </returns>
        public virtual CatalogValueSet GetValueSet()
        {
            if (this.Values != null)
            {
                return(this.Values);
            }

            this.Values = this.CreateValueSet(-1);
            return(this.Values);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the copy.
        /// </summary>
        /// <returns>
        /// The <see cref="CatalogValueSet"/>.
        /// </returns>
        public CatalogValueSet CreateCopy()
        {
            var copy = new CatalogValueSet();

            if (this.Count <= 0)
            {
                return(copy);
            }

            for (var i = 0; i < this.Count; i++)
            {
                copy.Add(this.Values[i].CreateCopy());
            }

            return(copy);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sets the catalog value set with ownership.
 /// </summary>
 /// <param name="valueSet">
 /// The value set.
 /// </param>
 public virtual void SetCatalogValueSetWithOwnership(CatalogValueSet valueSet)
 {
     this.Values = valueSet;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Resets the value set.
 /// </summary>
 public virtual void ResetValueSet()
 {
     this.Values = null;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates the value set.
        /// </summary>
        /// <param name="parentCode">
        /// The parent code.
        /// </param>
        /// <returns>
        /// The <see cref="CatalogValueSet"/>.
        /// </returns>
        public virtual CatalogValueSet CreateValueSet(int parentCode)
        {
            // bool variable, dep;
            // SYS_CHAR tableName[MAX_CATALOG_TABLENAME];
            var catalogValueRecordSet = new DatabaseRecordSet(this.Database);

            var memorybuffer = new StringBuilder();

            memorybuffer.Append("SELECT code, text, sortinfo, access");

            if (this.IsVariable)
            {
                memorybuffer.Append(", extkey, tenant");
            }

            if (this.IsDependent)
            {
                memorybuffer.Append(", parentcode");
            }

            memorybuffer.Append(" FROM ");
            memorybuffer.Append(this.GetDatabaseTableName());

            var parameterCount = 0;

            if (this.IsDependent && parentCode >= 0)
            {
                memorybuffer.Append($" WHERE parentcode = {parentCode}");
                parameterCount = 1;
            }

            var returnString = memorybuffer.ToString();

            int             ret;
            CatalogValueSet values = null;

            if (parameterCount > 0)
            {
                ret = catalogValueRecordSet.Execute(returnString, new[] { $"{parentCode}" }, 0);
            }
            else
            {
                ret = catalogValueRecordSet.Query.Prepare(returnString) ? 0 : 1;
                if (ret == 0)
                {
                    ret = catalogValueRecordSet.Execute();
                }
            }

            if (ret == 0)
            {
                values = new CatalogValueSet {
                    SortFunction = this.GetSortFunction
                };

                int         i, catalogValueCount = catalogValueRecordSet.RowCount;
                DatabaseRow row;
                for (i = 0; i < catalogValueCount; i++)
                {
                    row = catalogValueRecordSet.GetRow(i);
                    if (this.IsDependent)
                    {
                        values.AddDependentCatalogValue(
                            row.GetColumnInt(0),
                            row.GetColumnInt(6),
                            row.GetColumn(1),
                            row.GetColumnInt(5),
                            row.GetColumn(4),
                            row.GetColumnInt(2),
                            row.GetColumnInt(3));
                    }
                    else if (this.IsVariable)
                    {
                        values.AddVariableCatalogValue(
                            row.GetColumnInt(0),
                            row.GetColumn(1),
                            row.GetColumnInt(5),
                            row.GetColumn(4),
                            row.GetColumnInt(2),
                            row.GetColumnInt(3));
                    }
                    else
                    {
                        values.AddFixedCatalogValue(
                            row.GetColumnInt(0),
                            row.GetColumn(1),
                            row.GetColumnInt(2),
                            row.GetColumnInt(3));
                    }
                }
            }

            if (values == null)
            {
                values = new CatalogValueSet();
            }

            values.Sort();
            return(values);
        }