zoukankan      html  css  js  c++  java
  • 开发长事务工具需要注意点

    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;

            }

  • 相关阅读:
    【批处理】for命令
    【批处理】if命令,注释方式
    【批处理】choice命令,call 命令,start 命令,rem
    LoadLibrary加载动态库失败
    编译器如何实现静态变量只初始化一次
    汇编语言中 cs, ds,ss 的区别
    变量在内存中的位置
    call和ret指令
    函数调用
    浮动
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/2111786.html
Copyright © 2011-2022 走看看