Ejemplo n.º 1
0
        private bool updatePolygon(IFeatureClass ftrCls, int oid)
        {
            bool           x     = false;
            IGeometry      geo   = ftrCls.GetFeature(oid).ShapeCopy;
            ISpatialFilter spFlt = new SpatialFilterClass();

            spFlt.WhereClause = ftrCls.OIDFieldName + " <> " + oid.ToString();
            spFlt.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
            IQueryFilterDefinition2 qryDef2 = (IQueryFilterDefinition2)spFlt;

            qryDef2.PostfixClause = "Order by Shape_Area DESC";
            spFlt.Geometry        = geo;
            spFlt.GeometryField   = ftrCls.ShapeFieldName;
            spFlt.SearchOrder     = esriSearchOrder.esriSearchOrderSpatial;
            IFeatureCursor ftrCur         = ftrCls.Search(spFlt, false);
            int            shapeAreaIndex = ftrCur.FindField("Shape_Area");
            IFeature       ftr            = ftrCur.NextFeature();

            while (ftr != null)
            {
                IGeometry             geoMax    = ftr.ShapeCopy;
                int                   beforeCnt = ((IGeometryCollection)geoMax).GeometryCount;
                ITopologicalOperator4 tp        = (ITopologicalOperator4)geoMax;
                IGeometry             uGeo      = tp.Union(geo);
                int                   afterCnt  = ((IGeometryCollection)uGeo).GeometryCount;
                if (beforeCnt >= afterCnt)
                {
                    try
                    {
                        ftr.Shape = uGeo;
                        if (shapeAreaEdit)
                        {
                            ftr.set_Value(shapeAreaIndex, ((IArea)uGeo).Area);
                        }
                        ftr.Store();
                        x = true;
                        return(x);
                    }
                    catch (Exception e)
                    {
                        x = false;
                        Console.WriteLine(e.ToString());
                        return(x);
                    }
                }
                ftr = ftrCur.NextFeature();
            }
            return(x);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查询任务列表
        /// </summary>
        /// <returns></returns>
        public List <string[]> GetTaskInfoList(string pTaskName, string pDept, string pStatus)
        {
            List <string[]>   infos    = new List <string[]>();
            IFeatureWorkspace ws       = Util.ServerWorkspace as IFeatureWorkspace;
            ITable            task_tbl = ws.OpenTable("TaskLog");
            IQueryFilter      filter   = new QueryFilterClass();
            string            whereStr = "";

            if (pTaskName != string.Empty)
            {
                whereStr = "TaskName like '%" + pTaskName + "%'";
            }
            if (pDept != string.Empty)
            {
                if (whereStr != string.Empty)
                {
                    whereStr += " and ";
                }
                whereStr += "Dept like '%" + pDept + "%'";
            }
            if (pStatus != string.Empty)
            {
                if (whereStr != string.Empty)
                {
                    whereStr += " and ";
                }
                whereStr += "Status='" + pStatus + "'";
            }
            filter.WhereClause = whereStr;
            IQueryFilterDefinition2 qfd = filter as IQueryFilterDefinition2;

            qfd.PostfixClause = "Order by CheckOutDate Desc";
            ICursor cur = task_tbl.Search(filter, false);
            IRow    rw  = cur.NextRow();

            while (rw != null)
            {
                string[] values = new string[6];
                values[0] = rw.get_Value(task_tbl.FindField("TaskName")) as string;
                values[1] = rw.get_Value(task_tbl.FindField("Dept")) as string;
                values[2] = rw.get_Value(task_tbl.FindField("CheckOutDate")) as string;
                values[3] = rw.get_Value(task_tbl.FindField("CheckInDate")) as string;
                string status = rw.get_Value(task_tbl.FindField("Status")) as string;
                switch (status)
                {
                case TaskManager.CHECKOUT_STATUS:
                    values[4] = "下发";
                    break;

                case TaskManager.CHECKIN_STATUS:
                    values[4] = "上传";
                    break;

                case TaskManager.FINISH_STATUS:
                    values[4] = "结束";
                    break;

                case TaskManager.MANUALCHECK_STATUS:
                    values[4] = "监理已检查";
                    break;
                }
                values[5] = rw.get_Value(task_tbl.FindField("FinishDate")) as string;
                //values[6] = rw.get_Value(task_tbl.FindField("comment")) as string;
                //values[7] = rw.get_Value(task_tbl.FindField("totalUpdateItems")) as string;
                //values[8] = rw.get_Value(task_tbl.FindField("totalAddItems")) as string;
                //values[9] = rw.get_Value(task_tbl.FindField("totalDeleteItems")) as string;
                //values[10] = rw.get_Value(task_tbl.FindField("totalUpdateGrids")) as string;
                //values[11] = rw.get_Value(task_tbl.FindField("totalUpdateGridsArea")) as string;
                infos.Add(values);
                rw = cur.NextRow();
            }
            return(infos);
        }
Ejemplo n.º 3
0
        bool FindEmptyPlans(ICadastralFabric Fabric, IStepProgressor StepProgressor,
                            ITrackCancel TrackCancel, out IFIDSet EmptyPlans)
        {
            ICursor    pPlansCur          = null;
            ICursor    pParcelCur         = null;
            IFIDSet    pEmptyPlansFIDSet  = new FIDSetClass();
            List <int> pNonEmptyPlansList = new List <int>();
            IDataset   pDS = (IDataset)Fabric;
            IWorkspace pWS = pDS.Workspace;

            ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
            string     sPref      = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
            string     sSuff      = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

            try
            {
                ITable pPlansTable   = Fabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
                ITable pParcelsTable = Fabric.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels);

                ////build a list of ids for all the plans found via parcels
                //if a Personal GDB then don't try to use DISTINCT
                if (pWS.Type == esriWorkspaceType.esriLocalDatabaseWorkspace && pWS.PathName.ToLower().EndsWith(".mdb"))
                {
                    pParcelCur = pParcelsTable.Search(null, false);
                }
                else
                {
                    IQueryFilter pQuF = new QueryFilterClass();
                    pQuF.SubFields = "PLANID";
                    IQueryFilterDefinition2 queryFilterDef = (IQueryFilterDefinition2)pQuF;
                    queryFilterDef.PrefixClause = "DISTINCT PLANID";
                    pParcelCur = pParcelsTable.Search(pQuF, true); //Recycling set to true
                }

                Int32 iPlanIDX = pParcelCur.Fields.FindField("PLANID");
                IRow  pParcRow = pParcelCur.NextRow();

                while (pParcRow != null)
                {
                    //Create a collection of planIDs from Parcels table that we know are not empty
                    Int32  iPlanID  = -1;
                    object Attr_val = pParcRow.get_Value(iPlanIDX);
                    if (Attr_val != DBNull.Value)
                    {
                        iPlanID = (Int32)Attr_val;
                        if (iPlanID > -1)
                        {
                            if (!pNonEmptyPlansList.Contains(iPlanID))
                            {
                                pNonEmptyPlansList.Add(iPlanID);
                            }
                        }
                    }
                    Marshal.ReleaseComObject(pParcRow);
                    pParcRow = pParcelCur.NextRow();
                }

                if (pParcelCur != null)
                {
                    Marshal.FinalReleaseComObject(pParcelCur);
                }

                pPlansCur = pPlansTable.Search(null, false);

                IRow pPlanRow = pPlansCur.NextRow();
                while (pPlanRow != null)
                {
                    bool bFound = false;
                    bFound = pNonEmptyPlansList.Contains(pPlanRow.OID);
                    if (!bFound) //This plan was not found in our parcel-referenced plans
                    {
                        //check if this is the default map plan, so it can be excluded from deletion
                        Int32  iPlanNameIDX = pPlanRow.Fields.FindField("NAME");
                        string sPlanName    = (string)pPlanRow.get_Value(iPlanNameIDX);
                        if (sPlanName.ToUpper() != "<MAP>")
                        {
                            pEmptyPlansFIDSet.Add(pPlanRow.OID);
                        }
                    }
                    Marshal.ReleaseComObject(pPlanRow);
                    pPlanRow = pPlansCur.NextRow();
                }
                EmptyPlans = pEmptyPlansFIDSet;

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(Convert.ToString(ex.Message), "Find Empty Plans");
                EmptyPlans = null;
                return(false);
            }
            finally
            {
                if (pParcelCur != null)
                {
                    do
                    {
                    }while (Marshal.ReleaseComObject(pParcelCur) > 0);
                }

                if (pNonEmptyPlansList != null)
                {
                    pNonEmptyPlansList.Clear();
                    pNonEmptyPlansList = null;
                }

                if (pParcelCur != null)
                {
                    do
                    {
                    }while (Marshal.ReleaseComObject(pParcelCur) > 0);
                }
            }
        }