示例#1
0
        internal IQueryFilter SiteFilter(RefugeeSite site)
        {
            IQueryFilter filter = new QueryFilterClass();

            filter.WhereClause = _fc.OIDFieldName + " = " + site.OID.ToString();
            return(filter);
        }
        public void SupplyResource(RefugeeSite site)
        {
            do
            {
                IFeatureClass facilityClass  = _repositoryCol.FeatureClass;
                IQueryFilter  facilityFilter = _repositoryCol.ValidFilter();

                if (facilityClass.FeatureCount(facilityFilter) == 0)
                {
                    LogHelper.Error("没有足够的" + site.ResourceName());
                    break;
                }
                _roadNetwork.SetFacilities(facilityClass, facilityFilter);

                IQueryFilter  siteFilter = _refugeSiteCol.SiteFilter(site);
                IFeatureClass siteClass  = _refugeSiteCol.FeatureClass;
                _roadNetwork.SetIncidents(siteClass, siteFilter);

                SupplyRoute route = _roadNetwork.FindRoute();
                if (route == null)
                {
                    LogHelper.Error("剩余的" + site.ResourceName() + "因为路径不通无法配送");
                    break;
                }
                Repository repo   = _repositoryCol.FindRepoByID(route.RepoID);
                int        amount = 0;
                if (repo.Remain >= site.ResourceInNeed)
                {
                    amount = site.ResourceInNeed;
                }
                else
                {
                    amount = repo.Remain;
                }

                _repositoryCol.SupplyResource(repo, amount);
                site.ReplenishResource(amount);
                //_refugeSiteCol.ReplenishResource(site, amount);

                route.SetMessagePara(site.ResourceName(), amount, site.ResourceUnit());
                route.IncidentID = site.OID;

                AddRouteFeature(route);
                _siteRoutes.Add(route);
            }while (site.ResourceInNeed > 0);

            IFeatureClassManage manage = this._outputFC as IFeatureClassManage;

            manage.UpdateExtent();
        }
示例#3
0
        private int GetInsertIndex(List <RefugeeSite> col, RefugeeSite site)
        {
            int index = 0;

            for (int i = 0; i < col.Count; i++)
            {
                RefugeeSite s = col[i];
                if (site.Priority < s.Priority)
                {
                    index++;
                }
            }
            return(index);
        }
示例#4
0
        protected List <RefugeeSite> GetRefugeeSites()
        {
            _totalResourceNeeds = 0;
            List <RefugeeSite> results = new List <RefugeeSite>();
            IFeatureCursor     cursor  = null;

            try
            {
                cursor = _fc.Search(null, true);
                IFeature feature = cursor.NextFeature();

                while (feature != null)
                {
                    RefugeeSite site = CreateSite(feature);
                    if (site == null)
                    {
                        feature = cursor.NextFeature();
                        continue;
                    }

                    int insertIndex = GetInsertIndex(results, site);
                    results.Insert(insertIndex, site);
                    feature = cursor.NextFeature();

                    _totalResourceNeeds += site.ResourceInNeed;
                }
                return(results);
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(null);
            }
            finally
            {
                ComReleaser.ReleaseCOMObject(cursor);
            }
        }