Exemplo n.º 1
0
 private static Location CreateLocationInstance(GeoMessageLocation table)
 {
     return new Location()
     {
         Course = table.Course,
         ExtraInfo = table.ExtraInfo,
         IsValid = table.IsValid,
         LocationMethod = table.LocationMethod,
         Speed = table.Speed,
         TimeStamp = table.TimeStamp.Value.Ticks
     };
 }
Exemplo n.º 2
0
        private static GeoMessageLocation GetGeoMessageLocation(Int32 locationID, SqlConnection connection, SqlTransaction transaction)
        {
            var location = new GeoMessageLocation();

            SqlCommand cmd = new SqlCommand(
                "select AddressInfoID, Course, LocationMethod, QualifiedCoordinatesID, Speed, TimeStamp, IsValid, ExtraInfo from GeoMessageLocation where GeoMessageLocationID = @locationID",
                connection,
                transaction);
            cmd.Parameters.AddWithValue("@locationID", locationID);
            SqlDataReader reader = cmd.ExecuteReader();

            try
            {
                while (reader.Read())
                {
                    Int32? addressInfo = null;
                    Object addressInfoRaw = reader[0];
                    if (!(addressInfoRaw is DBNull))
                        addressInfo = Convert.ToInt32(addressInfoRaw);

                    Single course = Single.NaN;
                    Object courseRaw = reader[1];
                    if (!(courseRaw is DBNull))
                        course = Convert.ToSingle(courseRaw);

                    Int32 locationMethod = Convert.ToInt32(reader[2]);
                    Int32 qualifiedCoordinatesID = Convert.ToInt32(reader[3]);

                    Single speed = Single.NaN;
                    Object speedRaw = reader[4];
                    if (!(speedRaw is DBNull))
                        speed = Convert.ToSingle(speedRaw);

                    DateTime timeStamp = Convert.ToDateTime(reader[5]);
                    Boolean isValid = Convert.ToBoolean(reader[6]);
                    String extraInfo = Convert.ToString(reader[7]);

                    location.AddressInfoID = addressInfo;
                    location.Course = course;
                    location.ExtraInfo = extraInfo;
                    location.ID = locationID;
                    location.IsValid = isValid;
                    location.LocationMethod = locationMethod;
                    location.QualifiedCoordinatesID = qualifiedCoordinatesID;
                    location.Speed = speed;
                    location.TimeStamp = timeStamp;
                }
            }
            finally
            {
                if (reader != null)
                    reader.Close();
            }

            return location;
        }