Exemple #1
0
        internal EditLogger(ISDUTExtension ext, Transaction current, TransactionConfig config, QAManager qaManager)
        {
            chg_evnt = new IEditEvents_OnChangeFeatureEventHandler(LogFeatureUpdate);
            crt_evnt = new IEditEvents_OnCreateFeatureEventHandler(LogFeatureInsert);
            del_evnt = new IEditEvents_OnDeleteFeatureEventHandler(LogFeatureDelete);

            transaction = current;
            this.config = config;
            this.qaManager = qaManager;

            editor = ext.Editor;

            ((IEditEvents_Event)editor).OnChangeFeature += chg_evnt;
            ((IEditEvents_Event)editor).OnCreateFeature += crt_evnt;
            ((IEditEvents_Event)editor).OnDeleteFeature += del_evnt;
        }
Exemple #2
0
        public void add(int txid, TransactionConfig.LayerConfig layer, IFeature feature)
        {
            //string prefix = this.ext.get_SystemValue(DAOUtils.ISDUT_SCHEMA_KEY);
            //if(prefix !=null && !prefix.Equals("") && !prefix.EndsWith("."))
            //{
            //    prefix = prefix+".";
            //}

            //ITable table = ((IFeatureWorkspace)ext.TransactionManager.ConnectionManager.Isdut).OpenTable(prefix+TABLE_NAME);

            //ICursor crs = null;
            //try{
            //    crs = table.Insert(false);
            //    IRowBuffer buffer = table.CreateRowBuffer();

            //    /*
            //     create table ISDUT_EDIT_EXTENT_FEATURES
            //        (
            //        EDIT_EXTENT_FEATURE_ID    INTEGER not null,
            //        OPERATIONAL_DATASET_NAME  VARCHAR2(32) not null,
            //        SDE_LAYER_NAME            VARCHAR2(60) not null,
            //        SPATIAL_EDIT_EXTENT_SP_ID INTEGER not null,
            //        PRIMARY_KEY_VALUE         VARCHAR2(132) not null,
            //        WHO_CREATED               VARCHAR2(30) not null,
            //        WHEN_CREATED              DATE not null,
            //        WHO_UPDATED               VARCHAR2(30),
            //        WHEN_UPDATED              DATE,
            //        OBJECTID                  INTEGER not null
            //        )
            //     */

            //    string t = null;
            //    switch (layer.BusinessArea)
            //    {
            //        case BusinessArea.ForAdmBound:
            //            t = "FADM";
            //            break;
            //        case BusinessArea.Tantalis:
            //            t = "TANT";
            //            break;
            //        default:
            //            break;
            //    }
            //    buffer.set_Value(crs.FindField(OSDB_NAME_COL),t);
            //    buffer.set_Value(crs.FindField(SDE_LAYER_COL),layer.OsdbLayerName);
            //    buffer.set_Value(crs.FindField(SEE_COL),txid);

            //    t = null;
            //    for(int i=0;i<layer.Keys.Length;i++)
            //    {

            //        int index = feature.Fields.FindField(layer.Keys[i]);
            //        if( index != -1)
            //        {
            //            if(t == null)
            //            {
            //                // first time
            //                t = ""+feature.get_Value(index);
            //            }
            //            else
            //            {
            //                t = t + "|"+feature.get_Value(index);
            //            }
            //        }
            //    }
            //    buffer.set_Value(crs.FindField(PK_COL),t);

            //    crs.InsertRow(buffer);
            //    crs.Flush();
            //}
            //finally
            //{
            //    if(crs != null)
            //    {
            //        Utils.Release(crs);
            //    }
            //}
        }
Exemple #3
0
        private ArrayList findTopologies(TransactionConfig.LayerConfig lc)
        {
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)this.pgdbConnection;

            IFeatureClass fc = featureWorkspace.OpenFeatureClass(lc.WorkingLayerName);
            // assumption made here about the template format!
            IFeatureDataset fd = fc.FeatureDataset;
            ITopologyContainer topocon = (ITopologyContainer)fd;
            if (topocon.TopologyCount > 0)
            {
                ArrayList r = new ArrayList();

                for (int i = 0; i < topocon.TopologyCount; i++)
                {
                    ITopology t = (ITopology)topocon.get_Topology(i);
                    if (t != null)
                    {
                        r.Add(t);
                    }
                }

                return r;
            }
            return null;
        }
Exemple #4
0
        private void enableTopology(TransactionConfig.LayerConfig lc)
        {
            // find a topology if it exists
            ArrayList l = findTopologies(lc);

            if (l != null)
            {
                for (int i = 0; i < l.Count; i++)
                {
                    ITopology t = (ITopology)l[i];

                    ITopologyRuleContainer trc = (ITopologyRuleContainer)t;
                    IEnumRule rls = trc.Rules;
                    for (IRule rl = rls.Next(); rl != null; rl = rls.Next())
                    {
                        ITopologyRule trl = (ITopologyRule)rl;
                        trl.TriggerErrorEvents = true;
                    }

                    ISegmentCollection location = (ISegmentCollection)new PolygonClass();
                    IGeoDataset geoDataset = (IGeoDataset)t;
                    IEnvelope env = geoDataset.Extent;
                    if (!env.IsEmpty)
                    {
                        try
                        {
                            t.ValidateTopology(env);
                        }
                        catch (AccessViolationException e)
                        {
                            throw new TopoValidException(e, lc.WorkingLayerName);
                        }
                        catch (Exception e)
                        {
                            throw new TopoValidException(e,lc.WorkingLayerName);
                        }
                    }
                }
            }
        }
Exemple #5
0
        private void disableTopology(TransactionConfig.LayerConfig lc)
        {
            // find a topology if it exists
            ArrayList l = findTopologies(lc);

            if (l != null)
            {
                for (int i = 0; i < l.Count; i++)
                {
                    ITopology t = (ITopology)l[i];
                    ITopologyRuleContainer trc = (ITopologyRuleContainer)t;
                    IEnumRule rls = trc.Rules;
                    for (IRule rl = rls.Next(); rl != null; rl = rls.Next())
                    {
                        ITopologyRule trl = (ITopologyRule)rl;
                        trl.TriggerErrorEvents = false;
                    }
                }
            }
        }
Exemple #6
0
 internal ConnectionManager(IApplication app, ISDUTExtension ext, TransactionConfig transactionConfig)
 {
     this.app = app;
     this.ext = ext;
 }
Exemple #7
0
 public EditsDAO(IFeatureWorkspace transactionDB, TransactionConfig config)
 {
     this.transactionDB = transactionDB;
     this.config = config;
 }
Exemple #8
0
        private int count(string prefix, TransactionConfig.LayerConfig layer, IWorkspace sdeConn, SEE see)
        {
            if(prefix !=null && !prefix.Equals("") && !prefix.EndsWith("."))
            {
                prefix = prefix+".";
            }

            Logger.Write("Opening "+prefix+layer.OsdbLayerName);
            IFeatureClass osdb_fc = null;
            try
            {
                osdb_fc = ((IFeatureWorkspace)sdeConn).OpenFeatureClass(prefix+layer.OsdbLayerName);
            }
            catch(Exception e)
            {
                throw new HandledException(e);
            }

            ITable osdb_tbl = (ITable)osdb_fc;
            string[] keys = layer.Keys;

            IRelationshipClass osdb_rltn = null;
            if(layer.JoinName != null)
            {
                Logger.Write("Creating Join");
                IMemoryRelationshipClassFactory memoryRelClassFactory = new MemoryRelationshipClassFactoryClass();

                ITable osdb_jtbl = null;
                try
                {
                    osdb_jtbl = ((IFeatureWorkspace)sdeConn).OpenTable(prefix+layer.JoinTable);
                }
                catch(Exception e)
                {
                    MessageBox.Show("Table "+prefix+layer.JoinTable+" Not Found in OSDB",
                        "EXCEPTION", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    throw new HandledException(e);
                }

                string kprint = null;
                for(int i=0;i<keys.Length;i++)
                {
                    if(kprint == null)
                    {
                        kprint = keys[i];
                    }
                    else
                    {
                        kprint = kprint+","+keys[i];
                    }
                }

                osdb_rltn = memoryRelClassFactory.Open(layer.JoinName,osdb_fc,kprint,(IObjectClass)osdb_jtbl,kprint,
                    "forward","backward",esriRelCardinality.esriRelCardinalityOneToOne);
            }

            ISpatialFilter osdb_filter = new SpatialFilterClass();
            osdb_filter.Geometry = see.Shape;
            osdb_filter.GeometryField = osdb_fc.ShapeFieldName;
            osdb_filter.SubFields = osdb_fc.OIDFieldName;
            osdb_filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelRelation;
            if (layer.isPoint)
            {
                osdb_filter.SpatialRelDescription = Transaction.ExtractPointMask;
            }
            else
            {
                if (layer.isLine)
                {
                    osdb_filter.SpatialRelDescription = Transaction.ExtractLineMask;
                }
                else
                {
                    if (layer.isPoly)
                    {
                        osdb_filter.SpatialRelDescription = Transaction.ExtractPolyMask;
                    }
                    else
                    {
                        // default
                        osdb_filter.SpatialRelDescription = Transaction.ExtractPolyMask;
                    }
                }
            }

            Logger.Write("Create extract cursor");
            ICursor osdb_cursor = null;
            int r = 0;
            try
            {
                osdb_cursor = osdb_tbl.Search(osdb_filter, false);
                for (IRow row = osdb_cursor.NextRow(); row != null; row = osdb_cursor.NextRow())
                {
                    if (row != null)
                        r++;
                }
            }
            finally
            {
                if (osdb_filter != null)
                {
                    Utils.Release(osdb_filter);
                }
                if (osdb_cursor != null)
                {
                    Utils.Release(osdb_cursor);
                }
            }
            return r;
        }