コード例 #1
0
ファイル: InfernoLive.cs プロジェクト: styniu2/InfernoCS
        private void FillResult(Temperatures result, string json)
        {
            JsonParser parser = new JsonParser(json);

            result.Buffer = parser.GetValue("buffer");
            result.BusFeed = parser.GetValue("bus_feed");
            result.BusReturn = parser.GetValue("bus_ret");
            result.FloorFeed = parser.GetValue("flr_feed");
            result.FloorReturn = parser.GetValue("flr_ret");
            result.HeaterFeed = parser.GetValue("htr_feed");
            result.HeaterReturn = parser.GetValue("htr_ret");
            result.Outside = parser.GetValue("outside");
            result.SystemFeed = parser.GetValue("sys_feed");
            result.SystemReturn = parser.GetValue("sys_ret");
            result.UpdatedAt = DateTime.Parse(parser.GetValue("updated_at"));
            result.WaterFeed = parser.GetValue("wat_feed");
            result.WaterReturn = parser.GetValue("wat_ret");
        }
コード例 #2
0
ファイル: InfernoSql.cs プロジェクト: styniu2/InfernoCS
        public IEnumerable<Temperatures> GetRows(int numberOfRows)
        {
            List<Temperatures> result = new List<Temperatures>();

            using (SqlConnection connection = new SqlConnection(this.connectionString))
            {
                connection.Open();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.Text;
                cmd.Connection = connection;
                cmd.CommandText = "SELECT TOP (@Rows) * FROM dbo.Temperatures;";
                cmd.Parameters.AddWithValue("@Rows", numberOfRows);

                using(SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while(reader.Read())
                    {
                        Temperatures temperatures = new Temperatures() {
                            Buffer = reader.GetFieldValue<string>(0),
                            BusFeed = reader.GetFieldValue<string>(1),
                            BusReturn = reader.GetFieldValue<string>(2),
                            FloorFeed = reader.GetFieldValue<string>(3),
                            FloorReturn = reader.GetFieldValue<string>(4),
                            HeaterFeed = reader.GetFieldValue<string>(5),
                            HeaterReturn = reader.GetFieldValue<string>(6),
                            Outside = reader.GetFieldValue<string>(7),
                            SystemFeed = reader.GetFieldValue<string>(8),
                            SystemReturn = reader.GetFieldValue<string>(9),
                            UpdatedAt = reader.GetFieldValue<DateTime>(10),
                            WaterFeed = reader.GetFieldValue<string>(11),
                            WaterReturn = reader.GetFieldValue<string>(12)
                        };

                        result.Add(temperatures);
                    }
                }
            }

            return result;
        }
コード例 #3
0
ファイル: InfernoLive.cs プロジェクト: styniu2/InfernoCS
        public Temperatures Get()
        {
            Temperatures result = new Temperatures();

            try
            {
                HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(this.url + DateTime.Now.Ticks.ToString());
                myHttpWebRequest.Method = "GET";
                myHttpWebRequest.AllowAutoRedirect = true;
                SetBasicAuthHeader(myHttpWebRequest, this.login, this.pass);

                WebResponse webResponse = myHttpWebRequest.GetResponse();
                using (StreamReader sr = new StreamReader(webResponse.GetResponseStream()))
                {
                    string json = sr.ReadToEnd();
                    FillResult(result, json);
                }
            }
            catch { }

            return result;
        }
コード例 #4
0
ファイル: InfernoMongo.cs プロジェクト: styniu2/InfernoCS
        private IEnumerable<Temperatures> ConvertToTemperatures(IEnumerable<BsonDocument> rows)
        {
            foreach (BsonDocument bson in rows)
            {
                Temperatures temps = new Temperatures()
                {
                    Buffer = bson["buffer"].AsString,
                    BusFeed = bson["bus_feed"].AsString,
                    BusReturn = bson["bus_ret"].AsString,
                    FloorFeed = bson["flr_feed"].AsString,
                    FloorReturn = bson["flr_ret"].AsString,
                    HeaterFeed = bson["htr_feed"].AsString,
                    HeaterReturn = bson["htr_ret"].AsString,
                    Outside = bson["outside"].AsString,
                    SystemFeed = bson["sys_feed"].AsString,
                    SystemReturn = bson["sys_ret"].AsString,
                    UpdatedAt = bson["updated_at"].ToLocalTime(),
                    WaterFeed = bson["wat_feed"].AsString,
                    WaterReturn = bson["wat_ret"].AsString
                };

                yield return temps;
            }
        }