Exemplo n.º 1
0
        public Task PostImport(string uid, [FromBody] MqttImportTopicParameters parameters)
        {
            if (uid == null)
            {
                throw new ArgumentNullException(nameof(uid));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            return(_mqttService.StartTopicImport(uid, parameters));
        }
Exemplo n.º 2
0
        public string start_topic_import(string uid, PythonDictionary parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var topicImportParameters = new MqttImportTopicParameters
            {
                Server   = Convert.ToString(parameters.get("server")),
                Port     = Convert.ToInt32(parameters.get("port", 1883)),
                UseTls   = Convert.ToBoolean(parameters.get("tls", false)),
                Username = Convert.ToString(parameters.get("username")),
                Password = Convert.ToString(parameters.get("password")),
                ClientId = Convert.ToString(parameters.get("client_id", Guid.NewGuid().ToString("N"))),
                Topic    = Convert.ToString(parameters.get("topic")),
                QualityOfServiceLevel = (MqttQualityOfServiceLevel)Convert.ToInt32(parameters.get("qos"))
            };

            return(_mqttService.StartTopicImport(uid, topicImportParameters));
        }