public static Track ConvertToTrack(string gpxString)
        {
            gpx.gpxType gpx = null;
            try
            {
                var xmlSerialize = new System.Xml.Serialization.XmlSerializer(typeof(gpx.gpxType));
                var stream       = new System.IO.StringReader(gpxString);
                gpx = (gpx.gpxType)xmlSerialize.Deserialize(stream);
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
                return(null);
            }

            Track track = new Track();

            track.TrackPoints = new List <TrackPoint>();
            track.StartTime   = gpx.metadata.timeSpecified ? (DateTime?)gpx.metadata.time : null;

            track.TrackPoints = new List <TrackPoint>();
            foreach (var i in gpx.trk)
            {
                foreach (var j in i.trkseg)
                {
                    foreach (var k in j.trkpt)
                    {
                        var p = new TrackPoint();
                        p.Altitude    = k.eleSpecified ? (double)k.ele : 0;
                        p.Latitude    = (double)k.lat;
                        p.Longitude   = (double)k.lon;
                        p.GpsTime     = k.timeSpecified ? k.time : DateTime.MinValue;
                        p.MessageTime = p.GpsTime;
                        p.VehicleName = gpx.creator;
                        p.Track       = track;

                        track.TrackPoints.Add(p);
                    }
                }
            }
            return(track);
        }
Exemple #2
0
        /// <summary>
        /// Occur when Load Thread is done
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void LoadWork_WorkerDone(object sender, WorkerDoneEventArgs <DataLoadedEventArgs> e)
        {
            // 当中途停止,e.Interrupted = true, result = null;
            DataLoadedEventArgs e2 = e.Result;

            try
            {
                if (this.DisplayManager != null && e2 != null && e2.DataSource != null)
                {
                    this.DisplayManager.SetDataBinding(e2.DataSource, string.Empty);
                }
            }
            finally
            {
                OnDataLoaded(e2);
            }

            if (e.Exception != null)
            {
                ExceptionProcess.ProcessWithNotify(e.Exception);
            }
        }
Exemple #3
0
        /// <summary>
        /// 按照自定义规则按照地址导航程序到某个界面
        /// http://cd/{action}/exp={exp}&order={order}&pos={pos}
        /// http://cd/action/查询统计_人员单位/?exp=编号 = 100000&order=编号&pos=1
        /// </summary>
        /// <param name="app"></param>
        /// <param name="address"></param>
        public static void NavigateTo(this IApplication app, string address)
        {
            if (string.IsNullOrEmpty(address) || !address.StartsWith(s_addressHeader))
            {
                return;
            }

            string content = address.Substring(s_addressHeader.Length);

            if (!content.Contains("action/"))
            {
                content = Decrypt(content);
                address = s_addressHeader + content;
            }

            UriTemplate template    = new UriTemplate("action/{action}/?exp={exp}&order={order}&pos={pos}");
            Uri         baseAddress = new Uri(s_addressHeader + SystemConfiguration.ApplicationName);
            Uri         fullUri     = new Uri(address);


            // Match a URI to a template
            UriTemplateMatch results = template.Match(baseAddress, fullUri);

            if (results != null && results.BaseUri == baseAddress)
            {
                try
                {
                    IDisplayManagerContainer dmC = app.ExecuteAction(results.BoundVariables["action"]) as IDisplayManagerContainer;
                    if (dmC == null)
                    {
                        return;
                    }
                    if (dmC.DisplayManager != null && dmC.DisplayManager.SearchManager != null)
                    {
                        var t = results.BoundVariables["first"];
                        if (t != null)
                        {
                            int?first = Feng.Utils.ConvertHelper.ToInt(t);
                            if (first.HasValue)
                            {
                                dmC.DisplayManager.SearchManager.FirstResult = first.Value;
                            }
                        }
                        t = results.BoundVariables["count"];
                        if (t != null)
                        {
                            int?count = Feng.Utils.ConvertHelper.ToInt(t);
                            if (count.HasValue)
                            {
                                dmC.DisplayManager.SearchManager.MaxResult = count.Value;
                            }
                        }
                        t = results.BoundVariables["exp"];
                        if (t != null)
                        {
                            var exp   = SearchExpression.Parse(t);
                            var order = SearchOrder.Parse(results.BoundVariables["order"]);

                            if (exp != null)
                            {
                                dmC.DisplayManager.SearchManager.LoadData(exp, order);
                                dmC.DisplayManager.Position = 0;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionProcess.ProcessWithNotify(ex);
                }
            }
        }