コード例 #1
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;
            }
        }
コード例 #2
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
        }