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; } }
/// <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 }
private void ReadChangeDetectionItem(XmlReader xmlReader, double dtdVersion, string Name) { // Read the change detection items ONChangeDetectionInfo lCD; try { lCD = (ONChangeDetectionInfo)mChangesDetectionList[Name.ToLower()]; if (lCD == null) { xmlReader.Skip(); return; } } catch { return; } switch (lCD.Type) { case DataTypeEnumerator.Autonumeric: { lCD.OldValue = ONXmlAutonumeric.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Bool: { lCD.OldValue = ONXmlBool.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Blob: { lCD.OldValue = ONXmlBlob.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Date: { lCD.OldValue = ONXmlDate.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.DateTime: { lCD.OldValue = ONXmlDateTime.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Int: { lCD.OldValue = ONXmlInt.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Nat: { lCD.OldValue = ONXmlNat.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Password: { lCD.OldValue = ONXmlPassword.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Real: { lCD.OldValue = ONXmlReal.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.String: { lCD.OldValue = ONXmlString.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Text: { lCD.OldValue = ONXmlText.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Time: { lCD.OldValue = ONXmlTime.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.OID: { object[] lArgs = new object[2]; lArgs[0] = xmlReader; lArgs[1] = dtdVersion; lCD.OldValue = ONContext.InvoqueMethod(ONContext.GetType_XML(lCD.ClassName), "XML2ON", lArgs) as IONType; break; } } }
private void ReadArgument(XmlReader xmlReader, double dtdVersion, string Name) { // Read the arguments and process ONArgumentInfo lArg; try { lArg = (ONArgumentInfo)mArgumentList[Name.ToLower()]; } catch { return; } switch (lArg.Type) { case DataTypeEnumerator.Autonumeric: { lArg.Value = ONXmlAutonumeric.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Bool: { lArg.Value = ONXmlBool.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Blob: { lArg.Value = ONXmlBlob.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Date: { lArg.Value = ONXmlDate.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.DateTime: { lArg.Value = ONXmlDateTime.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Int: { lArg.Value = ONXmlInt.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Nat: { lArg.Value = ONXmlNat.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Password: { lArg.Value = ONXmlPassword.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Real: { lArg.Value = ONXmlReal.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.String: { lArg.Value = ONXmlString.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Text: { lArg.Value = ONXmlText.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.Time: { lArg.Value = ONXmlTime.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_LITERAL); break; } case DataTypeEnumerator.OID: { object[] lArgs = new object[2]; lArgs[0] = xmlReader; lArgs[1] = dtdVersion; lArg.Value = ONContext.InvoqueMethod(ONContext.GetType_XML(lArg.ClassName), "XML2ON", lArgs) as IONType; break; } } }