コード例 #1
0
        private void InsertUpdateRow(SqlConnection CN)
        {
            StringBuilder SB = new StringBuilder(HeadingHistory);

            if (dbLat == lat && dbLon == lon)
            {
                //keep the history. do not change
            }
            else
            {
                int HistoryCount = HeadingHistory.Count(c => c == ',');
                if (HistoryCount >= 5)
                {
                    SB.Remove(0, HeadingHistory.IndexOf(',') + 1);
                }
                if (SB.Length > 0)
                {
                    SB.Append(',');
                }
                SB.Append(track);
            }

            String IPAddress = "0.0.0.0";

            try {
                IPAddress = System.Web.HttpContext.Current.Request.UserHostAddress;
            } catch {
            }

            String SQL = $@"[usp_ADSB_UpdateInsert]
		@FlightID = N'{flight}',
		@HexID = N'{hex}',
		@FlightTime = N'{ ADSBDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}',
		@Lat = {lat},
		@Lon = {lon},
		@Alt = {Alt()},
		@speed = {speed},
		@track = N'{track}',
		@flightsource = N'{flightsource}',
		@newtrack = N'{SB.ToString()}',
		@category = N'{category}',
		@IPAddress = N'{IPAddress}'"        ;

            using (SqlCommand cmd = new SqlCommand(SQL, CN)) {
                cmd.ExecuteNonQuery();
            }//using (SqlCommand cmd)
        }
コード例 #2
0
ファイル: ADSB.cs プロジェクト: sojanml/cat62_parser
        internal void Update(SqlConnection CN)
        {
            StringBuilder SB        = new StringBuilder();
            String        IPAddress = "0.0.0.0";


            String SQL = $@"[dbo].[usp_ADSB_UpdateInsert]
		    @FlightID = N'{this.Registration}',
		    @HexID = N'{this.HexCode}',
		    @FlightTime = N'{ ADSBDate.ToString("yyyy-MM-dd HH:mm:ss")}',
		    @Lat = {Latitude},
		    @Lon = {Longtitude},
		    @Alt = {Altitude},
		    @speed = {Speed},
		    @track = N'{this.Heading}',
		    @flightsource = N'Exponent',
		    @newtrack = N'{Registration}',
		    @category = N'ADSI',
		    @IPAddress = N'{IPAddress}'"        ;

            using (SqlCommand cmd = new SqlCommand(SQL, CN)) {
                cmd.ExecuteNonQuery();
            }//using (SqlCommand cmd)
        }