Exemplo n.º 1
0
 public static void RemoveEditor(LayerUpdatingRunner item)
 {
     if (layerEditors.Contains(item))
     {
         layerEditors.Remove(item);
     }
 }
Exemplo n.º 2
0
        protected override void OnStart(string[] args)
        {
            ConfigurationManager.RefreshSection("agolFeatureLayerConfig");
            string connectionString = ConfigurationManager.ConnectionStrings["ODBC_ConnectionString"].ConnectionString;
            string tokenUsername    = ConfigurationManager.AppSettings.Get("Token_Username");
            string tokenPassword    = ConfigurationManager.AppSettings.Get("Token_Password");

            if (string.IsNullOrWhiteSpace(tokenUsername))
            {
                esriFLU_EventLog.WriteEntry("Username of the user permitted to edit the feature layer is not configured"); return;
            }
            if (string.IsNullOrWhiteSpace(tokenPassword))
            {
                esriFLU_EventLog.WriteEntry("Password of the user permitted to edit the feature layer is not configured"); return;
            }

            try
            {
                AgolFeatureLayerConfiguration layerConfiguration = ConfigurationManager.GetSection("agolFeatureLayerConfig") as AgolFeatureLayerConfiguration;
                if (layerConfiguration == null || layerConfiguration.FeatureLayers == null)
                {
                    esriFLU_EventLog.WriteEntry("ArcGIS hosted feature layers section is not configured properly"); return;
                }
                AgolFeatureLayer[] featureLayers = new AgolFeatureLayer[layerConfiguration.FeatureLayers.Count];
                layerConfiguration.FeatureLayers.CopyTo(featureLayers, 0);
                EditorStateManager.layerEditors.Clear();
                updatingThreads.Clear();

                //Thread.Sleep(30000);
                for (int i = 0; i < featureLayers.Length; i++)
                {
                    if (string.IsNullOrWhiteSpace(featureLayers[i].AgolAdminUrl))
                    {
                        esriFLU_EventLog.WriteEntry("ArcGIS Online Hosted Feature Service Admin Url is not configured"); break;
                    }
                    if (string.IsNullOrWhiteSpace(featureLayers[i].AgolLayerUrl))
                    {
                        esriFLU_EventLog.WriteEntry("ArcGIS Online Hosted Feature Service Url is not configured"); break;
                    }

                    LayerUpdatingRunner updatingRunner = new LayerUpdatingRunner(tokenUsername, tokenPassword, featureLayers[i], connectionString, LogMessageCallback);
                    updatingRunner.IsSharingService = featureLayers.LongCount(layer => (layer.AgolAdminUrl.Equals(featureLayers[i].AgolAdminUrl, StringComparison.CurrentCultureIgnoreCase))) > 1;
                    EditorStateManager.layerEditors.Add(updatingRunner);

                    Thread updatingThread = new Thread(new ThreadStart(updatingRunner.StartUpdating));
                    updatingThread.Name         = featureLayers[i].Name;
                    updatingThread.IsBackground = true;
                    updatingThreads.Add(updatingThread);
                }

                updatingThreads.ForEach(thread => { thread.Start(); });
            }
            catch (Exception ex)
            {
                esriFLU_EventLog.WriteEntry("ArcGIS Hosted Feature Layer Configuration Error: " + ex.Message, EventLogEntryType.Error);
            }
        }
Exemplo n.º 3
0
 public static bool IsAnyEditing(LayerUpdatingRunner currentEditor)
 {
     return(layerEditors.Any(editor => (editor != currentEditor && editor.IsSharingService && editor.IsEditing)));
 }