Ejemplo n.º 1
0
        public void AddPulse(Pulse p)
        {
            string query = "INSERT INTO Pulses ('PulseId', 'Name', 'Description', 'TLP', 'Created', 'Modified')" +
                           "VALUES (@pulseId, @name, @description, @tlp, @created, @modified)";

            OpenConnection();
            SQLiteCommand command = new SQLiteCommand(query, connection);

            command.Parameters.AddWithValue("@pulseId", p.Id);
            command.Parameters.AddWithValue("@name", p.Name);
            command.Parameters.AddWithValue("@description", p.Description);
            command.Parameters.AddWithValue("@tlp", p.Tlp);
            command.Parameters.AddWithValue("@created", p.Created.ToString());
            command.Parameters.AddWithValue("@modified", p.Modified.ToString());
            var result = command.ExecuteNonQuery();

            if (p.Indicators != null)
            {
                foreach (var i in p.Indicators)
                {
                    AddIndicator(i);
                }
            }

            CloseConnection();
        }
Ejemplo n.º 2
0
        public void GetPulseById(string id)
        {
            parameters = new Dictionary <string, object>();
            parameters.Add("id", id);

            HttpResponseMessage <string> responsePulse = restTemplate.Exchange <string>("/api/v1/pulses/{id}", HttpMethod.GET, requestEntity, parameters);

            if (responsePulse.StatusCode == HttpStatusCode.OK)
            {
                Pulse pulse = JsonSerializer.Deserialize <Pulse>(responsePulse.Body);
                database.AddPulse(pulse);
                File.WriteAllText(string.Format("./pulse-{0}.json", pulse.Id), JsonSerializer.Serialize(pulse, serializerOptions));
                Console.WriteLine(pulse);
                return;
            }

            Console.WriteLine("Response status: {0}", responsePulse.StatusCode.ToString());
        }