c# - 创建新的地震采集海洋框架

标签 c# transactions ocean petrel

我正在尝试使用以下代码片段创建一个新的空地震集合。

Collection 已创建并添加到输入 Pane ,但尝试创建 NewSeismicCollection 会抛出一个

A plug-in has triggered error: Slb.Ocean.Core.TransactionLockException; Transaction lock failure.

if(seismicProj.SeismicCollectionCount == 0)
{
    PetrelLogger.InfoOutputWindow("No seismic collections in current project");
    using (ITransaction trans2 = DataManager.NewTransaction())
    {
        trans2.Lock(proj);
        Collection col2 = proj.CreateCollection("Collection"); 
    }

    using (ITransaction txn = DataManager.NewTransaction())
    {
        try
        {
            txn.Lock(seismicProj);
            SeismicCollection seisColl = seismicProj.CreateSeismicCollection(
                "NewSeismicCollection");
        }
        catch (InvalidOperationException e)
        {
            PetrelLogger.InfoOutputWindow(e.Message);
        }
        finally
        {
            txn.Commit();
        }
    }
}
else
{
    // do something else
}

最佳答案

不应该在您在 try block 中提交的单个事务中,如:

using (ITransaction txn = DataManager.NewTransaction())
{
    try
    {
        txn.Lock(proj);
        Collection col2 = proj.CreateCollection("Collection"); 
        txn.Lock(seismicProj);
        SeismicCollection seisColl = seismicProj.CreateSeismicCollection("NewSeismicCollection");
        txn.Commit();
    }
    catch (Exception e)
    {
        PetrelLogger.InfoOutputWindow(e.Message);
        throw;
    }
}

或者找出错误:尝试作为两个单独的事务:

using (ITransaction txn = DataManager.NewTransaction())
{
    try
    {
        txn.Lock(proj);
        Collection col2 = proj.CreateCollection("Collection"); 
        txn.Commit();
    }
    catch (Exception e)
    {
        PetrelLogger.InfoOutputWindow(e.Message);
        throw;
    }
}

using (ITransaction txn = DataManager.NewTransaction())
{
    try
    {
        txn.Lock(seismicProj);
        SeismicCollection seisColl = seismicProj.CreateSeismicCollection("NewSeismicCollection");
        txn.Commit();
    }
    catch (Exception e)
    {
        PetrelLogger.InfoOutputWindow(e.Message);
        throw;
    }
}

关于c# - 创建新的地震采集海洋框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29956723/

相关文章:

mysql - 我可以跨两个 MySQL 数据库执行事务吗?

ocean - 在虚拟机中运行 Petrel?

ocean - 通过例如大规模部署 PIP组策略?

c# - 这两种事务处理方式有什么区别

java - 将事务传播到 Forkjoin 提交

c# - 如何加密/解密以存储敏感数据(ASP.NET Web API 项目)

c# - 使用 goto 语句从一种方法跳转到另一种方法

c# - 使用海洋在 Petrel 3D 窗口中绘制地震体积墙

c# - NServiceBus升级后"Unable to find assembly"

c# - mvc模式中模型和 Controller 的分离