/// <summary> /// Copy constructor /// </summary> /// <param name="onContext">Context to copy from</param> public ONContext(ONContext onContext) { mOidAgent = onContext.OidAgent; mSqlConnection = null; CalculateQueryInstancesNumber = false; LeafActiveAgentFacets = onContext.LeafActiveAgentFacets; }
/// <summary> /// Constructor /// </summary> /// <param name="onContext">Context with all the information about the execution of the request</param> /// <param name="className">Name of the class that represents the instance</param> /// <param name="idClass">Identificator of the class</param> public ONInstance(ONContext onContext, string className, string idClass) { ClassName = className; IdClass = idClass; Oid = null; Lmd = ONDateTime.Null; Modified = false; OnContext = onContext; }
/// <summary> /// Constructor /// </summary> /// <param name="onContext">Context with all the information about the execution of the request</param> /// <param name="className">Name of the class that represents the instance</param> public ONQuery(ONContext onContext, string className, bool isLegacyView) { if (onContext != null) OnContext = onContext; else OnContext = new ONContext(); ClassName = className; IsLegacyView = isLegacyView; }
/// <summary> /// Create an instance of the Server component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> /// <param name="instance">Object of type instance needed to create an object of this type</param> public static ONServer GetComponent_Server(string className, ONContext onContext, ONInstance instance) { object[] lParams = {onContext, instance}; //if (className == "") // return GetComponent("SIGEM.Business.Server.GlobalTransactionServer", lParams) as ONServer; if (className == "" || className == "GlobalTransaction") return new GlobalTransactionServer(onContext as ONServiceContext) as ONServer; else return GetComponent("SIGEM.Business.Server." + className + "Server", lParams) as ONServer; }
/// <summary> /// Create an instance of the Collection component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> public static ONCollection GetComponent_Collection(string className, ONContext onContext) { object[] lParams = { onContext }; return(GetComponent("SIGEM.Business.Collection." + className + "Collection", lParams) as ONCollection); }
/// <summary> /// Create an instance of the Instance component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> public static ONInstance GetComponent_Instance(string className, ONContext onContext) { object[] lParams = {onContext}; if (className == "") return GetComponent("SIGEM.Business.Instance.GlobalTransactionInstance", lParams) as ONInstance; else return GetComponent("SIGEM.Business.Instance." + className + "Instance", lParams) as ONInstance; }
/// <summary> /// Create an instance of the Query component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> public static ONQuery GetComponent_Query(string className, ONContext onContext) { object[] lParams = {onContext}; return GetComponent("SIGEM.Business.Query." + className + "Query", lParams) as ONQuery; }
/// <summary> /// Create an instance of the Collection component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> public static ONCollection GetComponent_Collection(string className, ONContext onContext) { object[] lParams = {onContext}; return GetComponent("SIGEM.Business.Collection." + className + "Collection", lParams) as ONCollection; }
/// <summary> /// Create an instance of the Data component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> public static ONData GetComponent_Data(string className, ONContext onContext) { object[] lParams = {onContext}; if (className == "") return GetComponent("SIGEM.Business.Data.GlobalTransactionData", lParams) as ONData; else return GetComponent("SIGEM.Business.Data." + className + "Data", lParams) as ONData; }
/// <summary> /// Destroy all the resources that are associated with the object /// </summary> public void Dispose() { if (OnContext != null) { OnContext.Dispose(); OnContext = null; } }
public static ONOid ValidateTicket(double dtdVersion, string ticket, string clientName) { try { string lServerName = ""; string lClientName = ""; ONOid lAgentOid; ONDateTime lTimeStamp; ONNat lValidity; #region Open xml string lTicket = UncipherTicket(ticket); XmlTextReader lXMLReader = new XmlTextReader(new StringReader(lTicket)); lXMLReader.WhitespaceHandling = WhitespaceHandling.None; lXMLReader.MoveToContent(); #endregion #region Load information lXMLReader.ReadStartElement("ONTicket"); // Server name lServerName = lXMLReader.ReadElementString("Server"); // Client name lClientName = lXMLReader.ReadElementString("Client"); // Agent oid object[] lParam = new object[2]; lParam[0] = lXMLReader; lParam[1] = dtdVersion; lXMLReader.ReadStartElement("Agent"); string lAgentClass = lXMLReader.GetAttribute("Class"); lAgentOid = ONContext.InvoqueMethod(ONContext.GetType_XML(lAgentClass), "XML2ON", lParam) as ONOid; lXMLReader.ReadEndElement(); // Agent // TimeStamp lTimeStamp = ONXmlDateTime.XML2ON(lXMLReader, dtdVersion, "Timestamp"); // Validity lValidity = ONXmlNat.XML2ON(lXMLReader, dtdVersion, "Validity"); lXMLReader.ReadEndElement(); // ONTicket #endregion #region Validate information // Server name if (lServerName != mServerName) { throw new ONAgentValidationException(null); } // Client name if (lClientName != clientName) { throw new ONAgentValidationException(null); } // Agent oid if (ONSecureControl.SecureServer) { if (lAgentOid == null) { throw new ONAgentValidationException(null); } } // TimeStamp if (ONStdFunctions.datetimeAfter(lTimeStamp, ONStdFunctions.systemDateTime())) { throw new ONAgentValidationException(null); } if (new ONBool(mValidity > 0) && (ONStdFunctions.datetimeBefore(ONStdFunctions.dateTimeAdd(new ONString("s"), lValidity, lTimeStamp), ONStdFunctions.systemDateTime()))) { throw new ONAgentValidationException(null); } // Validity if (new ONBool(mValidity > 0) && (lValidity != new ONNat(mValidity))) { throw new ONAgentValidationException(null); } #endregion #region Close xml lXMLReader.Close(); #endregion return(lAgentOid); } catch (ONAgentValidationException) { throw; } catch { throw new ONAgentValidationException(null); } }
public virtual ONCollection FilterInLegacy(ONContext onContext, ONLinkedToList lLinkedToList, ONOrderCriteria comparer, ONOid startRowOid, int blockSize) { return null; }
/// <summary> /// Default Constructor /// </summary> public ONData(ONContext onContext, string className) { ClassName = className; mOnContext = onContext; }
/// <summary> /// Point of access to the application. /// </summary> /// <param name="xmlRequest">The message with the request in XML format</param> public string XMLRequest(string xmlRequest) { // Start Time DateTime lStartTime = DateTime.Now; // Response Type string lResponseType = "Service.Response"; // Request Attributes string lSecuence = ""; string lDTDVersionResponse = ""; double lDTDVersion = 0; try { // Create XMLReader XmlTextReader lXMLReader = new XmlTextReader(new StringReader(xmlRequest)); lXMLReader.WhitespaceHandling = WhitespaceHandling.None; lXMLReader.MoveToContent(); // Read Attributes string lApplication = lXMLReader.GetAttribute("Application"); string lIdCnx = lXMLReader.GetAttribute("IdCnx"); lSecuence = lXMLReader.GetAttribute("Sequence"); lDTDVersion = ExtractDTDVersion(lXMLReader.GetAttribute("VersionDTD")); if (lDTDVersion >= 3.0) lDTDVersionResponse = "CARE.Response v. " + lDTDVersion.ToString("#.00", ONXml.ComXMLFormat); else lDTDVersionResponse = "CARE.Response v." + lDTDVersion.ToString("#.0", ONXml.ComXMLFormat); lXMLReader.ReadStartElement("Request"); // Check Secure server if ((ONSecureControl.SecureServer) && (lDTDVersion < 3.1)) throw new ONAgentValidationException(null); // Create XMLWriter MemoryStream lXMLMemoryStream = new MemoryStream(); XmlTextWriter lXMLWriter = new XmlTextWriter(lXMLMemoryStream, new System.Text.UTF8Encoding()); lXMLWriter.WriteStartDocument(); // Create XMLWriterRequest XmlTextWriter lXMLWriterRequest = null; // Load agent ONOid lAgentOID = GetAgent(lXMLReader, lDTDVersion); string lTicket = ""; if (lDTDVersion >= 3.1) lTicket = GetTicket(lXMLReader, lDTDVersion); lStartTime = DateTime.Now; if (lXMLReader.IsStartElement("Service.Request")) { string lService = lXMLReader.GetAttribute("Service"); if ((lDTDVersion >= 3.1) && (string.Compare(lService, "MVAgentValidation", true) != 0)) { using (ONContext lOnContext = new ONContext()) { if (((object) lAgentOID == null) || !lAgentOID.IsAnonymousAgent) { ONOid lAgentOid = lOnContext.SetTicket(lDTDVersion, lApplication, lTicket); if (ONSecureControl.SecureServer) if (lAgentOID != lAgentOid) throw new ONAgentValidationException(null); } } } // Response Type lResponseType = "Service.Response"; // Read Attributes string lClass = lXMLReader.GetAttribute("Class"); // Global services if ((lClass == "") || (lClass == "InteraccionGlobal") || (lClass == "GlobalTransactions")) lClass = "GlobalTransaction"; ONXml lComponent = ONContext.GetComponent_XML(lClass); lComponent.XMLRequestService(ref lTicket, lAgentOID, lXMLReader, out lXMLWriterRequest, lDTDVersion, lApplication); } else if (lXMLReader.IsStartElement("Query.Request")) { if (lDTDVersion >= 3.1) { using (ONContext lOnContext = new ONContext()) { if (((object) lAgentOID == null) || !lAgentOID.IsAnonymousAgent) { ONOid lAgentOid = lOnContext.SetTicket(lDTDVersion, lApplication, lTicket); if (ONSecureControl.SecureServer) if (lAgentOID != lAgentOid) throw new ONAgentValidationException(null); } } } // Response Type lResponseType = "Query.Response"; // Read Attributes string lClass = lXMLReader.GetAttribute("Class"); ONXml lComponent = ONContext.GetComponent_XML(lClass); lComponent.XMLRequestQuery(ref lTicket, lAgentOID, lXMLReader, out lXMLWriterRequest, lDTDVersion, lApplication); } else throw new ONXMLException(null, "Request type"); // Get Time DateTime lEndTime = DateTime.Now; double lElapsedTime = (lEndTime.Ticks - lStartTime.Ticks) / 10000; // Write Response lXMLWriter.WriteStartElement("Response"); lXMLWriter.WriteAttributeString("Sequence", lSecuence); lXMLWriter.WriteAttributeString("VersionDTD", lDTDVersionResponse); lXMLWriter.WriteStartElement("Statistics"); lXMLWriter.WriteAttributeString("StartTime", lStartTime.ToString().Trim()); lXMLWriter.WriteAttributeString("EndTime", lEndTime.ToString().Trim()); lXMLWriter.WriteAttributeString("ElapsedTime", lElapsedTime.ToString().Trim()); lXMLWriter.WriteEndElement(); // Statistics if (lDTDVersion >= 3.1) lXMLWriter.WriteElementString("Ticket", lTicket); // Write Query / Service XML MemoryStream lXMLMemoryStreamRequest = lXMLWriterRequest.BaseStream as MemoryStream; lXMLWriter.Flush(); lXMLWriterRequest.Flush(); lXMLMemoryStreamRequest.Flush(); lXMLMemoryStreamRequest.Position = 0; lXMLMemoryStreamRequest.WriteTo(lXMLMemoryStream); lXMLWriter.WriteEndElement(); // Response // Get Response lXMLWriter.Flush(); lXMLMemoryStream.Flush(); lXMLMemoryStream.Position = 0; StreamReader lXMLStreamReader = new StreamReader(lXMLMemoryStream); string lResponse = lXMLStreamReader.ReadToEnd(); // Close Writer lXMLWriterRequest.Close(); lXMLWriter.Close(); // Close Reader lXMLReader.Close(); return lResponse; } catch (Exception e) { // Create XMLWriter MemoryStream lXMLMemoryStream = new MemoryStream(); XmlTextWriter lXMLWriter = new XmlTextWriter(lXMLMemoryStream, new System.Text.UTF8Encoding()); lXMLWriter.WriteStartDocument(); // Write Response lXMLWriter.WriteStartElement("Response"); lXMLWriter.WriteAttributeString("Sequence", lSecuence); lXMLWriter.WriteAttributeString("VersionDTD", lDTDVersionResponse); // Get Time DateTime lEndTime = DateTime.Now; double lElapsedTime = (lEndTime.Ticks - lStartTime.Ticks) / 10000; // Write Statistics lXMLWriter.WriteStartElement("Statistics"); lXMLWriter.WriteAttributeString("StartTime", lStartTime.ToString().Trim()); lXMLWriter.WriteAttributeString("EndTime", lEndTime.ToString().Trim()); lXMLWriter.WriteAttributeString("ElapsedTime", lElapsedTime.ToString().Trim()); lXMLWriter.WriteEndElement(); // Statistics // Write ServiceResponse / QueryResponse lXMLWriter.WriteStartElement(lResponseType); if (lDTDVersion > 2) { if (e is ONException) ONXml.CreateXMLError(lXMLWriter, e as ONException, lDTDVersion); else { lXMLWriter.WriteStartElement("Error"); lXMLWriter.WriteAttributeString("Type", "Model"); lXMLWriter.WriteAttributeString("Number", "999"); lXMLWriter.WriteElementString("Error.Message",""); lXMLWriter.WriteElementString("Error.Params", ""); lXMLWriter.WriteElementString("Error.Trace",""); lXMLWriter.WriteEndElement(); // Error } } else { lXMLWriter.WriteStartElement("Error"); lXMLWriter.WriteAttributeString("Type", "External"); lXMLWriter.WriteAttributeString("Number", "999"); lXMLWriter.WriteString(e.Message); lXMLWriter.WriteEndElement(); // Error } lXMLWriter.WriteEndElement(); // Service.Response / Query.Response // Write Response lXMLWriter.WriteEndElement(); // Response // Get Response lXMLWriter.Flush(); lXMLMemoryStream.Flush(); lXMLMemoryStream.Position = 0; StreamReader lXMLStreamReader = new StreamReader(lXMLMemoryStream); string lResponse = lXMLStreamReader.ReadToEnd(); // Close Writer lXMLWriter.Close(); return lResponse; } }
public static string GetTargetClass(ONContext onContext, Type typeInstance, ONPath path) { foreach (string lRole in path.Roles) { // Attributes ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRole + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return (lAttributeAttribute.FacetOfField); // Roles ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRole + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) typeInstance = ONContext.GetType_Instance(lRoleAttribute.Domain); else break; } if (typeInstance != null) { object[] lParameters = new object[1]; lParameters[0] = onContext; ONInstance lInstance = Activator.CreateInstance(typeInstance, lParameters) as ONInstance; return lInstance.ClassName; } else return ""; }
/// <summary> /// Method of Copy /// </summary> /// <param name="instance">Instance to be copied</param> public virtual void Copy(ONInstance instance) { if (instance != null) { OnContext = instance.OnContext; ClassName = instance.ClassName; if ((object)instance.Lmd.Value == null) Lmd = null; else if (instance.Lmd.Value == null) Lmd = ONDateTime.Null; else Lmd = new ONDateTime(instance.Lmd.TypedValue); Modified = instance.Modified; } }
/// <summary> /// Checks if the attributes of a determinate class are visible according to the agent connected /// </summary> /// <param name="typeInstance">Type fo the class to check the visibility</param> /// <param name="attributeVisibility">Attribute to be checked, it is not owned to the class that is being checked</param> /// <param name="onContext">Request context </param> public static bool IsVisibleInv(Type typeInstance, ONPath attributeVisibility, ONContext onContext) { if (attributeVisibility.Count == 0) return true; ONPath lAttributeVisibility = new ONPath(attributeVisibility); string lRol = lAttributeVisibility.RemoveHead(); // Attributes if (lAttributeVisibility.Count == 0) { ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute; if (lAttributeAttribute != null) return (lAttributeAttribute.IsVisible(onContext)); } // Roles ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute; if (lRoleAttribute != null) { Type lTypeInstanceInv = ONContext.GetType_Instance(lRoleAttribute.Domain); return (IsVisible(lTypeInstanceInv, lRoleAttribute.RoleInv, onContext) && IsVisibleInv(lTypeInstanceInv, lAttributeVisibility, onContext)); } return false; }
/// <summary> /// Checks if the attributes of a determinate class are visible according to the agent connected /// </summary> /// <param name="typeInstance">Type fo the class to check the visibility</param> /// <param name="attributeVisibility">Attribute to be checked</param> /// <param name="onContext">Request context </param> public static bool IsVisibleInv(Type typeInstance, string attributeVisibility, ONContext onContext) { return IsVisibleInv(typeInstance, new ONPath(attributeVisibility), onContext); }
public virtual bool IsVisible(ONContext context) { return true; }
/// <summary> /// Create an instance of the Query component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> public static ONQuery GetComponent_Query(string className, ONContext onContext) { object[] lParams = { onContext }; return(GetComponent("SIGEM.Business.Query." + className + "Query", lParams) as ONQuery); }
/// <summary> /// Create an instance of the Action component /// </summary> /// <param name="className">Name of the class necessary to create the component</param> /// <param name="onContext">Object of type onContext needed to create an object of this type</param> public static ONAction GetComponent_Action(string className, ONContext onContext) { object[] lParams = {onContext}; if (className == "") return GetComponent("SIGEM.Business.Action.GlobalTransactionAction", lParams) as ONAction; else return GetComponent("SIGEM.Business.Action." + className + "Action", lParams) as ONAction; }
public static string GetNextTicket(double dtdVersion, string clientName, ONOid agentOid) { #region Open xml MemoryStream lXMLMemoryStream = new MemoryStream(); XmlTextWriter lXMLWriter = new XmlTextWriter(lXMLMemoryStream, new System.Text.UTF8Encoding()); lXMLWriter.WriteStartDocument(); #endregion #region Save information lXMLWriter.WriteStartElement("ONTicket"); // Server name lXMLWriter.WriteElementString("Server", mServerName); // Client name lXMLWriter.WriteElementString("Client", clientName); // Agent oid if (agentOid == null) { lXMLWriter.WriteStartElement("Agent"); lXMLWriter.WriteStartElement(ONXml.XMLTAG_OID); lXMLWriter.WriteAttributeString(ONXml.XMLATT_CLASS, "Agente"); lXMLWriter.WriteElementString(ONXml.XMLTAG_OIDFIELD, "DEBUG"); lXMLWriter.WriteEndElement(); // Oid lXMLWriter.WriteEndElement(); // Agent } else { object[] lParam = new object[4]; lParam[0] = lXMLWriter; lParam[1] = agentOid; lParam[2] = dtdVersion; lParam[3] = "OID.Field"; lXMLWriter.WriteStartElement("Agent"); ONContext.InvoqueMethod(ONContext.GetType_XML(agentOid.ClassName), "ON2XML", lParam); lXMLWriter.WriteEndElement(); // Agent } // TimeStamp ONXmlDateTime.ON2XML(lXMLWriter, ONStdFunctions.systemDateTime(), dtdVersion, "Timestamp"); // Validity ONXmlNat.ON2XML(lXMLWriter, new ONNat(mValidity), dtdVersion, "Validity"); lXMLWriter.WriteEndElement(); // ONTicket #endregion #region Get xml lXMLWriter.Flush(); lXMLMemoryStream.Flush(); lXMLMemoryStream.Position = 0; StreamReader lXMLStreamReader = new StreamReader(lXMLMemoryStream); string lText = lXMLStreamReader.ReadToEnd(); #endregion #region Close xml lXMLWriter.Close(); #endregion return(CipherTicket(lText)); }