Tuesday, 31 March 2015

AIMS / MapGuide backup batch script

I used to create backups for the repository files and the library - by running the batch files provided by MapGuide manually and using the Admin web interface for creating a package. To simplify the process I have written one batch file for the whole procedure. As I'm not familiar with batch file scripting there is probably lots of space for improvements left. Here are some details:


1. make package 
I modified the existing "makepackage.php" script (...\Autodesk Infrastructure Web Server Extension 2013\www\mapadmin) in order to run it from command line. It needs some configuration parameters such as path to webconfig.ini and the Administrator's credentials (MapGuide Admin).

2. repository backup batch files
The backup scripts provided by MapGuide need a little modification - I added an "exit" at the end of each of the files I use and renamed them as well (kept the originals).

 ...  
 echo.  
 php -n RepositoryAdmin.php -c Restore -i "%cd%\..\BackupRepositories\Library\LastColdBackup" -o "%cd%\..\Repositories\Library"  
 echo.  
 exit  

  
3. batch script 
One batch script is needed to run all other scripts, for shutting down and restarting MapGuide service and for copying the backed up files to a different drive.

To run other batch files use:

 ...  
 start /wait call %batch_file_backup%  
 if ERRORLEVEL 1 goto error_start  
 ...  


This will run another batch file and wait until the batch file has finished. If the batch file does not finish succesfully you can catch an error code. A modification of the original batch files provided by Mapguide is required to get this to work - see above.

One click and files are backed up:


backup batch file in action

Script files are available here.

Install:

1) Copy files to "..\Autodesk Infrastructure Map Server\RepositoryAdmin" folder.
2) check and modify settings in "makepackagescript.php"
3) check and modify settings in "AIMS_backup.bat"
4) run "AIMS_backup.bat"

This should work for AIMS 2013 and the corresponding MGOS version.

Friday, 20 March 2015

Oracle Trigger - display debug information

Just for my own reference:

(1) within trigger use DBMS_OUTPUT.PUT_LINE, e.g.


 DBMS_OUTPUT.PUT_LINE(REC_INSP.FID || ' ' || REC_INSP.FID_BAUM);  

to display text in SQL Developer:

(2a) - open DBMS output panel 
(2b) - in DBMS-output panel : choose active Oracle connection

or:

(3) - run:

 SET SERVEROUTPUT ON  


(4) execute SQL in SQL Developer which fires trigger


>> Debug information will be displayed either in DBMS-output or Script output panel



SQL Developer - DBMS output panel

Source Code Formatter

Tuesday, 17 March 2015

MapGuide / AIMS - WMS layer and background transparency and opacity

We set up a few new FDO WMS data sources and created layers accordingly. For an unknown reason for layers from some data sources the background was not transparent. All WMS layers are provided by the same organisation, we set up all data sources and layers the same way.
I finally found out that changing settings in "Set coordinate system overrides" for the data source and re-creating the layers solved the problem. I just changed image format from png to something else and unchecked the "Transparent" checkbox, saved the changes and then set the original values back again and saved it. 

WMS data source - cs overrides does the trick....

When creating a layer for the modified data source afterwards background transparency was present again. It is probably sufficient to just uncheck the "Transparent" checkbox but I haven't tested that - wasted enough time already...

After this issue was solved the second question came up - can we now set an opacity for the WMS layer? No, we can't... It is possible in AutoCAD Map to apply opacity to a raster layer but this does not work for raster layers in AIMS/MapGuide (at least not with FDO Raster Provider) and for WMS based layers.
Would be a nice enhancement if it were possible...

"Opacity" with Map raster layers - here you will find further information (German language),

Map, AIMS 2013

Tuesday, 17 February 2015

Jobs in AutoCAD Map - job-disable a feature class

AutoCAD Maps Job concept is - from a technical point of view - quite complicated (jobs are only available for Industry Models in Oracle and Oracle needs to be an Enterprise edition). In some circumstances one has to use Jobs - as we have to in our Landmanagement industry model. In LandManagement jobs are usually in pending state for weeks or months. The reason why we have long running jobs is the legal framework - which is different from country to country.
Anyway - Landmanagement data is essential and is used in many other applications (such as by tax authority). To provide data to other applications becomes tricky when using jobs. And secondly - if you use jobs then all feature classes are "job enabled" although this is not required from a user's perspective. Often there is the need to have feature classes which are not job enabled. Today I'm going to show how one can have job-disabled feature classes in a job-enabled document (although without any guarantee it will work as expected).

Firstly - when you job-enable an industry model there are lots of tables which are not job enabled - for example as all "system" tables (starting with TB_). If you add the plot extension then all plot related tables will not be job enabled as well (plot tables start with PLT_). If you do intersections the result tables will not be job enabled either. Whereas the TB_ tables do not contain feature data the plot and intersection result tables do. So there is a mechanism in Map which allows having job-disabled feature classes in a job enabled document.

I believe that the first releases of the new AutoCAD Topobase (releases 2007-2009?) did allow the creation of job-disabled feature classes alongside job-enabled feature classes. For some reason this feature has been removed and whenever you create a feature class now (either in Map Administrator or by using the API functionality) feature classes get job enabled by default. It seems there is no flag or entry in one of the TB_ tables which controls whether the feature class is job enabled or not (although TB_DICTIONARY still contains a column called "Version_Enabled" but it doesn't seem to be used by Map).

Using the .net API an existing feature class can be job-disabled:

featureClass.JobDisable();

By doing so  - amongst other things - all JOB related data refering to the table (including job related columns in the table itself) are removed for good. When you open the industry model next time in Map-Administrator an error message will pop up, informing you that the job-configuration is not right and therefore needs to be repaired. It seems you can ignore the message but it is not nice being greeted by an error message whenever you start up Map-Administrator. To avoid the message and in order to create a feature class job-disabled right from the start a plugin is required. A simple implementation looks like this:

public class MyDocument : Autodesk.Map.IM.Forms.DocumentPlugIn
    {               
        public override void OnLoad(object sender, EventArgs e)
        {                      
            this.Document.Connection.FeatureClasses.JobEnableStateChanging += new EventHandler<FeatureClassJobEnableStateChangeEventArgs>(FeatureClasses_JobEnableStateChanging);
        }
        private void FeatureClasses_JobEnableStateChanging(object sender, FeatureClassJobEnableStateChangeEventArgs e)
        {         
            if (e.FeatureClass.ParentTopic.Name == "NOJOBS" && e.JobEnableFc)
            {
                e.Cancel = true;
            }
        }
    }

When a document (Industry model) is opened in Map-Administrator the OnLoad function is called and an event listener is registered. The event will be raised whenever Map tries to job-enable a feature class. The event occurs when the industry model is opened - Map performs some checks and will display the aforementioned error message if it finds job-disabled feature classes. The event also occurs when a new feature class is created.

In the example given above - as long as you create a new feature class in topic "NOJOBS" it will not be job-enabled and you will not receive any error messages when opening the Industry model.

We haven't yet tested extensively whether this works well or not. Autodesk certainly did have good reasons to disable the usage of job-disabled feature classes in a job enabled document. But on the other side - they do it themselve all the time. Would be nice to have more documentation on - in particular if there are any drawbacks....

If you have any further insight on how you can have job-disabled feature classes in a job-enabled document - please let me know. I might create a new blog entry about the underlying job concept in the near future.

Map 2013, SP2

Monday, 2 February 2015

blog activity - outlook 2015

My blogging activity has decreased over the last months - mainly because the number of issues we ran into and questions we encountered has reduced since late autumn. Since then we have Map 2013 successfully in production for most of our applications. The most important ones are:

- wastewater
- water
- gas
- electricity
- district heating

Additionally we have a number of smaller "industry models" successfully migrated from Topobase 2. A few are still managed in TB2 and we will probably migrate them in summer.
Now, that Map and our intranet web gis system (based on TBVIEW by Gerst) is up and running we are now more focussed on fine tuning. So, over the next months you will see some activity here but not as much as last year I suppose. 

Rob

Schema collection must contain exactly ONE schema!

We have a re-occurring error message in our AIMS log file:

<2014-10-29T06:25:59> 1900 Intranet-WebGIS Stadt Winterthur (Prod.) 10.61.140.38 Anonymous
 Error: An exception occurred in FDO component.
        Schema collection must contain exactly ONE schema!
 StackTrace:
  - MgFeatureServiceHandler.ProcessOperation() line 83 file d:\build\ims2013\build_58.2\ent\os\server\src\services\feature\FeatureServiceHandler.cpp
  - MgOpGetIdentityProperties.Execute() line 112 file d:\build\ims2013\build_58.2\ent\os\server\src\services\feature\OpGetIdentityProperties.cpp
  ...

The message appears intermittently.

A few days ago a MAP user called me to his desk, telling me that he can't generate any graphics anymore. Instead the following error message appeared (translated):

Error whilst generating graphics. Adding layer failed: layer_name: Exception in FDO-Component: Schema collection must contain exactly ONE schema!

I was a bit surprised as I had seen the message before - but only in AIMS log files. Suddenly more an more users were complaining about the same issue - no one was able to work anymore.

We have multiple MAPSYS in use and users connect to different enterprise models - so the issues was not related to a specific enterprise or display model. As everyone was affected the cause was most likely to be found in our database. We decided to restart Oracle and the issue was solved. Our DBA noticed, that Oracle had reached the maximum number of sessions just before the issue became apparent. We have now increased the value in order to avoid similar issues in the future. The error message in AIMS occasionally still appears.

Map 2013, SP2

Saturday, 3 January 2015

default number of records when opening a form

First of all - all the best for 2015.

When opening a form a filter is applied to show 100 records. According to Autodesk Support it is not possible the modify the default value of 100.

Map 2013, SP2