Exemplo n.º 1
0
        public override void FilterInData(ONSqlSelect onSql, ONDBData data)
        {
            if (InLegacy)
                return;

            //Fix Instance
            data.InhFixInstance(onSql, null, null, mOid);
        }
Exemplo n.º 2
0
        public void LoadRelated(ONContext onContext, ONDisplaySet displaySet, object[] columns, int index, ONInstance instance)
        {
            // Related attributes
            for (; index < displaySet.ElementsInData; index++)
            {
                ONDisplaySetItem lDSItem   = displaySet[index];
                string           lTypeName = ONInstance.GetTypeOfAttribute(instance.GetType(), new ONPath(lDSItem.Path));

                instance.RelatedValues.Add(lDSItem.Path, ONDBData.GetBasicTypeFromDB(lTypeName, columns[index]));
            }
        }
        public override void FilterInData(ONSqlSelect onSql, ONDBData data)
        {
            if (InLegacy)
            return;

               	data.InhAddPath(onSql, mRelatedOid.ClassName, ONPath, "");

            //Fix Instance
              	ONDBData lData = ONContext.GetComponent_Data(mRelatedOid.ClassName, data.OnContext) as ONDBData;
               	lData.InhFixInstance(onSql, null, ONPath, mRelatedOid);
        }
        public override void FilterInData(ONSqlSelect onSql, ONDBData data)
        {
            if (IsUnableToFilterInData(data.OnContext))
                return;

            #region Horizontal visibility for agent 'Administrador'
            if(data.OnContext.LeafActiveAgentFacets.Contains("Administrador"))
            {
                // No Horizontal Visibility formula
            }
            #endregion Horizontal visibility for agent 'Administrador'
        }
Exemplo n.º 5
0
        /// <summary>
        /// Fix related instance
        /// </summary>
        /// <param name="onSql">Sentence SQL to be executed</param>
        /// <param name="linkedTo">List to reach the class to retrieve the related instance</param>
        protected bool AddLinkedTo(ONSqlSelect onSql, ONLinkedToList linkedTo)
        {
            // Fix related instance
            foreach (KeyValuePair <ONPath, ONOid> lDictionaryEntry in linkedTo)
            {
                ONPath lPath = lDictionaryEntry.Key as ONPath;
                ONOid  lOID  = lDictionaryEntry.Value as ONOid;

                string lAliasRelated = InhAddPath(onSql, lOID.ClassName, lPath, "", true);

                // Check Visibility
                if (!ONInstance.IsVisibleInv(ONContext.GetType_Instance(ClassName), lPath, OnContext))
                {
                    return(false);
                }

                ONDBData lData = ONContext.GetComponent_Data(lOID.ClassName, OnContext) as ONDBData;
                lData.InhFixInstance(onSql, null, lPath, lOID, true);
            }

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Executes the SQL statment over the Data Base connected
        /// </summary>
        /// <param name="onSql">This parameter has the current SQL statment</param>
        /// <param name="onFilterList">List of filters to check</param>
        /// <param name="comparer">This parameter has all the information refering to the order criteria to add to SQL statment</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>
        public override ONCollection ExecuteSql(ONSql onSql, ONFilterList onFilterList, ONDisplaySet displaySet, ONOrderCriteria orderCriteria, ONOid startRowOid, int blockSize)
        {
            AeronaveCollection lQuery = null;
            bool lWithStartRow        = (startRowOid != null).TypedValue;
            long lCount = -1;

            if (!lWithStartRow)
            {
                lCount = 0;
            }

            IDataReader     lDataReader      = null;
            ONSQLConnection lOnSQLConnection = null;

            try
            {
                lDataReader = Execute(onSql) as IDataReader;

                AeronaveInstance lInstance    = null;
                AeronaveInstance lAntInstance = null;
                if (lDataReader != null)
                {
                    object[] lColumns;
                    if (displaySet == null)
                    {
                        lColumns = new object[4];
                    }
                    else
                    {
                        lColumns = new object[displaySet.ElementsInData];
                    }

                    lQuery = new AeronaveCollection(OnContext);
                    bool lFoundStartRow = false;
                    while (lDataReader.Read())
                    {
                        lAntInstance = lInstance;

                        // Read Columns
                        lDataReader.GetValues(lColumns);

                        // Read Instance
                        int lIndex = 0;
                        lInstance = LoadFacet(OnContext, displaySet, lColumns, ref lIndex);

                        // Read related attributes
                        if (displaySet != null)
                        {
                            LoadRelated(OnContext, displaySet, lColumns, lIndex, lInstance);
                        }

                        if (lCount >= 0)                         // Add the load instance
                        {
                            if ((onFilterList == null) || (!onFilterList.InMemory))
                            {
                                // Add to the Instance list
                                lQuery.Add(lInstance);
                                lCount++;
                            }
                            else
                            {
                                ONSQLConnection lSQLConnectionOld = (ONSQLConnection)lInstance.OnContext.SqlConnection;

                                // Set another connection because it is imposible to use
                                // the same connection that is used in the DataReader
                                if (lOnSQLConnection == null)
                                {
                                    lOnSQLConnection = GetConnection();
                                }
                                lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                if (onFilterList.FilterInMemory(lInstance))
                                {
                                    // Add to the Instance list
                                    lQuery.Add(lInstance);
                                    lCount++;
                                }

                                lInstance.OnContext.SqlConnection = lSQLConnectionOld;
                            }
                        }
                        else
                        {
                            if ((orderCriteria != null) && (orderCriteria.InMemory))                             // Need to load for ordering in memory after loading
                            {
                                if (lAntInstance != null)
                                {
                                    // Set another connection because it is imposible to use
                                    // the same connection that is used in the DataReader
                                    ONSQLConnection lOnSQLConnectionOld = lInstance.OnContext.SqlConnection as ONSQLConnection;
                                    if (lOnSQLConnection == null)
                                    {
                                        lOnSQLConnection = GetConnection();
                                    }
                                    lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                    int lCompare = orderCriteria.CompareSql(lInstance, lAntInstance);
                                    if (lCompare != 0)
                                    {
                                        if (lFoundStartRow)
                                        {
                                            lCount = 1;
                                        }
                                        else
                                        {
                                            lQuery.Clear();
                                        }
                                    }

                                    // Restores the old connection
                                    lInstance.OnContext.SqlConnection = lOnSQLConnectionOld;
                                }

                                if ((onFilterList == null) || (!onFilterList.InMemory))
                                {
                                    // Add to the Instance list
                                    lQuery.Add(lInstance);
                                }
                                else
                                {
                                    ONSQLConnection lSQLConnectionOld = (ONSQLConnection)lInstance.OnContext.SqlConnection;

                                    // Set another connection because it is imposible to use
                                    // the same connection that is used in the DataReader
                                    if (lOnSQLConnection == null)
                                    {
                                        lOnSQLConnection = GetConnection();
                                    }
                                    lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                    if (onFilterList.FilterInMemory(lInstance))
                                    {
                                        // Add to the Instance list
                                        lQuery.Add(lInstance);
                                    }
                                    else
                                    {
                                        lCount--;
                                    }

                                    lInstance.OnContext.SqlConnection = lSQLConnectionOld;
                                }

                                if (lInstance.Oid.Equals(startRowOid))
                                {
                                    lFoundStartRow = true;
                                }
                            }

                            else if (lInstance.Oid.Equals(startRowOid))                             // Search the start row
                            {
                                lCount = 0;
                            }
                        }

                        // Stop loading
                        if ((blockSize != 0) && (lCount > blockSize))
                        {
                            if (orderCriteria == null)
                            {
                                break;
                            }
                            else
                            {
                                // Set another connection because it is imposible to use
                                // the same connection that is used in the DataReader
                                ONSQLConnection lOnSQLConnectionOld = lInstance.OnContext.SqlConnection as ONSQLConnection;
                                if (lOnSQLConnection == null)
                                {
                                    lOnSQLConnection = GetConnection();
                                }
                                lInstance.OnContext.SqlConnection = lOnSQLConnection;

                                int lCompare = orderCriteria.CompareSql(lInstance, lAntInstance);

                                // Restores the old connection
                                lInstance.OnContext.SqlConnection = lOnSQLConnectionOld;

                                if (lCompare > 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string ltraceItem = "Method: ExecuteSql, Component: AeronaveData";
                if (e is ONSystemException)
                {
                    ONSystemException lException = e as ONSystemException;
                    lException.addTraceInformation(ltraceItem);
                    throw lException;
                }
                throw new ONSystemException(e, ltraceItem);
            }
            finally
            {
                if (lOnSQLConnection != null)
                {
                    ONDBData.CloseConnection(lOnSQLConnection);
                }
                if (lDataReader != null)
                {
                    if (mSqlCommand != null)
                    {
                        mSqlCommand.Cancel();
                    }
                    lDataReader.Close();
                }
                Close();
                if ((onFilterList != null) && (onFilterList.InMemory) && !lWithStartRow && (lCount <= blockSize))
                {
                    lQuery.totalNumInstances = lQuery.Count;
                }
            }

            return(lQuery);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Makes the data checks
 /// </summary>
 /// <param name="onSql">Sql to execute</param>
 /// <param name="data">Data componente of the class</param>
 public virtual void FilterInData(ONSqlSelect onSql, ONDBData data)
 {
 }