예제 #1
0
        /// <summary>
        /// Generates a native Subscribe Message
        /// </summary>
        /// <param name="sessionKey">Session Key</param>
        /// <param name="ontology">Ontoogy</param>
        /// <param name="msRefresh">Refresh Time in milliseconds</param>
        /// <param name="query">Query</param>
        /// <param name="queryType">Query Type</param>
        /// <returns>Subscribe Message</returns>
        public SSAPMessage <SSAPBodySubscribeMessage> GenerateSubscribeMessage(string sessionKey, string ontology, int msRefresh, string query, SSAPQueryTypeEnum queryType)
        {
            var body = new SSAPBodySubscribeMessage()
            {
                Query     = query,
                MsRefresh = msRefresh,
                QueryType = queryType
            };

            return(new SSAPMessage <SSAPBodySubscribeMessage>()
            {
                SessionKey = sessionKey,
                Body = body,
                Direction = SSAPMessageDirectionEnum.REQUEST,
                MessageType = SSAPMessageTypesEnum.SUBSCRIBE,
                Ontology = ontology
            });
        }
예제 #2
0
        /// <summary>
        /// Generates a Update Message
        /// </summary>
        /// <param name="sessionKey">Session Key</param>
        /// <param name="ontology">Ontoogy</param>
        /// <param name="data">Update Data</param>
        /// <param name="query">Query</param>
        /// <param name="queryType">Query Type</param>
        /// <exception cref="SQLSentenceNotAllowedForThisOperationException">No Update Query
        /// given</exception>
        /// <returns>Update Message</returns>
        public SSAPMessage <SSAPBodyOperationMessage> GenerateUpdateMessage(string sessionKey, string ontology, string data, string query, SSAPQueryTypeEnum queryType)
        {
            if (!IsUpdate(query, queryType))
            {
                throw new SQLSentenceNotAllowedForThisOperationException("ERROR - Expected update query");
            }

            var body = new SSAPBodyOperationMessage()
            {
                Data      = data,
                QueryType = queryType,
                Query     = query
            };

            return(new SSAPMessage <SSAPBodyOperationMessage>()
            {
                SessionKey = sessionKey,
                Body = body,
                Direction = SSAPMessageDirectionEnum.REQUEST,
                MessageType = SSAPMessageTypesEnum.UPDATE,
                Ontology = ontology
            });
        }
예제 #3
0
        /// <summary>
        /// Generates a Query Message
        /// </summary>
        /// <param name="sessionKey">Session Key</param>
        /// <param name="ontology">Ontoogy</param>
        /// <param name="query">Query</param>
        /// <param name="queryType">Query Type</param>
        /// <exception cref="SQLSentenceNotAllowedForThisOperationException">Bad format query</exception>
        /// <returns>Query Message</returns>
        public SSAPMessage <SSAPBodyOperationMessage> GenerateQueryMessage(string sessionKey, string ontology, string query, SSAPQueryTypeEnum queryType)
        {
            if (!IsQuery(query, queryType))
            {
                throw new SQLSentenceNotAllowedForThisOperationException("ERROR - statement no expected");
            }

            var body = new SSAPBodyOperationMessage()
            {
                QueryType = queryType,
                Query     = query
            };

            return(new SSAPMessage <SSAPBodyOperationMessage>()
            {
                SessionKey = sessionKey,
                Body = body,
                Direction = SSAPMessageDirectionEnum.REQUEST,
                MessageType = SSAPMessageTypesEnum.QUERY,
                Ontology = ontology
            });
        }
예제 #4
0
        /// <summary>
        /// Generates an Insert Message
        /// </summary>
        /// <param name="sessionKey">Session Key</param>
        /// <param name="ontology">Ontoogy</param>
        /// <param name="data">Insert Data</param>
        /// <param name="queryType">Query Type</param>
        /// <exception cref="SQLSentenceNotAllowedForThisOperationException">No Insert values given</exception>
        /// <returns>Insert Message</returns>
        public SSAPMessage <SSAPBodyOperationMessage> GenerateInsertMessage(string sessionKey, string ontology, string data, SSAPQueryTypeEnum queryType)
        {
            if (!IsInsert(data, queryType))
            {
                throw new SQLSentenceNotAllowedForThisOperationException("ERROR - Expected insert values");
            }

            var body = new SSAPBodyOperationMessage()
            {
                Data      = data,
                QueryType = queryType
            };

            if (queryType == SSAPQueryTypeEnum.SQLLIKE)
            {
                body.Query = data;
            }
            else
            {
                //body.Data = data;
                body.Data = JObject.Parse(data);
            }
            return(new SSAPMessage <SSAPBodyOperationMessage>()
            {
                SessionKey = sessionKey,
                Body = body,
                Direction = SSAPMessageDirectionEnum.REQUEST,
                MessageType = SSAPMessageTypesEnum.INSERT,
                Ontology = ontology
            });
        }