コード例 #1
0
        public async Task <ActionResult <GpsInfo> > PostGpsInfo(GpsInfo gpsInfo)
        {
            _context.GpsInfo.Add(gpsInfo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGpsInfo", new { id = gpsInfo.Id }, gpsInfo));
        }
コード例 #2
0
        public async Task <IActionResult> PutGpsInfo(int id, GpsInfo gpsInfo)
        {
            if (id != gpsInfo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(gpsInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GpsInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public bool AddRecord(SocketSession session, GpsInfo record)
        {
            GpsInfo rc = new GpsInfo(record);

            gpsCache.Enqueue(rc);
            return(true);
        }
コード例 #4
0
 private void cache2Table()
 {
     if (!gpsCache.IsEmpty)
     {
         for (int i = 0; i < gpsCache.Count; i++)
         {
             GpsInfo item = null;
             if (gpsCache.TryDequeue(out item))
             {
                 var r = gpsTb.NewRow();
                 r["车辆GUID"] = item.ID;
                 r["经度"]     = item.Lng;
                 r["纬度"]     = item.Lat;
                 r["速度"]     = item.Speed;
                 r["日期"]     = item.Date;
                 if (item.Speed > 0.1)
                 {
                     r["状态"] = "正常行驶";
                 }
                 else
                 {
                     r["状态"] = "停车";
                 }
                 gpsTb.Rows.Add(r);
             }
         }
     }
 }
コード例 #5
0
        private void CleanScreen()
        {
            TrackModel = null;
            RmoveTrack();
            var gpsinfo = new GpsInfo()
            {
                UTCTime   = DateTime.UtcNow,
                Latitude  = 29.592966F,
                Longitude = 118.983188F,
            };

            var by = new Buoy()
            {
                Id  = 1,
                gps = gpsinfo,
                IP  = "192.168.2.101",
            };

            Buoy1 = by;
            by.Id = 2;
            Buoy2 = by;
            by.Id = 3;
            Buoy3 = by;
            by.Id = 4;
            Buoy4 = by;
            //UnitCore.Instance.TargetObj.Latitude = 29.592966F;
            //UnitCore.Instance.TargetObj.Longitude = 118.983188F;
            //UnitCore.Instance.TargetObj.Status = "未定位";
            RefreshBuoy(0, Buoy1);
            RefreshBuoy(1, Buoy2);
            RefreshBuoy(2, Buoy3);
            RefreshBuoy(3, Buoy4);

            RefreshBuoyInfo(BuoyInfoVisible);
        }
コード例 #6
0
ファイル: Authorization.cs プロジェクト: junbao520/AndroidApp
        public bool CheckPeriod(GpsInfo tempGpsInfo)
        {
            //gps无信号时,禁止使用
            if (tempGpsInfo.FixedSatelliteCount < 2)
            {
                speaker.PlayAudioAsync("GPS无信号,请检查");
                return(false);
            }

            if (isFirstOpen)
            {
                try
                {
                    DateTime tempTime = tempGpsInfo.LocalTime;
                    Logger.DebugFormat("获取当前gps日期:{0}", tempTime);
                    if (tempTime.Year > 2014)
                    {
                        //isFirstOpen = false;
                        if (!ShowInfo(tempTime))
                        {
                            return(false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string str = ex.Message;
                    Logger.ErrorFormat("获取验证码出错:{0}", ex.Message);
                }
            }
            return(true);
        }
コード例 #7
0
ファイル: HuaZhongSmall.cs プロジェクト: junbao520/AndroidApp
        protected bool CheckAuth(GpsInfo gpsInfo)
        {
            bool checkAuthState = authorization.CheckPeriod(gpsInfo);

            if (!checkAuthState)
            {
                speaker.PlayAudioAsync("试用已到期请激活");
                return(false);
            }

            return(true);
        }
コード例 #8
0
        protected bool CheckAuth(GpsInfo gpsInfo)
        {
            bool checkAuthState = authorization.CheckPeriod(gpsInfo);

            if (!checkAuthState)
            {
                // Toast.MakeText(this,"GPS无信号或试用已到期,请检查",ToastLength.Long);
                speaker.PlayAudioAsync("GPS无信号或试用已到期,请检查");
                return(false);
            }

            return(true);
        }
コード例 #9
0
 public static GpsInfo ParseGps(byte[] buffer)
 {
     if (GPS.Parse(Encoding.Default.GetString(buffer)))
     {
         GpsInfo info = new GpsInfo()
         {
             UTCTime   = GPS.UTCTime,
             Latitude  = GPS.Latitude,
             Longitude = GPS.Longitude
         };
         return(info);
     }
     return(null);
 }
コード例 #10
0
        protected bool CheckAuth(GpsInfo gpsInfo)
        {
            bool checkAuthState = authorization.CheckPeriod(gpsInfo);

            if (!checkAuthState)
            {
                string AuthCode = authorization.GetAuthorizationCode();
                string message  = string.Format("设备识别码:{0},请联系销售人员激活软件。", AuthCode);
                speaker.PlayAudioAsync(message);
                return(false);
            }

            return(true);
        }
コード例 #11
0
 public double CalculateAngle(GpsInfo current)
 {
     //return current.AngleDegrees;
     foreach (var gps in CarSignalSet.Where(x => x.IsGpsValid).Select(x => x.Gps))
     {
         var distance = GeoHelper.GetDistanceFast(current.LongitudeDegrees, current.LatitudeDegrees,
                                                  gps.LongitudeDegrees, gps.LatitudeDegrees);
         if (distance > 0.5)
         {
             var angle = GeoHelper.GetBearing(gps.LongitudeDegrees, gps.LatitudeDegrees, current.LongitudeDegrees,
                                              current.LatitudeDegrees);
             return(angle);
         }
     }
     return(double.NaN);
 }
コード例 #12
0
        private void InitAllGpsList()
        {
            if (this.allGpsList == null)
            {
                String sql = "select gpsid, orgid, carno, sssjmc, ssfjmc, ssdwmc, loctype from PGIS_DWXX.T_GPS_INFO_DZSP t";

                try
                {
                    using (OleDbConnection conn = new OleDbConnection(this.gpsDeviceDBConnectBuilder.ConnectionString))
                    {
                        conn.Open();
                        OleDbCommand    cmd    = new OleDbCommand(sql, conn);
                        OleDbDataReader reader = cmd.ExecuteReader();

                        this.gpsCarList = new Dictionary <string, GpsInfo>();
                        while (reader.Read())
                        {
                            GpsInfo info = new GpsInfo();
                            //GPSID
                            if (!reader.IsDBNull(0))
                            {
                                info.GpsId = reader[0].ToString();
                            }
                            //orgid
                            if (!reader.IsDBNull(1))
                            {
                                info.OrgId = reader[1].ToString();
                            }
                            //carno
                            if (!reader.IsDBNull(2))
                            {
                                info.CarNo = reader[2].ToString();
                            }
                            //sssjmc
                            if (!reader.IsDBNull(3))
                            {
                                info.Sssjmc = reader[3].ToString();
                            }
                            //ssfjmc
                            if (!reader.IsDBNull(4))
                            {
                                info.Ssfjmc = reader[4].ToString();
                            }
                            //ssdwmc
                            if (!reader.IsDBNull(5))
                            {
                                info.Ssdwmc = reader[5].ToString();
                            }
                            //gps type
                            if (!reader.IsDBNull(6))
                            {
                                info.GpsType = Convert.ToInt32(reader[6].ToString());
                            }


                            if (!this.gpsCarList.ContainsKey(info.GpsId))
                            {
                                this.gpsCarList.Add(info.GpsId, info);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogMgr.Instance.Error(String.Format("执行轨迹信息查询失败,SQL:{0}", sql), ex);
                    throw ex;
                }
            }
        }
コード例 #13
0
ファイル: UnitCore.cs プロジェクト: BJFX/Torp
        private void ReadInitPara()
        {
            string gridname = MonConf.GetInstance().MyExecPath + "\\" + "default.ini";
            Stream stream   = null;

            try
            {
                stream = new FileStream(gridname, FileMode.Open, FileAccess.Read, FileShare.Read);
                IFormatter formatter = new BinaryFormatter();
                initpara = (InitialData)formatter.Deserialize(stream);
                stream.Close();
                Buoy = initpara.buoy;
                if (Buoy.Count == 0)
                {
                    throw new Exception();//use default value
                }
                //clean the range info,only need gps location
                foreach (var buoy in Buoy.Values)
                {
                    var b = (Buoy)buoy;
                    b.Range1     = 0;
                    b.Range2     = 0;
                    b.liteRange1 = new LiteRange();
                    b.teleRange1 = new TeleRange();
                    b.liteRange2 = new LiteRange();
                    b.teleRange2 = new TeleRange();
                }
                //InfoBoard = initpara.info;
            }
            catch (Exception MyEx)
            {
                if (stream != null)
                {
                    stream.Close();
                }
                var gpsinfo = new GpsInfo()
                {
                    UTCTime   = DateTime.UtcNow,
                    Latitude  = 29.592966F,
                    Longitude = 118.983188F,
                };

                var by1 = new Buoy()
                {
                    Id  = 1,
                    gps = gpsinfo,
                    IP  = "192.168.2.101",
                };
                Buoy.Add(0, by1);
                gpsinfo = new GpsInfo()
                {
                    UTCTime   = DateTime.UtcNow,
                    Latitude  = 29.502966F,
                    Longitude = 118.903188F,
                };
                var by2 = new Buoy()
                {
                    Id  = 2,
                    gps = gpsinfo,
                    IP  = "192.168.2.102",
                };
                Buoy.Add(1, by2);
                gpsinfo = new GpsInfo()
                {
                    UTCTime   = DateTime.UtcNow,
                    Latitude  = 29.512966F,
                    Longitude = 118.913188F,
                };
                var by3 = new Buoy()
                {
                    Id  = 3,
                    gps = gpsinfo,
                    IP  = "192.168.2.103",
                };
                Buoy.Add(2, by3);
                gpsinfo = new GpsInfo()
                {
                    UTCTime   = DateTime.UtcNow,
                    Latitude  = 29.542966F,
                    Longitude = 118.943188F,
                };
                var by4 = new Buoy()
                {
                    Id  = 4,
                    gps = gpsinfo,
                    IP  = "192.168.2.104",
                };
                Buoy.Add(3, by4);
                //InfoBoard = new Hashtable();
                SaveInitPara();
                var errmsg = new ErrorEvent(MyEx, LogType.Both)
                {
                    Message = "浮标信息读取失败,使用默认参数"
                };
                UnitCore.Instance.EventAggregator.PublishMessage(errmsg);
            }
        }
コード例 #14
0
        protected virtual GpsInfo ParseGpsInfo(string[] commands)
        {
            var reading = GpsReading.Parse(commands);

            if (reading.FixedGpsData == null)
            {
                return(null);
            }

            var gpsInfo = new GpsInfo();

            if (reading.FixedGpsData.Elevation != null)
            {
                gpsInfo.AltitudeMeters = Convert.ToDouble(reading.FixedGpsData.Elevation.Value);
            }
            if (reading.FixedGpsData.Position != null)
            {
                gpsInfo.LatitudeDegrees  = Convert.ToDouble(reading.FixedGpsData.Position.Latitude.Degrees);
                gpsInfo.LongitudeDegrees = Convert.ToDouble(reading.FixedGpsData.Position.Longitude.Degrees);
            }

            //采用gps本身提供的日期,20160509
            gpsInfo.UtcTime = reading.Summary.UtcDateTime;

            //gpsInfo.UtcTime = reading.FixedGpsData.UtcTime;
            gpsInfo.LocalTime             = gpsInfo.UtcTime.ToLocalTime();
            gpsInfo.FixedSatelliteCount   = reading.FixedGpsData.NumberOfSatelitesInUse;
            gpsInfo.TrackedSatelliteCount = gpsInfo.FixedSatelliteCount;
            gpsInfo.FixQuality            = reading.FixedGpsData.Quality;
            if (reading.GroundVector != null && reading.GroundVector.GroundSpeedInKmh != 0)
            {
                gpsInfo.SpeedInKmh = reading.GroundVector.GroundSpeedInKmh;
            }
            if (reading.Summary != null && reading.Summary.GroundSpeed != 0)
            {
                var summary = reading.Summary;
                gpsInfo.SpeedInKmh   = Convert.ToDouble(summary.GroundSpeed);
                gpsInfo.AngleDegrees = Convert.ToDouble(summary.Heading);
            }
            if (reading.Heading != null)
            {
                //20160111,使用高精度版本
                tempVersion          = true;
                gpsInfo.AngleDegrees = reading.Heading.BearingDegrees;
                //高精度和普通科三gps角度会差180度,如:高精度3°,普通184°
                //gpsInfo.AngleDegrees = gpsInfo.AngleDegrees + 180;
                //if (gpsInfo.AngleDegrees > 360)
                //    gpsInfo.AngleDegrees = gpsInfo.AngleDegrees - 360;

                gpsInfo.FixedSatelliteCount   = reading.Heading.SatellitesInSolution;
                gpsInfo.TrackedSatelliteCount = reading.Heading.SatellitesInTrack;
                //记录上一次角度
                lastAngleDegrees = gpsInfo.AngleDegrees;
            }
            if (tempVersion)
            {
                //20160111,使用高精度版本,(有时Heading为空的情况)
                gpsInfo.HighPrecisionVersion = true;
                if (reading.Heading == null)
                {
                    gpsInfo.AngleDegrees = lastAngleDegrees;
                }
            }
            return(gpsInfo);
        }
コード例 #15
0
        public void JustFirst(SocketSession session, GpsInfo info)
        {
            if (lstJustRecords.Count < 1)
            {
                QueryHistory(session.CarID);//获得历史的最后一个点的位置
            }
            if (dLastLng > 0 && dLastLat > 0)
            {
                double dis = GetDistance(info.Lat, info.Lng, dLastLat, dLastLng);
                if (dis < 100)
                {
                    lstRecords.Add(info);
                    lstJustRecords.Clear();

                    AddRecord(session, info);
                    Console.WriteLine("*****根据历史添加:");

                    return;
                }
            }
            lstJustRecords.Add(info);

            if (lstJustRecords.Count >= 5)
            {
                //开始判断最后几个点
                //判断第一个
                List <PointDis> lstDis = new List <PointDis>();
                for (int i = lstJustRecords.Count - 1; i >= lstJustRecords.Count - 5; i--)
                {
                    double dis = 0;
                    for (int j = lstJustRecords.Count - 1; j >= lstJustRecords.Count - 5; j--)
                    {
                        if (i == j)
                        {
                            continue;
                        }
                        dis += GetDistance(lstJustRecords[i].Lat, lstJustRecords[i].Lng, lstJustRecords[j].Lat, lstJustRecords[j].Lng);
                    }
                    PointDis pt = new PointDis();
                    pt.Index    = i;
                    pt.Distance = dis;
                    lstDis.Add(pt);
                }
                lstDis.Sort();
                int iFristIndex = lstDis[0].Index;
                for (int i = iFristIndex + 1; i < lstJustRecords.Count - 1; i++)
                {
                    double dis = GetDistance(lstJustRecords[i].Lat, lstJustRecords[i].Lng, lstJustRecords[i - 1].Lat, lstJustRecords[i - 1].Lng);
                    if (dis > 50)
                    {
                        lstJustRecords.RemoveAt(i);
                        i--;
                    }
                }
                for (int i = iFristIndex - 1; i > 0; i--)
                {
                    double dis = GetDistance(lstJustRecords[i].Lat, lstJustRecords[i].Lng, lstJustRecords[i + 1].Lat, lstJustRecords[i + 1].Lng);
                    if (dis > 50)
                    {
                        lstJustRecords.RemoveAt(i);
                    }
                }

                if (lstJustRecords.Count < 1)
                {
                    return;
                }
                //开始写入数据库
                lstRecords.Add(lstJustRecords[lstJustRecords.Count - 1]);
                for (int i = 0; i < lstJustRecords.Count; i++)
                {
                    AddRecord(session, lstJustRecords[i]);
                    Console.WriteLine("*****首次添加:");
                }
                lstJustRecords.Clear();
            }
        }
コード例 #16
0
        public void AddRecord(SocketSession session, SocketRequestInfo requestInfo)
        {
            String strKey = requestInfo.Key;
            String strVal = requestInfo.OriginBody;

            if (strKey == "" || strKey == string.Empty)
            {
                return;
            }
            bool bAddNewCar = false;
            var  strCarID   = session.CarID;

            #region RFID
            if (strKey == "RFID")
            {
                strVal = requestInfo.TargetBody;
                if (strCarID == "")
                {
                    strCarID = "未知";
                    CarLoad(strCarID);
                    //((SWGPSServer)(base.AppServer)).CarLoad(this, strCarID);
                }
                //  lock (m_FrozedProcessLock)
                {
                    try
                    {
                        strVal = strVal.Replace(" ", "");
                        string[] strParts = Regex.Split(strVal, "11003F", RegexOptions.IgnoreCase);

                        bool bStart = false;
                        if (strParts.Length >= 1)
                        {
                            if (strVal.Substring(0, 6) == "11003F")
                            {
                                bStart = true;
                            }
                            else
                            {
                                bStart = false;
                            }

                            #region 获得此次RFID
                            List <String> lstIDS = new List <string>();
                            for (int i = 0; i < strParts.Length; i++)
                            {
                                if (strParts[i].Length < 26)
                                {
                                    continue;
                                }
                                if (i == 0)
                                {
                                    if (bStart == false)
                                    {
                                        continue;
                                    }
                                }
                                String strRFID = "";
                                strRFID = strParts[i].Substring(0, 26);
                                if (lstIDS.Contains(strRFID))
                                {
                                    continue;
                                }
                                lstIDS.Add(strRFID);
                                Console.WriteLine("收到-" + strRFID);
                            }
                            #endregion
                            #region 判断是否可入库
                            if (lstIDS.Count > 0)
                            {
                                List <RfidInfo> lstAdd = new List <RfidInfo>();
                                for (int i = 0; i < lstIDS.Count; i++)
                                {
                                    if (lstRFIDCodes.Contains(lstIDS[i]))
                                    {
                                        for (int j = lstRFID.Count - 1; j >= 0; j--)
                                        {
                                            if (lstRFID[j].Code == lstIDS[i])
                                            {
                                                //判断时间间隔
                                                if ((System.DateTime.Now - lstRFID[j].PutDateTime).Minutes < 20)
                                                {
                                                    break;
                                                }
                                                else
                                                {
                                                    lstRFID.RemoveAt(j);
                                                    lstRFIDCodes.RemoveAt(j);
                                                    lstRFIDCodes.Add(lstIDS[i]);
                                                    RfidInfo rf = new RfidInfo();
                                                    rf.Code        = lstIDS[i];
                                                    rf.PutDateTime = System.DateTime.Now.ToLocalTime();
                                                    rf.DateDesri   = rf.PutDateTime.ToString("yyyy-MM-dd HH:mm:ss");
                                                    rf.Car         = strCarID;
                                                    lstRFID.Add(rf);
                                                    if (lstRFID.Count > 100)
                                                    {
                                                        lstRFID.RemoveRange(0, lstRFID.Count - 100);
                                                    }
                                                    if (lstRFIDCodes.Count > 100)
                                                    {
                                                        lstRFIDCodes.RemoveRange(0, lstRFIDCodes.Count - 100);
                                                    }
                                                    Console.WriteLine("写入" + rf.Code);
                                                    if (rf.Car == "" || rf.Car == "未知")
                                                    {
                                                        lstRFIDNull.Add(rf);
                                                    }
                                                    else
                                                    {
                                                        lstAdd.Add(rf);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        lstRFIDCodes.Add(lstIDS[i]);
                                        if (lstRFIDCodes.Count > 100)
                                        {
                                            lstRFIDCodes.RemoveRange(0, lstRFIDCodes.Count - 100);
                                        }
                                        RfidInfo rf = new RfidInfo();
                                        rf.Code        = lstIDS[i];
                                        rf.PutDateTime = System.DateTime.Now.ToLocalTime();
                                        rf.DateDesri   = rf.PutDateTime.ToString("yyyy-MM-dd HH:mm:ss");
                                        rf.Car         = strCarID;
                                        lstRFID.Add(rf);
                                        if (lstRFID.Count > 100)
                                        {
                                            lstRFID.RemoveRange(0, lstRFID.Count - 100);
                                        }
                                        Console.WriteLine("写入" + rf.Code);
                                        if (rf.Car == "" || rf.Car == "未知")
                                        {
                                            lstRFIDNull.Add(rf);
                                        }
                                        else
                                        {
                                            lstAdd.Add(rf);
                                        }
                                    }
                                }
                                if (lstAdd.Count > 0)
                                {
                                    AddRFID(session, lstAdd);

                                    if (strCarID != "" && strCarID != "未知")
                                    {
                                        for (int i = 0; i < lstRFIDNull.Count; i++)
                                        {
                                            lstRFIDNull[i].Car = strCarID;
                                        }
                                        AddRFID(session, lstRFIDNull);
                                        lstRFIDNull.Clear();
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    catch (Exception ex)
                    {
                        return;
                    }
                }
                return;
            }
            #endregion



            String[] strValues = strVal.Split(',');
            if (strValues == null)
            {
                return;
            }
            if (strValues.Length < 10)
            {
                return;
            }
            String strLog = strValues[0];
            if (strLog.Length > 7)
            {
                String strID = strLog.Replace("$GPSLOC", "");
                strLog = strLog.Substring(strID.Length, strLog.Length - strID.Length);
                strID  = "鲁" + strID;
                if (string.IsNullOrEmpty(strCarID) || strCarID == "未知")
                {
                    strCarID      = strID;
                    session.CarID = strCarID;
                    CarLoad(strCarID);
                    lstJustRecords.Clear();
                    lstRecords.Clear();
                    Console.WriteLine(strCarID + "上线");
                }
            }
            if (strCarID == "")
            {
                strCarID = "未知";
                CarLoad(strCarID);
                lstJustRecords.Clear();
                lstRecords.Clear();
            }
            String strJD = strValues[2]; //经度
            if (double.Parse(strJD) < 1)
            {
                return;
            }
            {
                if (strJD == "")
                {
                    return;
                }
                if (Convert.ToDouble(strJD) < 0.1)
                {
                    return;
                }
                int    iPos   = strJD.IndexOf('.');//4
                String str1   = strJD.Substring(0, iPos);
                String strFen = str1.Substring(str1.Length - 2, 2);
                string strDu  = str1.Substring(0, str1.Length - strFen.Length);
                string strDot = strJD.Substring(iPos, strJD.Length - str1.Length);
                strJD = (Convert.ToDouble(strDu) + Convert.ToDouble(strFen + strDot) / 60).ToString();
            }
            String strWD = strValues[1]; //纬度
            if (double.Parse(strWD) < 1)
            {
                return;
            }
            {
                if (strWD == "")
                {
                    return;
                }
                if (Convert.ToDouble(strWD) < 0.1)
                {
                    return;
                }
                int    iPos   = strWD.IndexOf('.');//4
                String str1   = strWD.Substring(0, iPos);
                String strFen = str1.Substring(str1.Length - 2, 2);
                string strDu  = str1.Substring(0, str1.Length - strFen.Length);
                string strDot = strWD.Substring(iPos, strWD.Length - str1.Length);
                strWD = (Convert.ToDouble(strDu) + Convert.ToDouble(strFen + strDot) / 60).ToString();
            }
            String          strGD   = strValues[3]; //高度
            String          strTime = strValues[4]; //时间
            System.DateTime tm      = default(System.DateTime);
            try
            {
                string strY = strTime.Substring(0, 4);
                string strM = strTime.Substring(4, 2);
                string strD = strTime.Substring(6, 2);
                string strH = strTime.Substring(8, 2);
                // strH = (Convert.ToInt32(strH) + 8).ToString();
                string strMinute = strTime.Substring(10, 2);
                string strsecond = strTime.Substring(12, strTime.Length - 12 - 1);
                strsecond = Convert.ToInt32(Convert.ToDouble(strsecond)).ToString();
                strTime   = strY + "-" + strM + "-" + strD + " " + strH + ":" + strM + ":" + strsecond;
                try
                {
                    tm = new DateTime(Convert.ToInt32(strY), Convert.ToInt32(strM), Convert.ToInt32(strD), Convert.ToInt32(strH), Convert.ToInt32(strMinute), Convert.ToInt32(strsecond), DateTimeKind.Utc);
                    System.DateTime tnew = tm.ToLocalTime();
                    strTime = tnew.ToString("yyyy-MM-dd HH:mm:ss");
                }
                catch (Exception all)
                {
                    return;
                }
            }
            catch (Exception fe)
            {
                session.AppServer.Logger.Error("date format exception :" + fe.Message + fe.StackTrace);
                return;
            }
            string strWXNum = strValues[6];//卫星个数
            string strSpeed = strValues[7];
            double dSpeed   = 0;
            if (strSpeed != "")
            {
                try
                {
                    dSpeed = Convert.ToDouble(strSpeed);
                    //dSpeed = dSpeed * 0.5144;//米/秒
                    //dSpeed = dSpeed * 3600 / 1000;
                    dSpeed   = dSpeed * 1.85184;
                    strSpeed = dSpeed.ToString("###.##");
                }
                catch (Exception e)
                {
                }
            }
            else
            {
                strSpeed = "0";
            }
            if (strSpeed == "")
            {
                strSpeed = "0";
            }
            string strFix = strValues[5];
            string strHx  = strValues[8];
            if (strWXNum == "")
            {
                strWXNum = "3";
            }
            if (Convert.ToInt32(strWXNum) < 4)
            {
                return;
            }
            if (strGD == "")
            {
                strGD = "6000";
            }
            if (Convert.ToDouble(strGD) > 3000)
            {
                return;
            }
            if (double.Parse(strSpeed) > 200)
            {
                return;
            }
            String  strXH = "0";
            GpsInfo info  = new GpsInfo();
            info.ID           = strCarID;
            info.Lat          = double.Parse(strWD);
            info.Lng          = double.Parse(strJD);
            info.Speed        = double.Parse(strSpeed);
            info.StarNum      = int.Parse(strWXNum);
            info.Hight        = double.Parse(strGD);
            info.Order        = int.Parse(strXH);
            info.Date         = strTime;
            info.StandardTime = tm;


            if (lstRecords.Count < 1)
            {
                JustFirst(session, info);
            }
            else
            {
                //开始判断下一个点是否符合要求
                int    iIndex       = lstRecords.Count - 1;
                double dDistanceNew = GetDistance(lstRecords[0].Lat, lstRecords[0].Lng, info.Lat, info.Lng);
                if (dDistanceNew < 200)
                {
                    lstRecords.Add(info);
                    lstRecords.RemoveAt(0);
                    if (lstJumpRecords.Count > 0)
                    {
                        lstJumpRecords.Clear();
                    }
                    AddRecord(session, info);
                    Console.WriteLine("*****添加:" + strVal);
                    return;
                }
                else
                {
                    if (lstJumpRecords.Count < 1)
                    {
                        lstJumpRecords.Add(info);
                        return;
                    }
                    else
                    {
                        double dis = GetDistance(lstJumpRecords[lstJumpRecords.Count - 1].Lat, lstJumpRecords[lstJumpRecords.Count - 1].Lng, info.Lat, info.Lng);
                        if (dis < 200)
                        {
                            lstJumpRecords.Add(info);
                            return;
                        }
                    }
                    if ((info.StandardTime - lstRecords[iIndex].StandardTime).TotalSeconds > 120)
                    {
                        lstRecords.Clear();
                        lstJustRecords.Clear();
                        lstJumpRecords.Clear();
                        dLastLat = -1;
                        dLastLng = -1;
                        Console.WriteLine("&&&&&&&&&&&&&&重新计算:" + strVal);
                        return;
                    }
                    else
                    {
                        Console.WriteLine("异常点舍弃:" + strVal);
                    }
                }
            }
        }
コード例 #17
0
        public static void Initialize(HindsiteContext context)
        {
            if (context.Clients.Any())
            {
                return;
            }

            //Clients
            var clients = new Client[]
            {
                new Client
                {
                    CompanyName = "Jonah Energy",
                    Location    = "Jonah Energy LLC, 83 Luman Road Pinedale, WY 82941, Boulder, WY 82923"
                },
                new Client
                {
                    CompanyName = "Linn Energy",
                    Location    = "E Oklahoma Ave, Ulysses, KS 67880"
                }
            };

            foreach (Client c in clients)
            {
                context.Clients.Add(c);
            }
            context.SaveChanges();

            // Client Password Table
            var clientPasswords = new ClientPassword[]
            {
                new ClientPassword
                {
                    ClientUserName  = "******",
                    ClientPasswords = "Password"
                }
            };

            foreach (ClientPassword p in clientPasswords)
            {
                context.ClientPasswords.Add(p);
            }
            context.SaveChanges();

            // Employee's
            var employees = new Employee[]
            {
                new Employee
                {
                    FirstName = "David",
                    LastName  = "Jones"
                },
                new Employee
                {
                    FirstName = "Nolan",
                    LastName  = "Jones"
                }
            };

            foreach (Employee e in employees)
            {
                context.Employees.Add(e);
            }
            context.SaveChanges();

            // Employee Passwords Table
            var employeePasswords = new EmployeePassword[]
            {
                new EmployeePassword
                {
                    EmployeeUserName  = "******",
                    EmployeePasswords = "Password"
                }
            };

            foreach (EmployeePassword ep in employeePasswords)
            {
                context.EmployeePasswords.Add(ep);
            }
            context.SaveChanges();

            // Gps Info table
            var gpsInfos = new GpsInfo[]
            {
                new GpsInfo
                {
                    GpsFile   = "file address",
                    Locations = "SHB 101",
                    Date      = DateTime.Parse("2019-07-10")
                }
            };

            foreach (GpsInfo g in gpsInfos)
            {
                context.GpsInfoes.Add(g);
            }
            context.SaveChanges();
        }