2.5 Issue with Feature Service Editing Updates window

280
6
Jump to solution
02-07-2020 08:49 AM
MKa
by
Occasional Contributor III
protected async override void OnClick()
        {
            try
            {
                await QueuedTask.Run(async () =>
                {
                    Inspector selectedItemInspr = new Inspector();
                    selectedItemInspr = await FeatureServiceManagement.GetFirstSelectedItem();

                    if (!selectedItemInspr.IsNullOrEmpty() && !selectedItemInspr.Shape.IsNullOrEmpty())
                    {
                        FeatureLayer FieldFeatureLayer = FeatureServiceManagement.GetFeatureLayer("Field");

                        if (FieldFeatureLayer != null)
                        {
                            EditOperation CreateCurrentOperation = new EditOperation
                            {
                                Name = "Create Field Button"
                            };

                            //Create a feature with a polygon
                            CreateCurrentOperation.Create(FieldFeatureLayer, selectedItemInspr.Shape);
//THIS IS HUNG
                            CreateCurrentOperation.Execute();
                        }
                    }
                });
            }
            catch (Exception e)
            {
                LogError("CreateField - OnClick", e);
            }
        }

I just installed 2.5 and have begun to test my addin and have run into a problem right away.  I have a button that creates a feature based on a selected feature using an Edit operation.  After the Execute() command is run, it looks like the warning box for editing updates might be blocking the UI.  It just sits and spins waiting for the Execute command to finish.

0 Kudos
1 Solution

Accepted Solutions
SeanJones
Esri Regular Contributor

This was discovered too late in the 2.5 release to get in. The fix to not show the dialog for api calls is in for 2.6 and is a patch candidate for 2.5. 

The setting is stored in the application settings file (user.config) at \Users\user\AppData\Local\ComapnyName\Hashed_AppName\version.

The workaround is to let user manually click 'dont show again' when the dialog appears.

The following code can be used to toggle the value:

internal class Module1 : Module
       {
              private static Module1 _this = null;

              public static readonly string DontShowFSEditNotificationSetting =
                     "DontShowFSEditNotification";

internal class ToggleFSEditNotification : Button
       {
              protected override void OnClick()
              {
                     var dontShow = GetDontShowFSEditNotificationSetting();
                     SetDontShowFSEditNotificationSetting(!dontShow);
              }

              private bool GetDontShowFSEditNotificationSetting()
              {
                     var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                     var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup;
                     var editingSection = group.Sections["ArcGIS.Desktop.Editing.Settings"] as ClientSettingsSection;
                     var dontShowSetting = editingSection?.Settings.Get(Module1.DontShowFSEditNotificationSetting);
                     var rawValue = dontShowSetting?.Value?.ValueXml?.InnerText ?? "False";
                     return Boolean.Parse(rawValue);
              }
              private void SetDontShowFSEditNotificationSetting(bool dontShow)
              {
                     var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                     var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup;
                     var editingSection = group.Sections["ArcGIS.Desktop.Editing.Settings"] as ClientSettingsSection;

                     var dontShowSetting = editingSection.Settings.Get(Module1.DontShowFSEditNotificationSetting);
                     //null check...
                     if (dontShowSetting == null)
                     {
                           //create a new value
                           var element = new SettingElement(Module1.DontShowFSEditNotificationSetting,
                                  SettingsSerializeAs.String);
                           var xElement = new XElement(XName.Get("value"));
                           XmlDocument doc = new XmlDocument();
                           XmlElement valueXml = doc.ReadNode(xElement.CreateReader()) as XmlElement;
                           valueXml.InnerText = dontShow.ToString();
                           element.Value.ValueXml = valueXml;
                           editingSection.Settings.Add(element);
                     }
                     else
                     {
                           //change the value
                           XmlDocument doc = new XmlDocument();
                           var sr = new StringReader(dontShowSetting.Value.ValueXml.OuterXml);
                           XmlElement valueXml = doc.ReadNode(XmlReader.Create(sr)) as XmlElement;
                           valueXml.InnerText = dontShow.ToString();
                           dontShowSetting.Value.ValueXml = valueXml;
                     }
                     config.Save();
              }

       }

 

View solution in original post

6 Replies
MKa
by
Occasional Contributor III

This is also happening on a DataInspector.Apply().  The Screen comes up and i hit ok, but my code is stuck on the Apply line of the code

0 Kudos
MKa
by
Occasional Contributor III

I need a quick workaround to this or to somehow set the registry setting on the users install?  Is there a registry setting for this that is configurable on install, much like the "Check for Updates" option.  Ideally I would like to make a code change and prevent the popup in general.

0 Kudos
SeanJones
Esri Regular Contributor

This was discovered too late in the 2.5 release to get in. The fix to not show the dialog for api calls is in for 2.6 and is a patch candidate for 2.5. 

The setting is stored in the application settings file (user.config) at \Users\user\AppData\Local\ComapnyName\Hashed_AppName\version.

The workaround is to let user manually click 'dont show again' when the dialog appears.

The following code can be used to toggle the value:

internal class Module1 : Module
       {
              private static Module1 _this = null;

              public static readonly string DontShowFSEditNotificationSetting =
                     "DontShowFSEditNotification";

internal class ToggleFSEditNotification : Button
       {
              protected override void OnClick()
              {
                     var dontShow = GetDontShowFSEditNotificationSetting();
                     SetDontShowFSEditNotificationSetting(!dontShow);
              }

              private bool GetDontShowFSEditNotificationSetting()
              {
                     var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                     var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup;
                     var editingSection = group.Sections["ArcGIS.Desktop.Editing.Settings"] as ClientSettingsSection;
                     var dontShowSetting = editingSection?.Settings.Get(Module1.DontShowFSEditNotificationSetting);
                     var rawValue = dontShowSetting?.Value?.ValueXml?.InnerText ?? "False";
                     return Boolean.Parse(rawValue);
              }
              private void SetDontShowFSEditNotificationSetting(bool dontShow)
              {
                     var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                     var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup;
                     var editingSection = group.Sections["ArcGIS.Desktop.Editing.Settings"] as ClientSettingsSection;

                     var dontShowSetting = editingSection.Settings.Get(Module1.DontShowFSEditNotificationSetting);
                     //null check...
                     if (dontShowSetting == null)
                     {
                           //create a new value
                           var element = new SettingElement(Module1.DontShowFSEditNotificationSetting,
                                  SettingsSerializeAs.String);
                           var xElement = new XElement(XName.Get("value"));
                           XmlDocument doc = new XmlDocument();
                           XmlElement valueXml = doc.ReadNode(xElement.CreateReader()) as XmlElement;
                           valueXml.InnerText = dontShow.ToString();
                           element.Value.ValueXml = valueXml;
                           editingSection.Settings.Add(element);
                     }
                     else
                     {
                           //change the value
                           XmlDocument doc = new XmlDocument();
                           var sr = new StringReader(dontShowSetting.Value.ValueXml.OuterXml);
                           XmlElement valueXml = doc.ReadNode(XmlReader.Create(sr)) as XmlElement;
                           valueXml.InnerText = dontShow.ToString();
                           dontShowSetting.Value.ValueXml = valueXml;
                     }
                     config.Save();
              }

       }

 

MKa
by
Occasional Contributor III

This worked great.  I will remove the code for 2.6, but I put this in the initialize of my module to only change the value if the user has the initial value or somehow set it to show.

bool DontShowEditWarning = GetDontShowFSEditNotificationSetting();
if (!DontShowEditWarning)
{
SetDontShowFSEditNotificationSetting(!DontShowEditWarning);
}

0 Kudos
MKa
by
Occasional Contributor III

This code fails when the user loads their Map for the first time as the section 

ArcGIS.Desktop.Editing.Settings

Is not present in the user.config.  When i try to create the section it says the config is locked.  I need to be able to get to that flag at startup regardless of whether the section is currently there?  How can I make the section at startup? 

This doesn't work right now when I do config.save.  Again this is on the first time map load, remove user.config and the code should break at config.save

I had to account for the editingsection missing and then create it.  I can't seem to accomplish this

private void SetDontShowFSEditNotificationSetting(bool dontShow)
        {
            var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
            var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup;
            var editingSection = group.Sections["ArcGIS.Desktop.Editing.Settings"] as ClientSettingsSection;

//I NEED TO CREATE THE MISSING SECTION ON FIRST TIME LOAD
            if (editingSection == null)
            {
                ClientSettingsSection customSection = new ClientSettingsSection();
                group.Sections.Add("ArcGIS.Desktop.Editing.Settings", customSection);
                editingSection = group.Sections["ArcGIS.Desktop.Editing.Settings"] as ClientSettingsSection;
            }

            var dontShowSetting = editingSection?.Settings.Get(ProMapBlackModule.DontShowFSEditNotificationSetting);
            //null check...
            if (dontShowSetting == null)
            {
                //create a new value
                var element = new SettingElement(ProMapBlackModule.DontShowFSEditNotificationSetting,SettingsSerializeAs.String);
                var xElement = new XElement(XName.Get("value"));
                XmlDocument doc = new XmlDocument();
                XmlElement valueXml = doc.ReadNode(xElement.CreateReader()) as XmlElement;
                valueXml.InnerText = dontShow.ToString();
                element.Value.ValueXml = valueXml;
                editingSection.Settings.Add(element);
            }
            else
            {
                //change the value
                XmlDocument doc = new XmlDocument();
                var sr = new StringReader(dontShowSetting.Value.ValueXml.OuterXml);
                XmlElement valueXml = doc.ReadNode(XmlReader.Create(sr)) as XmlElement;
                valueXml.InnerText = dontShow.ToString();
                dontShowSetting.Value.ValueXml = valueXml;
            }

//THIS WILL FAIL WITH LOCK ERROR
            config.Save();
        }
0 Kudos
MKa
by
Occasional Contributor III

I had to add the section like this below in order to get the config to save.  It now works and I can create the section.

if (editingSection == null)
            {
                ClientSettingsSection customSection = new ClientSettingsSection();
                customSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser;

                group.Sections.Add("ArcGIS.Desktop.Editing.Settings", customSection);
                editingSection = group.Sections["ArcGIS.Desktop.Editing.Settings"] as ClientSettingsSection;
            }
0 Kudos