/// <summary> /// Extracts the OID from the XML message and converts it in structures of the application /// </summary> /// <param name="xmlReader">XML with the request message</param> /// <param name="dtdVersion">Version of DTD that follows the XML message</param> public static RevisionPasajeroOid XML2ON(XmlReader xmlReader, double dtdVersion) { try { if (xmlReader.IsStartElement(ONXml.XMLTAG_NULL)) { xmlReader.Skip(); return(RevisionPasajeroXml.Null); } if (!xmlReader.IsStartElement(ONXml.XMLTAG_OID)) { throw new ONXMLStructureException(null, ONXml.XMLTAG_OID); } } catch (Exception e) { throw new ONXMLStructureException(e, ONXml.XMLTAG_OID); } string lClass = xmlReader.GetAttribute("Class"); if (string.Compare(lClass, "RevisionPasajero", true) != 0) { throw new ONXMLOIDWrongClassException(null, "Clas_1348178673664478_Alias", "RevisionPasajero", lClass); } RevisionPasajeroOid lOid = new RevisionPasajeroOid(); xmlReader.ReadStartElement(ONXml.XMLTAG_OID); try { lOid.Id_RevisionPasajeroAttr = ONXmlAutonumeric.XML2ON(xmlReader, dtdVersion, ONXml.XMLTAG_OIDFIELD); } catch (Exception e) { throw new ONXMLOIDFieldException(e, "Clas_1348178673664478_Alias", "RevisionPasajero", "Clas_1348178673664478Atr_1_Alias", "id_RevisionPasajero"); } try { xmlReader.ReadEndElement(); } catch { throw new ONXMLStructureException(null, ONXml.XMLTAG_OID); } return(lOid); }
/// <summary> /// Converts an OID into XML in order to put it in XML message response /// </summary> /// <param name="xmlWriter">XML with the response message</param> /// <param name="oid">OID that will be insert into XML message</param> /// <param name="dtdVersion">Version of DTD that follows the XML message</param> /// <param name="xmlElement">Element in the XML message in order to convert in the right form of the XML</param> public static void ON2XML(XmlWriter xmlWriter, PasajeroOid oid, double dtdVersion, string xmlElement) { if (oid == null) { xmlWriter.WriteElementString(ONXml.XMLTAG_NULL, null); } else { xmlWriter.WriteStartElement(ONXml.XMLTAG_OID); xmlWriter.WriteAttributeString(ONXml.XMLATT_CLASS, "Pasajero"); ONXmlAutonumeric.ON2XML(xmlWriter, oid.Id_PasajeroAttr, dtdVersion, xmlElement); xmlWriter.WriteEndElement(); // OID } }
/// <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; } } }