コード例 #1
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
            });
        }
コード例 #2
0
        protected override SSAPBodyMessage Create(Type objectType, JObject jsonObject)
        {
            string type = jsonObject["@type"].Value <String>();

            switch (type)
            {
            case "SSAPBodyReturnMessage":
                return(SSAPBodyReturnMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyConfigMessage":
                return(SSAPBodyConfigMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyJoinMessage":
                return(SSAPBodyJoinMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyJoinTokenMessage":
                return(SSAPBodyJoinMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyJoinUserAndPasswordMessage":
                return(SSAPBodyJoinUserAndPasswordMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyLeaveMessage":
                return(SSAPBodyLeaveMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyMessage":
                return(SSAPBodyMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyOperationMessage":
                return(SSAPBodyOperationMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyQueryMessage":
                return(SSAPBodyQueryMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyQueryWithParamMessage":
                return(SSAPBodyQueryWithParamMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodySubscribeMessage":
                return(SSAPBodySubscribeMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyUnsubscribeMessage":
                return(SSAPBodyUnsubscribeMessage.FromJson(jsonObject.ToString()));

            case "SSAPBodyLogMessage":
                return(SSAPBodyLogMessage.FromJson(jsonObject.ToString()));

            default:
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// Generates an Insert Message
        /// </summary>
        /// <param name="sessionKey">Session Key</param>
        /// <param name="ontology">Ontoogy</param>
        /// <param name="data">Insert Data</param>
        /// <returns>Insert Message</returns>
        public SSAPMessage <SSAPBodyOperationMessage> GenerateInsertMessage(string sessionKey, string ontology, string data)
        {
            var body = new SSAPBodyOperationMessage()
            {
                Data = JObject.Parse(data)
            };

            return(new SSAPMessage <SSAPBodyOperationMessage>()
            {
                SessionKey = sessionKey,
                Body = body,
                Direction = SSAPMessageDirectionEnum.REQUEST,
                MessageType = SSAPMessageTypesEnum.INSERT,
                Ontology = ontology
            });
        }
コード例 #4
0
        /// <summary>
        /// Generates a Native Remove Message
        /// </summary>
        /// <param name="sessionKey">Session Key</param>
        /// <param name="ontology">Ontoogy</param>
        /// <param name="query">Query</param>
        /// <returns>Remove Message</returns>
        public SSAPMessage <SSAPBodyMessage> GenerateRemoveMessage(string sessionKey, string ontology, string query)
        {
            var body = new SSAPBodyOperationMessage()
            {
                Query     = query,
                QueryType = SSAPQueryTypeEnum.NATIVE
            };

            return(new SSAPMessage <SSAPBodyMessage>()
            {
                SessionKey = sessionKey,
                Body = body,
                Direction = SSAPMessageDirectionEnum.REQUEST,
                MessageType = SSAPMessageTypesEnum.DELETE,
                Ontology = ontology
            });
        }
コード例 #5
0
        /// <summary>
        /// Generates a Native 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>
        /// <returns>Update Message</returns>
        public SSAPMessage <SSAPBodyOperationMessage> GenerateUpdateMessage(string sessionKey, string ontology, string data, string query)
        {
            var body = new SSAPBodyOperationMessage()
            {
                Data      = JObject.Parse(data),
                Query     = query,
                QueryType = SSAPQueryTypeEnum.NATIVE
            };

            return(new SSAPMessage <SSAPBodyOperationMessage>()
            {
                SessionKey = sessionKey,
                Body = body,
                Direction = SSAPMessageDirectionEnum.REQUEST,
                MessageType = SSAPMessageTypesEnum.UPDATE,
                Ontology = ontology
            });
        }
コード例 #6
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
            });
        }
コード例 #7
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
            });
        }