예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.__timer.Enabled = false;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Debug.WriteLine(
                    string.Format("frmGPSReceiver.button2_Click  ->  = {0}"
                                  , saveFileDialog1.FileName));
                string  strPath = saveFileDialog1.FileName;
                DataSet ds      = new DataSet("Points");

                DataTable dt = new DataTable("point");
                dt.Columns.Add("time", typeof(string));
                dt.Columns.Add("latitude", typeof(string));
                dt.Columns.Add("longitude", typeof(string));
                ds.Tables.Add(dt);

                for (int i = 0; i < __pointList.Count; i++)
                {
                    CarPoint c = __pointList[i];
                    dt.Rows.Add(new object[] { c.strTime, c.strLatitude, c.strLongitude });
                }

                ds.WriteXml(strPath);
            }

            return;
        }
예제 #2
0
        // www.motathink.com
        void helper_RequestCompleted_return(object o)
        {
            deleControlInvoke dele = delegate(object op)
            {
                string strLocations = (string)op;
                Debug.WriteLine(
                    string.Format("frmGPSReceiver.helper_RequestCompleted_return  ->  = {0}"
                                  , strLocations));
                CarPoint c = (CarPoint)fastJSON.JSON.Instance.ToObject(strLocations, typeof(CarPoint));
                //如果返回的最新的位置不符合当前的时间要求,就不显示
                if (string.Compare(this.__timerStamp, c.Time) < 0)
                {
                    this.__timerStamp       = c.Time;
                    this.txtLocations.Text += c.toLocationString();
                    this.__pointList.Add(c);
                }
                //object olist = fastJSON.JSON.Instance.ToObjectList(strLocations, typeof(List<CarPoint>), typeof(CarPoint));
                //List<CarPoint> locationList = (List<CarPoint>)olist;
                //this.__pointList.AddRange(locationList);
                //for (int i = 0; i < locationList.Count; i++)
                //{
                //    //
                //    this.txtLocations.Text += locationList[i].toLocationString();
                //    if (i == locationList.Count - 1)
                //    {
                //        if (string.Compare(this.__timerStamp, locationList[i].strTime) < 0)
                //        {
                //            this.__timerStamp = locationList[i].strTime;
                //        }
                //    }
                //}
            };

            this.Invoke(dele, o);
        }
예제 #3
0
        void __timer_Tick(object sender, EventArgs e)
        {
            //this.__IP = "localhost";
            //string restUrl = "http://182.18.26.127:80/index.php/LogisTechBase/CarMonitorGet/getLatestCarPoints";
            string restUrl = "http://" + this.__IP + ":" + this.__port + "/index.php/LogisTechBase/CarMonitorGet/getLatestCarPoints";
            //Location l = new Location(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), this.__MobileName);
            CarPoint c = new CarPoint();

            c.strTime  = this.__timerStamp;
            c.strCarID = this.__MobileName;
            string         jsonString = fastJSON.JSON.Instance.ToJSON(c);
            HttpWebConnect helper     = new HttpWebConnect();

            helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_return);
            helper.TryPostData(restUrl, jsonString);
        }
예제 #4
0
        void __timer_Tick(object sender, EventArgs e)
        {
            try
            {
                string restUrl = "http://" + this.__IP + ":" + this.__port + "/index.php/GPSAPIPost/postCarPoint";
                //Location l = new Location(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), this.__MobileName);
                CarPoint c = new CarPoint();

                c.Latitude  = (double.Parse(this.txtLat.Text) * 3600000).ToString();
                c.Longitude = (double.Parse(this.txtLng.Text) * 3600000).ToString();
                c.Time      = this.__timerStamp;
                c.CarID     = this.__MobileName;
                string         jsonString = fastJSON.JSON.Instance.ToJSON(c);
                HttpWebConnect helper     = new HttpWebConnect();
                helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_return);
                // {"state":null,"strCarID":"J001","strTime":"2012-02-12 11:42:45","strLatitude":"0","strLongitude":"0"}
                helper.TryPostData(restUrl, jsonString);
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }