Thought I'd share my Rec/Post Script

1820
0
01-31-2012 08:00 AM
FernandoLlamasJr
New Contributor II
Using the original post made by a member:  http://forumsstg.arcgis.com/threads/26052-Reconcile-and-Post-script-for-ArcGIS10-ArcGIS-server-10

I was able to build a similar script that can be used to reconcile and post versions based upon what you want as an ArcSDE administrator.  It then spits out a log file at a location of your choosing so that you can track it. 

Currently I have this running hourly with a daily compress script at the end of the day.  I'm using a SQL SSIS job to run this python script since the Task Scheduler was not reliable.

You can build on this to reconcile and post not only to default , but also from version to version.

Cheers!

# ---------------------------------------------------------------------------
# AutoRecNPostVersions_012412.py
# Created on: 2012-01-24 18:25:07.00000
#   (generated by ArcGIS/ModelBuilder)
# Editted by: Fernando M Llamas
# Description: Python module that will automatically reconcile and post certain versions witin
# the Geodatabase using the data owner BurienGIS
# ---------------------------------------------------------------------------

# Set the necessary product code
import arceditor, arcpy, os, logging


# Local variables:
workspace = r"D:\\ArcGISServer\DC_BurienGIS@Burien.DEFAULT.sde"     #Location of the SDE connection.  You can create one in ArcCatalog and then copy it fromt he user settings in Windows to a \\server\share
Version_Name = ["DBO.Addressing","DBO.Stormwater","DBO.MasterPlans"]    #Add versions you want here that you want to reconcile and post
Version_Name_RecOnly = ["DBO.Basic Editting"]   #Add versions you want to just reconcile down from parent to child versions
Target_Version = "sde.DEFAULT"
Conflict_Definition = "BY_OBJECT"
Conflict_Resolution = "FAVOR_TARGET_VERSION"
Abort_if_conflicts = "true"
Aquire_locks_during_reconcile = "true"
Post_version_after_reconcile = "true"

logging.basicConfig(filename=r'C:\\recnpost\RecNPost.log', format='%(asctime)s     %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO)    #Logging file is created everytime this is run.  Modify the filename and path here

logging.info ('                                    ')
logging.info ('------------------------------------')
logging.info ('Starting to Reconcile Versions')

try:
# Process: Reconcile and Post Versions in the Version_Name list above
    for Version_Name in Version_Name:
        arcpy.gp.ReconcileVersion(workspace, Version_Name, Target_Version, Conflict_Definition, Conflict_Resolution, Aquire_locks_during_reconcile, Abort_if_conflicts, Post_version_after_reconcile)
        logging.info ('Reconciled and Posted '+Version_Name)
        logging.info ('                                    ')
except Exception as e:
    logging.info ('Cannot run managment process due to:')
    logging.info ('                                    ')
    logging.info (e.message)
    logging.info ('------------------------------------')
    
try:
# Process: Reconcile Only the Versions in the Version_Name_RecOnly list above
    for Version_Name_RecOnly in Version_Name_RecOnly:
        arcpy.gp.ReconcileVersion(workspace, Version_Name_RecOnly, Target_Version, Conflict_Definition, Conflict_Resolution, Aquire_locks_during_reconcile, Abort_if_conflicts, "NO_POST")
        logging.info ('Reconciled '+Version_Name_RecOnly)
        logging.info ('------------------------------------')
        logging.info ('                                    ')
except Exception as e:
    logging.info ('Cannot run managment process due to:')
    logging.info ('                                    ')
    logging.info (e.message)
    logging.info ('------------------------------------')
Tags (2)
0 Replies