1、压力测试
比如说rasterdataset入rastercatalog开始可以达到10条/s,但是一段时间以后只能2条/s,要注意
2、日志记录
长事务容易出错,要有据可查,要注意
3、重复检查
长事务如果出错了,是否可以不清空,重新来过呢?这就需要支持重复检查,要注意
如下就是长事务
public static bool AddRasterToCatalog(ref IRasterCatalog targetRasterCatalog, string strRasterName, IRasterDataset sourceRasterDataset)
{
IFeatureClass pFeatureClass = targetRasterCatalog as IFeatureClass;
int nameindex = targetRasterCatalog.NameFieldIndex;
int rasterindex = targetRasterCatalog.RasterFieldIndex;
IFeatureBuffer pBuffer = null;
IFeatureCursor pCursor = pFeatureClass.Insert(false);
IRasterValue pRasterValue = new RasterValueClass();
pRasterValue.RasterDataset = sourceRasterDataset;
pRasterValue.RasterStorageDef = GetDefaultRasterStorageDef(); //存储参数
bool bSuccess = false;
try
{
pBuffer = pFeatureClass.CreateFeatureBuffer();
pBuffer.set_Value(rasterindex, pRasterValue); //有点像blog字段啊
pBuffer.set_Value(nameindex, strRasterName);
pCursor.InsertFeature(pBuffer);
pCursor.Flush();
bSuccess = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor); //非常重要,不然出现异常
System.Runtime.InteropServices.Marshal.ReleaseComObject(pBuffer);
System.Runtime.InteropServices.Marshal.ReleaseComObject(pRasterValue);
return bSuccess;
}