Ejemplo n.º 1
0
        /// <summary>
        /// Execute a query to retrieve a set of instances, without any condition.
        /// </summary>
        /// <param name="context">Current context.</param>
        /// <returns>A DataTable with the instances searched.</returns>
        public static DataTable ExecuteQueryPopulation(IUPopulationContext context)
        {
            // Last Oid
            PasajeroOid lLastOid = null;

            if (context.LastOids.Count > 0)
            {
                lLastOid = new PasajeroOid(context.LastOids.Peek());
            }

            // Last Block
            bool lLastBlock = true;
            NavigationalFiltering navigationalFiltering = NavigationalFiltering.GetNavigationalFiltering(context);
            DataTable             lDataTable            = ExecuteQueryRelated(context.Agent, new Dictionary <string, Oid>(), context.DisplaySetAttributes, context.OrderCriteriaNameSelected, navigationalFiltering, lLastOid, context.BlockSize, ref lLastBlock);

            context.LastBlock = lLastBlock;

            return(lDataTable);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute a query related with other instance.
        /// </summary>
        /// <param name="context">Current context.</param>
        /// <returns>A DataTable with the instances searched.</returns>
        public static DataTable ExecuteQueryRelated(IUQueryContext context)
        {
            try
            {
                ExchangeInfo lExchangeInfo = context.ExchangeInformation;

                if (lExchangeInfo.ExchangeType != ExchangeType.Navigation || lExchangeInfo.SelectedOids.Count == 0)
                {
                    return(null);
                }

                IUPopulationContext lIUContext = context as IUPopulationContext;
                int blockSize = 1;
                if (lIUContext != null)
                {
                    blockSize = lIUContext.BlockSize;
                }
                ExchangeInfoNavigation lNavInfo = lExchangeInfo as ExchangeInfoNavigation;
                // Specific case. No role name indicates Query by Instance.
                if (lNavInfo.RolePath == "")
                {
                    if (lIUContext != null)
                    {
                        lIUContext.LastBlock = true;
                    }

                    PasajeroOid lOidInstance = new PasajeroOid(lNavInfo.SelectedOids[0]);
                    return(ExecuteQueryInstance(context.Agent, lOidInstance, context.DisplaySetAttributes));
                }

                // Get link items.
                Oid lOid = lNavInfo.SelectedOids[0];
                Dictionary <string, Oid> lLinkItems = new Dictionary <string, Oid>(StringComparer.CurrentCultureIgnoreCase);
                lLinkItems.Add(lNavInfo.RolePath, lOid);

                bool        lLastBlock     = true;
                PasajeroOid lLastOid       = null;
                string      lOrderCriteria = string.Empty;

                // Get population members.
                if (lIUContext != null)
                {
                    if (lIUContext.LastOid != null)
                    {
                        lLastOid = new PasajeroOid(lIUContext.LastOid);
                    }
                    lOrderCriteria = lIUContext.OrderCriteriaNameSelected;
                }
                NavigationalFiltering navigationalFiltering = NavigationalFiltering.GetNavigationalFiltering(context);
                DataTable             lDataTable            = ExecuteQueryRelated(context.Agent, lLinkItems, context.DisplaySetAttributes, lOrderCriteria, navigationalFiltering, lLastOid, blockSize, ref lLastBlock);

                if (lIUContext != null)
                {
                    lIUContext.LastBlock = lLastBlock;
                }

                return(lDataTable);
            }
            catch (Exception e)
            {
                ScenarioManager.LaunchErrorScenario(e);
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Execute a query related with other instance.
        /// </summary>
        /// <param name="agent">Application agent.</param>
        /// <param name="linkItems">List of related instance oids (path - role).</param>
        /// <param name="displaySet">List of attributes to return.</param>
        /// <param name="orderCriteria">Order criteria name.</param>
        /// <param name="lastOid">Oid from which to search (not included).</param>
        /// <param name="blockSize">Number of instances to return (0 for all population).</param>
        /// <param name="lastBlock">Indicates if it is last block.</param>
        /// <returns>A DataTable with the instances searched.</returns>
        public static DataTable ExecuteQueryRelated(Oid agent, Dictionary <string, Oid> linkItems, string displaySet, string orderCriteria, NavigationalFiltering navigationalFiltering, Oid lastOid, int blockSize, ref bool lastBlock)
        {
            DataTable lDataTable = Logic.Adaptor.ExecuteQueryRelated(agent, "Pasajero", linkItems, displaySet, orderCriteria, navigationalFiltering, lastOid, blockSize);

            // Last block
            if (lDataTable.ExtendedProperties.Contains("LastBlock"))
            {
                lastBlock = (bool)lDataTable.ExtendedProperties["LastBlock"];
            }
            else
            {
                lastBlock = false;
            }

            return(lDataTable);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Execute a query to retrieve a set of instances, without any condition.
 /// </summary>
 /// <param name="agent">Application agent.</param>
 /// <param name="displaySet">List of attributes to return.</param>
 /// <param name="orderCriteria">Order criteria name.</param>
 /// <param name="lastOid">Oid from which to search (not included).</param>
 /// <param name="blockSize">Number of instances to return (0 for all population).</param>
 /// <returns>A DataTable with the instances searched.</returns>
 public static DataTable ExecuteQueryPopulation(Oid agent, string displaySet, string orderCriteria, NavigationalFiltering navigationalFiltering, Oid lastOid, int blockSize, ref bool lastBlock)
 {
     return(ExecuteQueryRelated(agent, new Dictionary <string, Oid>(), displaySet, orderCriteria, navigationalFiltering, lastOid, blockSize, ref lastBlock));
 }
        /// <summary>
        /// Serializes a NavigationalFiltering to an XML stream.
        /// </summary>
        /// <param name="writer">XML stream to write.</param>
        /// <param name="navigationalFiltering">NavigationalFiltering.</param>
        /// <returns>XML stream with the NavigationalFiltering.</returns>
        public static XmlWriter Serialize(XmlWriter writer, NavigationalFiltering navigationalFiltering)
        {
            #region <NavFilt>
            writer.WriteStartElement(DTD.Request.QueryRequest.TagNavFilt);

            if (navigationalFiltering.IsNavigationalArgument)
            {
            #region <NavFilt.Argument>
            writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltArgument);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagClass, navigationalFiltering.Argument.ClassName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagService, navigationalFiltering.Argument.ServiceName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagArgument, navigationalFiltering.Argument.ArgumentName);

            #region <Arguments>
                XMLNavigationalFilteringArgumentsListSerializer.Serialize(writer, navigationalFiltering.Argument.Arguments);
            #endregion <Arguments>

            writer.WriteEndElement();
            #endregion <NavFilt.Argument>
            }
            else if (navigationalFiltering.IsNavigationalFilterVariable)
            {
                #region <NavFilt.Variable>
                writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltVariable);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagClass, navigationalFiltering.FilterVariable.ClassName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagFilter, navigationalFiltering.FilterVariable.FilterName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagVariable, navigationalFiltering.FilterVariable.ArgumentName);

                #region <Filter.Variables>
                XMLNavigationalFilteringVariablesListSerializer.Serialize(writer, navigationalFiltering.FilterVariable.Arguments);
                #endregion <Filter.Variables>

                writer.WriteEndElement();
                #endregion <NavFilt.Variable>
            }
            else if(navigationalFiltering.IsNavigationalSelectObject)
            {
                #region <NavFilt.SelectedObject>
                writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltSelectedObject);

                #region <NavFilt.SelectedObject NavFilterID Attribute>
                if (navigationalFiltering.SelectedObject.NavigationalFilterID.Length > 0)
                {
                    writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.TagNavFilterID, navigationalFiltering.SelectedObject.NavigationalFilterID);
                }
                #endregion <NavFilt.SelectedObject NavFilterID Attribute>

                #region OID
                XMLAdaptorOIDSerializer.Serialize(writer, navigationalFiltering.SelectedObject.SelectedObjectOID);
                #endregion OID

                writer.WriteEndElement();
                #endregion <NavFilt.SelectedObject>
            }
            else if (navigationalFiltering.IsNavigationalServiceIU)
            {
            #region <NavFilt.ServiceIU>
                writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltServiceIU);

                #region <NavFilt.ServiceIU NavFilterID Attribute>
                if (navigationalFiltering.ServiceIU.NavigationalFilterID.Length > 0)
                {
                    writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.TagNavFilterID, navigationalFiltering.ServiceIU.NavigationalFilterID);
                }
                #endregion <NavFilt.ServiceIU NavFilterID Attribute>

                #region <Arguments>
                XMLNavigationalFilteringArgumentsListSerializer.Serialize(writer, navigationalFiltering.ServiceIU.Arguments);
                #endregion <Arguments>

                writer.WriteEndElement();
            #endregion <NavFilt.ServiceIU>
            }

            writer.WriteEndElement();
            return writer;
            #endregion <NavFilt>
        }
        /// <summary>
        /// Serializes a NavigationalFiltering to an XML stream.
        /// </summary>
        /// <param name="writer">XML stream to write.</param>
        /// <param name="navigationalFiltering">NavigationalFiltering.</param>
        /// <returns>XML stream with the NavigationalFiltering.</returns>
        public static XmlWriter Serialize(XmlWriter writer, NavigationalFiltering navigationalFiltering)
        {
            #region <NavFilt>
            writer.WriteStartElement(DTD.Request.QueryRequest.TagNavFilt);

            if (navigationalFiltering.IsNavigationalArgument)
            {
                #region <NavFilt.Argument>
                writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltArgument);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagClass, navigationalFiltering.Argument.ClassName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagService, navigationalFiltering.Argument.ServiceName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltArgument.TagArgument, navigationalFiltering.Argument.ArgumentName);

                #region <Arguments>
                XMLNavigationalFilteringArgumentsListSerializer.Serialize(writer, navigationalFiltering.Argument.Arguments);
                #endregion <Arguments>

                writer.WriteEndElement();
                #endregion <NavFilt.Argument>
            }
            else if (navigationalFiltering.IsNavigationalFilterVariable)
            {
                #region <NavFilt.Variable>
                writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltVariable);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagClass, navigationalFiltering.FilterVariable.ClassName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagFilter, navigationalFiltering.FilterVariable.FilterName);
                writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.NaviFiltVariable.TagVariable, navigationalFiltering.FilterVariable.ArgumentName);

                #region <Filter.Variables>
                XMLNavigationalFilteringVariablesListSerializer.Serialize(writer, navigationalFiltering.FilterVariable.Arguments);
                #endregion <Filter.Variables>

                writer.WriteEndElement();
                #endregion <NavFilt.Variable>
            }
            else if (navigationalFiltering.IsNavigationalSelectObject)
            {
                #region <NavFilt.SelectedObject>
                writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltSelectedObject);

                #region <NavFilt.SelectedObject NavFilterID Attribute>
                if (navigationalFiltering.SelectedObject.NavigationalFilterID.Length > 0)
                {
                    writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.TagNavFilterID, navigationalFiltering.SelectedObject.NavigationalFilterID);
                }
                #endregion <NavFilt.SelectedObject NavFilterID Attribute>

                #region OID
                XMLAdaptorOIDSerializer.Serialize(writer, navigationalFiltering.SelectedObject.SelectedObjectOID);
                #endregion OID

                writer.WriteEndElement();
                #endregion <NavFilt.SelectedObject>
            }
            else if (navigationalFiltering.IsNavigationalServiceIU)
            {
                #region <NavFilt.ServiceIU>
                writer.WriteStartElement(DTD.Request.QueryRequest.NavFilt.TagNavFiltServiceIU);

                #region <NavFilt.ServiceIU NavFilterID Attribute>
                if (navigationalFiltering.ServiceIU.NavigationalFilterID.Length > 0)
                {
                    writer.WriteAttributeString(DTD.Request.QueryRequest.NavFilt.TagNavFilterID, navigationalFiltering.ServiceIU.NavigationalFilterID);
                }
                #endregion <NavFilt.ServiceIU NavFilterID Attribute>

                #region <Arguments>
                XMLNavigationalFilteringArgumentsListSerializer.Serialize(writer, navigationalFiltering.ServiceIU.Arguments);
                #endregion <Arguments>

                writer.WriteEndElement();
                #endregion <NavFilt.ServiceIU>
            }

            writer.WriteEndElement();
            return(writer);

            #endregion <NavFilt>
        }