These classes read the configuration file to setup deed drafter.
Пример #1
0
        private bool ReadBaseLayer(XmlDocument xmlDocument, string xmlTag, ref List <LayerDefinition> layers)
        {
            XmlNode xmlParentNode = xmlDocument.SelectSingleNode(_root + xmlTag);

            if (xmlParentNode == null)
            {
                return(false);
            }

            XmlAttributeCollection amlAttributes = xmlParentNode.Attributes;

            string url;

            if (!GetValue(amlAttributes, "url", out url))
            {
                return(false);
            }

            // Layer name is never displayed, no name search of display fields, base layers are always tiled.
            LayerDefinition layerDef = new LayerDefinition(url, "0", "", "", "BaseLayer", "", "tiled");

            layers.Insert(0, layerDef);

            return(true);
        }
Пример #2
0
        private void RunFindParcelQuery(LayerDefinition layerDefn)
        {
            QueryTask queryTask = new QueryTask(layerDefn.Layer());

            if (queryTask == null)
            {
                return;
            }

            queryTask.ExecuteCompleted += QueryLayer_ExecuteCompleted;
            queryTask.Failed           += QueryLayer_Failed;
            queryTask.CancelAsync();

            Query query = new ESRI.ArcGIS.Client.Tasks.Query();

            query.OutFields.AddRange(layerDefn.AllFields);
            query.ReturnGeometry      = true;
            query.OutSpatialReference = ParcelMap.SpatialReference;

            // if the upper function is null/empty (it defaults to UPPER), then
            // an exact case search is performed.

            string upper = _xmlConfiguation.UpperFunction;
            string wild  = _xmlConfiguation.WildcardCharacter;
            string endFn = "";

            if (upper != "")
            {
                upper += "(";
                endFn  = ")";
            }

            // if the wide card function is null/empty (it defaults to %), then
            // an exact search (case and value) is performed.

            string where = "";
            foreach (string field in layerDefn.SearchFields)
            {
                if (where != "")
                {
                    where += " or ";
                }

                if (wild == "")
                {
                    where += "(" + field + " = '" + SearchItem.Text + "')";
                }
                else
                {
                    where += "(" + upper + field + endFn + " like '" + wild + SearchItem.Text.ToUpper() + wild + "')";
                }
            }
            query.Where = where;

            queryTask.ExecuteAsync(query, layerDefn);
        }
Пример #3
0
        private void QueryLayer_Failed(object sender, TaskFailedEventArgs args)
        {
            LayerDefinition layerDefn = (LayerDefinition)args.UserState;

            System.Threading.Interlocked.Increment(ref _queryAttributeComplete);
            if (_queryAttributeCount == _queryAttributeComplete)
            {
                Loading.Visibility = System.Windows.Visibility.Collapsed;
            }

            MessageBox.Show(layerDefn.Layer() + "\n\n" + (string)Application.Current.FindResource("strQueryServiceSupport") + "\n\n" + args.Error, (string)Application.Current.FindResource("strQueryServiceFailed"));
        }
Пример #4
0
        private bool ReadLayerInfo(XmlDocument xmlDocument, string xmlTag, ref List <LayerDefinition> layers, ref List <LayerDefinition> snapLayers, ref List <LayerDefinition> displayLayers)
        {
            XmlNode xmlParentNode = xmlDocument.SelectSingleNode(_root + xmlTag);

            if (xmlParentNode == null)
            {
                return(false);
            }

            XmlAttributeCollection amlAttributes = xmlParentNode.Attributes;

            string value, parentUrl = "";

            if (GetValue(amlAttributes, "url", out value))
            {
                parentUrl = value;
            }

            XmlNodeList nodeList = xmlParentNode.SelectNodes("operationalLayer");

            foreach (XmlNode xmlNode in nodeList)
            {
                string url, displayFields, searchFields, name, id, type, tooltip;

                amlAttributes = xmlNode.Attributes;

                GetValue(amlAttributes, "name", out name);

                GetValue(amlAttributes, "tooltip", out tooltip);

                GetValue(amlAttributes, "searchFields", out searchFields);

                GetValue(amlAttributes, "displayFields", out displayFields);
                if (displayFields == "")
                {
                    displayFields = searchFields;
                }

                if (!GetValue(amlAttributes, "id", out id))
                {
                    System.Diagnostics.Debug.WriteLine("Missing ID on layer. Layer {0} skipped.", name);
                    continue;
                }

                if (!GetValue(amlAttributes, "url", out url))
                {
                    url = parentUrl;
                }
                if (url.Length == 0)
                {
                    System.Diagnostics.Debug.WriteLine("Missing URL on layer. Layer {0} skipped.", name);
                    continue;
                }

                if (!GetValue(amlAttributes, "type", out type))
                {
                    if (url.Contains(@"/FeatureServer"))
                    {
                        type = "feature";
                    }
                    else if (url.Contains(@"/MapService"))
                    {
                        type = "dynamic";
                    }
                    else if (url.Contains(@"/ImageService"))
                    {
                        type = "image";
                    }

                    // Since tiled services use a MapService URL, we can't default to this. Tiled services
                    // are generally stated as a base layer (in this app), where tiled is the only option. Thus,
                    // define your tile service as a base layer. If it needs to be an operational layer, set its
                    // type to "tiled".
                }

                LayerDefinition layerDef = new LayerDefinition(url, id, displayFields, searchFields, name, tooltip, type);

                if (GetValue(amlAttributes, "draw", out value) && (value.ToLower() == "true"))
                {
                    layers.Insert(0, layerDef);
                }

                if ((displayFields != "") && (searchFields != ""))
                {
                    displayLayers.Insert(0, layerDef);
                }

                if (GetValue(amlAttributes, "snap", out value) && (value.ToLower() == "true"))
                {
                    snapLayers.Add(layerDef);
                }

                if (GetValue(amlAttributes, "identify", out value) && (value.ToLower() == "true"))
                {
                    if (_identifyURL == "")
                    {
                        _identifyURL = url;
                    }

                    if ((name == null) || (name.Length == 0))
                    {
                        name = Application.Current.FindResource("strLayer") + " " + id;
                    }

                    // If all the identifies come from one URL, try to use an identify query

                    int idValue;
                    int.TryParse(id, out idValue);
                    if (_identifyLayerUrl == null)
                    {
                        _identifyLayers     = new List <int>();
                        _identifyLayerNames = new List <string>();
                        _identifyLayerUrl   = new List <string>();
                    }
                    if (_identifyURL == url)
                    {
                        _identifyLayers.Add(idValue);
                    }
                    else
                    {
                        UseQueryIdentify = true; // Automatically use query since we have different sources.
                    }
                    _identifyLayerNames.Add(name);

                    _identifyLayerUrl.Add(url + "/" + idValue);
                }
            }

            return(true);
        }
Пример #5
0
        private bool ReadLayerInfo(XmlDocument xmlDocument, string xmlTag, ref List<LayerDefinition> layers, ref List<LayerDefinition> snapLayers, ref List<LayerDefinition> displayLayers)
        {
            XmlNode xmlParentNode = xmlDocument.SelectSingleNode(_root + xmlTag);
              if (xmlParentNode == null)
            return false;

              XmlAttributeCollection amlAttributes = xmlParentNode.Attributes;

              string value, parentUrl = "";
              if (GetValue(amlAttributes, "url", out value))
            parentUrl = value;

              XmlNodeList nodeList = xmlParentNode.SelectNodes("operationalLayer");
              foreach (XmlNode xmlNode in nodeList)
              {
            string url, displayFields, searchFields, name, id, type, tooltip;

            amlAttributes = xmlNode.Attributes;

            GetValue(amlAttributes, "name", out name);

            GetValue(amlAttributes, "tooltip", out tooltip);

            GetValue(amlAttributes, "searchFields", out searchFields);

            GetValue(amlAttributes, "displayFields", out displayFields);
            if (displayFields == "")
              displayFields = searchFields;

            if (!GetValue(amlAttributes, "id", out id))
            {
              System.Diagnostics.Debug.WriteLine("Missing ID on layer. Layer {0} skipped.", name);
              continue;
            }

            if (!GetValue(amlAttributes, "url", out url))
              url = parentUrl;
            if (url.Length == 0)
            {
              System.Diagnostics.Debug.WriteLine("Missing URL on layer. Layer {0} skipped.", name);
              continue;
            }

            if (!GetValue(amlAttributes, "type", out type))
            {
              if (url.Contains(@"/FeatureServer"))
            type = "feature";
              else if (url.Contains(@"/MapService"))
            type = "dynamic";
              else if (url.Contains(@"/ImageService"))
            type = "image";

              // Since tiled services use a MapService URL, we can't default to this. Tiled services
              // are generally stated as a base layer (in this app), where tiled is the only option. Thus,
              // define your tile service as a base layer. If it needs to be an operational layer, set its
              // type to "tiled".
            }

            LayerDefinition layerDef = new LayerDefinition(url, id, displayFields, searchFields, name, tooltip, type);

            if (GetValue(amlAttributes, "draw", out value) && (value.ToLower() == "true"))
              layers.Insert(0, layerDef);

            if ((displayFields != "") && (searchFields != ""))
              displayLayers.Insert(0, layerDef);

            if (GetValue(amlAttributes, "snap", out value) && (value.ToLower() == "true"))
              snapLayers.Add(layerDef);

            if (GetValue(amlAttributes, "identify", out value) && (value.ToLower() == "true"))
            {
              if (_identifyURL == "")
            _identifyURL = url;

              if ((name == null) || (name.Length == 0))
            name = Application.Current.FindResource("strLayer") + " " + id;

              // If all the identifies come from one URL, try to use an identify query

              int idValue;
              int.TryParse(id, out idValue);
              if (_identifyLayerUrl == null)
              {
            _identifyLayers = new List<int>();
            _identifyLayerNames = new List<string>();
            _identifyLayerUrl = new List<string>();
              }
              if (_identifyURL == url)
            _identifyLayers.Add(idValue);
              else
            UseQueryIdentify = true;   // Automatically use query since we have different sources.

              _identifyLayerNames.Add(name);

              _identifyLayerUrl.Add(url + "/" + idValue);
            }
              }

              return true;
        }
Пример #6
0
        private bool ReadBaseLayer(XmlDocument xmlDocument, string xmlTag, ref List<LayerDefinition> layers)
        {
            XmlNode xmlParentNode = xmlDocument.SelectSingleNode(_root + xmlTag);
              if (xmlParentNode == null)
            return false;

              XmlAttributeCollection amlAttributes = xmlParentNode.Attributes;

              string url;
              if (!GetValue(amlAttributes, "url", out url))
            return false;

              // Layer name is never displayed, no name search of display fields, base layers are always tiled.
              LayerDefinition layerDef = new LayerDefinition(url, "0", "", "", "BaseLayer", "", "tiled");
              layers.Insert(0, layerDef);

              return true;
        }
Пример #7
0
        private void QueryLayer_ExecuteCompleted(object sender, QueryEventArgs args)
        {
            ObservableCollection <FindResultValue> findResults = FindResultControl.ItemsSource as ObservableCollection <FindResultValue>;

            if (!_foundParcel)
            {
                findResults.Clear();
            }

            LayerDefinition layerDefn = (LayerDefinition)args.UserState;

            // display search results for this layers query.

            if (args.FeatureSet.Features.Count > 0)
            {
                // Show search window
                if (!_foundParcel)
                {
                    FindResultControl.Visibility = System.Windows.Visibility.Visible;
                }

                foreach (Graphic feature in args.FeatureSet.Features)
                {
                    _foundParcel = true;

                    string name = "";
                    foreach (string fieldName in layerDefn.DisplayFields)
                    {
                        if (name != "")
                        {
                            name += ", ";
                        }

                        // Since accessing the dictionary via the [] operator is case sensitive,
                        //   ie, name += (string)feature.Attributes[fieldName];
                        // we need to enum thru all the values.
                        foreach (var att in feature.Attributes)
                        {
                            if (att.Key.ToLower() == fieldName.ToLower())
                            {
                                if (att.Value != null)
                                {
                                    name += att.Value.ToString();
                                }
                                break;
                            }
                        }
                    }

                    if (!_foundParcel)
                    {
                        ParcelMap.PanTo(feature.Geometry); // Pan to the first result
                    }
                    _foundParcel = true;

                    FindResultValue resultValue = new FindResultValue()
                    {
                        Layer = layerDefn.Name, Item = name, ItemTooltip = layerDefn.Tooltip
                    };
                    resultValue.Geometry = feature.Geometry; // "Zoom to" geometry
                    findResults.Add(resultValue);            // display result values
                }
            }
            else
            {
                System.Console.WriteLine("No features returned from {0}", layerDefn.Name);
            }

            // when we have received the same number of replies as we issued, then hide the spinning arrow
            System.Threading.Interlocked.Increment(ref _queryAttributeComplete);
            if (_queryAttributeCount == _queryAttributeComplete)
            {
                Loading.Visibility = System.Windows.Visibility.Collapsed; // spinning arrow
                CalculateAndAddLineGraphics();
            }
        }