当前位置:首页 > articles > 正文内容

如何为Neo4j服务经理编程?

Luz4周前 (07-20)articles133

How to program a Neo4j Service Manager?

  • Caslon Melior 问题:
    • I am trying to write a Neo4j service manager program in C# that can start and stop local graph databases using the current Neo4j version, 3.3.5. The program should replicate the functionality of the discontinued
      Neo4j-ce.exe
      program. The program will call the same PowerShell commands that are in the
      Neo4j.bat
      file. This is the first PowerShell script I have tried to write.
    • 到目前为止,程序在启动时会出现许多异常错误,这些错误以“无法找到或打开PDB文件”结束当我运行PowerShell实例代码时,会引发安全异常。。。
    • Exception thrown: 'System.DllNotFoundException' in System.Management.Automation.dllException thrown: 'System.Security.SecurityException' in mscorlib.dll
    • ... Yet the
      PowerShellInstance.Streams.Error.Count
      is zero.
    • Neo4j.bat
      contains this call to PowerShell:
    • PowerShell -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -Command "try { Unblock-File -Path '%~dp0Neo4j-Management\*.*' -ErrorAction 'SilentlyContinue' } catch {};Import-Module '%~dp0Neo4j-Management.psd1'; Exit (Invoke-Neo4j %*)"
    • Neo4jServiceManager.exe
      contains this button event:
    • private void btnNeo4jStart_Click(object sender, EventArgs e){    // Create runspace to be used by PowerShell instance.    Runspace myRunspace = RunspaceFactory.CreateRunspace();    myRunspace.Open();    // Start PowerShell instance.    using (PowerShell PowerShellInstance = PowerShell.Create())    {        // Add runspace to PowerShell instance.        PowerShellInstance.Runspace = myRunspace;        // Add command to pipeline.        // Import module: Neo4j-Management.psd1 and execute Invoke-Neo4j cmdlet.        PowerShellInstance.AddScript(@"C:\; cd C:\neo4j-community-3.3.5; SETLOCAL; try { Unblock-File -Path 'C:\neo4j-community-3.3.5\bin\Neo4j-Management\*.*' -ErrorAction 'SilentlyContinue' } catch {}; Exit ('C:\neo4j-community-3.3.5\bin\Neo4j-Management\Invoke-Neo4j.psd1 install-service')");        // Invoke execution on the pipeline (and collect output).        Collection<PSObject> PSOutput = PowerShellInstance.Invoke();        // Loop through each output object item.        foreach (PSObject outputItem in PSOutput)        {            // if null object was dumped to the pipeline during the script then a null            // object may be present here. check for null to prevent potential NRE.            if (outputItem != null)            {                //TODO: do something with the output item                 // outputItem.BaseOBject            }        }        // Check the other output streams (for example, the error stream).        // If PowerShellInstance.Streams.Error.Count = 1, then        // PowerShellInstance.Streams.Error[0].CategoryInfo returns information.        if (PowerShellInstance.Streams.Error.Count > 0)        {            // error records were written to the error stream.            // do something with the items found.        }    }}
  • 回答:

相关文章

使用nodejs和mongodb进行前端搜索

Frontend search with nodejs and mongodbCaleb 问题: 我今天刚开始学习mongodb,我有一段代码可以用来查询我的数据库和搜索地址:“Park Lane 38”。这是代码,这是结果:...

单元测试名称重要吗?

Are unit-test names important?Xian 问题: 如果单元测试名称随着时间的推移而变得过时,如果您认为测试本身是最重要的事情,那么选择明智的测试名称是重要的吗?ie[Test]public void Sh...

应该如何使用kotlin将findViewById传递数据从活动页面写入片段页面

How should write the findViewById pass data to Fragment page from Activity page using kotlinMIN LEE 问题: //这是我的活动页面覆盖...

脚本1 linux中的crear usuarios和demás

Script 1 de crear usuarios y demás en linuxMaría Isabel De la Osa Rocha 问题: Cómo se haría el script del usuario porq...

C++:泛型&gt&gt;如何为一个通用函数定义多个模板解题,该函数充当静态实例创建者

C++:Generics >> How to define several template deklarations for a generic function, which serves as an static inst...

三js如何向FBX模型添加多个没有蒙皮的Mixamo动画?

Three.js how to add multiple Mixamo animations without skin to an FBX model?Anye 问题: I'm trying to create a game whe...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。