Exemplo n.º 1
0
        private static void CheckStatusCompletedEventHandler(object sender, StatusCompletedEventArgs e)
        {
            //  "status": "partial | processing | failed | completed"
            if (e.Response.status == "completed")
            {
                AGOLClient client = new AGOLClient(userCreds);

                Console.WriteLine("Publishing Feature Service");
                PublishItemParameters publishParams = new PublishItemParameters("shapefile");
                publishParams.ItemId = e.Response.itemId;
                (publishParams.PublishParameters as PublishParametersShapefile).name = "Myservicetest";
                (publishParams.PublishParameters as PublishParametersShapefile).description = "My service description";
                JsonPublishResponse publishResponse = client.Publish(publishParams, token);

                foreach (JsonServiceResponse serviceResponse in publishResponse.services)
                {
                    Console.WriteLine(string.Format("{0} published", serviceResponse.type));
                    Console.WriteLine(string.Format("{0}", serviceResponse.serviceItemId));
                    Console.WriteLine(string.Format("{0}\n", serviceResponse.serviceurl));
                }

                if (publishResponse.services.Length == 0)
                {
                    Console.WriteLine(string.Format("Service publishing failed\n"));
                }
            }

            Console.WriteLine("\nPress Esc to quit");
        }
Exemplo n.º 2
0
        public async Task CheckStatusAsync(string itemId)
        {
            //call Portal API and poll for updates
            HttpClient httpClient = new HttpClient();
            JsonStatusResponse jsonStatusResponse = null;
            string status = null;
            while (status != "completed")
            {
                string response = await httpClient.GetStringAsync(string.Format("http://www.arcgis.com/sharing/content/users/{0}/items/{1}/status?f=json&token={2}", _userCredentials.Username, itemId, _token));
                jsonStatusResponse = JsonConvert.DeserializeObject<JsonStatusResponse>(response);
                status = jsonStatusResponse.status;
                await Task.Delay(1000);
            }

            //raise event to return response
            StatusCompletedEventArgs e = new StatusCompletedEventArgs(jsonStatusResponse);
            CheckStatusCompletedEvent(this, e);
        }