コード例 #1
0
        public void updateCoverages(double deadCoverage, double receptionCoverage)
        {
            IWorkspaceEdit pWorkspaceEdit = null;

            try
            {
                pWorkspaceEdit = (IWorkspaceEdit)((IDataset)ServiceTerritoryFeature.Class).Workspace;

                IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit;

                pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                //pWorkspaceEdit.StartEditing(true);
                pWorkspaceEdit.StartEditOperation();

                ServiceTerritoryFeature.set_Value(ServiceTerritoryFeature.Fields.FindField("DEADCOVERAGE"), deadCoverage);
                ServiceTerritoryFeature.set_Value(ServiceTerritoryFeature.Fields.FindField("RECEPTIONCOVERAGE"), receptionCoverage);
                ServiceTerritoryFeature.Store();

                pWorkspaceEdit.StopEditOperation();
                pWorkspaceEdit.StopEditing(true);
            }
            catch
            {
                pWorkspaceEdit.AbortEditOperation();
            }
        }
コード例 #2
0
        /// <summary>
        /// changed this to private since this need to be called only from within generate range
        /// </summary>
        private void GenerateDeadAreas()
        {
            //get the service territory
            IWorkspaceEdit pWorkspaceEdit;

            pWorkspaceEdit = (IWorkspaceEdit)this._workspace;
            try
            {
                IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit;

                // ServiceTerritory mainST = new ServiceTerritory(_workspace, "MAIN");

                if (this.ServiceTerritoryFeature != null)
                {
                    IGeometry pSVGeometry = ServiceTerritoryFeature.Shape;
                    //IGeometry pRecptionGeometry = mainST.getReceptionArea();
                    //union all the signals and get one big reception area geometry

                    //edit and add to fc
                    IGeometry pDeadArea = getDeadArea();
                    //pWorkspaceEdit.StartEditing(true);

                    IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit;

                    pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                    pWorkspaceEdit.StartEditOperation();

                    double deadCoverage      = ((IArea)pDeadArea).Area * 100 / ((IArea)pSVGeometry).Area;
                    double receptionCoverage = 100 - deadCoverage;

                    IFeatureClass pDeadAreasFC = pFWorkspace.OpenFeatureClass("sde.DeadAreas");


                    //delete all features
                    IFeatureCursor pcursor       = pDeadAreasFC.Update(null, false);
                    IFeature       pfeaturerange = pcursor.NextFeature();
                    while (pfeaturerange != null)
                    {
                        //we need to change that later
                        pfeaturerange.Delete();
                        pfeaturerange = pcursor.NextFeature();
                    }


                    IFeature pDeadAreaFeature = pDeadAreasFC.CreateFeature();
                    pDeadAreaFeature.Shape = pDeadArea;
                    pDeadAreaFeature.Store();

                    pWorkspaceEdit.StopEditOperation();
                    pWorkspaceEdit.StopEditing(true);

                    updateCoverages(deadCoverage, receptionCoverage);
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
                pWorkspaceEdit.AbortEditOperation();
            }
        }
コード例 #3
0
        /// <summary>
        /// updates the device information
        /// </summary>
        public void Store()
        {
            IFeatureWorkspace pFWorkspace    = (IFeatureWorkspace)_workspace;
            IWorkspaceEdit    pWorkspaceEdit = (IWorkspaceEdit)pFWorkspace;

            IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit;

            pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
            //  pWorkspaceEdit.StartEditing(true);
            pWorkspaceEdit.StartEditOperation();

            IFeatureClass pDeviceFC = pFWorkspace.OpenFeatureClass("sde.Device");
            IQueryFilter  pQFilter  = new QueryFilter();

            pQFilter.WhereClause = "DEVICEID = '" + DeviceID + "'";
            IFeatureCursor pFCursor       = pDeviceFC.Search(pQFilter, false);
            IFeature       pDeviceFeature = pFCursor.NextFeature();

            if (pDeviceFeature != null)
            {
                if (connectedTower != null)
                {
                    pDeviceFeature.set_Value(pDeviceFeature.Fields.FindField("CONNECTEDTOWERID"), connectedTower.ID);
                }
                else
                {
                    pDeviceFeature.set_Value(pDeviceFeature.Fields.FindField("CONNECTEDTOWERID"), DBNull.Value);
                }

                pDeviceFeature.set_Value(pDeviceFeature.Fields.FindField("BARS"), Bars);
                pDeviceFeature.Shape = DeviceLocation;
                pDeviceFeature.Store();
            }
            else
            {
                IFeature pNewFeature = pDeviceFC.CreateFeature();
                pNewFeature.set_Value(pNewFeature.Fields.FindField("DEVICEID"), DeviceID);

                if (connectedTower != null)
                {
                    pNewFeature.set_Value(pNewFeature.Fields.FindField("CONNECTEDTOWERID"), connectedTower.ID);
                }
                else
                {
                    pNewFeature.set_Value(pNewFeature.Fields.FindField("CONNECTEDTOWERID"), DBNull.Value);
                }


                pNewFeature.set_Value(pNewFeature.Fields.FindField("BARS"), Bars);
                pNewFeature.Shape = DeviceLocation;
                pNewFeature.Store();
            }


            pWorkspaceEdit.StopEditOperation();


            pWorkspaceEdit.StopEditing(true);
        }
コード例 #4
0
        public override void StartEditing(bool versioned)
        {
            IMultiuserWorkspaceEdit workspaceEdit = GetEditingWorkspace;

            if (versioned && workspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned))
            {
                workspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
            }
            else if (!versioned && workspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMNonVersioned))
            {
                workspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned);
            }
            else
            {
                throw new WorkspaceEditHandlerException("Não é possível inicar uma edição multi-usuário.");
            }
        }
コード例 #5
0
        public bool StartEditing(IWorkspace TheWorkspace, bool IsUnversioned) // Start EditSession + create EditOperation
        {
            bool IsFileBasedGDB =
                (!(TheWorkspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriRemoteDatabaseWorkspace));

            IWorkspaceEdit pWSEdit = (IWorkspaceEdit)TheWorkspace;

            if (pWSEdit.IsBeingEdited())
            {
                MessageBox.Show("The workspace is being edited by another process.");
                return(false);
            }

            if (!IsFileBasedGDB)
            {
                IMultiuserWorkspaceEdit pMUWSEdit = (IMultiuserWorkspaceEdit)TheWorkspace;
                try
                {
                    if (pMUWSEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMNonVersioned) && IsUnversioned)
                    {
                        pMUWSEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned);
                    }
                    else if (pMUWSEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned) && !IsUnversioned)
                    {
                        pMUWSEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                    }

                    else
                    {
                        return(false);
                    }
                }
                catch (COMException ex)
                {
                    MessageBox.Show(ex.Message + "  " + Convert.ToString(ex.ErrorCode), "Start Editing");
                    return(false);
                }
            }
            else
            {
                try
                {
                    pWSEdit.StartEditing(false);
                }
                catch (COMException ex)
                {
                    MessageBox.Show(ex.Message + "  " + Convert.ToString(ex.ErrorCode), "Start Editing");
                    return(false);
                }
            }

            pWSEdit.DisableUndoRedo();
            try
            {
                pWSEdit.StartEditOperation();
            }
            catch
            {
                pWSEdit.StopEditing(false);
                return(false);
            }
            return(true);
        }
コード例 #6
0
        /// <summary>
        /// Generate the tower coverage
        /// </summary>
        public void GenerateReceptionArea()
        {
            IWorkspaceEdit pWorkspaceEdit;

            pWorkspaceEdit = (IWorkspaceEdit)this._workspace;
            try
            {
                //get all towers in this service territory
                Towers pTowers = GetTowers();

                IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit;

                IFeatureClass pTowerRangeFC = pFWorkspace.OpenFeatureClass("sde.TowerRange");



                IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit;

                pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                // pWorkspaceEdit.StartEditing(true);
                pWorkspaceEdit.StartEditOperation();

                //delete all ranges , we should later change that to delete only dirty towers
                IFeatureCursor pcursor       = pTowerRangeFC.Update(null, false);
                IFeature       pfeaturerange = pcursor.NextFeature();
                while (pfeaturerange != null)
                {
                    //we need to change that later
                    pfeaturerange.Delete();

                    pfeaturerange = pcursor.NextFeature();
                }

                foreach (Tower pTower in pTowers.Items)
                {
                    ITopologicalOperator pTopo = (ITopologicalOperator)pTower.TowerLocation;

                    IPolygon range3Bars      = (IPolygon)pTopo.Buffer(pTower.TowerCoverage / 3);
                    IPolygon range2BarsWhole = (IPolygon)pTopo.Buffer((pTower.TowerCoverage * 2) / 3);
                    IPolygon range1BarsWhole = (IPolygon)pTopo.Buffer(pTower.TowerCoverage);

                    ITopologicalOperator pIntTopo = (ITopologicalOperator)range2BarsWhole;

                    ITopologicalOperator pIntTopo1 = (ITopologicalOperator)range1BarsWhole;


                    IPolygon range2BarsDonut = (IPolygon)pIntTopo.SymmetricDifference(range3Bars);       //,esriGeometryDimension.esriGeometry2Dimension);
                    IPolygon range1BarsDonut = (IPolygon)pIntTopo1.SymmetricDifference(range2BarsWhole); //,esriGeometryDimension.esriGeometry2Dimension);


                    IFeature pFeature = pTowerRangeFC.CreateFeature();

                    pFeature.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID);
                    pFeature.set_Value(pFeature.Fields.FindField("RANGE"), 3);

                    pFeature.Shape = range3Bars;
                    pFeature.Store();


                    IFeature pFeature2Bar = pTowerRangeFC.CreateFeature();

                    pFeature2Bar.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID);
                    pFeature2Bar.set_Value(pFeature.Fields.FindField("RANGE"), 2);

                    pFeature2Bar.Shape = range2BarsDonut;
                    pFeature2Bar.Store();


                    IFeature pFeature1Bar = pTowerRangeFC.CreateFeature();

                    pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("TOWERID"), pTower.ID);
                    pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("RANGE"), 1);

                    pFeature1Bar.Shape = range1BarsDonut;
                    pFeature1Bar.Store();
                }


                pWorkspaceEdit.StopEditOperation();
                pWorkspaceEdit.StopEditing(true);


                //generate dead areas
                GenerateDeadAreas();
            }
            catch (Exception ex)
            {
                //if anything went wrong, just roll back
                pWorkspaceEdit.AbortEditOperation();
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
コード例 #7
0
        public void UpdateAssetsTest()
        {
            RuntimeManager.Bind(ProductCode.Desktop);
            (new AoInitializeClass()).Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard);
            IPropertySet propertySet = new PropertySetClass();

            propertySet.SetProperty("Server", "RJMSDDBT02");
            propertySet.SetProperty("Instance", "sde:oracle11g:gisdevl");
            propertySet.SetProperty("Database", "GISDEVL");
            propertySet.SetProperty("user", "MSD");
            propertySet.SetProperty("password", "jc_tc1954");
            propertySet.SetProperty("version", "MSD.QC");
            int flag = 0;

            try
            {
                IWorkspace          workspaceName      = (new SdeWorkspaceFactoryClass()).Open(propertySet, 0);
                IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspaceName;
                IEnumVersionInfo    enumVersionInfo    = versionedWorkspace.Versions;
                enumVersionInfo.Reset();
                IVersionInfo existversionInfo = enumVersionInfo.Next();
                while (existversionInfo != null)
                {
                    if (!existversionInfo.VersionName.Trim().Equals("MSD.DTS_EDIT"))
                    {
                        existversionInfo = enumVersionInfo.Next();
                    }
                    else
                    {
                        versionedWorkspace.FindVersion("MSD.DTS_EDIT").Delete();
                        flag = 1;
                        break;
                    }
                }
                enumVersionInfo.Reset();
                IVersion version    = (IVersion)((IFeatureWorkspace)workspaceName);
                string   name       = version.VersionInfo.VersionName;
                IVersion dtsVersion = version.CreateVersion("DTS_EDIT");
                dtsVersion.Access      = esriVersionAccess.esriVersionAccessPublic;
                dtsVersion.Description = "Update DTS to MSD Ownership via DTS app";
                if (dtsVersion.VersionName.Contains("DTS_EDIT"))
                {
                    IMultiuserWorkspaceEdit multiuserWorkspaceEdit = (IMultiuserWorkspaceEdit)dtsVersion;
                    IWorkspaceEdit          workspaceEdit          = (IWorkspaceEdit)dtsVersion;
                    IVersionEdit4           versionEdit            = (IVersionEdit4)workspaceEdit;
                    if (multiuserWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned))
                    {
                        multiuserWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                        versionEdit.Reconcile4("MSD.QC", true, false, false, false);
                        workspaceEdit.StartEditOperation();
                        IFeature featureEdit = ((IFeatureWorkspace)workspaceEdit).OpenFeatureClass("SWRAINGAUGE").GetFeature(330);
                        // Convert.ToString(featureEdit[6]);
                        Convert.ToString(featureEdit.Value[6]);
                        int      Totalfield          = featureEdit.Fields.FieldCount;
                        int      ownershipindex      = featureEdit.Fields.FindField("OWNERSHIP");
                        int      lastmodifieddtindex = featureEdit.Fields.FindField("LAST_MODIFIED_DATE");
                        DateTime lastmodifieddt      = DateTime.Now.Date;
                        //featureEdit[ownershipindex] = "1";
                        //featureEdit[lastmodifieddtindex] = lastmodifieddt.Date;
                        featureEdit.Value[ownershipindex]      = "1";
                        featureEdit.Value[lastmodifieddtindex] = lastmodifieddt.Date;
                        featureEdit.Store();
                        if (versionEdit.CanPost())
                        {
                            versionEdit.Post("MSD.QC");
                        }
                        workspaceEdit.StopEditOperation();
                        workspaceEdit.StopEditing(true);
                    }
                }
            }
            catch (COMException cOMException)
            {
                if (cOMException.ErrorCode == -2147217147)
                {
                }
            }
            catch (Exception exception)
            {
            }
        }
コード例 #8
0
        public int UpdateAssets(List <AssetModified> assetModifieds)
        {
            int num;

            this.dtStartTime = DateTime.Now;
            Assets.logger.Debug(string.Concat("UpdateAssets start at ", this.dtStartTime.ToString()));
            IPropertySet propertySet = Assets.GetPropertySet();
            int          counter     = 0;

            try
            {
                IWorkspace          workspaceName      = (new SdeWorkspaceFactoryClass()).Open(propertySet, 0);
                IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspaceName;
                IEnumVersionInfo    enumVersionInfo    = versionedWorkspace.Versions;
                enumVersionInfo.Reset();
                IVersionInfo existversionInfo = enumVersionInfo.Next();
                while (existversionInfo != null)
                {
                    if (!existversionInfo.VersionName.Trim().Equals("MSD.DTS_EDIT"))
                    {
                        existversionInfo = enumVersionInfo.Next();
                    }
                    else
                    {
                        versionedWorkspace.FindVersion("MSD.DTS_EDIT").Delete();
                        break;
                    }
                }
                enumVersionInfo.Reset();
                IVersion version    = (IVersion)((IFeatureWorkspace)workspaceName);
                string   name       = version.VersionInfo.VersionName;
                IVersion dtsVersion = version.CreateVersion("DTS_EDIT");
                dtsVersion.Access      = esriVersionAccess.esriVersionAccessPublic;
                dtsVersion.Description = "Update DTS to MSD Ownership via DTS app";
                if (dtsVersion.VersionName.Contains("DTS_EDIT"))
                {
                    IMultiuserWorkspaceEdit multiuserWorkspaceEdit = (IMultiuserWorkspaceEdit)dtsVersion;
                    IWorkspaceEdit          workspaceEdit          = (IWorkspaceEdit)dtsVersion;
                    IVersionEdit4           versionEdit            = (IVersionEdit4)workspaceEdit;
                    if (multiuserWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned))
                    {
                        multiuserWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                        versionEdit.Reconcile4("MSD.QC", true, false, false, false);
                        workspaceEdit.StartEditOperation();
                        ILog     log = Assets.logger;
                        DateTime now = DateTime.Now;
                        log.Debug(string.Concat("GetUpdateAssets start at ", now.ToString()));
                        counter = Assets.GetUpdateAssets(assetModifieds, counter, workspaceEdit);
                        ILog log1 = Assets.logger;
                        now = DateTime.Now;
                        log1.Debug(string.Concat("GetUpdateAssets end at ", now.ToString()));
                        if (versionEdit.CanPost())
                        {
                            versionEdit.Post("MSD.QC");
                        }
                        workspaceEdit.StopEditOperation();
                        workspaceEdit.StopEditing(true);
                    }
                }
                this.dtEndTime  = DateTime.Now;
                this.tsDiff     = this.dtEndTime.Subtract(this.dtStartTime);
                this.dlTimeDiff = this.tsDiff.TotalMilliseconds;
                Assets.logger.Debug(string.Concat("UpdateAssets end at ", this.dtStartTime.ToString(), " Total diff : ", this.dlTimeDiff.ToString()));
                num = counter;
            }
            catch (COMException cOMException)
            {
                COMException ex = cOMException;
                Assets.logger.Debug(string.Concat("Error from UpdateAssets : ", ex.Message, " ", ex.StackTrace));
                throw ex;
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                Assets.logger.Debug(string.Concat("Error from UpdateAssets : ", ex.Message, " ", ex.StackTrace));
                throw ex;
            }
            return(num);
        }