Dienstag, 17. Februar 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

Keine Kommentare:

Kommentar veröffentlichen