110,538
社区成员
发帖
与我相关
我的任务
分享
public bool CreateGISIndexesByKey(out string errMsg)
{
JD_TotalEntities entity = new JD_TotalEntities();
List<datum> datas = entity.data.ToList();
foreach (datum data in datas)
{
string folderId = data.DataFolderId;
string folders = data.DataFolders;
List<string> Folderlevel = new List<string>();
Folderlevel = folders.Split(',').ToList();
string folderPath = null;
if (Folderlevel.Count < 5)
{
folderPath = String.Format("{0}\\{1}", GlobalSetting.LucencePath3, Folderlevel[0]);
if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);
}
else
{
folderPath = String.Format("{0}\\{1}", GlobalSetting.LucencePath3, Folderlevel[Folderlevel.Count - 4]);
if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);
}
List<dataindex> DataIndexIds = entity.dataindexes.Where(di=>di.DataFolderId==data.DataFolderId).ToList();
foreach (dataindex DataIndexId in DataIndexIds)
{
var entityIndexValues = entity.entityindexvalues.Where(e => e.DataIndexId == DataIndexId.DataIndexId);
int count = entityIndexValues.Count();
int index = count / 10000;
if (count % 10000 != 0)
index++;
for (int i = 0; i < index; i++)
{
List<entityindexvalue> indexValues = entityIndexValues.OrderBy(o => o.DataEntityId).Skip(i * 10000).Take(10000).ToList();
List<LucenceDataGISEntity> GISEntitys = new List<LucenceDataGISEntity>();
foreach (entityindexvalue indexValue in indexValues)
{
LucenceDataGISEntity GISEntity = new LucenceDataGISEntity();
GISEntity.Key = indexValue.DataIndexId;
GISEntity.Value = indexValue.EntityIndexValue1 == null ? "" : indexValue.EntityIndexValue1.ToString();
GISEntity.EntityId = indexValue.DataEntityId;
dataentity dataentity = entity.dataentities.FirstOrDefault(o => o.DataEntityId == indexValue.DataEntityId);
GISEntity.IsGISData = (dataentity.DataLong != null && dataentity.DataLat != null) ? "1" : "0";
GISEntity.EntityLong = dataentity.DataLong == null ? "-1" : dataentity.DataLong.ToString();
GISEntity.EntityLat = dataentity.DataLat == null ? "-1" : dataentity.DataLat.ToString();
GISEntity.Folders = folders;
GISEntitys.Add(GISEntity);
}
IndexManager.CreateGISIndexsByKey(folderPath, folderId, GISEntitys, out errMsg);
}
}
}
errMsg = null;
return true;
}