Exemplo n.º 1
0
        /// <summary>
        /// Checks if a determinate instance exists
        /// </summary>
        /// <param name="oid">OID to search the instance</param>
        /// <param name="onFilterList">Filters to theck</param>
        /// <returns>If exists</returns>
        public override bool Exist(ONOid oid, ONFilterList onFilterList)
        {
            if ((onFilterList == null) || (!onFilterList.InMemory))
            {
                ONSqlCount lOnSql = new ONSqlCount();

                // Create select and first table
                string lAlias = lOnSql.CreateAlias(TableName, null, ClassName);
                lOnSql.AddSelect(lAlias);

                // Fix instance
                InhFixInstance(lOnSql, null, null, oid);

                // Add filter formula
                if (onFilterList != null)
                {
                    onFilterList.FilterInData(lOnSql, this);
                }

                // Execute
                return(Convert.ToInt32(Execute(lOnSql)) > 0);
            }
            else
            {
                return(Search(oid, onFilterList, null) != null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Searchs a determinate instance
        /// </summary>
        /// <param name="oid">OID to search the instance</param>
        /// <param name="onFilterList">Filter list</param>
        public override ONInstance Search(ONOid oid, ONFilterList onFilterList, ONDisplaySet displaySet)
        {
            ONFilterList lOnFilterList = null;

            if (onFilterList != null)
            {
                lOnFilterList = new ONFilterList(onFilterList);
            }
            else
            {
                lOnFilterList = new ONFilterList();
            }
            lOnFilterList.Add("QueryByOid", new QueryByOidFilter(oid));

            ONCollection lCollection = ExecuteQuery(new ONLinkedToList(), lOnFilterList, displaySet, null, null, 0);

            if (lCollection.Count > 0)
            {
                return(lCollection[0] as ONInstance);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method recovers all the population of the database
        /// </summary>
        /// <param name="onContext">Recovers the context of the execution of the service</param>
        /// <param name="linkedTo">List to reach the class to retrieve the related instance</param>
        /// <param name="comparer">Order Criteria that must be followed</param>
        /// <param name="${startRowOid}">OID frontier</param>
        /// <param name="blockSize">Number of instances to be returned</param>
        /// <returns>The population</returns>
        public override ONCollection FilterInLegacy(ONContext onContext, ONLinkedToList linkedTo, ONOrderCriteria comparer, ONOid startRowOID, int blockSize)
        {
            if (InData)
            {
                return(null);
            }
            ONLinkedToList lLinkedToList = new ONLinkedToList();

            // Add linkedToList to the new list
            foreach (KeyValuePair <ONPath, ONOid> lDictionaryEntry in linkedTo)
            {
                lLinkedToList.mLinkedToList.Add(lDictionaryEntry.Key, lDictionaryEntry.Value);
            }
            // Add relatedOid to the new list
            if (mRelatedOid != null)
            {
                lLinkedToList.mLinkedToList.Add(ONPath, mRelatedOid);
            }
            // Add parameters
            object[] lParameters = new object[5];
            lParameters[0] = onContext;
            lParameters[1] = linkedTo;
            lParameters[2] = comparer;
            lParameters[3] = startRowOID;
            lParameters[4] = blockSize;

            return(ONContext.InvoqueMethod(ONContext.GetType_LV(ClassName), "QueryByRelated", lParameters) as ONCollection);
        }
Exemplo n.º 4
0
        public void Create_instanceServ(ref string ticket, ref ONOid agentOid, XmlReader xmlReader, XmlWriter xmlWriter, double dtdVersion, string clientName)
        {
            // Process the service arguments
            ONServiceInfo lSInfo = new ONServiceInfo("Clas_1347649273856884Ser_1_Alias", NaveNodrizaClassText.Create_instanceServiceAlias, "Clas_1347649273856884_Alias", NaveNodrizaClassText.ClassAlias);

            lSInfo.AddDataValuedArgument("p_atrid_NaveNodriza", false, DataTypeEnumerator.Autonumeric, 0, "Clas_1347649273856884Ser_1Arg_1_Alias", NaveNodrizaClassText.Create_instance_P_atrid_NaveNodrizaArgumentAlias);
            lSInfo.AddDataValuedArgument("p_atrNombre_NaveNodriza", false, DataTypeEnumerator.String, 100, "Clas_1347649273856884Ser_1Arg_2_Alias", NaveNodrizaClassText.Create_instance_P_atrNombre_NaveNodrizaArgumentAlias);

            try
            {
                lSInfo.XML2ON(xmlReader, dtdVersion, true);
            }
            catch (Exception e)
            {
                throw new ONServiceArgumentsException(e, "Clas_1347649273856884_Alias", NaveNodrizaClassText.ClassAlias, "Clas_1347649273856884Ser_1_Alias", NaveNodrizaClassText.Create_instanceServiceAlias);
            }

            ONInt    lP_atrid_NaveNodrizaArg     = (ONInt)((ONArgumentInfo)lSInfo.mArgumentList["p_atrid_NaveNodriza"]).Value;
            ONString lP_atrNombre_NaveNodrizaArg = (ONString)((ONArgumentInfo)lSInfo.mArgumentList["p_atrNombre_NaveNodriza"]).Value;

            // Create Context
            ONServiceContext lOnContext = new ONServiceContext();

            lOnContext.OidAgent = agentOid;

            // Execute Service
            NaveNodrizaInstance lInstance = null;

            try
            {
                using (NaveNodrizaServer lServer = new NaveNodrizaServer(lOnContext, null))
                {
                    lServer.Create_instanceServ(lP_atrid_NaveNodrizaArg, lP_atrNombre_NaveNodrizaArg);
                    lInstance = lServer.Instance;
                }
                ticket = lOnContext.GetTicket(dtdVersion, clientName);
            }
            catch (SecurityException)
            {
                throw new ONAccessAgentValidationException(null);
            }
            catch
            {
                throw;
            }

            // Write Oid
            if (dtdVersion >= 3.1)
            {
                if (lInstance != null)
                {
                    ON2XML(xmlWriter, lInstance.Oid, dtdVersion, ONXml.XMLTAG_OIDFIELD);
                }
            }

            // Write Outbound Arguments
            xmlWriter.WriteStartElement("Arguments");
            // Write Outbound Arguments
            xmlWriter.WriteEndElement();             // Arguments
        }
Exemplo n.º 5
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="onContext">Context to copy from</param>
 public ONContext(ONContext onContext)
 {
     mOidAgent      = onContext.OidAgent;
     mSqlConnection = null;
     CalculateQueryInstancesNumber = false;
     LeafActiveAgentFacets         = onContext.LeafActiveAgentFacets;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the instance with the Oid
        /// </summary>
        /// <param name="oid">OID to search the instance</param>
        /// <param name="onFilterList">Filters to theck</param>
        /// <returns>The instance searched</returns>
        public override ONInstance Search(ONOid oid, ONFilterList onFilterList, ONDisplaySet displaySet)
        {
            ONSqlSelect lOnSql = new ONSqlSelect();

            // Create select and first table
            InhRetrieveInstances(lOnSql, displaySet, null, OnContext);

            // Fix instance
            InhFixInstance(lOnSql, null, null, oid);

            // Add filter formula
            onFilterList.FilterInData(lOnSql, this);

            // Execute
            ONCollection lCollection = ExecuteSql(lOnSql, onFilterList, displaySet, null, null, 0);

            if (lCollection.Count > 0)
            {
                return(lCollection[0] as ONInstance);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
        public ONCollection QueryByFilter_FUM(ref string ticket, ref ONOid agentOid, XmlReader xmlReader, ONDisplaySet displaySet, out ONOid startRowOID, out int blockSize, double dtdVersion, string clientName)
        {
            ONLinkedToList lLinkedTo = null;
            ONFilterList   lFilters  = new ONFilterList();

            // Read Request
            blockSize = int.Parse(xmlReader.GetAttribute("BlockSize"));
            if (!xmlReader.IsEmptyElement)
            {
                xmlReader.ReadStartElement("Query.Filter");
                if (xmlReader.IsStartElement("StartRow"))
                {
                    xmlReader.ReadStartElement("StartRow");
                    startRowOID = XML2ON(xmlReader, dtdVersion);
                    xmlReader.ReadEndElement();                     // StartRow
                }
                else
                {
                    startRowOID = null;
                }

                // Fill relations
                lLinkedTo = GetLinkedTo(xmlReader, dtdVersion);

                // Fill filter variables
                lFilters["FUM"] = GetFilter_FUM(xmlReader, dtdVersion);

                // Read Request
                xmlReader.ReadEndElement();                 // Query.Filter
            }
            else
            {
                xmlReader.ReadStartElement("Query.Filter");
                lLinkedTo   = new ONLinkedToList();
                startRowOID = null;
            }

            // Read Order Criteria
            string lOrderCriteria = "";

            if (xmlReader.IsStartElement("Sort"))
            {
                lOrderCriteria = xmlReader.GetAttribute("Criterium");
                xmlReader.Skip();                 // Sort
            }

            // Create Context
            ONContext lOnContext = new ONContext();

            lOnContext.OidAgent = agentOid;

            // Execute
            PasajeroQuery lQuery      = new PasajeroQuery(lOnContext);
            ONCollection  lCollection = lQuery.QueryByFilter(lLinkedTo, lFilters, displaySet, lOrderCriteria, startRowOID, blockSize);

            ticket = lOnContext.GetTicket(dtdVersion, clientName);

            return(lCollection);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Puts the Oid in the modified class list to check integrity constraints and trigger conditions
        /// The Oid is added thought it's not marked as modified
        /// </summary>
        /// <param name="oid">Oid that represents the instance to be added</param>
        public void AddUnmodifiedClass(ONOid oid)
        {
            ModifiedClass.Remove(oid);
            ONAction lAction = GetComponent_Action(oid.ClassName, this);

            lAction.Instance = GetComponent_Instance(oid.ClassName, this);
            ModifiedClass.Add(oid, lAction);
        }
Exemplo n.º 9
0
        public ONCollection QueryByOid(ONOid oid, ONDisplaySet displaySet)
        {
            //Create filters
            ONFilterList lOnFilterList = new ONFilterList();

            lOnFilterList.Add("QueryByOid", new QueryByOidFilter(oid));

            return(QueryByFilter(null, lOnFilterList, displaySet, null, null, 0));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="onContext">Context with all the information about the execution of the request</param>
 /// <param name="className">Name of the class that represents the instance</param>
 /// <param name="idClass">Identificator of the class</param>
 public ONInstance(ONContext onContext, string className, string idClass)
 {
     ClassName = className;
     IdClass   = idClass;
     Oid       = null;
     Lmd       = ONDateTime.Null;
     Modified  = false;
     OnContext = onContext;
 }
Exemplo n.º 11
0
        public QueryByOidFilter(ONOid oid)
            : base(oid.ClassName, "QueryByOid")
        {
            mOid = oid;

            Type lDataType = ONContext.GetType_Data(ClassName);

            InMemory = false;
            InData   = !lDataType.IsSubclassOf(typeof(ONLVData));
            InLegacy = lDataType.IsSubclassOf(typeof(ONLVData));
        }
Exemplo n.º 12
0
        public QueryByRelatedFilter(string className, ONPath onPath, ONOid relatedOid)
            : base(className, "QueryByRelated")
        {
            ONPath      = onPath;
            mRelatedOid = relatedOid;

            Type lDataType = ONContext.GetType_Data(ClassName);

            InMemory = false;
            InData   = !lDataType.IsSubclassOf(typeof(ONLVData));
            InLegacy = lDataType.IsSubclassOf(typeof(ONLVData));
        }
Exemplo n.º 13
0
        public void Preprocess(MarshalByRefObject inst, IMessage msg)
        {
            if (mServiceCacheItem == null)
            {
                mServiceCacheItem = ONServiceCacheItem.Get("Server", ClassName, ServiceName);
            }

            IMethodCallMessage lMsgIn = msg as IMethodCallMessage;

            // Extract Server
            ONServer lServer = inst as ONServer;

            // Take the active Instance
            bool lFind = false;

            foreach (ONInstance lInstance in lServer.OnContext.OperationStack)
            {
                if (((object)lInstance != null) && (lInstance == lServer.Instance))
                {
                    lServer.Instance = lInstance.GetFacet(lServer.Instance.ClassName);
                    lFind            = true;

                    break;
                }
            }

            // Push OID to Class Stack
            lServer.OnContext.OperationStack.Push(lServer.Instance);
            mInStack = true;

            // Check State Changes
            if (lServer.OnContext.NeedsVerification)
            {
                mServiceCacheItem.InvoqueCheckState(lServer, lMsgIn.Args);
                lServer.OnContext.NeedsVerification = false;
            }

            // Search all facets
            foreach (IONType lArgument in lMsgIn.InArgs)
            {
                ONOid lOidArgument = lArgument as ONOid;
                if (lOidArgument != null)
                {
                    if (!lOidArgument.Exist(lServer.OnContext, null))
                    {
                        throw new ONInstanceNotExistException(null, ONContext.GetComponent_Instance(lOidArgument.ClassName, lServer.OnContext).IdClass, lOidArgument.ClassName);
                    }
                }
            }

            // Check Precondition
            mServiceCacheItem.InvoquePrecondition(lServer, lMsgIn.Args);
        }
Exemplo n.º 14
0
        public void Preprocess(MarshalByRefObject inst, IMessage msg)
        {
            IMethodCallMessage lMsgIn = msg as IMethodCallMessage;

            // Extract Server
            ONServer lServer = inst as ONServer;

            // Take the active Instance
            bool lFind = false;

            foreach (ONInstance lInstance in lServer.OnContext.TransactionStack)
            {
                if (((object)lInstance != null) && (lInstance == lServer.Instance))
                {
                    lServer.Instance = lInstance.GetFacet(lServer.Instance.ClassName);
                    lFind            = true;

                    break;
                }
            }
            if (!lFind)
            {
                foreach (ONInstance lInstance in lServer.OnContext.OperationStack)
                {
                    if (((object)lInstance != null) && (lInstance == lServer.Instance))
                    {
                        lServer.Instance = lInstance.GetFacet(lServer.Instance.ClassName);
                        lFind            = true;

                        break;
                    }
                }
            }

            // Push OID to Class Stack
            lServer.OnContext.OperationStack.Push(lServer.Instance);
            mInStack = true;

            // Search all facets
            foreach (IONType lArgument in lMsgIn.InArgs)
            {
                ONOid lOidArgument = lArgument as ONOid;
                if (lOidArgument != null)
                {
                    if (!lOidArgument.Exist(lServer.OnContext, null))
                    {
                        throw new ONInstanceNotExistException(null, ONContext.GetComponent_Instance(lOidArgument.ClassName, lServer.OnContext).IdClass, lOidArgument.ClassName);
                    }
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Checks if the instance exists in local system.
        /// </summary>
        /// <param name="oid">OID to search the instance</param>
        public bool LocalExist(ONOid oid)
        {
            ONSqlSelect onSql = new ONSqlCount();

            // Create select and first table
            string lAlias = onSql.CreateAlias(ClassName, null, ClassName);

            onSql.AddSelect(lAlias);

            // Fix instance
            InhFixInstance(onSql, null, null, oid);

            // Execute
            return(Convert.ToInt32(Execute(onSql)) > 0);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Checks if a determinate instance exists
        /// </summary>
        /// <param name="oid">OID to search the instance</param>
        /// <param name="horizontalVisibility">Controls if it is needed to check the horizontal visibility</param>
        public override bool Exist(ONOid oid, ONFilterList onFilterList)
        {
            ONFilterList lOnFilterList = null;

            if (onFilterList != null)
            {
                lOnFilterList = new ONFilterList(onFilterList);
            }
            else
            {
                lOnFilterList = new ONFilterList();
            }
            lOnFilterList.Add("QueryByOid", new QueryByOidFilter(oid));

            return(ExecuteQuery(new ONLinkedToList(), lOnFilterList, null, null, null, 0).Count > 0);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the Agent of the XML mesage
        /// </summary>
        /// <param name="xmlReader">The message with the request in XML format</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        private ONOid GetAgent(XmlTextReader xmlReader, double dtdVersion)
        {
            ONOid lAgentOID = null;

            if ((dtdVersion < 3.1) || (xmlReader.IsStartElement("Agent")))
            {
                object[] lParam = new object[2];
                lParam[0] = xmlReader;
                lParam[1] = dtdVersion;

                xmlReader.ReadStartElement("Agent");
                string lAgentClass = xmlReader.GetAttribute("Class");
                lAgentOID = ONContext.InvoqueMethod(ONContext.GetType_XML(lAgentClass), "XML2ON", lParam) as ONOid;
                xmlReader.ReadEndElement();                 // Agent
            }

            return(lAgentOID);
        }
Exemplo n.º 18
0
        public ONOid SetTicket(double dtdVersion, string clientName, string ticket)
        {
            try
            {
                ONOid lAgent = ONSecureControl.ValidateTicket(dtdVersion, ticket, clientName);
                OidAgent = lAgent;
            }
            catch (ONAgentValidationException)
            {
                if (!ONSecureControl.SecureServer)
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(mOidAgent);
        }
Exemplo n.º 19
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.º 20
0
        /// <summary>
        /// Assign the agent connected as a principal of the system
        /// </summary>
        /// <param name="OidAgent">OID of the agent connected to the system</param>
        public IPrincipal AgentAssign(ONOid OidAgent)
        {
            // Retrieve old principal
            IPrincipal lPrincipalOld = Thread.CurrentPrincipal;

            // Create Identity
            GenericIdentity lIdentity = new GenericIdentity(OidAgent.ToString());

            // Create Principal
            string[] lRoles = new string[LeafActiveAgentFacets.Count];

            for (int i = 0; i < LeafActiveAgentFacets.Count; i++)
            {
                lRoles[i] = LeafActiveAgentFacets[i];
            }

            GenericPrincipal lPrincipal = new GenericPrincipal(lIdentity, lRoles);

            // Assign to the current thread
            Thread.CurrentPrincipal = lPrincipal;

            return(lPrincipalOld);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Treatment the part of the XML message that has links items
        /// </summary>
        /// <param name="xmlReader">Variable with the message XML to be treated</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        public ONLinkedToList GetLinkedTo(XmlReader xmlReader, double dtdVersion)
        {
            ONLinkedToList lLinkedToList = new ONLinkedToList();

            if (!xmlReader.IsStartElement("LinkedTo"))
            {
                return(lLinkedToList);
            }

            if (xmlReader.IsEmptyElement)
            {
                xmlReader.ReadStartElement("LinkedTo");
                return(lLinkedToList);
            }

            xmlReader.ReadStartElement("LinkedTo");
            while (xmlReader.IsStartElement("Link.Item"))
            {
                ONPath lPath = new ONPath(xmlReader.GetAttribute("Role"));
                xmlReader.ReadStartElement("Link.Item");

                object[] lParam = new object[2];
                lParam[0] = xmlReader;
                lParam[1] = dtdVersion;

                string lClassInstance = xmlReader.GetAttribute("Class");
                ONOid  lInstance      = ONContext.InvoqueMethod(ONContext.GetType_XML(lClassInstance), "XML2ON", lParam) as ONOid;

                lLinkedToList[lPath] = lInstance;

                xmlReader.ReadEndElement();         // Link.Item
            }
            xmlReader.ReadEndElement();             // LinkedTo

            return(lLinkedToList);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Process the request dedicated to loof for an instance with an OID given
        /// </summary>
        /// <param name="agentOid">OID with the agent connected to the system</param>
        /// <param name="xmlReader">XML with the request message</param>
        /// <param name="dtdVersion">Version of DTD that follows the XML message</param>
        public override ONCollection QueryByOid(ref string ticket, ref ONOid agentOid, XmlReader xmlReader, ONDisplaySet displaySet, double dtdVersion, string clientName)
        {
            // Get OID class
            string lClass = xmlReader.GetAttribute("Class");

            // Set OID parameter
            ONOid lOID = XML2ON(xmlReader, dtdVersion);

            // Read Request
            xmlReader.ReadEndElement();             // Query.Instance

            // Read Order Criteria
            if (xmlReader.IsStartElement("Sort"))             // Sort
            {
                xmlReader.Skip();
            }

            //Read Filter Navigation
            if (xmlReader.IsStartElement("NavFilt"))
            {
                xmlReader.Skip();
            }

            // Create Context
            ONContext lOnContext = new ONContext();

            lOnContext.OidAgent = agentOid;

            // Execute
            PasajeroQuery lQuery      = new PasajeroQuery(lOnContext);
            ONCollection  lCollection = lQuery.QueryByOid(lOID, displaySet);

            ticket = lOnContext.GetTicket(dtdVersion, clientName);

            return(lCollection);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Converts the instances returned by a query in XML format in order to put it in XML message response
        /// </summary>
        /// <param name="agentOid">OID with the agent connected to the system</param>
        /// <param name="xmlWriter">This parameter has the response message XML</param>
        /// <param name="val">Instances that fullfils with the query request</param>
        /// <param name="startRowOID">OID necessary to start the search</param>
        /// <param name="blockSize">Represents the number of instances to be returned</param>
        /// <param name="displaySet">Attributes to be returned in the response</param>
        /// <param name="dtdVersion">Version of DTD that follows the XML message</param>
        public override void ONQuery2XML(ONOid agentOid, XmlWriter xmlWriter, ONCollection val, ONOid startRowOID, int blockSize, ONDisplaySet displaySet, double dtdVersion)
        {
            xmlWriter.WriteStartElement("Head");
            xmlWriter.WriteStartElement("Head.OID");
            xmlWriter.WriteAttributeString("Class", "Pasajero");
            xmlWriter.WriteStartElement("Head.OID.Field");
            xmlWriter.WriteAttributeString("Name", "id_Pasajero");
            xmlWriter.WriteAttributeString("Type", "autonumeric");
            xmlWriter.WriteEndElement();             // Head.OID.Field

            xmlWriter.WriteEndElement();             // Head.OID

            xmlWriter.WriteStartElement("Head.Cols");
            foreach (ONDisplaySetItem lDisplaySetItem in displaySet)
            {
                xmlWriter.WriteStartElement("Head.Col");
                xmlWriter.WriteAttributeString("Name", lDisplaySetItem.Path);
                string lType = ONInstance.GetTypeOfAttribute(typeof(PasajeroInstance), new ONPath(lDisplaySetItem.Path));
                if (lType == "")
                {
                    lType = "string";
                }
                xmlWriter.WriteAttributeString("Type", lType);
                xmlWriter.WriteEndElement();         // Head.Col
            }
            xmlWriter.WriteEndElement();             // Head.Cols
            xmlWriter.WriteEndElement();             // Head

            // Search StartRow
            int i = 0;

            if (startRowOID != null)
            {
                i = val.IndexOf(startRowOID) + 1;
            }

            // Instance count
            int    lInstances    = 0;
            int    lNumInstances = 0;
            string lLastBlock    = "True";

            if (i >= 0)
            {
                lNumInstances = val.Count - i;
                if ((blockSize > 0) && (lNumInstances > blockSize))
                {
                    lNumInstances = blockSize;
                    lLastBlock    = "False";
                }
            }

            xmlWriter.WriteStartElement("Data");
            xmlWriter.WriteAttributeString("Rows", lNumInstances.ToString());
            xmlWriter.WriteAttributeString("LastBlock", lLastBlock);
            xmlWriter.WriteAttributeString("TotalRows", val.totalNumInstances.ToString());
            while ((lInstances++ < lNumInstances) && (i < val.Count))
            {
                PasajeroInstance lInstance = val[i++] as PasajeroInstance;

                xmlWriter.WriteStartElement("R");
                ONXmlAutonumeric.ON2XML(xmlWriter, lInstance.Oid.Id_PasajeroAttr, dtdVersion, ONXml.XMLTAG_O);


                foreach (ONDisplaySetItem lDisplaySetItem in displaySet)
                {
                    if (lDisplaySetItem.Visibility == VisibilityState.NotChecked)
                    {
                        if (ONInstance.IsVisible(lInstance.GetType(), lDisplaySetItem.Path, lInstance.OnContext))
                        {
                            lDisplaySetItem.Visibility = VisibilityState.Visible;
                        }
                        else
                        {
                            lDisplaySetItem.Visibility = VisibilityState.NotVisible;
                        }
                    }
                    if (lDisplaySetItem.Visibility == VisibilityState.NotVisible)                     // No Visibility
                    {
                        xmlWriter.WriteElementString("V", null);
                    }
                    else
                    {
                        ONSimpleType lAttribute;
                        if (lDisplaySetItem.HasHV)
                        {
                            lAttribute = lInstance.DisplaysetItemValue(lDisplaySetItem.Path);
                        }
                        else
                        {
                            lAttribute = lInstance[lDisplaySetItem.Path] as ONSimpleType;
                        }

                        if (lAttribute is ONInt)
                        {
                            ONXmlInt.ON2XML(xmlWriter, lAttribute as ONInt, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONString)
                        {
                            ONXmlString.ON2XML(xmlWriter, lAttribute as ONString, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONBlob)
                        {
                            ONXmlBlob.ON2XML(xmlWriter, lAttribute as ONBlob, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONBool)
                        {
                            ONXmlBool.ON2XML(xmlWriter, lAttribute as ONBool, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONReal)
                        {
                            ONXmlReal.ON2XML(xmlWriter, lAttribute as ONReal, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONInt)
                        {
                            ONXmlAutonumeric.ON2XML(xmlWriter, lAttribute as ONInt, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONDate)
                        {
                            ONXmlDate.ON2XML(xmlWriter, lAttribute as ONDate, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONDateTime)
                        {
                            ONXmlDateTime.ON2XML(xmlWriter, lAttribute as ONDateTime, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONTime)
                        {
                            ONXmlTime.ON2XML(xmlWriter, lAttribute as ONTime, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONNat)
                        {
                            ONXmlNat.ON2XML(xmlWriter, lAttribute as ONNat, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONText)
                        {
                            ONXmlText.ON2XML(xmlWriter, lAttribute as ONText, dtdVersion, ONXml.XMLTAG_V);
                        }
                        else if (lAttribute is ONString)
                        {
                            ONXmlPassword.ON2XML(xmlWriter, lAttribute as ONString, dtdVersion, ONXml.XMLTAG_V);
                        }
                    }
                }
                xmlWriter.WriteEndElement();         // R
            }
            xmlWriter.WriteEndElement();             // Data
        }
Exemplo n.º 24
0
        public void Create_instanceServ(ref string ticket, ref ONOid agentOid, XmlReader xmlReader, XmlWriter xmlWriter, double dtdVersion, string clientName)
        {
            // Process the service arguments
            ONServiceInfo lSInfo = new ONServiceInfo("Clas_1348178542592658Ser_1_Alias", PasajeroClassText.Create_instanceServiceAlias, "Clas_1348178542592658_Alias", PasajeroClassText.ClassAlias);

            lSInfo.AddOIDArgument("p_agrPasajeroAeronave", false, "PasajeroAeronave", "Clas_1348178542592658Ser_1Arg_4_Alias", PasajeroClassText.Create_instance_P_agrPasajeroAeronaveArgumentAlias);
            lSInfo.AddDataValuedArgument("p_atrid_Pasajero", false, DataTypeEnumerator.Autonumeric, 0, "Clas_1348178542592658Ser_1Arg_1_Alias", PasajeroClassText.Create_instance_P_atrid_PasajeroArgumentAlias);
            lSInfo.AddDataValuedArgument("p_atrNombre", false, DataTypeEnumerator.Text, 0, "Clas_1348178542592658Ser_1Arg_2_Alias", PasajeroClassText.Create_instance_P_atrNombreArgumentAlias);

            try
            {
                lSInfo.XML2ON(xmlReader, dtdVersion, true);
            }
            catch (Exception e)
            {
                throw new ONServiceArgumentsException(e, "Clas_1348178542592658_Alias", PasajeroClassText.ClassAlias, "Clas_1348178542592658Ser_1_Alias", PasajeroClassText.Create_instanceServiceAlias);
            }

            PasajeroAeronaveOid lP_agrPasajeroAeronaveArg = (PasajeroAeronaveOid)((ONArgumentInfo)lSInfo.mArgumentList["p_agrPasajeroAeronave"]).Value;
            ONInt  lP_atrid_PasajeroArg = (ONInt)((ONArgumentInfo)lSInfo.mArgumentList["p_atrid_Pasajero"]).Value;
            ONText lP_atrNombreArg      = (ONText)((ONArgumentInfo)lSInfo.mArgumentList["p_atrNombre"]).Value;

            // Create Context
            ONServiceContext lOnContext = new ONServiceContext();

            lOnContext.OidAgent = agentOid;

            // Execute Service
            PasajeroInstance lInstance = null;

            try
            {
                ONFilterList             lFilterList = new ONFilterList();
                PasajeroAeronaveInstance lp_agrPasajeroAeronaveInstance = new PasajeroAeronaveInstance(lOnContext);
                if (lP_agrPasajeroAeronaveArg != null)
                {
                    lFilterList = new ONFilterList();
                    lFilterList.Add("HorizontalVisibility", new PasajeroAeronaveHorizontalVisibility());
                    lp_agrPasajeroAeronaveInstance = lP_agrPasajeroAeronaveArg.GetInstance(lOnContext, lFilterList);
                    if (lp_agrPasajeroAeronaveInstance == null)
                    {
                        throw new ONInstanceNotExistException(null, "Clas_1348178542592177_Alias", PasajeroAeronaveClassText.ClassAlias);
                    }
                }

                using (PasajeroServer lServer = new PasajeroServer(lOnContext, null))
                {
                    lServer.Create_instanceServ(lP_agrPasajeroAeronaveArg, lP_atrid_PasajeroArg, lP_atrNombreArg);
                    lInstance = lServer.Instance;
                }
                ticket = lOnContext.GetTicket(dtdVersion, clientName);
            }
            catch (SecurityException)
            {
                throw new ONAccessAgentValidationException(null);
            }
            catch
            {
                throw;
            }

            // Write Oid
            if (dtdVersion >= 3.1)
            {
                if (lInstance != null)
                {
                    ON2XML(xmlWriter, lInstance.Oid, dtdVersion, ONXml.XMLTAG_OIDFIELD);
                }
            }

            // Write Outbound Arguments
            xmlWriter.WriteStartElement("Arguments");
            // Write Outbound Arguments
            xmlWriter.WriteEndElement();             // Arguments
        }
Exemplo n.º 25
0
        public override ONCollection QueryByRelated(ref string ticket, ref ONOid agentOid, XmlReader xmlReader, ONDisplaySet displaySet, out ONOid startRowOID, out int blockSize, double dtdVersion, string clientName)
        {
            ONLinkedToList lLinkedTo = null;
            ONFilterList   lFilters  = new ONFilterList();

            // Read Request
            blockSize = int.Parse(xmlReader.GetAttribute("BlockSize"));
            if (!xmlReader.IsEmptyElement)
            {
                xmlReader.ReadStartElement("Query.Related");
                if (xmlReader.IsStartElement("StartRow"))
                {
                    xmlReader.ReadStartElement("StartRow");
                    startRowOID = XML2ON(xmlReader, dtdVersion);
                    xmlReader.ReadEndElement();                     // StartRow
                }
                else
                {
                    startRowOID = null;
                }

                // Fill relations
                lLinkedTo = GetLinkedTo(xmlReader, dtdVersion);

                // Read Request
                xmlReader.ReadEndElement();                 // Query.Related
            }
            else
            {
                xmlReader.ReadStartElement("Query.Related");
                lLinkedTo   = new ONLinkedToList();
                startRowOID = null;
            }

            // Read Order Criteria
            string lOrderCriteria = "";

            if (xmlReader.IsStartElement("Sort"))
            {
                lOrderCriteria = xmlReader.GetAttribute("Criterium");
                xmlReader.Skip();                 // Sort
            }

            //Read Navigational Filter
            string lNavFilterId    = "";
            ONOid  lSelectedObject = null;

            if (xmlReader.IsStartElement("NavFilt"))
            {
                xmlReader.ReadStartElement("NavFilt");
                if (xmlReader.IsStartElement("NavFilt.SelectedObject"))
                {
                    lNavFilterId = xmlReader.GetAttribute("NavFilterID");
                    xmlReader.ReadStartElement("NavFilt.SelectedObject");
                    string lClassName = xmlReader.GetAttribute("Class");
                    if (lClassName == "")
                    {
                        lClassName = "GlobalTransaction";
                    }
                    object[] lArgs = new object[2];
                    lArgs[0]        = xmlReader;
                    lArgs[1]        = dtdVersion;
                    lSelectedObject = ONContext.InvoqueMethod(ONContext.GetType_XML(lClassName), "XML2ON", lArgs) as ONOid;

                    lArgs    = new Object[1];
                    lArgs[0] = lSelectedObject;

                    lFilters.Add(lNavFilterId, ONContext.GetComponent_NavigationalFilter(lNavFilterId, lArgs) as ONFilter);
                }
                else if (xmlReader.IsStartElement("NavFilt.Argument"))
                {
                    string lClassName = xmlReader.GetAttribute("Class");
                    if (lClassName == "")
                    {
                        lClassName = "GlobalTransaction";
                    }
                    string lServiceName  = xmlReader.GetAttribute("Service");
                    string lArgumentName = xmlReader.GetAttribute("Argument");
                    xmlReader.ReadStartElement("NavFilt.Argument");

                    string lFilterName = lClassName + "_" + lServiceName + "Service_" + lArgumentName + "_NavigationalFilter";
                    if (xmlReader.IsStartElement("Arguments"))
                    {
                        object[] lArgs = new object[3];
                        lArgs[0] = xmlReader;
                        lArgs[1] = dtdVersion;
                        lArgs[2] = lArgumentName;

                        lFilters.Add(lFilterName, ONContext.InvoqueMethod(ONContext.GetComponent_XML(lClassName), typeof(ONNavigationalFilterXMLAttribute), "<Filter>" + lServiceName + "</Filter>", lArgs) as ONFilter);
                    }
                    else
                    {
                        lFilters.Add(lFilterName, ONContext.GetComponent_Filter(lFilterName, null) as ONFilter);
                    }

                    xmlReader.ReadEndElement();                     //NavFilt.Argument
                }
                else if (xmlReader.IsStartElement("NavFilt.ServiceIU"))
                {
                    lNavFilterId = xmlReader.GetAttribute("NavFilterID");
                    xmlReader.ReadStartElement("NavFilt.ServiceIU");

                    if (xmlReader.IsStartElement("Arguments"))
                    {
                        object[] lArgs = new object[2];
                        lArgs[0] = xmlReader;
                        lArgs[1] = dtdVersion;

                        ONServiceInfo lSInfo = new ONServiceInfo("", "", "", "");
                        lSInfo.XML2ON(xmlReader, dtdVersion, false);

                        HybridDictionary lArguments = new HybridDictionary(true);
                        foreach (ONArgumentInfo lArgument in lSInfo.mArgumentList.Values)
                        {
                            lArguments.Add(lArgument.Name, lArgument.Value);
                        }
                        lFilters.Add(lNavFilterId, ONContext.GetComponent_NavigationalFilter(lNavFilterId, new object[1] {
                            lArguments
                        }) as ONFilter);
                    }
                    else
                    {
                        lFilters.Add(lNavFilterId, ONContext.GetComponent_NavigationalFilter(lNavFilterId, null) as ONFilter);
                    }

                    xmlReader.ReadEndElement();                     //NavFilt.ServiceIU
                }
                else if (xmlReader.IsStartElement("NavFilt.Variable"))
                {
                    string lClassName        = xmlReader.GetAttribute("Class");
                    string lSourceFilterName = xmlReader.GetAttribute("Filter");
                    string lVariableName     = xmlReader.GetAttribute("Variable");

                    xmlReader.ReadStartElement("NavFilt.Variable");
                    string lFilterName = lClassName + "_" + lSourceFilterName + "Filter_" + lVariableName + "_NavigationalFilter";
                    if (xmlReader.IsStartElement("Filter.Variables"))
                    {
                        object[] lArgs = new object[3];
                        lArgs[0] = xmlReader;
                        lArgs[1] = dtdVersion;
                        lArgs[2] = lVariableName;

                        lFilters.Add(lFilterName, ONContext.InvoqueMethod(ONContext.GetComponent_XML(lClassName), typeof(ONNavigationalFilterXMLAttribute), "<Filter>" + lSourceFilterName + "</Filter>", lArgs) as ONFilter);
                    }
                    else
                    {
                        lFilters.Add(lFilterName, ONContext.GetComponent_Filter(lFilterName, null) as ONFilter);
                    }

                    xmlReader.ReadEndElement();                     //NavFilt.Variable
                }
            }

            // Create Context
            ONContext lOnContext = new ONContext();

            lOnContext.OidAgent = agentOid;

            foreach (ONFilter lFilter in lFilters.Values)
            {
                lFilter.CheckFilterVariables(lOnContext);
            }

            // Execute
            lOnContext.CalculateQueryInstancesNumber = true;
            PasajeroQuery lQuery      = new PasajeroQuery(lOnContext);
            ONCollection  lCollection = lQuery.QueryByFilter(lLinkedTo, lFilters, displaySet, lOrderCriteria, startRowOID, blockSize);

            ticket = lOnContext.GetTicket(dtdVersion, clientName);

            return(lCollection);
        }
Exemplo n.º 26
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.º 27
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid, bool isLinkedTo)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid, isLinkedTo);
 }
Exemplo n.º 28
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid);
 }
Exemplo n.º 29
0
        ///<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;
        }
Exemplo n.º 30
0
        /// <summary>Solves the filters defined in this class</summary>
        /// <param name="linkedTo">This parameter has the related instance to retrieve the requested instances</param>
        /// <param name="filters">This parameter has all the filters defined with this class</param>
        /// <param name="orderCriteria">This parameter has the name of 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>
        public override ONCollection QueryByFilter(ONLinkedToList linkedTo, ONFilterList filters, ONDisplaySet displaySet, string orderCriteria, ONOid startRowOID, int blockSize)
        {
            // OrderCriteria
            ONOrderCriteria lComparer = GetOrderCriteria(orderCriteria);

            // Horizontal visibility
            if (filters == null)
            {
                filters = new ONFilterList();
            }
            filters.Add("HorizontalVisibility", new NaveNodrizaHorizontalVisibility());

            // Linked To List
            if (linkedTo == null)
            {
                linkedTo = new ONLinkedToList();
            }

            // Call Data
            try
            {
                NaveNodrizaData lData       = new NaveNodrizaData(OnContext);
                ONCollection    lCollection = lData.ExecuteQuery(linkedTo, filters, displaySet, lComparer, startRowOID, blockSize);

                // OrderCriteria
                if (lComparer != null)
                {
                    lCollection.Sort(lComparer);
                }

                return(lCollection);
            }
            catch (Exception e)
            {
                if (e is ONException)
                {
                    throw e;
                }
                else
                {
                    string ltraceItem = "Error in query, Method: ExecuteQuery, Component: NaveNodrizaQuery";
                    if (e is ONSystemException)
                    {
                        ONSystemException lException = e as ONSystemException;
                        lException.addTraceInformation(ltraceItem);
                        throw lException;
                    }
                    throw new ONSystemException(e, ltraceItem);
                }
            }
        }