/// <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); }
public static void ONChangeTypeToXML(XmlTextWriter xmlWriter, ONChangeDetectionInfo pDifference, double dtdVersion) { if (pDifference.Type != DataTypeEnumerator.OID) { xmlWriter.WriteAttributeString(ONXml.XMLATT_TYPE, GetNameTypeForXml(pDifference.Type)); //Write Old Value xmlWriter.WriteStartElement(XMLTAG_CHANGEDITEMOLDVALUE); GetType_XMLSimple(pDifference.Type, xmlWriter, pDifference.OldValue as ONSimpleType, dtdVersion); xmlWriter.WriteEndElement(); // ChangedItemOldValue //Write New Value xmlWriter.WriteStartElement(XMLTAG_CHANGEDITEMNEWVALUE); GetType_XMLSimple(pDifference.Type, xmlWriter, pDifference.NewValue as ONSimpleType, dtdVersion); xmlWriter.WriteEndElement(); // ChangedItemNewValue } else { xmlWriter.WriteAttributeString(ONXml.XMLATT_TYPE, pDifference.ClassName); //Write Old Value xmlWriter.WriteStartElement(XMLTAG_CHANGEDITEMOLDVALUE); Type lTypeXML = ONContext.GetType_XML(pDifference.ClassName); object[] parameters = new object[4]; parameters[0] = xmlWriter; parameters[1] = pDifference.OldValue; parameters[2] = dtdVersion; parameters[3] = ONXml.XMLTAG_OIDFIELD; ONContext.InvoqueMethod(lTypeXML, "ON2XML", parameters); xmlWriter.WriteEndElement(); // ChangedItemOldValue //Write New Value xmlWriter.WriteStartElement(XMLTAG_CHANGEDITEMNEWVALUE); parameters[1] = pDifference.NewValue; ONContext.InvoqueMethod(lTypeXML, "ON2XML", parameters); xmlWriter.WriteEndElement(); // ChangedItemNewValue } }
/// <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); }
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); }
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; } } }