Esempio n. 1
0
        void loadSiteSensor(vwSiteDegree site)
        {
            MapApplication.Web.DbContext db = new Web.DbContext();

            string site_id = site.SITE_ID;
            if (sensorsCollection != null)
                sensorsCollection.Clear();

                EntityQuery<vwSensorDegree> qry = from n in db.GetVwSensorDegreeQuery() where n.SITE_ID == site_id select n;
                LoadOperation<vwSensorDegree> lo = db.Load<vwSensorDegree>(qry);
                lo.Completed += (s, a) =>
                    {
                        if (lo.Error != null)
                        {
                            MessageBox.Show(lo.Error.Message);
                            return;

                        }
                        dictSensors.Clear();
                        sensorsCollection = new ObservableCollection<vwSensorDegree>(lo.Entities);
                        this.lstMenu.ItemTemplate = this.Resources["SITE_VIEW_TEMPLATE"] as DataTemplate;
                        this.lstMenu.ItemsSource = sensorsCollection;
                        foreach (vwSensorDegree sensorInfo in sensorsCollection)
                        {
                            ElementLayer lyr = this.map1.Layers["sensorLyr"] as ElementLayer;
                            Sensor sensor = new Sensor();

                            MapPoint mp = ConvertMapPointTo102100(new MapPoint((double)sensorInfo.X, (double)sensorInfo.Y));
                            sensor.DataContext = sensorInfo;

                            ElementLayer.SetEnvelope(sensor, new Envelope(mp, mp));
                            dictSensors.Add(sensorInfo.SENSOR_ID, sensor);
                            lyr.Children.Add(sensor);

                        }

                    };
        }
Esempio n. 2
0
        void loadSiteSensor(vwSiteDegree site)
        {
            MapApplication.Web.DbContext db = new Web.DbContext();

            string site_id = site.SITE_ID;
            if (sensorsCollection != null)
                sensorsCollection.Clear();

                EntityQuery<vwSensorDegree> qry = from n in db.GetVwSensorDegreeQuery() where n.SITE_ID == site_id select n;
                LoadOperation<vwSensorDegree> lo = db.Load<vwSensorDegree>(qry);
                lo.Completed += (s, a) =>
                    {
                        if (lo.Error != null)
                        {
                            MessageBox.Show(lo.Error.Message);
                            return;

                        }
                        dictSensors.Clear();
                        sensorsCollection = new ObservableCollection<vwSensorDegree>(lo.Entities);
                        this.lstMenu.ItemTemplate = this.Resources["SITE_VIEW_TEMPLATE"] as DataTemplate;
                        this.lstMenu.ItemsSource = sensorsCollection;
                        foreach (vwSensorDegree sensorInfo in sensorsCollection)
                        {
                            ElementLayer lyr = this.map1.Layers["sensorLyr"] as ElementLayer;
                            Sensor sensor = new Sensor();

                            MapPoint mp = ConvertMapPointTo102100(new MapPoint((double)sensorInfo.X, (double)sensorInfo.Y));
                            sensor.DataContext = sensorInfo;

                            ElementLayer.SetEnvelope(sensor, new Envelope(mp, mp));
                            dictSensors.Add(sensorInfo.SENSOR_ID, sensor);
                            lyr.Children.Add(sensor);

                        }

                    };
                EntityQuery<tblTC> qBA = from n in db.GetTblTCQuery() where n.SITE_ID == this.CURRENT_SITE_ID && n.DEVICE_TYPE == "BA" select n;
                LoadOperation<tblTC> loBA = db.Load<tblTC>(qBA);
                loBA.Completed += (s, a) =>
                {
                    if (loBA.Error != null)
                    {
                        MessageBox.Show(lo.Error.Message);
                        return;
                    }
                    if (loBA.Entities.Count() == 0)
                        txtBA.Visibility = System.Windows.Visibility.Collapsed;
                    else
                    {
                        txtBA.Visibility = System.Windows.Visibility.Visible;
                        if (loBA.Entities.FirstOrDefault().ISCONNECTED == "N")
                            txtBA.Foreground = new SolidColorBrush(Colors.Gray);
                        else
                            txtBA.Foreground = new SolidColorBrush(Colors.Green);
                    }

                };
        }