internal static void subRowEvent()
        {
            Dockpane1ViewModel pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID) as Dockpane1ViewModel;

            QueuedTask.Run(() =>
            {
                if (MapView.Active.GetSelectedLayers().Count == 0)
                {
                    MessageBox.Show("Select a feature class from the Content 'Table of Content' first.");
                    Utils.RunOnUIThread(() => {
                        var contentsPane = FrameworkApplication.DockPaneManager.Find("esri_core_contentsDockPane");
                        contentsPane.Activate();
                    });
                    return;
                }
                //Listen for row events on a layer
                var featLayer      = MapView.Active.GetSelectedLayers().First() as FeatureLayer;
                var layerTable     = featLayer.GetTable();
                pane.SelectedLayer = featLayer as BasicFeatureLayer;

                //subscribe to row events
                var rowCreateToken  = RowCreatedEvent.Subscribe(pane.onCreatedRowEvent, layerTable);
                var rowChangedToken = RowChangedEvent.Subscribe(pane.onRowChangedEvent, layerTable);
            });
        }
 protected void onCreatedRowEvent(RowChangedEventArgs args)
 {
     Utils.RunOnUIThread(() => {
         Dockpane1ViewModel.Show();
         var pane = FrameworkApplication.DockPaneManager.Find("esri_editing_AttributesDockPane");
         pane.Activate();
     });
 }
        public Dockpane1View()
        {
            InitializeComponent();

            _taskTrackingViewModel = new Dockpane1ViewModel();

            base.DataContext = _taskTrackingViewModel;
        }
        public static void DeleteFeatures(string service, int objectid)

        {
            var token = Dockpane1ViewModel.token;

            if (token == "")
            {
                Dockpane1ViewModel.Hide();
                return;
            }


            // Create a request for the URL.
            var        operation = "deleteFeatures";
            var        url       = $"{service}/{operation}";
            WebRequest request   = WebRequest.Create(url);

            request.Method = "POST";

            var format   = "json";
            var postData = $"objectids={objectid}&f={format}&token={token}";

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = byteArray.Length;

            Stream dataStream = request.GetRequestStream();

            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            // Get the response.
            WebResponse response = request.GetResponse();

            // Display the status.
            Debug.WriteLine(((HttpWebResponse)response).StatusDescription);

            // Get the stream containing content returned by the server.
            // The using block ensures the stream is automatically closed.
            using (dataStream = response.GetResponseStream())
            {
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                Debug.WriteLine(responseFromServer);
            }

            // Close the response.
            response.Close();
            return;
        }
        protected override void OnClick()
        {
            if (Dockpane1ViewModel.token != "")
            {
                //Dockpane1View.ReinitializeComponent();
                //Module1.Reinitialice();
                Dockpane1ViewModel.Show();
            }

            else
            {
                MessageBox.Show("Debe iniciar sesión en ArcGIS Pro para acceder al administrador");
            }
        }
        public static Object Query(string service, string where, string outFields)

        {
            var token = Dockpane1ViewModel.token;

            if (token == "")
            {
                Dockpane1ViewModel.Hide();
                return(null);
            }

            Object features;
            var    operation = "query";
            // Create a request for the URL.
            var        format  = "pjson";
            var        url     = $"{service}/{operation}?where={where}&outFields={outFields}&f={format}&token={token}";
            WebRequest request = WebRequest.Create(url);

            // If required by the server, set the credentials.
            request.Credentials = CredentialCache.DefaultCredentials;

            // Get the response.
            WebResponse response = request.GetResponse();

            // Display the status.
            Debug.WriteLine(((HttpWebResponse)response).StatusDescription);

            // Get the stream containing content returned by the server.
            // The using block ensures the stream is automatically closed.
            using (Stream dataStream = response.GetResponseStream())
            {
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                Debug.WriteLine(responseFromServer);

                JavaScriptSerializer ser = new JavaScriptSerializer();
                var dict = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(responseFromServer);
                features = dict["features"];
            }

            // Close the response.
            response.Close();
            return(features);
        }
Esempio n. 7
0
        //private DataTable data = new DataTable();


        public Dockpane1View()
        {
            Dockpane1ViewModel.Hide();
            InitializeComponent();
        }
 protected override void OnClick()
 {
     Dockpane1ViewModel.subRowEvent();
     Dockpane1ViewModel.Show();
 }
        public static int UpdateFeatures(string service, int objectid, Object _attributes)

        {
            var token = Dockpane1ViewModel.token;

            if (token == "")
            {
                Dockpane1ViewModel.Hide();
                return(0);
            }


            // Create a request for the URL.
            var        operation = "updateFeatures";
            var        url       = $"{service}/{operation}";
            WebRequest request   = WebRequest.Create(url);

            request.Method = "POST";

            var _features = new { attributes = _attributes };

            var serializer = new JavaScriptSerializer();
            var features   = "[" + serializer.Serialize(_features) + "]";

            var format   = "pjson";
            var postData = $"features={features}&f={format}&token={token}";

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = byteArray.Length;

            Stream dataStream = request.GetRequestStream();

            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            // Get the response.
            WebResponse response = request.GetResponse();

            // Display the status.
            Debug.WriteLine(((HttpWebResponse)response).StatusDescription);

            // Get the stream containing content returned by the server.
            // The using block ensures the stream is automatically closed.
            using (dataStream = response.GetResponseStream())
            {
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();

                // Display the content.
                Debug.WriteLine(responseFromServer);

                // Desealize content
                var result = serializer.Deserialize <UpdateResults>(responseFromServer);

                var updateResult = result.updateResults[0];

                if (updateResult.success != null)
                {
                    objectid = updateResult.objectId;
                }
            }

            // Close the response.
            response.Close();

            return(objectid);
        }