コード例 #1
0
        /// <summary>
        /// Gets a list of all the map documents stored in the current WMX database
        /// </summary>
        /// <returns>A sorted list of the MXDs</returns>
        private SortedList <string, string> ListMapDocumentsInDatabase()
        {
            SortedList <string, string> mapDocumentNames = new SortedList <string, string>();

            IJTXConfiguration3 configMgr    = WmxDatabase.ConfigurationManager as IJTXConfiguration3;
            IJTXMapSet         mapDocuments = configMgr.JTXMaps;

            for (int i = 0; i < mapDocuments.Count; i++)
            {
                IJTXMap map = mapDocuments.get_Item(i);
                mapDocumentNames.Add(map.Name, null);
            }

            return(mapDocumentNames);
        }
コード例 #2
0
        /// <summary>
        /// Builds a domain containing the names of all the map documents embedded
        /// in the database
        /// </summary>
        /// <param name="wmxDb">A reference to the active Workflow Manager database</param>
        /// <returns>A coded value domain as an IGPDomain</returns>
        public static IGPDomain BuildMapDocumentDomain(IJTXDatabase3 wmxDb)
        {
            IGPCodedValueDomain         mxdNames         = new GPCodedValueDomainClass();
            SortedList <string, string> mapDocumentNames = new SortedList <string, string>();

            IJTXConfiguration3 configMgr = wmxDb.ConfigurationManager as IJTXConfiguration3;
            IJTXMapSet         maps      = configMgr.JTXMaps;

            for (int i = 0; i < maps.Count; i++)
            {
                IJTXMap map = maps.get_Item(i);
                mapDocumentNames.Add(map.Name, null);
            }

            foreach (string mapDocName in mapDocumentNames.Keys)
            {
                mxdNames.AddStringCode(mapDocName, mapDocName);
            }

            return(mxdNames as IGPDomain);
        }
コード例 #3
0
        /// <summary>
        /// Find those map documents embedded in the database that are not being
        /// referenced in any way
        /// </summary>
        /// <returns>The total number of orphaned items found</returns>
        private int UpdateOrphanedMapDocuments()
        {
            SortedList <string, int> unusedItems = new SortedList <string, int>();
            IJTXDatabase3            wmxDb       = this.WmxDatabase;
            IJTXConfiguration3       configMgr   = wmxDb.ConfigurationManager as IJTXConfiguration3;
            IJTXConfigurationEdit2   configEdit  = wmxDb.ConfigurationManager as IJTXConfigurationEdit2;

            IJTXMapSet allMaps = configMgr.JTXMaps;
            Dictionary <string, int> allMapNames = new Dictionary <string, int>();

            for (int i = 0; i < allMaps.Count; i++)
            {
                IJTXMap map = allMaps.get_Item(i);
                allMapNames[map.Name] = map.ID;
            }

            Dictionary <string, int> usedItems = new Dictionary <string, int>();

            // Find the map types that are associated with job types
            IJTXJobTypeSet allJobTypes = configMgr.JobTypes;

            for (int i = 0; i < allJobTypes.Count; i++)
            {
                // TODO: Skip orphaned job types

                IJTXJobType3 jobType = allJobTypes.get_Item(i) as IJTXJobType3;
                if (jobType.AOIMap != null)
                {
                    usedItems[jobType.AOIMap.Name] = jobType.AOIMap.ID;
                }
                if (jobType.JobMap != null)
                {
                    usedItems[jobType.JobMap.Name] = jobType.JobMap.ID;
                }
            }

            // If necessary, find the map types launched by custom steps.  Look for
            // the "/mxd:" argument as an identifier.
            IJTXStepTypeSet allStepTypes = wmxDb.ConfigurationManager.StepTypes;

            for (int i = 0; i < allStepTypes.Count; i++)
            {
                IJTXStepType2 stepType = allStepTypes.get_Item(i) as IJTXStepType2;

                // Skip orphaned step types
                if (m_unusedStepTypes.Keys.Contains(stepType.ID))
                {
                    continue;
                }

                for (int j = 0; j < stepType.Arguments.Length; j++)
                {
                    string stepArg = stepType.Arguments[j].ToString();
                    if (stepArg.StartsWith(C_MAP_DOC_FLAG))
                    {
                        string suffix = stepArg.Substring(C_MAP_DOC_FLAG.Length);
                        suffix = suffix.Trim(new char[] { '"' });
                        if (allMapNames.Keys.Contains(suffix))
                        {
                            usedItems[suffix] = allMapNames[suffix];
                        }
                    }
                }
            }

            // Add in the map document that's used as the template map document
            // (if one exists)
            IJTXConfigurationProperties configProps = this.WmxDatabase.ConfigurationManager as IJTXConfigurationProperties;
            string mapIdStr = configProps.GetProperty(Constants.JTX_PROPERTY_MAPVIEW_MAP_GUID);

            if (mapIdStr != null && !mapIdStr.Equals(string.Empty))
            {
                for (int i = 0; i < allMaps.Count; i++)
                {
                    IJTXMap        tempMap   = allMaps.get_Item(i);
                    IJTXIdentifier tempMapId = tempMap as IJTXIdentifier;
                    if (tempMapId.GUID.Equals(mapIdStr))
                    {
                        usedItems[tempMap.Name] = tempMap.ID;
                        break;
                    }
                }
            }

            // Loop over all the map documents in the DB, looking for anything
            // that we didn't identify as "in use"
            foreach (string name in allMapNames.Keys)
            {
                if (!usedItems.ContainsKey(name))
                {
                    m_unusedMapDocs[name] = allMapNames[name];
                }
            }

            return(m_unusedMapDocs.Count);
        }