コード例 #1
0
        /*private void set_equipment(object sender, RoutedEventArgs e)
         * {
         *  if ((Boolean)((CheckBox)sender).IsChecked)
         *  {
         *      DataSourceSelectorEquipment.IsEnabled = true;
         *      //EquipmentUIDComboBox.IsEnabled = true;
         *      //EquipmentHFComboBox.IsEnabled = true;
         *      //EquipmentLabelComboBox.IsEnabled = true;
         *  }
         *  else
         *  {
         *      if (DataSources.Count > 1)
         *      {
         *          DataSources.Remove(DataSources[1]);
         *      }
         *      DataSourceSelectorEquipment.IsEnabled = false;
         *      //EquipmentUIDComboBox.IsEnabled = false;
         *      //EquipmentHFComboBox.IsEnabled = false;
         *      //EquipmentLabelComboBox.IsEnabled = false;
         *  }
         * }*/

        private async void AddDatasourceToCache(OOBDataSource ods)
        {
            try
            {
                String Uid       = ods.UIDField;
                String HF        = ods.HFField;
                String DF        = ods.DescField;
                String Labels    = "";
                String DescFlds  = "";
                String CacheName = ods.Key;
                Dictionary <String, String> fields = new Dictionary <String, String>();
                fields["UID"] = Uid;
                fields["HF"]  = HF;

                Int32 numBaseFlds = 2;
                if (DF != null)
                {
                    fields["DESCFIELD"] = DF;
                    numBaseFlds         = 3;
                }

                Int32    arraySize = ods.LabelFields.Count + ods.DescriptionFields.Count + numBaseFlds;
                string[] qfields   = new string[arraySize];
                qfields[0] = Uid;
                qfields[1] = HF;
                if (DF != null)
                {
                    qfields[2] = DF;
                }
                Int32   c     = numBaseFlds;
                Boolean first = true;
                foreach (String f in ods.LabelFields)
                {
                    if (!first)
                    {
                        Labels += ",";
                    }
                    else
                    {
                        first = false;
                    }
                    Labels    += f;
                    qfields[c] = f;
                    ++c;
                }
                first = true;
                foreach (String f in ods.DescriptionFields)
                {
                    if (!first)
                    {
                        DescFlds += ",";
                    }
                    else
                    {
                        first = false;
                    }
                    DescFlds  += f;
                    qfields[c] = f;
                    ++c;
                }
                fields["LABELS"]   = Labels;
                fields["DESCFLDS"] = DescFlds;
                Query q = new Query();



                q.Fields = qfields;
                cache.AddFeatuereContainer(CacheName);

                DataSource ds = ods.DataSource;
                q.ReturnGeometry = true;
                QueryResult res = await ds.ExecuteQueryAsync(q);

                var resultOids = from feature in res.Features select System.Convert.ToInt32(feature.Attributes[ds.ObjectIdFieldName]);

                MapWidget           mw = MapWidget.FindMapWidget(ds);
                client.FeatureLayer fl = mw.FindFeatureLayer(ds);
                //fl.Update();
                client.UniqueValueRenderer r = fl.Renderer as client.UniqueValueRenderer;
                foreach (client.Graphic g in fl.Graphics)
                {
                    cache.AddFeature(CacheName, g, ods.BaseDescription, ods.BaseLabel, fields, r);
                }
                ods.IsCacheCreated = true;

                //cache.AddFeature
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message + "/n" + e.Source
                                               + "/n" + e.StackTrace);
            }
        }
コード例 #2
0
 public OOBCacheTest()
 {
     cache = new OOBCache();
     cache.AddFeatuereContainer("UNITS");
     cache.AddFeatuereContainer("EQUIPMENT");
 }