Esempio n. 1
0
 private void OnEditingError()
 {
     this.IsEditing = false;
     EditorStateManager.RemoveEditor(this);
     if (logCallback != null)
     {
         logCallback(string.Format("{0} updating thread is aborting. Left living threads: {1}", Thread.CurrentThread.Name, EditorStateManager.layerEditors.Count), EventLogEntryType.Warning);
     }
     Thread.CurrentThread.Join();
 }
Esempio n. 2
0
        private bool ChangeServiceCapability(bool enableEditing)
        {
            lock ((this.IsSharingService) ? realLocker : fakeLocker)
            {
                bool isChanged = false;
                this.IsEditing = enableEditing;
                if (this.IsSharingService && EditorStateManager.IsAnyEditing(this))
                {
                    return(true);
                }

                string         capabilities = (enableEditing) ? "Create,Delete,Query,Update,Editing" : "Query";
                string         jsonData     = string.Format("f=json&updateDefinition={{\"capabilities\":\"{0}\"}}&async=false&token={1}", capabilities, AgolToken.staticToken);
                string         url          = this.FeatureLayer.AgolAdminUrl + (this.FeatureLayer.AgolAdminUrl.EndsWith("/") ? "updateDefinition" : "/updateDefinition");
                HttpWebRequest agolRequest  = CreateHttpRequest(url, jsonData);

                using (HttpWebResponse response = (HttpWebResponse)agolRequest.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        DataContractJsonSerializer serializer    = new DataContractJsonSerializer(typeof(AgolAdminResponse));
                        AgolAdminResponse          adminResponse = (AgolAdminResponse)serializer.ReadObject(responseStream);

                        if (adminResponse.success)
                        {
                            isChanged = true;
                            if (logCallback != null)
                            {
                                logCallback(string.Format("Update {0} Feature Layer Definition to \"{1}\"", this.FeatureLayer.Name, capabilities), EventLogEntryType.Information);
                            }
                        }
                        else
                        {
                            isChanged          = false;
                            this.IsEditing     = false;
                            this.isErrorLogged = true;
                            if (logCallback != null)
                            {
                                logCallback(string.Format("Update {0} Feature Layer Definition Error - {1}", this.FeatureLayer.Name, (adminResponse.error != null) ? (adminResponse.error.message + "; " + string.Join(", ", adminResponse.error.details)) : "Unknown error"), EventLogEntryType.Error);
                            }
                        }
                    }
                }

                return(isChanged);
            }
        }