/// <summary> /// Load the data retrieved from the Data Base to components of the application /// </summary> /// <param name="onContext">This parameter has the current context</param> /// <param name="columns">This parameter has the data collected from the database</param> /// <param name="index">This parameter has the position of the first data to fix in the application</param> public static AeronaveInstance LoadFacet(ONContext onContext, ONDisplaySet displaySet, object[] columns, ref int index) { AeronaveInstance lInstance = new AeronaveInstance(onContext); lInstance.Oid = new AeronaveOid(); // Field 'id_Aeronave' lInstance.Oid.Id_AeronaveAttr = new ONInt(Convert.ToInt32(columns[index++])); lInstance.StateObj = new ONString(((string)columns[index++]).TrimEnd()); lInstance.Lmd = new ONDateTime((DateTime)columns[index++]); // Field 'MaximoPasajeros' lInstance.MaximoPasajerosAttr = new ONInt(Convert.ToInt32(columns[index++])); if ((displaySet != null) && (displaySet.Contains("Nombre"))) { lInstance.NombreAttr = new ONText((string)columns[index++]); } if ((displaySet != null) && (displaySet.Contains("Origen"))) { lInstance.OrigenAttr = new ONText((string)columns[index++]); } if ((displaySet != null) && (displaySet.Contains("Destino"))) { lInstance.DestinoAttr = new ONText((string)columns[index++]); } lInstance.Modified = false; return(lInstance); }
/// <summary> /// Compare with oid fields /// </summary> /// <param name="instance1">Instance 1</param> /// <param name="instance2">Instance 2</param> /// <returns>0 if equals, -1 if instance1 is minor, 1 if instance2 is mayor</returns> public override int CompareUnionOID(ONInstance instance1, ONInstance instance2) { // Null Management if ((instance1 == null) && (instance2 == null)) { return(0); } else if (instance1 == null) { return(-1); } else if (instance2 == null) { return(1); } AeronaveInstance lInstance1 = instance1 as AeronaveInstance; AeronaveInstance lInstance2 = instance2 as AeronaveInstance; int lCompare = 0; // id_Aeronave(Asc) lCompare = lInstance1.Id_AeronaveAttr.CompareTo(lInstance2.Id_AeronaveAttr); if (lCompare != 0) { return(lCompare); } return(0); }
/// <summary>This method builds the SQL statement to edit the instance in database</summary> /// <param name="instance">This parameter represents the instance to be modified in the database</param> public override void UpdateEdited(ONInstance instance) { AeronaveInstance lInstance = instance as AeronaveInstance; ONSqlUpdate lOnSql = new ONSqlUpdate(); lOnSql.AddUpdate(CtesBD.TBL_AERONAVE); // Field 'id_Aeronave' // Update not needed (OID) lOnSql.AddSet(CtesBD.FLD_AERONAVE_ESTADOOBJ, lInstance.StateObj); lOnSql.AddSet(CtesBD.FLD_AERONAVE_FUM, new ONDateTime(DateTime.Now)); // Field 'Nombre' if (lInstance.NombreAttrModified) { lOnSql.AddSet(CtesBD.FLD_AERONAVE_NOMBRE, lInstance.NombreAttr); } // Field 'MaximoPasajeros' if (lInstance.MaximoPasajerosAttrModified) { lOnSql.AddSet(CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS, lInstance.MaximoPasajerosAttr); } // Field 'Origen' if (lInstance.OrigenAttrModified) { lOnSql.AddSet(CtesBD.FLD_AERONAVE_ORIGEN, lInstance.OrigenAttr); } // Field 'Destino' if (lInstance.DestinoAttrModified) { lOnSql.AddSet(CtesBD.FLD_AERONAVE_DESTINO, lInstance.DestinoAttr); } lOnSql.AddWhere(CtesBD.FLD_AERONAVE_ID_AERONAVE, lInstance.Oid.Id_AeronaveAttr); Execute(lOnSql); }
public override bool FilterInMemory(ONInstance instance) { AeronaveInstance lInstance = instance as AeronaveInstance; // SQL Optimized return(true); }
///<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; }
///<summary> /// This method builds the SQL statment to delete the instance in database ///</summary> ///<param name = instance> ///This parameter represents the instance to be deleted in the database ///</param> public override void UpdateDeleted(ONInstance instance) { AeronaveInstance lInstance = instance as AeronaveInstance; ONSqlDelete lOnSql = new ONSqlDelete(); lOnSql.AddFrom(CtesBD.TBL_AERONAVE); lOnSql.AddWhere(CtesBD.FLD_AERONAVE_ID_AERONAVE, lInstance.Oid.Id_AeronaveAttr); Execute(lOnSql); }
public AeronaveInstance Create_instanceServ(PasajeroAeronaveOid p_agrPasajeroAeronaveArg, ONInt p_atrid_AeronaveArg, ONText p_atrNombreArg, ONInt p_atrMaximoPasajerosArg, ONText p_atrOrigenArg, ONText p_atrDestinoArg) { // Create new context using (ONServiceContext lOnContext = new ONServiceContext(OnContext)) { // Call Executive AeronaveExecutive lExecutive = new AeronaveExecutive(); lExecutive.OnContext = lOnContext; lExecutive.Instance = Instance; Instance = lExecutive.Create_instanceServ(p_agrPasajeroAeronaveArg, p_atrid_AeronaveArg, p_atrNombreArg, p_atrMaximoPasajerosArg, p_atrOrigenArg, p_atrDestinoArg); } return(Instance); }
protected override ONInstance InhGetInstance(ONContext onContext, ONFilterList onFilterList) { // Add oid filter to the list ONFilterList lOnFilterList = new ONFilterList(onFilterList); lOnFilterList.Add("QueryByOid", new QueryByOidFilter(this)); // Search Instance ONInstance lInstance = new AeronaveInstance(onContext); lInstance.Oid = this; lInstance = lInstance.Find(lOnFilterList); if (lInstance == null) { lInstance = new AeronaveInstance(onContext); } return(lInstance); }
internal AeronaveInstance Create_instanceServ(PasajeroAeronaveOid p_agrPasajeroAeronaveArg, ONInt p_atrid_AeronaveArg, ONText p_atrNombreArg, ONInt p_atrMaximoPasajerosArg, ONText p_atrOrigenArg, ONText p_atrDestinoArg) { if (Instance != null) { ONFilterList onfilt = new ONFilterList(); onfilt.Add("QueryByOid", new QueryByOidFilter(Instance.Oid)); Instance.Find(onfilt); } // Execute service AeronaveAction lAction = new AeronaveAction(OnContext); lAction.Instance = new AeronaveInstance(OnContext); Instance = lAction.Create_instanceServ(p_agrPasajeroAeronaveArg, p_atrid_AeronaveArg, p_atrNombreArg, p_atrMaximoPasajerosArg, p_atrOrigenArg, p_atrDestinoArg); OnContext.OperationStack.Pop(); OnContext.OperationStack.Push(Instance); return(Instance); }
/// <summary>This method builds the SQL statement to insert the instance in database</summary> /// <param name="instance">This parameter represents the instance to be inserted in the database</param> public override void UpdateAdded(ONInstance instance) { AeronaveInstance lInstance = instance as AeronaveInstance; ONSqlInsert lOnSql = new ONSqlInsert(); lOnSql.AddInto(CtesBD.TBL_AERONAVE); // Field 'id_Aeronave' lOnSql.AddValue(CtesBD.FLD_AERONAVE_ID_AERONAVE, lInstance.Oid.Id_AeronaveAttr); lOnSql.AddValue(CtesBD.FLD_AERONAVE_ESTADOOBJ, lInstance.StateObj); lOnSql.AddValue(CtesBD.FLD_AERONAVE_FUM, new ONDateTime(DateTime.Now)); // Field 'Nombre' lOnSql.AddValue(CtesBD.FLD_AERONAVE_NOMBRE, lInstance.NombreAttr); // Field 'MaximoPasajeros' lOnSql.AddValue(CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS, lInstance.MaximoPasajerosAttr); // Field 'Origen' lOnSql.AddValue(CtesBD.FLD_AERONAVE_ORIGEN, lInstance.OrigenAttr); // Field 'Destino' lOnSql.AddValue(CtesBD.FLD_AERONAVE_DESTINO, lInstance.DestinoAttr); Execute(lOnSql); }
/// <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); }
public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext) { string lAlias = onSql.CreateAlias(CtesBD.TBL_AERONAVE, onPath, "Aeronave"); ONDisplaySet lSourceDS = null; if (displaySet != null) { lSourceDS = new ONDisplaySet(displaySet); displaySet.Clear(); } if (displaySet == null) { onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_FUM + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS); } else { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ID_AERONAVE)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ESTADOOBJ)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ESTADOOBJ); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_FUM)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_FUM); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS); if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_NOMBRE)) { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_NOMBRE)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_NOMBRE); } if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_ORIGEN)) { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ORIGEN)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ORIGEN); } if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_DESTINO)) { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_DESTINO)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_DESTINO); } } // Related attributes if (displaySet != null) { foreach (ONDisplaySetItem lDisplaySetItem in lSourceDS) { if ((lDisplaySetItem.Path.IndexOf(".") > 0) && (lDisplaySetItem.InData) && (!lDisplaySetItem.HasHV)) { displaySet.Add(lDisplaySetItem); string lPath = lDisplaySetItem.Path.Substring(0, lDisplaySetItem.Path.LastIndexOf(".")); string lFacetName = AeronaveInstance.GetTargetClass(onContext, typeof(AeronaveInstance), new ONPath(lDisplaySetItem.Path)); onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(AeronaveInstance), new ONPath(lDisplaySetItem.Path))); } } } return(lAlias); }
/// <summary> /// Constructor /// </summary> /// <param name="onContext">This parameter has the current context</param> /// <param name="instance">This parameter has the instance that exectues the service</param> public AeronaveServer(ONServiceContext onContext, AeronaveInstance instance) : base(onContext, instance, "Aeronave") { }
/// <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", "Aeronave"); xmlWriter.WriteStartElement("Head.OID.Field"); xmlWriter.WriteAttributeString("Name", "id_Aeronave"); 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(AeronaveInstance), 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)) { AeronaveInstance lInstance = val[i++] as AeronaveInstance; xmlWriter.WriteStartElement("R"); ONXmlAutonumeric.ON2XML(xmlWriter, lInstance.Oid.Id_AeronaveAttr, 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 }
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_1348178411520734Ser_1_Alias", AeronaveClassText.Create_instanceServiceAlias, "Clas_1348178411520734_Alias", AeronaveClassText.ClassAlias); lSInfo.AddOIDArgument("p_agrPasajeroAeronave", false, "PasajeroAeronave", "Clas_1348178411520734Ser_1Arg_6_Alias", AeronaveClassText.Create_instance_P_agrPasajeroAeronaveArgumentAlias); lSInfo.AddDataValuedArgument("p_atrid_Aeronave", false, DataTypeEnumerator.Autonumeric, 0, "Clas_1348178411520734Ser_1Arg_1_Alias", AeronaveClassText.Create_instance_P_atrid_AeronaveArgumentAlias); lSInfo.AddDataValuedArgument("p_atrNombre", false, DataTypeEnumerator.Text, 0, "Clas_1348178411520734Ser_1Arg_2_Alias", AeronaveClassText.Create_instance_P_atrNombreArgumentAlias); lSInfo.AddDataValuedArgument("p_atrMaximoPasajeros", false, DataTypeEnumerator.Int, 0, "Clas_1348178411520734Ser_1Arg_3_Alias", AeronaveClassText.Create_instance_P_atrMaximoPasajerosArgumentAlias); lSInfo.AddDataValuedArgument("p_atrOrigen", false, DataTypeEnumerator.Text, 0, "Clas_1348178411520734Ser_1Arg_4_Alias", AeronaveClassText.Create_instance_P_atrOrigenArgumentAlias); lSInfo.AddDataValuedArgument("p_atrDestino", false, DataTypeEnumerator.Text, 0, "Clas_1348178411520734Ser_1Arg_5_Alias", AeronaveClassText.Create_instance_P_atrDestinoArgumentAlias); try { lSInfo.XML2ON(xmlReader, dtdVersion, true); } catch (Exception e) { throw new ONServiceArgumentsException(e, "Clas_1348178411520734_Alias", AeronaveClassText.ClassAlias, "Clas_1348178411520734Ser_1_Alias", AeronaveClassText.Create_instanceServiceAlias); } PasajeroAeronaveOid lP_agrPasajeroAeronaveArg = (PasajeroAeronaveOid)((ONArgumentInfo)lSInfo.mArgumentList["p_agrPasajeroAeronave"]).Value; ONInt lP_atrid_AeronaveArg = (ONInt)((ONArgumentInfo)lSInfo.mArgumentList["p_atrid_Aeronave"]).Value; ONText lP_atrNombreArg = (ONText)((ONArgumentInfo)lSInfo.mArgumentList["p_atrNombre"]).Value; ONInt lP_atrMaximoPasajerosArg = (ONInt)((ONArgumentInfo)lSInfo.mArgumentList["p_atrMaximoPasajeros"]).Value; ONText lP_atrOrigenArg = (ONText)((ONArgumentInfo)lSInfo.mArgumentList["p_atrOrigen"]).Value; ONText lP_atrDestinoArg = (ONText)((ONArgumentInfo)lSInfo.mArgumentList["p_atrDestino"]).Value; // Create Context ONServiceContext lOnContext = new ONServiceContext(); lOnContext.OidAgent = agentOid; // Execute Service AeronaveInstance 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 (AeronaveServer lServer = new AeronaveServer(lOnContext, null)) { lServer.Create_instanceServ(lP_agrPasajeroAeronaveArg, lP_atrid_AeronaveArg, lP_atrNombreArg, lP_atrMaximoPasajerosArg, lP_atrOrigenArg, lP_atrDestinoArg); 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 }
public void Edit_instanceServ(ref string ticket, ref ONOid agentOid, XmlReader xmlReader, XmlWriter xmlWriter, double dtdVersion, string clientName) { // Process the service arguments ONServiceInfo lSInfo = new ONServiceInfo("Clas_1348178411520734Ser_3_Alias", AeronaveClassText.Edit_instanceServiceAlias, "Clas_1348178411520734_Alias", AeronaveClassText.ClassAlias); lSInfo.AddOIDArgument("p_thisAeronave", false, "Aeronave", "Clas_1348178411520734Ser_3Arg_1_Alias", AeronaveClassText.Edit_instance_P_thisAeronaveArgumentAlias); try { lSInfo.XML2ON(xmlReader, dtdVersion, true); } catch (Exception e) { throw new ONServiceArgumentsException(e, "Clas_1348178411520734_Alias", AeronaveClassText.ClassAlias, "Clas_1348178411520734Ser_3_Alias", AeronaveClassText.Edit_instanceServiceAlias); } AeronaveOid lP_thisAeronaveArg = (AeronaveOid)((ONArgumentInfo)lSInfo.mArgumentList["p_thisAeronave"]).Value; // Create Context ONServiceContext lOnContext = new ONServiceContext(); lOnContext.OidAgent = agentOid; // Execute Service AeronaveInstance lInstance = null; try { ONFilterList lFilterList = new ONFilterList(); AeronaveInstance lThisInstance = new AeronaveInstance(lOnContext); if (lP_thisAeronaveArg != null) { lFilterList = new ONFilterList(); lFilterList.Add("HorizontalVisibility", new AeronaveHorizontalVisibility()); lThisInstance = lP_thisAeronaveArg.GetInstance(lOnContext, lFilterList); if (lThisInstance == null) { throw new ONInstanceNotExistException(null, "Clas_1348178411520734_Alias", AeronaveClassText.ClassAlias); } } using (AeronaveServer lServer = new AeronaveServer(lOnContext, lThisInstance)) { lServer.Edit_instanceServ(lP_thisAeronaveArg); 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 }