Beispiel #1
0
        public void DrowGraphical(string url)
        {
            WebAPIHelper  dt       = new WebAPIHelper();
            GraphicsLayer Cityrode = map.Layers["GraphicsLayerCq"] as GraphicsLayer;

            dt.GetDataCompleted += (s, args) =>
            {
                List <MapGraphical> list = args.DataResult as List <MapGraphical>;
                foreach (var model in list)
                {
                    SimpleFillSymbol style        = new SimpleFillSymbol();
                    string[]         str          = model.colour.Split(',');
                    List <MapPoint>  MapPointList = new List <MapPoint>();
                    foreach (var po in model.MapPointList)
                    {
                        MapPointList.Add(new MapPoint {
                            X = po.X, Y = po.Y
                        });
                    }
                    //Color ColorFill = ConvertToHtml(model.colour);
                    Graphic graphic = new Graphic();
                    style.Fill = new SolidColorBrush(Color.FromArgb(0x7f, Convert.ToByte(str[0]), Convert.ToByte(str[1]), Convert.ToByte(str[2])));
                    ESRI.ArcGIS.Client.Geometry.PointCollection pCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection(MapPointList);
                    ESRI.ArcGIS.Client.Geometry.Polygon         g           = new ESRI.ArcGIS.Client.Geometry.Polygon();
                    g.Rings.Add(pCollection);
                    graphic.Geometry = g;
                    graphic.Symbol   = style;
                    //ESRI.ArcGIS.Client.Geometry.Polygon polygon = (ESRI.ArcGIS.Client.Geometry.Polygon)graphic.Geometry;
                    //GraphicsLayerCq
                    Cityrode.Graphics.Add(graphic);
                }
            };
            dt.GetDataAsync <List <MapGraphical> >(url);
        }
Beispiel #2
0
        private void GetAllPersons(string value)
        {
            ContainerManager.ToastTip.Text     = "正在加载..";
            ContainerManager.ToastTip.IsOpened = true;

            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                List <MapElement> _currentList  = args.DataResult as List <MapElement>;
                List <MapElement> _positionList = _currentList.Where(m => m.X != null).ToList();
                //var list = _positionList.Where(m => m.MapElementCategoryID == _mapElementCategoryID).Distinct(new SchoolComparer()).ToList();
                //List<Image> img = getImage(_mapElementCategoryID);
                Dictionary <int, Image> imglist = GetIconUrl(_mapElementCategoryID);
                foreach (MapElement obj in _positionList)
                {
                    if (obj.X == null)
                    {
                        continue;
                    }
                    //MarkerMapElement element = new MarkerMapElement(obj, 0, ContainerManager.Map, LayerManager.ElementLayer);
                    MarkerMapElement element = new MarkerMapElement(obj, 0, ContainerManager.Map, LayerManager.ElementLayer, imglist);
                    element.AddToMap();
                    _currentMapElementList.Add(element);
                }

                //ContainerManager.Map.Extent = GpsHelper.MapExtent4Road(_currentList);
            };

            _results["ReservedField1"] = value;
            string url = "api/MapElement/Query";

            dt.GetDataAsync <List <MapElement> >(url, _results);
        }
Beispiel #3
0
        public void BindRadTreeView()
        {
            WebAPIHelper dt1 = new WebAPIHelper();

            dt1.GetDataCompleted += (s, args) =>
            {
                IList <Region> RL  = args.DataResult as IList <Region>;
                List <Region>  pRL = RL.Where(a => a.ParentID == 0 && a.Code != "-100").ToList();
                foreach (var c in pRL)
                {
                    RadTreeViewItem parentitem = new RadTreeViewItem();
                    parentitem.Style  = App.Current.Resources["RadTreeViewItemStyle1"] as Style;
                    parentitem.Header = c.Name;
                    List <Region> cRL = RL.Where(a => a.ParentID == c.ID).ToList();
                    foreach (var child in cRL)
                    {
                        RadTreeViewItem childitem = new RadTreeViewItem();
                        childitem.Style           = App.Current.Resources["RadTreeViewItemStyle1"] as Style;
                        childitem.Header          = child.Name;
                        childitem.DefaultImageSrc = "/Techzen.ICS.CS.Controls;component/Images/sousuo.png";

                        parentitem.Items.Add(childitem);
                    }
                    radTreeView.Items.Add(parentitem);
                }
            };
            string statUrl1 = "/api/Region/Query";

            dt1.GetDataAsync <List <Region> >(statUrl1);
        }
Beispiel #4
0
        private void GetAllRound(double radius, string categoriesID, MapElement entity, string value)
        {
            ContainerManager.ToastTip.Text     = "正在加载..";
            ContainerManager.ToastTip.IsOpened = true;

            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                List <MapElement> currentList = args.DataResult as List <MapElement>;

                //   listWindow.DataSource = currentList;

                foreach (MapElement obj in currentList)
                {
                    MarkerMapElement element = new MarkerMapElement(obj.ID, obj.MapElementCategoryID, obj.ReservedField1, new Point((double)obj.X, (double)obj.Y), 0, ContainerManager.Map, LayerManager.ElementLayer);
                    element.AddToMap();
                    _currentMarkerMapElementList.Add(element);
                }

                //ContainerManager.Map.Extent = Helper.GpsHelper.MapExtent4Road(currentList);
            };

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("MapElementCategoryIDArr", categoriesID);
            string url = String.Format(@"api/MapElementCoord/GetNearList?x={0}&y={1}&radius={2}", (double)entity.X, (double)entity.Y, radius);

            dt.GetDataAsync <List <MapElement> >(url, dic);
        }
Beispiel #5
0
        private void _tzPlayback_Playing(object sender, EventArgs e)
        {
            if (this._tzPlayback.IsPaused)
            {
                this._tzPlayback.Play(this._gpsPointList);
            }
            else
            {
                this.rbiLoad.IsBusy        = true;
                this._tzPlayback.IsEnabled = false;

                WebAPIHelper dt = new WebAPIHelper();

                dt.GetDataCompleted += (s, args) =>
                {
                    this.rbiLoad.IsBusy        = false;
                    this._tzPlayback.IsEnabled = true;

                    List <GPSPoint> list = args.DataResult as List <GPSPoint>;

                    //if (list == null || list.Count == 0)
                    //{
                    //    this.toastTip.Text = "暂无定位数据";
                    //    this.toastTip.IsOpened = true;
                    //    return;
                    //}

                    this._gpsPointList = list;//list.Where(t => t.Longitude != null && t.Latitude != null && t.X != null & t.Y != null)
                    //.Select(t => new GPSPoint()
                    //{
                    //    Longitude = (double)t.Latitude,
                    //    Latitude = (double)t.Latitude,
                    //    X = (double)t.X,
                    //    Y = (double)t.Y,
                    //    Speed = t.Speed == null ? 0 : (int)t.Speed,
                    //    StartTime = t.SatelliteTime,
                    //    EndTime = t.SatelliteTime
                    //}).ToList();

                    //double x1 = (double)list.Min(m => m.X);
                    //double y1 = (double)list.Min(m => m.Y);
                    //double x2 = (double)list.Max(m => m.X);
                    //double y2 = (double)list.Max(m => m.Y);
                    //new ESRI.ArcGIS.Client.Geometry.Envelope(x1, y1, x2, y2);

                    this._tzPlayback.Play(this._gpsPointList);
                };
                string url = string.Format(_url, Convert.ToDateTime(_tzPlayback.StartTime).ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToDateTime(_tzPlayback.EndTime).ToString("yyyy-MM-dd HH:mm:ss"));
                dt.GetDataAsync <List <GPSPoint> >(url);
            }

            //this._tzPlayback.Play(GetTestGPSPoints());
        }
Beispiel #6
0
        private void BindData()
        {
            List <FolderView> folders = new List <FolderView>();

            WebAPIHelper dt1 = new WebAPIHelper();

            dt1.GetDataCompleted += (s, args) =>
            {
                IList <Region> cps = args.DataResult as IList <Region>;

                WebAPIHelper dt2 = new WebAPIHelper();
                dt2.GetDataCompleted += (s2, args2) =>
                {
                    IList <Region> cps2 = args2.DataResult as IList <Region>;

                    foreach (Region item in cps)
                    {
                        FolderView folder = new FolderView();
                        folder.Name       = item.Name;
                        folder.Visibility = "Collapsed";

                        IList <Region>     iRegion        = cps2.Where(d => d.ParentID == item.ID).ToList();
                        IList <FolderView> folderChildren = new List <FolderView>();

                        foreach (Region children in iRegion)
                        {
                            FolderView fv = new FolderView();

                            fv.Name       = children.Name;
                            fv.Visibility = "Visible";
                            fv.Children   = null;

                            folderChildren.Add(fv);
                        }
                        folder.Children = folderChildren;
                        folders.Add(folder);
                    }

                    this.treeView.ItemsSource = folders;
                };
                string statUrl2 = "/api/Region/Query";
                Dictionary <string, object> itemFilters2 = new Dictionary <string, object>();
                itemFilters2.Add("RegionTypeID", 3);
                dt2.GetDataAsync <List <Region> >(statUrl2, itemFilters2);
            };
            string statUrl1 = "/api/Region/Query";
            Dictionary <string, object> itemFilters1 = new Dictionary <string, object>();

            itemFilters1.Add("RegionTypeID", 2);
            dt1.GetDataAsync <List <Region> >(statUrl1, itemFilters1);
        }
Beispiel #7
0
        //种类
        private void categories_Load()
        {
            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                rbiLoad.IsBusy = true;

                List <MapElementCategorie> _dataList = args.DataResult as List <MapElementCategorie>;

                TZCheckBox cbtnAll = new TZCheckBox();
                cbtnAll.Value               = -1;
                cbtnAll.Content             = "全部";
                cbtnAll.Foreground          = new SolidColorBrush(Colors.White);
                cbtnAll.Width               = 120;
                cbtnAll.Margin              = new Thickness(10, 6, 0, 0);
                cbtnAll.HorizontalAlignment = HorizontalAlignment.Left;
                cbtnAll.IsChecked           = true;
                cbtnAll.Checked            += CbtnAll_Checked;
                cbtnAll.Unchecked          += CbtnAll_Unchecked;

                wpZL.Children.Add(cbtnAll);

                foreach (var item in _dataList)
                {
                    TZCheckBox cbtn = new TZCheckBox();
                    cbtn.Value               = item.ID;
                    cbtn.Content             = item.Name;
                    cbtn.Foreground          = new SolidColorBrush(Colors.White);
                    cbtn.Width               = 120;
                    cbtn.Margin              = new Thickness(10, 6, 0, 0);
                    cbtn.HorizontalAlignment = HorizontalAlignment.Left;
                    cbtn.Checked            += Cbtn_Checked;
                    cbtn.Unchecked          += Cbtn_Unchecked;
                    cbtn.IsChecked           = true;

                    wpZL.Children.Add(cbtn);
                }

                rbiLoad.IsBusy = false;
            };

            string url = "api/MapElementCategorie/Query";

            dt.GetDataAsync <List <MapElementCategorie> >(url);
        }
Beispiel #8
0
        private void GetPersons(string value)
        {
            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                list = args.DataResult as MapElementPaging;
                _listWindow.ItemCount = list.Total;
                CreateItems(columnList, list.Items);
            };

            _results["ReservedField1"] = value;
            int    pageIndex = this._listWindow.PageIndex + 1;
            string url       = "api/MapElement/Query?pageSize=10&currentPage=" + pageIndex;

            dt.GetDataAsync <MapElementPaging>(url, _results);
        }
Beispiel #9
0
        private void GetMonitors(string value)
        {
            MessageBox.Show("GetMonitors" + this.listWindow.PageIndex);

            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                list = args.DataResult as MapElementPaging;
                listWindow.DataSource = list.Items;
                listWindow.ItemCount  = list.Total;
            };
            _results["ReservedField1"] = value;
            int    pageIndex = this.listWindow.PageIndex + 1;
            string url       = "api/MapElement/Query?pageSize=10&currentPage=" + pageIndex;

            dt.GetDataAsync <MapElementPaging>(url, _results);
        }
Beispiel #10
0
        private void OnTimedEvent(object sender, EventArgs e)
        {
            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                List <MapElement> _currentList = args.DataResult as List <MapElement>;
                _currentList           = _currentList.Where(m => m.X > 0).ToList();
                _currentMapElementList = _currentMapElementList.OrderBy(m => m.ID).ToList();

                List <MapElement> list =
                    (from a in _currentList
                     join b in _currentMapElementList on a.ID equals b.ID
                     select new MapElement()
                {
                    ID = a.ID,
                    X = a.X,
                    Y = a.Y,
                    Latitude = (decimal?)b.Point.X,
                    Longitude = (decimal?)b.Point.Y
                }).OrderBy(m => m.ID).ToList();

                for (int i = 0; i < list.Count; i++)
                {
                    if (Math.Round((double)list[i].X) == Math.Round((double)list[i].Latitude) && Math.Round((double)list[i].Y) == Math.Round((double)list[i].Longitude))
                    {
                        continue;
                    }
                    Point point = new Point();
                    point.X = (double)list[i].X;
                    point.Y = (double)list[i].Y;
                    _currentMapElementList[i].BeginMoveTo(point);
                }
            };

            _results.Remove("ReservedField1");
            _results.Add("ReservedField1", _value);
            _results["MapElementCategoryID"] = _mapElementCategoryID;
            string url = "api/MapElement/Query";

            dt.GetDataAsync <List <MapElement> >(url, _results);
        }
Beispiel #11
0
        private void GetRound(double radius, string categoriesID, MapElement entity, string value)
        {
            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                MapElementPaging list = args.DataResult as MapElementPaging;
                listWindow.DataSource = list.Items;
                listWindow.ItemCount  = list.Total;
            };

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("MapElementCategoryIDArr", categoriesID);
            dic.Add("ReservedField1", value);
            int    pageIndex = this.listWindow.PageIndex + 1;
            string url       = String.Format(@"api/MapElementCoord/GetNearList?pageSize=10&currentPage={0}&x={1}&y={2}&radius={3}", pageIndex, (double)entity.X, (double)entity.Y, radius);

            dt.GetDataAsync <MapElementPaging>(url, dic);
        }
Beispiel #12
0
        public void CreateMonitorListWindow()
        {
            TZMonitor.Width  = 230;
            TZMonitor.Height = 450;

            TextBlock t  = CreateHeadTextBlock("名称", new Thickness(4, 0, 0, 0));
            TextBlock t1 = CreateHeadTextBlock("类型", new Thickness(121, 0, 0, 0));

            listWindow.ELWListHeader.Children.Add(t);
            listWindow.ELWListHeader.Children.Add(t1);

            listWindow.WatermarkContent = "请输入名称";
            listWindow.ListDataTemplate = listDataTemplate;

            WebAPIHelper dt = new WebAPIHelper();

            dt.GetDataCompleted += (s, args) =>
            {
                list = args.DataResult as MapElementPaging;
                listWindow.DataSource = list.Items;
                listWindow.ItemCount  = list.Total;
            };

            Dictionary <string, object> dic = new Dictionary <string, object>();
            //dic.Add("MapElementCategoryIDArr", 1);
            // dic.Add("ReservedField1", "");
            int    pageIndex = listWindow.PageIndex + 1;
            string url       = String.Format(@"api/MapElement/Query?pageSize=10&currentPage={0}", pageIndex);

            dt.GetDataAsync <MapElementPaging>(url);



            listWindow.PositionAllButtonClick += listWindow_PositionAllButtonClick;
            listWindow.ELWSearcherButtonClick += listWindow_ELWSearcherButtonClick;
            listWindow.PagerIndexChanged      += listWindow_PagerIndexChanged;
        }
Beispiel #13
0
        private void Info_Init()
        {
            List <SystemConfig> configList = new List <SystemConfig>();

            List <SystemConfig> detailsConfig = ContainerManager.SystemConfigs.GetSystemConfigs("MapElement", _mapElement.MapElementCategoryID, "MapInfoPanel");

            string controlMode = detailsConfig.Where(t => t.Name == "ControlMode").FirstOrDefault().Value;
            string controlName = detailsConfig.Where(t => t.Name == "ControlName").FirstOrDefault().Value;
            string displayMode = detailsConfig.Where(t => t.Name == "DisplayMode").FirstOrDefault().Value;


            //标题
            this.detailTitle.Text = "详情";

            //控件模式
            switch (controlMode)
            {
            case "Auto":        //自动生成
                SystemConfig        tempConfig = detailsConfig.Where(t => t.Name == "FieldItems").FirstOrDefault();
                List <SystemConfig> dsList     = ContainerManager.SystemConfigs.GetSystemConfigs(tempConfig);

                if (displayMode == "Data")
                {
                    #region 数据显示模式

                    for (int i = 0; i < dsList.Count; i++)
                    {
                        List <SystemConfig> itemConfig = ContainerManager.SystemConfigs.GetSystemConfigs(dsList[i]);
                        if (itemConfig.Count == 0)
                        {
                            break;
                        }
                        string name;
                        string bindField;
                        string value;

                        #region 获得配置信息

                        name      = itemConfig.Where(t => t.Name == "Name").FirstOrDefault().Value;
                        bindField = itemConfig.Where(t => t.Name == "BindField").FirstOrDefault().Value;
                        value     = bindField.IndexOf('.') == -1 ? GetFieldValue(bindField) : GetXMLFieldValue(bindField);

                        TZPanelItem pItem = new TZPanelItem();
                        pItem.NameText  = name;
                        pItem.ValueText = value;
                        this.infoPanel.Children.Add(pItem);

                        #endregion
                    }
                    #endregion
                }
                else if (displayMode == "Avatar")
                {
                    //创建详情面板
                    Grid grid = new Grid()
                    {
                        Margin = new Thickness(5, 8, 0, 8)
                    };

                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(80, GridUnitType.Pixel)
                    });
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    });

                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(5, GridUnitType.Star)
                    });
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(5, GridUnitType.Star)
                    });

                    this.infoPanel.Children.Insert(0, grid);

                    StackPanel topPanel = new StackPanel()
                    {
                        VerticalAlignment = VerticalAlignment.Center
                    };

                    topPanel.SetValue(Grid.RowProperty, 0);
                    topPanel.SetValue(Grid.ColumnProperty, 1);
                    grid.Children.Add(topPanel);

                    Image avatarImage = new Image()
                    {
                        Stretch             = Stretch.Uniform,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(0, 0, 5, 0),
                        Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(this._mapElement.Avatar == null ? "" : this._mapElement.Avatar, UriKind.RelativeOrAbsolute))
                    };

                    avatarImage.SetValue(Grid.RowProperty, 0);
                    avatarImage.SetValue(Grid.ColumnProperty, 0);
                    grid.Children.Add(avatarImage);

                    WrapPanel contentPanel = new WrapPanel();

                    contentPanel.SetValue(Grid.RowProperty, 1);
                    contentPanel.SetValue(Grid.ColumnSpanProperty, 2);
                    grid.Children.Add(contentPanel);

                    for (int i = 0; i < dsList.Count; i++)
                    {
                        List <SystemConfig> itemConfig = ContainerManager.SystemConfigs.GetSystemConfigs(dsList[i]);
                        string name;
                        string bindField;
                        string value;

                        #region 获得配置信息
                        name      = itemConfig.Where(t => t.Name == "Name").FirstOrDefault().Value;
                        bindField = itemConfig.Where(t => t.Name == "BindField").FirstOrDefault().Value;
                        value     = bindField.IndexOf('.') == -1 ? GetFieldValue(bindField) : GetXMLFieldValue(bindField);

                        #endregion

                        if (i > 2)
                        {
                            TZPanelItem itemControl = new TZPanelItem()
                            {
                                NameText            = name,
                                ValueText           = value,
                                HorizontalAlignment = HorizontalAlignment.Left,
                                Margin = new Thickness(0, 5, 5, 0)
                            };

                            contentPanel.Children.Add(itemControl);
                        }
                        else
                        {
                            TextBlock itemControl = new TextBlock()
                            {
                                Text = value,
                                HorizontalAlignment = HorizontalAlignment.Left,
                                Margin = new Thickness(6),
                                Style  = Application.Current.Resources["DefaultTextBlockStyle3"] as Style
                            };
                            topPanel.Children.Add(itemControl);
                        }
                    }
                }
                break;

            case "Custom":      //自定义
                //UIElement customControl = Activator.CreateInstance(Type.GetType(controlName)) as UIElement;
                //PropertyInfo propInfo = customControl.GetType().GetProperty("MapElement");
                //propInfo.SetValue(customControl, this._mapElement, null);
                //this.Content = customControl;
                break;
            }

            SystemConfig        tempBtnItemsConfig = detailsConfig.Where(t => t.Name == "ButtonItems").FirstOrDefault();
            List <SystemConfig> btnItems           = ContainerManager.SystemConfigs.GetSystemConfigs(tempBtnItemsConfig);

            foreach (SystemConfig btnItem in btnItems)
            {
                List <SystemConfig> itemPropertys = ContainerManager.SystemConfigs.GetSystemConfigs(btnItem);

                string type     = itemPropertys.Where(t => t.Name == "Type").FirstOrDefault().Value;
                string tooltip  = itemPropertys.Where(t => t.Name == "Tooltip").FirstOrDefault().Value;
                string imageUrl = itemPropertys.Where(t => t.Name == "ImageUrl").FirstOrDefault().Value;
                string command  = itemPropertys.Where(t => t.Name == "Command").FirstOrDefault().Value;

                ConfigHelper.ProcessImageUrl(ref imageUrl);

                Image btn = new Image()
                {
                    Height  = 18,
                    Width   = 18,
                    Stretch = Stretch.Uniform,
                    Source  = new System.Windows.Media.Imaging.BitmapImage(new Uri(imageUrl, UriKind.RelativeOrAbsolute)),
                    Cursor  = Cursors.Hand
                };

                if (btnItems.IndexOf(btnItem) > 0)
                {
                    btn.Margin = new Thickness(10, 0, 0, 0);
                }

                switch (type)
                {
                case "Details":
                    btn.MouseLeftButtonUp += imgDetails_MouseLeftButtonUp;
                    break;

                case "Playback":
                    btn.MouseLeftButtonUp += imgTrajectory_MouseLeftButtonUp;
                    break;

                case "Round":
                    btn.MouseLeftButtonUp += imgRound_MouseLeftButtonUp;
                    break;

                case "Custom":
                    btn.MouseLeftButtonUp += imgDetails_MouseLeftButtonUp;
                    break;

                case "Cells":
                    btn.MouseLeftButtonUp += imgCells_MouseLeftButtonUp;
                    break;

                default:
                    break;
                }
                this.buttonItems.Children.Add(btn);
            }



            if (this._mapElement.MapElementCategoryID == 1)
            {
                this.tbLastLocationPanel.Visibility = Visibility.Visible;

                //最后定位时间
                WebAPIHelper dt = new WebAPIHelper();

                dt.GetDataCompleted += (s, args) =>
                {
                    MapElementHisCoord entity = args.DataResult as MapElementHisCoord;

                    if (entity != null)
                    {
                        DateTime nowTime     = DateTime.Now;
                        DateTime historyTime = entity.SatelliteTime;
                        TimeSpan ts          = nowTime.Subtract(historyTime).Duration();

                        if (ts.TotalMinutes > 0)
                        {
                            if (ts.TotalMinutes <= 60)
                            {
                                tbLastLocation.Text = string.Format("{0}分钟前", Convert.ToInt32(ts.TotalMinutes));
                            }
                            else if (ts.TotalHours <= 24)
                            {
                                tbLastLocation.Text = string.Format("{0}小时前", Convert.ToInt32(ts.TotalHours));
                            }
                            else
                            {
                                tbLastLocation.Text = string.Format("{0}天前", Convert.ToInt32(ts.TotalDays));
                            }
                        }
                    }
                };

                string url = String.Format("api/MapElementHisCoord/GetNew?mapElementCategoryID=1&mapElementID={0}", this._id);

                dt.GetDataAsync <MapElementHisCoord>(url);
            }
            else
            {
                this.tbLastLocationPanel.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #14
0
        public void CreateFilter(int typeID)
        {
            if (filterGrid != null)
            {
                this.filterGrid.Children.Clear();
            }

            List <SystemConfig> filterConfigs = ContainerManager.SystemConfigs.GetMapElementConfigs(typeID, "FilterWindow");

            //获得元素种类信息
            SystemConfig        itemsConfig = filterConfigs.Where(t => t.Name == "Filters").FirstOrDefault();
            List <SystemConfig> fsList      = ContainerManager.SystemConfigs.GetSystemConfigs(itemsConfig);

            //List<FilterModel> FilterModelList = new List<FilterModel>();
            ////获得筛选条件
            //FilterModel filte = new FilterModel()
            //{
            //    Name = "监控类型",
            //    FilterType = "Region",
            //    Height = "150"
            //};
            //FilterModel filte1 = new FilterModel()
            //{
            //    Name = "监控来源",
            //    FilterType = "Region",
            //    Height = "150"
            //};
            //FilterModel filte2 = new FilterModel()
            //{
            //    Name = "所属乡镇",
            //    FilterType = "Region",
            //    Height = "150"
            //};
            //FilterModelList.Add(filte);
            //FilterModelList.Add(filte1);
            //FilterModelList.Add(filte2);
            //循环生成筛选条件
            foreach (var f in fsList)
            {
                List <SystemConfig> fiConfig = ContainerManager.SystemConfigs.GetSystemConfigs(f);
                //获得筛选项配置
                string filterType;
                string name;
                double?height;

                #region 获得配置信息
                filterType = fiConfig.Where(t => t.Name == "FilterType").FirstOrDefault().Value;   //f.FilterType;

                name = fiConfig.Where(t => t.Name == "Name").FirstOrDefault().Value;               //f.Name;

                string strHeight = fiConfig.Where(t => t.Name == "Height").FirstOrDefault().Value; //f.Height;

                if (!string.IsNullOrEmpty(strHeight))
                {
                    height = double.Parse(strHeight);
                }
                else
                {
                    height = null;
                }
                #endregion

                //分组名称
                //sco.Content = filterGrid;
                string groupName = fiConfig.Where(t => t.Name == "Name").FirstOrDefault().Value; //f.Name;

                //生成一级筛选分组
                TZFilterGroup filterGroup = CreateFilterGroup(filterGrid, groupName, name, height);
                this._filterValues[filterGroup.Name] = -1;

                WebAPIHelper itemDt = new WebAPIHelper();

                itemDt.GetDataCompleted += (a, b) =>
                {
                    List <JObject> typeList = b.DataResult as List <JObject>;
                    foreach (var obj in typeList)
                    {
                        Statistic statEntity = new Statistic()
                        {
                            MapElementCategoryID = 1,
                            ID       = Convert.ToInt32(obj.GetValue("ID").ToString()),
                            Name     = obj.GetValue("Name").ToString(),
                            Onlines  = 0,
                            Offlines = 0,
                            Totals   = 0
                        };
                        TZFilterGroupItem itemControl = CreateFilterGroupItem(statEntity, filterType, filterType, -1);
                        filterGroup.Items.Add(itemControl);
                    }
                };

                Dictionary <string, object> itemFilters = new Dictionary <string, object>();
                itemFilters.Add("Level", "2");

                string itemTypeUrl = string.Format("api/{0}/Query", filterType);
                itemDt.GetDataAsync <List <JObject> >(itemTypeUrl, itemFilters);
            }
        }