コード例 #1
0
        private void InsertUpgradeNmeaBurst(NmeaBurst burst, SQLiteTransaction trans)
        {
            StringBuilder queryBeginning = new StringBuilder();
            StringBuilder queryEnd = new StringBuilder();
            queryBeginning.AppendFormat("INSERT INTO {0} (", TwoTrailsSchema.TtnmeaSchema.TableName);
            queryEnd.Append("(");

            //CN
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.CN);
            queryEnd.AppendFormat("'{0}',", Guid.NewGuid().ToString());

            //Point CN
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.PointCN);
            queryEnd.AppendFormat("'{0}',", burst._PointCN);

            //Used in Point
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.Used);
            if (burst._Used)
                queryEnd.AppendFormat("'{0}',", 1);
            else
                queryEnd.AppendFormat("'{0}',", 0);

            //DateTime
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.DateTimeZulu);
            queryEnd.AppendFormat("'{0}',", burst._datetime.ToString());

            //Longitude
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.Longitude);
            queryEnd.AppendFormat("'{0}',", burst._longitude);

            //Latitude
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.Latitude);
            queryEnd.AppendFormat("'{0}',", burst._latitude);

            //Latitude Direction
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.LatDir);
            queryEnd.AppendFormat("'{0}',", burst._latDir.ToString());

            //Longitude Direction
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.LonDir);
            queryEnd.AppendFormat("'{0}',", burst._longDir.ToString());

            //Magnetitc Variation
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.MagVar);
            queryEnd.AppendFormat("'{0}',", burst._magVar);

            //Magnetitc Variation Direction
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.MagDir);
            queryEnd.AppendFormat("'{0}',", burst._magVarDir.ToString());

            //UTM Zone
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.UtmZone);
            queryEnd.AppendFormat("'{0}',", burst._utm_zone);

            //UTM X
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.UtmX);
            queryEnd.AppendFormat("'{0}',", burst._X);

            //UTM Y
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.UtmY);
            queryEnd.AppendFormat("'{0}',", burst._Y);

            //Altitude
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.Altitude);
            queryEnd.AppendFormat("'{0}',", burst._altitude);

            //Altitude Unit Type
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.AltUnit);
            queryEnd.AppendFormat("'{0}',", burst._alt_unit.ToString());

            //Fix Quality
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.FixQuality);
            queryEnd.AppendFormat("'{0}',", burst._fix_quality);

            //Altitude Fix Type
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.Mode);
            queryEnd.AppendFormat("'{0}',", burst._fix);

            //PDOP
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.PDOP);
            queryEnd.AppendFormat("'{0}',", burst._PDOP);

            //HDOP
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.HDOP);
            queryEnd.AppendFormat("'{0}',", burst._HDOP);

            //VDOP
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.VDOP);
            queryEnd.AppendFormat("'{0}',", burst._VDOP);

            //PRNs
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.PRNS);
            queryEnd.AppendFormat("'{0}',", burst._fixed_PRNs);

            //Horizontal Dilution of Position
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.HDo_Position);
            queryEnd.AppendFormat("'{0}',", burst._horiz_dilution_position);

            //HAE
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.HAE);
            queryEnd.AppendFormat("'{0}',", burst._geoid_height);

            //HAE
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.HAE_Unit);
            queryEnd.AppendFormat("'{0}',", burst._geoid_unit);

            //Speed
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.Speed);
            queryEnd.AppendFormat("'{0}',", burst._speed);

            //HAE
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.Track_Angle);
            queryEnd.AppendFormat("'{0}',", burst._track_angle);

            //Satellite Count
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.SatelliteCount);
            queryEnd.AppendFormat("'{0}',", burst._num_of_sat);

            //Satellite Used
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.TtnmeaSchema.SatelliteUsed);
            queryEnd.AppendFormat("'{0}',", burst._num_of_used_sat);

            #region Satellites

            List<Satellite> sats = burst.GetSatellites();
            string satID = "", satElev = "", satAz = "", satSRN = "";

            for (int i = 0; i < sats.Count; i++)
            {
                switch (i)
                {
                    case 0:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN1ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN1Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN1Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN1SRN;
                            break;
                        }
                    case 1:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN2ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN2Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN2Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN2SRN;
                            break;
                        }
                    case 2:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN3ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN3Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN3Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN3SRN;
                            break;
                        }
                    case 3:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN4ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN4Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN4Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN4SRN;
                            break;
                        }
                    case 4:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN5ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN5Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN5Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN5SRN;
                            break;
                        }
                    case 5:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN6ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN6Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN6Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN6SRN;
                            break;
                        }
                    case 6:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN7ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN7Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN7Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN7SRN;
                            break;
                        }
                    case 7:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN8ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN8Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN8Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN8SRN;
                            break;
                        }
                    case 8:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN9ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN9Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN9Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN9SRN;
                            break;
                        }
                    case 9:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN10ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN10Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN10Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN10SRN;
                            break;
                        }
                    case 10:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN11ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN11Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN11Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN11SRN;
                            break;
                        }
                    case 11:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN12ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN12Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN12Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN12SRN;
                            break;
                        }
                }

                //Satellite Info
                queryBeginning.AppendFormat("{0},", satID);
                queryEnd.AppendFormat("'{0}',", sats[i].ID);

                queryBeginning.AppendFormat("{0},", satElev);
                queryEnd.AppendFormat("'{0}',", sats[i].Elevation);

                queryBeginning.AppendFormat("{0},", satAz);
                queryEnd.AppendFormat("'{0}',", sats[i].Azimuth);

                queryBeginning.AppendFormat("{0},", satSRN);
                queryEnd.AppendFormat("'{0}',", sats[i].SNR);
            }
            #endregion

            queryBeginning.Remove(queryBeginning.Length - 1, 1);
            queryEnd.Remove(queryEnd.Length - 1, 1);

            queryBeginning.Append(") values ");
            queryEnd.Append(");");
            queryBeginning.AppendFormat(" {0}", queryEnd.ToString());

            SQLiteCommand update = _dbConnection.CreateCommand();

            try
            {
                if (trans != null)
                    update.Transaction = trans;

                update.CommandText = queryBeginning.ToString();
                update.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessUpgrader:SaveNmeaBurst", ex.StackTrace);
            }
            finally
            {
                update.Dispose();
            }
        }
コード例 #2
0
        protected void UpdateNmeaBurst(NmeaBurst burst, string pointCN, SQLiteTransaction trans)
        {
            StringBuilder query = new StringBuilder();
            query.AppendFormat("Update {0} set ", TwoTrailsSchema.TtnmeaSchema.TableName);

            //Point CN
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.PointCN, pointCN);

            //Used
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.Used, (burst._Used)?(1):(0));

            //DateTime
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.DateTimeZulu, burst._datetime.ToString());

            //Longitude
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.Longitude, burst._longitude);

            //Latitude
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.Latitude, burst._latitude);

            //Latitude Direction
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.LatDir, burst._latDir.ToString());

            //Longitude Direction
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.LonDir, burst._longDir.ToString());

            //Magnetitc Variation
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.MagVar, burst._magVar);

            //Magnetitc Variation Direction
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.MagDir, burst._magVarDir.ToString());

            //UTM Zone
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.UtmZone, burst._utm_zone);

            //UTM X
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.UtmX, burst._X);

            //UTM Y
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.UtmY, burst._Y);

            //Altitude
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.Altitude, burst._altitude);

            //Altitude Unit Type
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.AltUnit, burst._alt_unit.ToString());

            //Fix Quality
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.FixQuality, burst._fix_quality);

            //Altitude Fix Type
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.Mode, burst._fix);

            //PDOP
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.PDOP, burst._PDOP);

            //HDOP
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.HDOP, burst._HDOP);

            //VDOP
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.VDOP, burst._VDOP);

            //PRNs
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.PRNS, burst._fixed_PRNs);

            //Horizontal Dilution of Position
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.HDo_Position, burst._horiz_dilution_position);

            //HAE
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.HAE, burst._geoid_height);

            //HAE
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.HAE_Unit, burst._geoid_unit);

            //Speed
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.Speed, burst._speed);

            //Angle
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.Track_Angle, burst._track_angle);

            //Satellite Count
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.SatelliteCount, burst._num_of_sat);

            //Satellite Used
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.TtnmeaSchema.SatelliteUsed, burst._num_of_used_sat);

            #region Satellites

            List<Satellite> sats = burst.GetSatellites();
            string satID = "", satElev = "", satAz = "", satSRN = "";

            for (int i = 0; i < sats.Count; i++)
            {
                switch (i)
                {
                    case 0:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN1ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN1Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN1Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN1SRN;
                            break;
                        }
                    case 1:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN2ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN2Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN2Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN2SRN;
                            break;
                        }
                    case 2:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN3ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN3Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN3Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN3SRN;
                            break;
                        }
                    case 3:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN4ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN4Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN4Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN4SRN;
                            break;
                        }
                    case 4:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN5ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN5Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN5Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN5SRN;
                            break;
                        }
                    case 5:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN6ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN6Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN6Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN6SRN;
                            break;
                        }
                    case 6:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN7ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN7Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN7Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN7SRN;
                            break;
                        }
                    case 7:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN8ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN8Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN8Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN8SRN;
                            break;
                        }
                    case 8:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN9ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN9Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN9Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN9SRN;
                            break;
                        }
                    case 9:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN10ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN10Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN10Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN10SRN;
                            break;
                        }
                    case 10:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN11ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN11Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN11Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN11SRN;
                            break;
                        }
                    case 11:
                        {
                            satID = TwoTrailsSchema.TtnmeaSchema.PRN12ID;
                            satElev = TwoTrailsSchema.TtnmeaSchema.PRN12Elev;
                            satAz = TwoTrailsSchema.TtnmeaSchema.PRN12Az;
                            satSRN = TwoTrailsSchema.TtnmeaSchema.PRN12SRN;
                            break;
                        }
                }

                //Satellite Info
                query.AppendFormat("{0} = '{1}', ", satID, sats[i].ID);

                query.AppendFormat("{0} = '{1}', ", satElev, sats[i].Elevation);

                query.AppendFormat("{0} = '{1}', ", satAz, sats[i].Azimuth);

                query.AppendFormat("{0} = '{1}'{2} ", satSRN, sats[i].SNR,
                    i == sats.Count - 1 ? "" : ",");
            }
            #endregion

            query.AppendFormat("where {0} = '{1}'", TwoTrailsSchema.SharedSchema.CN, burst._CN);

            SQLiteCommand update = _dbConnection.CreateCommand();

            try
            {
                if (trans != null)
                    update.Transaction = trans;

                update.CommandText = query.ToString();
                update.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessLayer:UpdateNmeaBurst");
            }
            finally
            {
                update.Dispose();
            }
        }