///<summary> This method adds the order criteria to the SQL statement </summary>
        ///<param name = "onSql"> This parameter represents the SQL component </param>
        ///<param name = "comparer"> This parameter has all the information refering to the order criteria to add to SQL statement</param>
        /// <param name="startRowOid">This parameter has the OID necessary to start the search</param>
        /// <param name="blockSize">This parameter represents the number of instances to be returned</param>
        protected override void AddOrderCriteria(ONSqlSelect onSql, ONOrderCriteria comparer, ONOid startRowOid, int blockSize, ONPath initialPath)
        {
            //Initilizate StartRow
            AeronaveInstance lInstance = null;

            if (startRowOid != null)
            {
                lInstance     = new AeronaveInstance(OnContext);
                lInstance.Oid = startRowOid as AeronaveOid;
            }

            //Default OrderCriteria
            if (comparer == null)
            {
                string lAlias = onSql.GetAlias("Aeronave", initialPath);
                if (lInstance != null)
                {
                    onSql.AddOrderBy(lAlias, CtesBD.FLD_AERONAVE_ID_AERONAVE, OrderByTypeEnumerator.Asc, lInstance.Oid.Id_AeronaveAttr);
                }
                else
                {
                    onSql.AddOrderBy(lAlias, CtesBD.FLD_AERONAVE_ID_AERONAVE, OrderByTypeEnumerator.Asc, null);
                }
                return;
            }

            //Add OrderCriteria
            bool lUseStartRow = (!comparer.InMemory);

            foreach (ONOrderCriteriaItem lOrderCriteriaItem in comparer.OrderCriteriaSqlItem)
            {
                ONPath lPath = new ONPath(lOrderCriteriaItem.OnPath);
                if ((lInstance != null) && (lUseStartRow))
                {
                    ONSimpleType lAttrStartRow = null;

                    if (lPath.Path == "")
                    {
                        lAttrStartRow = lInstance[lOrderCriteriaItem.Attribute] as ONSimpleType;
                    }
                    else
                    {
                        ONCollection lCollection = (lInstance[lPath.Path] as ONCollection);
                        if ((lCollection != null) && (lCollection.Count > 0))
                        {
                            lAttrStartRow = lCollection[0][lOrderCriteriaItem.Attribute] as ONSimpleType;
                        }
                    }
                    onSql.AddOrderBy(AeronaveData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, lAttrStartRow);
                    lUseStartRow = (lAttrStartRow != null);
                }
                else
                {
                    onSql.AddOrderBy(AeronaveData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, null);
                }
            }
            return;
        }
Beispiel #2
0
        public ONSimpleType DisplaysetItemValue(ONPath displaysetItem)
        {
            if ((displaysetItem == null) || (displaysetItem.Count == 0))
            {
                return(null);
            }

            ONPath       lDisplaysetItem = new ONPath(displaysetItem);
            string       lRol            = lDisplaysetItem.RemoveHead();
            PropertyInfo lProperty       = null;
            MethodInfo   lMethod         = null;
            string       methodName      = lRol + "RoleHV";

            // Last unique role (like attributes)
            if (lDisplaysetItem.Count == 0)
            {
                lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>");
                if (lProperty != null)
                {
                    return((lProperty.GetValue(this, null)) as ONSimpleType);
                }
            }

            // Roles
            lMethod = GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
            if (lMethod != null)
            {
                ONCollection lCollection = lMethod.Invoke(this, null) as ONCollection;
                if (lCollection.Count <= 0)
                {
                    return(ONSimpleType.Null(ONInstance.GetTypeOfAttribute(GetType(), displaysetItem)));
                }

                ONInstance lInstance = lCollection[0];

                return(lInstance.DisplaysetItemValue(lDisplaysetItem));
            }

            return(null);
        }
Beispiel #3
0
 /// <summary>
 /// Adds the fields and their values needed to insert into data base
 /// </summary>
 /// <param name="fieldName">Name of the field where the value will be inserted</param>
 /// <param name="fieldName">Value to be inserted in the Data Base</param>
 public void AddValue(string fieldName, ONSimpleType fieldValue)
 {
     mFields.Add(fieldName);
     AddParameter(fieldName, fieldValue);
 }
Beispiel #4
0
        public static void GetType_XMLSimple(DataTypeEnumerator pType, XmlTextWriter xmlWriter, ONSimpleType pValue, double dtdVersion)
        {
            switch (pType)
            {
            case (DataTypeEnumerator.Int):
                ONXmlInt.ON2XML(xmlWriter, pValue as ONInt, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.Bool):
                ONXmlBool.ON2XML(xmlWriter, pValue as ONBool, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.Blob):
                ONXmlBlob.ON2XML(xmlWriter, pValue as ONBlob, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.Date):
                ONXmlDate.ON2XML(xmlWriter, pValue as ONDate, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.DateTime):
                ONXmlDateTime.ON2XML(xmlWriter, pValue as ONDateTime, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.Nat):
                ONXmlNat.ON2XML(xmlWriter, pValue as ONNat, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.Real):
                ONXmlReal.ON2XML(xmlWriter, pValue as ONReal, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.String):
                ONXmlString.ON2XML(xmlWriter, pValue as ONString, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.Text):
                ONXmlText.ON2XML(xmlWriter, pValue as ONText, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;

            case (DataTypeEnumerator.Time):
                ONXmlTime.ON2XML(xmlWriter, pValue as ONTime, dtdVersion, ONXml.XMLTAG_LITERAL);
                break;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Add OrderBy fields
        /// </summary>
        /// <param name="alias">Table alias name</param>
        /// <param name="field">Field name</param>
        /// <param name="orderByType">Asc/Des order type</param>
        /// <param name="val">Bound value</param>
        public void AddOrderBy(string alias, string field, OrderByTypeEnumerator orderByType, ONSimpleType val)
        {
            // Compose alias
            StringBuilder lFieldBuilder = new StringBuilder();

            if (alias != "")
            {
                lFieldBuilder.Append(alias);
                lFieldBuilder.Append(".");
                lFieldBuilder.Append(field);
            }
            else
            {
                lFieldBuilder.Append(field);
            }

            // Add OrderBy
            if (orderByType == OrderByTypeEnumerator.Des)
            {
                mOrderBy.Add(lFieldBuilder.ToString() + " DESC");
            }
            else
            {
                mOrderBy.Add(lFieldBuilder.ToString());
            }

            // Without StartRow
            if (val == null)
            {
                return;
            }

            // Extract previous OrderBy
            StringBuilder lDisjuntionBuilder = new StringBuilder();

            if (mOrderByDisjuntion.Count > 0)             // Not first StartRow
            {
                lDisjuntionBuilder.Append(mOrderByDisjuntion[mOrderByDisjuntion.Count - 1]);
                lDisjuntionBuilder.Append(" AND ");
                mOrderByDisjuntion.RemoveAt(mOrderByDisjuntion.Count - 1);
            }

            // Add Field
            lDisjuntionBuilder.Append(lFieldBuilder);

            // Add StartRow
            if (orderByType == OrderByTypeEnumerator.Des)
            {
                mOrderByDisjuntion.Add(lDisjuntionBuilder.ToString() + " < ?");
                AddOrderByParameter(val);
            }
            else
            {
                mOrderByDisjuntion.Add(lDisjuntionBuilder.ToString() + " > ?");
                AddOrderByParameter(val);
            }

            mOrderByDisjuntion.Add(lDisjuntionBuilder.ToString() + " = ?");
        }
Beispiel #6
0
 /// <summary>
 /// Adds the WHERE part of the SQL sentence and adds tha parameter according to this part
 /// </summary>
 /// <param name="fieldName">Name of the field to put in the SQL sentence</param>
 /// <param name="fieldValue">Value of the data to put in the SQL sentence</param>
 public void AddWhere(string fieldName, ONSimpleType fieldValue)
 {
     mWhereConjuncion.Add(fieldName + " = ?");
     AddParameter(fieldName, fieldValue);
 }