protected override void OnClick() { if (!Utilities.DoesConfigFileExist) { //Send a warning that the extension needs to be setup MessageBox.Show(string.Format("No Configuration File Available. Please save config.xml at {0}", Utilities.iFormFolder)); } //Read all the Layers in the MXD and process the Sync Table for that workspace IEnumLayer layers = ArcMap.Document.FocusMap.get_Layers(); ILayer layer = layers.Next(); SelectionTargetComboBox s_combo = SelectionTargetComboBox.GetSelectionComboBox(); iFormBuilderAPI.iFormBuilder api = new iFormBuilderAPI.iFormBuilder(); api.ReadConfiguration(Utilities.iFormConfigFile); processedworkspaces = new List<IWorkspace>(); while (layer != null) { //if (layer.GetType() == typeof(IFeatureLayer)) //{ IFeatureLayer fLayer = layer as IFeatureLayer; IDataset pDataSet = fLayer.FeatureClass as IDataset; try { if (!processedworkspaces.Contains(pDataSet.Workspace)) { GPMessageEventHandler gpEventHandler = new GPMessageEventHandler(); //get an instance of the geoprocessor //instruct the geoprocessing engine to overwrite existing datasets GP.OverwriteOutput = true; GP.AddToolbox(Utilities.iFormFolder + "\\" + "iFormTools.tbx"); // Create a variant. Data is in the workspace. IVariantArray parameters = new VarArrayClass(); parameters.Add(pDataSet.Workspace.PathName); parameters.Add(Utilities.iFormConfigFile); parameters.Add(1); GP.ToolExecuted += new EventHandler<ESRI.ArcGIS.Geoprocessor.ToolExecutedEventArgs>(gpToolExecuted); GP.ExecuteAsync("SynciFormDatabase", parameters); //add this workspace to the processed workspaces processedworkspaces.Add(pDataSet.Workspace); } } catch { MessageBox.Show("Synchronization Failed"); } layer = layers.Next(); //} } }
// Privates private void Initialize() { // If the extension hasn't been started yet or it's been turned off, bail if (s_extension == null || this.State != ExtensionState.Enabled) return; // Reset event handlers IActiveViewEvents_Event avEvent = ArcMap.Document.FocusMap as IActiveViewEvents_Event; avEvent.ItemAdded += AvEvent_ItemAdded; avEvent.ItemDeleted += AvEvent_ItemAdded; avEvent.SelectionChanged += UpdateSelCountDockWin; avEvent.ContentsChanged += avEvent_ContentsChanged; // Update the UI m_map = ArcMap.Document.FocusMap; SelCountDockWin.SetEnabled(true); UpdateSelCountDockWin(); m_hasSelectableLayer = CheckForSelectableLayer(); //Intialize the Connection to iForms Data api = new iFormBuilderAPI.iFormBuilder(); api.ReadConfiguration(Utilities.iFormConfigFile); FillComboBox(); }