Skip to content

Commit

Permalink
successfully perform a commit from C#
Browse files Browse the repository at this point in the history
  • Loading branch information
cdriesler committed Oct 3, 2022
1 parent 9c14c68 commit 2773bfb
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 62 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "apps/speckle-server"]
path = apps/speckle-server
url = https://github.com/specklesystems/speckle-server.git
[submodule "packages/speckle-sharp"]
path = packages/speckle-sharp
url = [email protected]:specklesystems/speckle-sharp.git
117 changes: 62 additions & 55 deletions apps/rhino-compute-server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
using Nancy.TinyIoc;
using Nancy.Bootstrapper;
using NodePen.Converters;
using Newtonsoft.Json;
using Grasshopper.Kernel;
using GH_IO.Serialization;
using Speckle.Core.Api;
using Speckle.Core.Models;
using Speckle.Core.Credentials;
using Speckle.Core.Transports;
using Speckle.Newtonsoft.Json;

namespace Rhino.Compute
{
Expand All @@ -24,58 +24,7 @@ class Program

public static IDisposable RhinoCore { get; set; }

static void Main(string[] args)
{
RhinoInside.Resolver.Initialize();

HostFactory.Run((Host) =>
{
Host.Service<SelfHostService>();
Host.SetDisplayName("NodePen");
});

}

}

internal class SelfHostService : ServiceControl
{

public bool Start(HostControl host)
{
// Start headless Rhino process
Console.WriteLine($"Rhino system directory: {RhinoInside.Resolver.RhinoSystemDirectory}");
Program.RhinoCore = new Rhino.Runtime.InProcess.RhinoCore(null, Rhino.Runtime.InProcess.WindowStyle.NoWindow);

// Start web server
var options = new StartOptions();
options.Urls.Add("http://localhost:6500");

WebApp.Start<Startup>(options);

return true;
}

public bool Stop(HostControl host)
{
return true;
}

}

internal class Startup
{

public void Configuration(IAppBuilder app)
{
app.UseNancy();
}

}

public class Bootstrapper : Nancy.DefaultNancyBootstrapper
{
private async Task<string> TryThis()
private static async Task<string> TryThis()
{
var account = new Account()
{
Expand Down Expand Up @@ -103,7 +52,8 @@ private async Task<string> TryThis()
var data = new Base();
data["test"] = "Some Value 2";

var commitId = await Helpers.Send("http://localhost:3000/streams/b0d3a3c122/branches/main", data, "Test message");
Console.WriteLine("Sending!");
var commitId = await Helpers.Send("http://localhost:3000/streams/b0d3a3c122/branches/main", data, "Test message", useDefaultCache: false, account: account);

// var objectId = await Operations.Send(
// data,
Expand Down Expand Up @@ -146,6 +96,62 @@ private async Task<string> TryThis()

return commitId;
}

static void Main(string[] args)
{
var commitId = TryThis().Result;

Console.WriteLine(commitId);

// RhinoInside.Resolver.Initialize();

// HostFactory.Run((Host) =>
// {
// Host.Service<SelfHostService>();
// Host.SetDisplayName("NodePen");
// });

}

}

internal class SelfHostService : ServiceControl
{

public bool Start(HostControl host)
{
// Start headless Rhino process
Console.WriteLine($"Rhino system directory: {RhinoInside.Resolver.RhinoSystemDirectory}");
Program.RhinoCore = new Rhino.Runtime.InProcess.RhinoCore(null, Rhino.Runtime.InProcess.WindowStyle.NoWindow);

// Start web server
var options = new StartOptions();
options.Urls.Add("http://localhost:6500");

WebApp.Start<Startup>(options);

return true;
}

public bool Stop(HostControl host)
{
return true;
}

}

internal class Startup
{

public void Configuration(IAppBuilder app)
{
app.UseNancy();
}

}

public class Bootstrapper : Nancy.DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
// Load Grasshopper
Expand All @@ -163,7 +169,8 @@ protected override void ApplicationStartup(TinyIoCContainer container, IPipeline

// var streamUrl = "http://localhost:3000/streams/b0d3a3c122";

var commitId = TryThis().Result;
// var commitId = TryThis().Result;
var commitId = "ok";

// var commitId = client.CommitCreate(new CommitCreateInput()
// {
Expand Down
7 changes: 4 additions & 3 deletions apps/rhino-compute-server/Rhino.Compute.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
<PackageReference Include="Nancy" Version="1.4.4" />
<PackageReference Include="Nancy.Owin" Version="1.4.1" />
<PackageReference Include="Rhino.Inside" Version="7.0.0" />
<!-- <PackageReference Include="Speckle.Objects.Converter.Rhino7" Version="2.8.0" /> -->
<PackageReference Include="Speckle.Core" Version="2.8.0" />
<PackageReference Include="Speckle.Objects" Version="2.8.0" />
<PackageReference Include="Speckle.Objects.Converter.Rhino7" Version="2.8.0" />
<PackageReference Include="Speckle.Objects.Converter.Grasshopper7" Version="2.8.0" />
<PackageReference Include="Topshelf" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\packages\converters\Nodepen.Converters.csproj" />
<ProjectReference Include="..\..\packages\speckle-sharp\Core\Core\Core.csproj" />
<ProjectReference Include="..\..\packages\speckle-sharp\Objects\Objects\Objects.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion packages/speckle-sharp
Submodule speckle-sharp deleted from b5ebe1

0 comments on commit 2773bfb

Please sign in to comment.