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;

            }

  • 相关阅读:
    day14_oracle数据库备份
    day13_存储过程小记
    day13_先沃联盟定时任务
    day13_自动抽取数据——监控存储过程
    [笔记]《HTTP权威指南》- 实体和编码
    [笔记]《白帽子讲Web安全》- Web框架安全
    [笔记]《Vue移动开发实战技巧》- Vue-router使用
    WPF与Win32互操作
    [翻译]HTML5
    学习资料收藏
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/2111786.html
Copyright © 2011-2022 走看看