From becfc77dc2135361f9bb4669f30835b74d72d5d2 Mon Sep 17 00:00:00 2001 From: David Ellams Date: Fri, 13 Sep 2024 14:56:33 -0400 Subject: [PATCH] - Moved OAPPType enum from STAR ODK to OASIS.API.Core. - Moved ICoronalEjection interface from STAR ODK to OASIS.API.Core. - Moved IOAPPDNA from OASIS.API.ONODE.Core to OASIS.API.Core. - Moved CoronalEjection interface from STAR ODK to OASIS.API.Core. - Upgraded all methods in main STAR class in STAR ODK and STAR CLI.Lib to now allow providerType to be passed in. - Added OAPPDesc to all Light and LightAsync methods and removed reundant overloads in STAR in STAR ODK. - Re-wrote some of LightAsync method so now conforms to OASIS best standards (has better error handling/logging etc) and now calls the new CreateOAPPAsync method on the new OAPPManager/OAPP API so new OAPPs generated are now logged in the STARNET lib. - Added SeedAsync, Seed, UnSeedAsync & UnSeed methods to STAR in STAR ODK, which call the new PublishOAPPAsync and UnPublishOAPPAsync methods on the new OAPPManager/OAPP API. - Updated ReadyPlayerOne method in STAR CLI Lib for light command so works with the new OAPPDesc field. - Added a new unseed command to ReadyPlayerOne method and ShowCommands method in STAR CLI. - Updated LightWizard in STAR.CLI.Lib to work with the new OAPPDesc. --- .../Enums/OAPPType.cs | 23 ++ .../Interfaces/IOAPPDNA.cs | 27 +++ .../STAR/CelestialBodies/ICelestialBody.cs | 7 +- .../Interfaces/STAR/ICoronalEjection.cs | 12 + .../NextGenSoftware.OASIS.API.Core.csproj | 1 - .../Objects/{ => Star}/CoronalEjection.cs | 13 +- .../Enums/OAPPType.cs | 42 ++-- .../Holons/InstalledOAPP.cs | 3 +- .../Holons/OAPP.cs | 1 - .../Interfaces/Holons/IOAPP.cs | 1 - .../Interfaces/Objects/IOAPPDNA.cs | 56 +++-- .../Managers/OAPPManager.cs | 4 +- .../Objects/OAPPDNA.cs | 3 +- NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs | 56 ++--- NextGenSoftware.OASIS.STAR.CLI/Program.cs | 55 +++-- .../CelestialBodies/CelestialBody.cs | 2 +- .../CelestialBodies/WormHole.cs | 1 - .../Interfaces/ICoronalEjection.cs | 14 ++ .../NextGenSoftware.OASIS.STAR.csproj | 4 - .../Objects/CoronalEjection.cs | 15 ++ NextGenSoftware.OASIS.STAR/Star.cs | 210 +++++++++--------- 21 files changed, 322 insertions(+), 228 deletions(-) create mode 100644 NextGenSoftware.OASIS.API.Core/Enums/OAPPType.cs create mode 100644 NextGenSoftware.OASIS.API.Core/Interfaces/IOAPPDNA.cs create mode 100644 NextGenSoftware.OASIS.API.Core/Interfaces/STAR/ICoronalEjection.cs rename NextGenSoftware.OASIS.API.Core/Objects/{ => Star}/CoronalEjection.cs (53%) create mode 100644 NextGenSoftware.OASIS.STAR/Interfaces/ICoronalEjection.cs create mode 100644 NextGenSoftware.OASIS.STAR/Objects/CoronalEjection.cs diff --git a/NextGenSoftware.OASIS.API.Core/Enums/OAPPType.cs b/NextGenSoftware.OASIS.API.Core/Enums/OAPPType.cs new file mode 100644 index 000000000..e9b368d45 --- /dev/null +++ b/NextGenSoftware.OASIS.API.Core/Enums/OAPPType.cs @@ -0,0 +1,23 @@ + + +namespace NextGenSoftware.OASIS.API.Core.Enums +{ + public enum OAPPType + { + //CelestialBodies, + GeneratedCodeOnly, + Console, + Blazor, + WebMVC, + MAUI, + Unity, + WinForms, + WPF, + WindowsService, + RESTService, + gRPCService, + GraphQLService, + //ClassLibrary, + Custom + } +} diff --git a/NextGenSoftware.OASIS.API.Core/Interfaces/IOAPPDNA.cs b/NextGenSoftware.OASIS.API.Core/Interfaces/IOAPPDNA.cs new file mode 100644 index 000000000..1f2e02410 --- /dev/null +++ b/NextGenSoftware.OASIS.API.Core/Interfaces/IOAPPDNA.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using NextGenSoftware.OASIS.API.Core.Enums; +using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; + +namespace NextGenSoftware.OASIS.API.Core.Interfaces +{ + public interface IOAPPDNA + { + ICelestialBody CelestialBody { get; set; } //optional + Guid CelestialBodyId { get; set; } + string CelestialBodyName { get; set; } + HolonType CelestialBodyType { get; set; } + IEnumerable Zomes { get; set; } + Guid CreatedByAvatarId { get; set; } + DateTime CreatedOn { get; set; } + string Description { get; set; } + GenesisType GenesisType { get; set; } + Guid OAPPId { get; set; } + string OAPPName { get; set; } + OAPPType OAPPType { get; set; } + Guid PublishedByAvatarId { get; set; } + DateTime PublishedOn { get; set; } + bool PublishedOnSTARNET { get; set; } + string Version { get; set; } + } +} \ No newline at end of file diff --git a/NextGenSoftware.OASIS.API.Core/Interfaces/STAR/CelestialBodies/ICelestialBody.cs b/NextGenSoftware.OASIS.API.Core/Interfaces/STAR/CelestialBodies/ICelestialBody.cs index 4f50f0080..3df55d95f 100644 --- a/NextGenSoftware.OASIS.API.Core/Interfaces/STAR/CelestialBodies/ICelestialBody.cs +++ b/NextGenSoftware.OASIS.API.Core/Interfaces/STAR/CelestialBodies/ICelestialBody.cs @@ -4,7 +4,6 @@ using NextGenSoftware.OASIS.Common; using NextGenSoftware.OASIS.API.Core.Enums; using NextGenSoftware.OASIS.API.Core.Events; -using NextGenSoftware.OASIS.API.Core.Objects; namespace NextGenSoftware.OASIS.API.Core.Interfaces.STAR { @@ -48,7 +47,7 @@ public interface ICelestialBody : ICelestialHolon void Dim(); void Emit(); void Evolve(); - CoronalEjection Flare(); + ICoronalEjection Flare(); List GetHolonsThatBelongToZome(IZome zome); IZome GetZomeById(Guid id); IZome GetZomeByName(string name); @@ -65,8 +64,8 @@ public interface ICelestialBody : ICelestialHolon void Mutate(); void Radiate(); void Reflect(); - OASISResult Save(bool saveChildren = true, bool recursive = true, int maxChildDepth = 0, bool continueOnError = true, bool saveChildrenOnProvider = false, ProviderType providerType = ProviderType.Default); - Task> SaveAsync(bool saveChildren = true, bool recursive = true, int maxChildDepth = 0, bool continueOnError = true, bool saveChildrenOnProvider = false, ProviderType providerType = ProviderType.Default); + OASISResult Save(bool saveChildren = true, bool recursive = true, int maxChildDepth = 0, bool continueOnError = true, bool saveChildrenOnProvider = false, ProviderType providerType = ProviderType.Default); + Task> SaveAsync(bool saveChildren = true, bool recursive = true, int maxChildDepth = 0, bool continueOnError = true, bool saveChildrenOnProvider = false, ProviderType providerType = ProviderType.Default); OASISResult> SaveZomes(bool saveChildren = true, bool recursive = true, int maxChildDepth = 0, bool continueOnError = true, bool saveChildrenOnProvider = false, ProviderType providerType = ProviderType.Default); Task>> SaveZomesAsync(bool saveChildren = true, bool recursive = true, int maxChildDepth = 0, bool continueOnError = true, bool saveChildrenOnProvider = false, ProviderType providerType = ProviderType.Default); void Seed(); diff --git a/NextGenSoftware.OASIS.API.Core/Interfaces/STAR/ICoronalEjection.cs b/NextGenSoftware.OASIS.API.Core/Interfaces/STAR/ICoronalEjection.cs new file mode 100644 index 000000000..ded82c467 --- /dev/null +++ b/NextGenSoftware.OASIS.API.Core/Interfaces/STAR/ICoronalEjection.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace NextGenSoftware.OASIS.API.Core.Interfaces.STAR +{ + public interface ICoronalEjection + { + ICelestialBody CelestialBody { get; set; } + ICelestialSpace CelestialSpace { get; set; } + IOAPPDNA OAPPDNA { get; set; } + IEnumerable Zomes { get; set; } + } +} \ No newline at end of file diff --git a/NextGenSoftware.OASIS.API.Core/NextGenSoftware.OASIS.API.Core.csproj b/NextGenSoftware.OASIS.API.Core/NextGenSoftware.OASIS.API.Core.csproj index 800cbe097..7f60240a3 100644 --- a/NextGenSoftware.OASIS.API.Core/NextGenSoftware.OASIS.API.Core.csproj +++ b/NextGenSoftware.OASIS.API.Core/NextGenSoftware.OASIS.API.Core.csproj @@ -58,7 +58,6 @@ - diff --git a/NextGenSoftware.OASIS.API.Core/Objects/CoronalEjection.cs b/NextGenSoftware.OASIS.API.Core/Objects/Star/CoronalEjection.cs similarity index 53% rename from NextGenSoftware.OASIS.API.Core/Objects/CoronalEjection.cs rename to NextGenSoftware.OASIS.API.Core/Objects/Star/CoronalEjection.cs index fb8685906..f3e9e8fda 100644 --- a/NextGenSoftware.OASIS.API.Core/Objects/CoronalEjection.cs +++ b/NextGenSoftware.OASIS.API.Core/Objects/Star/CoronalEjection.cs @@ -1,15 +1,14 @@ - +using System.Collections.Generic; +using NextGenSoftware.OASIS.API.Core.Interfaces; using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; -using System.Collections.Generic; namespace NextGenSoftware.OASIS.API.Core.Objects { - public class CoronalEjection + public class CoronalEjection : ICoronalEjection { - //public string Message { get; set; } - //public bool ErrorOccured { get; set; } - public List Zomes { get; set; } //Will only be set if GenesisType is ZomesAndHolonsOnly. + public IEnumerable Zomes { get; set; } //Will only be set if GenesisType is ZomesAndHolonsOnly. public ICelestialBody CelestialBody { get; set; } //Will be null if GenesisType is ZomesAndHolonsOnly. public ICelestialSpace CelestialSpace { get; set; } //Will be null if GenesisType is ZomesAndHolonsOnly. + public IOAPPDNA OAPPDNA { get; set; } } -} +} \ No newline at end of file diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Enums/OAPPType.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Enums/OAPPType.cs index 73c131507..3d1906e44 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Enums/OAPPType.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Enums/OAPPType.cs @@ -1,23 +1,23 @@  -namespace NextGenSoftware.OASIS.API.ONode.Core.Enums -{ - public enum OAPPType - { - //CelestialBodies, - GeneratedCodeOnly, - Console, - Blazor, - WebMVC, - MAUI, - Unity, - WinForms, - WPF, - WindowsService, - RESTService, - gRPCService, - GraphQLService, - //ClassLibrary, - Custom - } -} +//namespace NextGenSoftware.OASIS.API.ONode.Core.Enums +//{ +// public enum OAPPType +// { +// //CelestialBodies, +// GeneratedCodeOnly, +// Console, +// Blazor, +// WebMVC, +// MAUI, +// Unity, +// WinForms, +// WPF, +// WindowsService, +// RESTService, +// gRPCService, +// GraphQLService, +// //ClassLibrary, +// Custom +// } +//} diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Holons/InstalledOAPP.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Holons/InstalledOAPP.cs index 52e552a87..ed28a7b89 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Holons/InstalledOAPP.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Holons/InstalledOAPP.cs @@ -2,8 +2,7 @@ using NextGenSoftware.OASIS.API.Core.Enums; using NextGenSoftware.OASIS.API.Core.CustomAttrbiutes; using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Holons; -using System; -using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects; +using NextGenSoftware.OASIS.API.Core.Interfaces; namespace NextGenSoftware.OASIS.API.ONode.Core.Holons { diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Holons/OAPP.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Holons/OAPP.cs index d11734312..c07507931 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Holons/OAPP.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Holons/OAPP.cs @@ -1,7 +1,6 @@ using System; using NextGenSoftware.OASIS.API.Core.Holons; using NextGenSoftware.OASIS.API.Core.Enums; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Holons; using NextGenSoftware.OASIS.API.Core.CustomAttrbiutes; diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Holons/IOAPP.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Holons/IOAPP.cs index 5ab38b87a..fc77cea5c 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Holons/IOAPP.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Holons/IOAPP.cs @@ -2,7 +2,6 @@ using NextGenSoftware.OASIS.API.Core.Enums; using NextGenSoftware.OASIS.API.Core.Interfaces; using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; namespace NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Holons { diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs index ec7961abd..e9c5e58ce 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Interfaces/Objects/IOAPPDNA.cs @@ -1,30 +1,28 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using NextGenSoftware.OASIS.API.Core.Enums; -using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; -using NextGenSoftware.OASIS.STAR.CelestialBodies; +//using System; +//using System.Collections.Generic; +//using NextGenSoftware.OASIS.API.Core.Enums; +//using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; +//using NextGenSoftware.OASIS.API.ONode.Core.Enums; -namespace NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects -{ - public interface IOAPPDNA - { - ICelestialBody CelestialBody { get; set; } //optional - Guid CelestialBodyId { get; set; } - string CelestialBodyName { get; set; } - HolonType CelestialBodyType { get; set; } - IEnumerable Zomes { get; set; } - Guid CreatedByAvatarId { get; set; } - DateTime CreatedOn { get; set; } - string Description { get; set; } - GenesisType GenesisType { get; set; } - Guid OAPPId { get; set; } - string OAPPName { get; set; } - OAPPType OAPPType { get; set; } - Guid PublishedByAvatarId { get; set; } - DateTime PublishedOn { get; set; } - bool PublishedOnSTARNET { get; set; } - string Version { get; set; } - } -} \ No newline at end of file +//namespace NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects +//{ +// public interface IOAPPDNA +// { +// ICelestialBody CelestialBody { get; set; } //optional +// Guid CelestialBodyId { get; set; } +// string CelestialBodyName { get; set; } +// HolonType CelestialBodyType { get; set; } +// IEnumerable Zomes { get; set; } +// Guid CreatedByAvatarId { get; set; } +// DateTime CreatedOn { get; set; } +// string Description { get; set; } +// GenesisType GenesisType { get; set; } +// Guid OAPPId { get; set; } +// string OAPPName { get; set; } +// OAPPType OAPPType { get; set; } +// Guid PublishedByAvatarId { get; set; } +// DateTime PublishedOn { get; set; } +// bool PublishedOnSTARNET { get; set; } +// string Version { get; set; } +// } +//} \ No newline at end of file diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs index b8926eac1..b9de7dcbb 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Managers/OAPPManager.cs @@ -12,10 +12,8 @@ using NextGenSoftware.OASIS.API.Core.Helpers; using NextGenSoftware.OASIS.API.Core.Interfaces; using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; using NextGenSoftware.OASIS.API.ONode.Core.Holons; using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Holons; -using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects; namespace NextGenSoftware.OASIS.API.ONode.Core.Managers { @@ -260,7 +258,7 @@ public async Task> CreateOAPPAsync(string OAPPName, string return result; } - public OASISResult CreateOAPP(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, , IEnumerable zomes = null, ProviderType providerType = ProviderType.Default) + public OASISResult CreateOAPP(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, Guid avatarId, ICelestialBody celestialBody = null, IEnumerable zomes = null, ProviderType providerType = ProviderType.Default) { OASISResult result = new OASISResult(); string errorMessage = "Error occured in OAPPManager.CreateOAPP, Reason:"; diff --git a/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs b/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs index 806960e7b..c6abe64f5 100644 --- a/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs +++ b/NextGenSoftware.OASIS.API.ONODE.Core/Objects/OAPPDNA.cs @@ -1,9 +1,8 @@ using System; using System.Collections.Generic; using NextGenSoftware.OASIS.API.Core.Enums; +using NextGenSoftware.OASIS.API.Core.Interfaces; using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; -using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects; namespace NextGenSoftware.OASIS.API.ONode.Core.Holons { diff --git a/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs b/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs index 704c05003..a32e3d3b6 100644 --- a/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs +++ b/NextGenSoftware.OASIS.STAR.CLI.Lib/STARCLI.cs @@ -19,7 +19,6 @@ using NextGenSoftware.OASIS.API.Core.Interfaces.NFT.GeoSpatialNFT; using NextGenSoftware.OASIS.API.Core.Interfaces.NFT.GeoSpatialNFT.Request; using NextGenSoftware.OASIS.API.Core.Objects.NFT.Request; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; using NextGenSoftware.OASIS.API.Providers.SEEDSOASIS.Membranes; using NextGenSoftware.OASIS.API.Providers.EOSIOOASIS.Entities.DTOs.GetAccount; using NextGenSoftware.OASIS.STAR.Zomes; @@ -35,7 +34,7 @@ public static class STARCLI private static Moon _jlaMoon; private static string _privateKey = ""; - public static async Task LightWizard() + public static async Task LightWizard(ProviderType providerType = ProviderType.Default) { OASISResult lightResult = null; @@ -56,6 +55,7 @@ public static async Task LightWizard() CLIEngine.ShowDivider(); string OAPPName = CLIEngine.GetValidInput("What is the name of the OAPP?"); + string OAPPDesc = CLIEngine.GetValidInput("What is the description of the OAPP?"); object value = CLIEngine.GetValidInputForEnum("What type of OAPP do you wish to create?", typeof(OAPPType)); long ourWorldLat = 0; long ourWorldLong = 0; @@ -201,7 +201,7 @@ public static async Task LightWizard() parentId = CLIEngine.GetValidInputForGuid("What is the Id (GUID) of the parent CelestialBody?"); CLIEngine.ShowWorkingMessage("Generating OAPP..."); - lightResult = await STAR.LightAsync(OAPPName, OAPPType, genesisType, dnaFolder, genesisFolder, genesisNamespace, parentId); + lightResult = await STAR.LightAsync(OAPPName, OAPPDesc, OAPPType, genesisType, dnaFolder, genesisFolder, genesisNamespace, parentId, providerType); } else { @@ -209,14 +209,14 @@ public static async Task LightWizard() CLIEngine.ShowErrorMessage($"You are only level {STAR.BeamedInAvatarDetail.Level}. You need to be at least level 33 to be able to change the parent celestialbody. Using the default of Our World."); Console.WriteLine(""); CLIEngine.ShowWorkingMessage("Generating OAPP..."); - lightResult = await STAR.LightAsync(OAPPName, OAPPType, genesisType, dnaFolder, genesisFolder, genesisNamespace); + lightResult = await STAR.LightAsync(OAPPName, OAPPDesc, OAPPType, genesisType, dnaFolder, genesisFolder, genesisNamespace, providerType); } } else { Console.WriteLine(""); CLIEngine.ShowWorkingMessage("Generating OAPP..."); - lightResult = await STAR.LightAsync(OAPPName, OAPPType, genesisType, dnaFolder, genesisFolder, genesisNamespace); + lightResult = await STAR.LightAsync(OAPPName, OAPPDesc, OAPPType, genesisType, dnaFolder, genesisFolder, genesisNamespace, providerType); } if (lightResult != null) @@ -245,10 +245,10 @@ public static async Task LightWizard() } } - public static async Task> GenerateCelestialBody(string name, ICelestialBody parentCelestialBody, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "") + public static async Task> GenerateCelestialBody(string OAPPName, string OAPPDesc, ICelestialBody parentCelestialBody, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ProviderType providerType = ProviderType.Default) { // Create (OApp) by generating dynamic template/scaffolding code. - string message = $"Generating {Enum.GetName(typeof(GenesisType), genesisType)} '{name}' (OApp)"; + string message = $"Generating {Enum.GetName(typeof(GenesisType), genesisType)} '{OAPPName}' (OApp)"; if (genesisType == GenesisType.Moon && parentCelestialBody != null) message = $"{message} For Planet '{parentCelestialBody.Name}'"; @@ -258,7 +258,7 @@ public static async Task> GenerateCelestialBody(str CLIEngine.ShowWorkingMessage(message); //Allows the celestialBodyDNAFolder, genesisFolder & genesisNameSpace params to be passed in overridng what is in the STARDNA.json file. - OASISResult lightResult = STAR.LightAsync(name, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, parentCelestialBody).Result; + OASISResult lightResult = STAR.LightAsync(OAPPName, OAPPDesc, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, parentCelestialBody, providerType).Result; //Will use settings in the STARDNA.json file. //OASISResult lightResult = STAR.LightAsync(OAPPType, genesisType, name, parentCelestialBody).Result; @@ -280,13 +280,13 @@ public static async Task> GenerateCelestialBody(str return lightResult; } - public static async Task> GenerateZomesAndHolons(string oAPPName, OAPPType OAPPType, string zomesAndHolonsyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "") + public static async Task> GenerateZomesAndHolons(string OAPPName, string OAPPDesc, OAPPType OAPPType, string zomesAndHolonsyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ProviderType providerType = ProviderType.Default) { // Create (OApp) by generating dynamic template/scaffolding code. CLIEngine.ShowWorkingMessage($"Generating Zomes & Holons..."); //OASISResult lightResult = STAR.LightAsync(oAPPName, OAPPType, zomesAndHolonsyDNAFolder, genesisFolder, genesisNameSpace).Result; - OASISResult lightResult = STAR.LightAsync(oAPPName, OAPPType, zomesAndHolonsyDNAFolder, genesisFolder, genesisNameSpace).Result; + OASISResult lightResult = STAR.LightAsync(OAPPName, OAPPDesc, OAPPType, zomesAndHolonsyDNAFolder, genesisFolder, genesisNameSpace).Result; //Will use settings in the STARDNA.json file. //OASISResult lightResult = STAR.LightAsync(oAPPName, OAPPType).Result; @@ -299,7 +299,7 @@ public static async Task> GenerateZomesAndHolons(st foreach (IZome zome in lightResult.Result.Zomes) iNoHolons += zome.Children.Count(); - CLIEngine.ShowSuccessMessage($"{lightResult.Result.Zomes.Count} Zomes & {iNoHolons} Holons Generated."); + CLIEngine.ShowSuccessMessage($"{lightResult.Result.Zomes.Count()} Zomes & {iNoHolons} Holons Generated."); Console.WriteLine(""); ShowZomesAndHolons(lightResult.Result.Zomes); @@ -323,7 +323,7 @@ public static async Task ListAllOAPPsAsync() CLIEngine.ShowErrorMessage("No OAPP's Found."); } - public static async Task ListOAPPsCreatedByBeamedInAvatar() + public static async Task ListOAPPsCreatedByBeamedInAvatarAsync(ProviderType providerType = ProviderType.Default) { if (STAR.BeamedInAvatar != null) { @@ -343,7 +343,7 @@ public static async Task ListOAPPsCreatedByBeamedInAvatar() CLIEngine.ShowErrorMessage("No Avatar Is Beamed In. Please Beam In First!"); } - public static async Task ListOAPPsInstalledForBeamedInAvatar() + public static async Task ListOAPPsInstalledForBeamedInAvatarAsync(ProviderType providerType = ProviderType.Default) { if (STAR.BeamedInAvatar != null) { @@ -363,7 +363,7 @@ public static async Task ListOAPPsInstalledForBeamedInAvatar() CLIEngine.ShowErrorMessage("No Avatar Is Beamed In. Please Beam In First!"); } - public static async Task LoadCelestialBodyAsync(T celestialBody, string name) where T : ICelestialBody, new() + public static async Task LoadCelestialBodyAsync(T celestialBody, string name, ProviderType providerType = ProviderType.Default) where T : ICelestialBody, new() { CLIEngine.ShowWorkingMessage($"Loading {name}..."); OASISResult celestialBodyResult = await celestialBody.LoadAsync(); @@ -377,7 +377,7 @@ public static async Task ListOAPPsInstalledForBeamedInAvatar() } } - public static async Task LoadHolonAsync(Guid id, string name) + public static async Task LoadHolonAsync(Guid id, string name, ProviderType providerType = ProviderType.Default) { CLIEngine.ShowWorkingMessage($"Loading Holon {name}..."); OASISResult holonResult = await STAR.OASISAPI.Data.LoadHolonAsync(id); @@ -470,7 +470,7 @@ public static async Task PlaceGeoNFTAsync() } } - public static async Task ListGeoNFTsAsync() + public static async Task ListGeoNFTsAsync(ProviderType providerType = ProviderType.Default) { CLIEngine.ShowWorkingMessage("Loading Geo-NFTs..."); OASISResult> nfts = await STAR.OASISAPI.NFTs.LoadAllGeoNFTsForAvatarAsync(STAR.BeamedInAvatar.Id); @@ -486,7 +486,7 @@ public static async Task ListGeoNFTsAsync() CLIEngine.ShowErrorMessage("No Geo-NFT's Found."); } - public static async Task ListNFTsAsync() + public static async Task ListNFTsAsync(ProviderType providerType = ProviderType.Default) { CLIEngine.ShowWorkingMessage("Loading NFTs..."); OASISResult> nfts = await STAR.OASISAPI.NFTs.LoadAllNFTsForAvatarAsync(STAR.BeamedInAvatar.Id); @@ -502,7 +502,7 @@ public static async Task ListNFTsAsync() CLIEngine.ShowErrorMessage("No NFT's Found."); } - public static async Task ShowNFTAsync(Guid id) + public static async Task ShowNFTAsync(Guid id, ProviderType providerType = ProviderType.Default) { CLIEngine.ShowWorkingMessage("Loading NFT..."); OASISResult nft = await STAR.OASISAPI.NFTs.LoadNftAsync(id); @@ -551,7 +551,7 @@ public static void ShowNFT(IOASISNFT nft) CLIEngine.ShowDivider(); } - public static async Task ShowGeoNFTAsync(Guid id) + public static async Task ShowGeoNFTAsync(Guid id, ProviderType providerType = ProviderType.Default) { CLIEngine.ShowWorkingMessage("Loading Geo-NFT..."); OASISResult nft = await STAR.OASISAPI.NFTs.LoadGeoNftAsync(id); @@ -701,7 +701,7 @@ public static async Task SendNFTAsync() } } - public static string GetValidEmail(string message, bool checkIfEmailAlreadyInUse) + public static string GetValidEmail(string message, bool checkIfEmailAlreadyInUse, ProviderType providerType = ProviderType.Default) { bool emailValid = false; string email = ""; @@ -746,7 +746,7 @@ public static string GetValidEmail(string message, bool checkIfEmailAlreadyInUse return email; } - public static string GetValidUsername(string message, bool checkIfUsernameAlreadyInUse = true) + public static string GetValidUsername(string message, bool checkIfUsernameAlreadyInUse = true, ProviderType providerType = ProviderType.Default) { bool usernameValid = false; string username = ""; @@ -788,7 +788,7 @@ public static string GetValidUsername(string message, bool checkIfUsernameAlread return username; } - public static bool CreateAvatar() + public static bool CreateAvatar(ProviderType providerType = ProviderType.Default) { ConsoleColor favColour = ConsoleColor.Green; ConsoleColor cliColour = ConsoleColor.Green; @@ -824,7 +824,7 @@ public static bool CreateAvatar() } } - public static async Task BeamInAvatar() + public static async Task BeamInAvatar(ProviderType providerType = ProviderType.Default) { OASISResult beamInResult = null; @@ -1403,10 +1403,10 @@ public static async Task RunCOSMICTests(OAPPType OAPPType, string celestialBodyD { CLIEngine.ShowWorkingMessage("BEGINNING STAR ODK/COSMIC TEST'S..."); - OASISResult result = await GenerateZomesAndHolons("Zomes And Holons Only", OAPPType, celestialBodyDNAFolder, Path.Combine(geneisFolder, "ZomesAndHolons"), "NextGenSoftware.OASIS.OAPPS.ZomesAndHolonsOnly"); + OASISResult result = await GenerateZomesAndHolons("Zomes And Holons Only", "Zomes And Holons Only Desc", OAPPType, celestialBodyDNAFolder, Path.Combine(geneisFolder, "ZomesAndHolons"), "NextGenSoftware.OASIS.OAPPS.ZomesAndHolonsOnly"); //Passing in null for the ParentCelestialBody will default it to the default planet (Our World). - result = await GenerateCelestialBody("The Justice League Academy", null, OAPPType, GenesisType.Moon, celestialBodyDNAFolder, Path.Combine(geneisFolder, "JLA"), "NextGenSoftware.OASIS.OAPPS.JLA"); + result = await GenerateCelestialBody("The Justice League Academy", "Test Moon", null, OAPPType, GenesisType.Moon, celestialBodyDNAFolder, Path.Combine(geneisFolder, "JLA"), "NextGenSoftware.OASIS.OAPPS.JLA"); // Currenly the JLA Moon and Our World Planet share the same Zome/Holon DNA (celestialBodyDNAFolder) but they can also have their own zomes/holons if they wish... // TODO: In future you will also be able to define the full CelestialBody DNA seperatley (cs/json) for each planet, moon, star etc where they can also define additional meta data for the moon/planet/star as well as their own zomes/holons like we have now, plus they can also refer to existing holons/zomes either in a folder (like we have now) or in STARNET Library using the GUID. @@ -1420,7 +1420,7 @@ public static async Task RunCOSMICTests(OAPPType OAPPType, string celestialBodyD } //Passing in null for the ParentCelestialBody will default it to the default Star (Our Sun Sol). - result = await GenerateCelestialBody("Our World", null, OAPPType, GenesisType.Planet, celestialBodyDNAFolder, Path.Combine(geneisFolder, "Our World"), "NextGenSoftware.OASIS.OAPPS.OurWorld"); + result = await GenerateCelestialBody("Our World", "Test Planet", null, OAPPType, GenesisType.Planet, celestialBodyDNAFolder, Path.Combine(geneisFolder, "Our World"), "NextGenSoftware.OASIS.OAPPS.OurWorld"); if (result != null && !result.IsError && result.Result != null && result.Result.CelestialBody != null) { @@ -1662,7 +1662,7 @@ public static async Task RunCOSMICTests(OAPPType OAPPType, string celestialBodyD // Build - CoronalEjection ejection = result.Result.CelestialBody.Flare(); + ICoronalEjection ejection = result.Result.CelestialBody.Flare(); //OR //CoronalEjection ejection = Star.Flare(ourWorld); @@ -1674,7 +1674,7 @@ public static async Task RunCOSMICTests(OAPPType OAPPType, string celestialBodyD STAR.Dim(result.Result.CelestialBody); // Deploy the planet (OApp) - STAR.Seed(result.Result.CelestialBody); + STAR.Seed(result.Result.CelestialBody.Id, ""); //TODO: Need to create test path for this. // Run Tests STAR.Twinkle(result.Result.CelestialBody); diff --git a/NextGenSoftware.OASIS.STAR.CLI/Program.cs b/NextGenSoftware.OASIS.STAR.CLI/Program.cs index f89f645cf..142f9cef2 100644 --- a/NextGenSoftware.OASIS.STAR.CLI/Program.cs +++ b/NextGenSoftware.OASIS.STAR.CLI/Program.cs @@ -1,7 +1,6 @@ using System; using System.Linq; -using System.Drawing; -using System.Reflection; +using System.Drawing using System.Threading.Tasks; using System.Collections.Generic; using MongoDB.Driver; @@ -19,7 +18,6 @@ using NextGenSoftware.OASIS.STAR.Enums; using NextGenSoftware.OASIS.STAR.ErrorEventArgs; using Console = System.Console; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; namespace NextGenSoftware.OASIS.STAR.CLI { @@ -275,21 +273,21 @@ private static async Task ReadyPlayerOne() Guid parentId = Guid.Empty; if (Guid.TryParse(inputArgs[7], out parentId)) - lightResult = await STAR.LightAsync(inputArgs[1], oappType, genesisType, inputArgs[3], inputArgs[4], inputArgs[5], parentId); + lightResult = await STAR.LightAsync(inputArgs[1], inputArgs[2], oappType, genesisType, inputArgs[4], inputArgs[5], inputArgs[6], parentId); else - CLIEngine.ShowErrorMessage($"The ParentCelestialBodyId Passed In ({inputArgs[5]}) Is Not Valid. Please Make Sure It Is One Of The Following: {EnumHelper.GetEnumValues(typeof(GenesisType), EnumHelperListType.ItemsSeperatedByComma)}."); + CLIEngine.ShowErrorMessage($"The ParentCelestialBodyId Passed In ({inputArgs[6]}) Is Not Valid. Please Make Sure It Is One Of The Following: {EnumHelper.GetEnumValues(typeof(GenesisType), EnumHelperListType.ItemsSeperatedByComma)}."); } else - lightResult = await STAR.LightAsync(inputArgs[1], oappType, genesisType, inputArgs[3], inputArgs[4], inputArgs[5]); + lightResult = await STAR.LightAsync(inputArgs[1], inputArgs[2], oappType, genesisType, inputArgs[4], inputArgs[5], inputArgs[6], ProviderType.Default); } else - CLIEngine.ShowErrorMessage($"The GenesisType Passed In ({inputArgs[6]}) Is Not Valid. Please Make Sure It Is One Of The Following: {EnumHelper.GetEnumValues(typeof(GenesisType), EnumHelperListType.ItemsSeperatedByComma)}."); + CLIEngine.ShowErrorMessage($"The GenesisType Passed In ({inputArgs[7]}) Is Not Valid. Please Make Sure It Is One Of The Following: {EnumHelper.GetEnumValues(typeof(GenesisType), EnumHelperListType.ItemsSeperatedByComma)}."); } else - lightResult = await STAR.LightAsync(inputArgs[1], oappType, inputArgs[3], inputArgs[4], inputArgs[5]); + lightResult = await STAR.LightAsync(inputArgs[1], inputArgs[2], oappType, inputArgs[4], inputArgs[5], inputArgs[6]); } else - CLIEngine.ShowErrorMessage($"The OAPPType Passed In ({inputArgs[2]}) Is Not Valid. Please Make Sure It Is One Of The Following: {EnumHelper.GetEnumValues(typeof(OAPPType), EnumHelperListType.ItemsSeperatedByComma)}."); + CLIEngine.ShowErrorMessage($"The OAPPType Passed In ({inputArgs[3]}) Is Not Valid. Please Make Sure It Is One Of The Following: {EnumHelper.GetEnumValues(typeof(OAPPType), EnumHelperListType.ItemsSeperatedByComma)}."); if (lightResult != null) { @@ -417,6 +415,14 @@ private static async Task ReadyPlayerOne() case "seed": { CLIEngine.ShowMessage("Coming soon..."); + //await STAR.SeedAsync(); + } + break; + + case "unseed": + { + CLIEngine.ShowMessage("Coming soon..."); + //await STAR.UnSeedAsync(); } break; @@ -485,7 +491,7 @@ private static async Task ReadyPlayerOne() if (CLIEngine.GetConfirmation("Do you want to list all OAPPs? Press 'Y' to list all OAPPs or 'N' to list only the OAPPs you have created.")) await STARCLI.ListAllOAPPsAsync(); else - await STARCLI.ListOAPPsCreatedByBeamedInAvatar(); + await STARCLI.ListOAPPsCreatedByBeamedInAvatarAsync(); } break; @@ -497,7 +503,7 @@ private static async Task ReadyPlayerOne() case "listinstalledoapps": { - await STARCLI.ListOAPPsInstalledForBeamedInAvatar(); + await STARCLI.ListOAPPsInstalledForBeamedInAvatarAsync(); } break; @@ -2617,24 +2623,25 @@ private static void ShowCommands() Console.WriteLine(" star version = Show the versions of STAR ODK, COSMIC ORM, OASIS Runtime & the OASIS Providers.."); Console.WriteLine(" star status = Show the status of STAR ODK."); Console.WriteLine(" star exit = Exit the STAR CLI."); - Console.WriteLine(" star light {OAPPName} {OAPPType} {dnaFolder} {geneisFolder} {genesisNameSpace} {genesisTyp} {parentCelestialBodyId} (optional) = Creates a new OAPP (Zomes/Holons/Star/Planet/Moon) at the given genesis folder location, from the given OAPP DNA."); + Console.WriteLine(" star light {OAPPName} {OAPPDesc} {OAPPType} {dnaFolder} {geneisFolder} {genesisNameSpace} {genesisTyp} {parentCelestialBodyId} (optional) = Creates a new OAPP (Zomes/Holons/Star/Planet/Moon) at the given genesis folder location, from the given OAPP DNA."); Console.WriteLine(" star light = Displays more detail on how to use this command and optionally launches the Light Wizard."); Console.WriteLine(" star light wiz = Start the Light Wizard."); Console.WriteLine(" star light transmute {hAppDNA} {geneisFolder} = Creates a new Planet (OApp) at the given folder genesis locations, from the given hApp DNA."); Console.WriteLine(" star bang = Generate a whole metaverse or part of one such as Multierveres, Universes, Dimensions, Galaxy Clusters, Galaxies, Solar Systems, Stars, Planets, Moons etc."); Console.WriteLine(" star wiz = Start the STAR ODK Wizard which will walk you through the steps for creating a OAPP tailored to your specefic needs (such as which OASIS Providers do you need and the specefic use case(s) you need etc)."); - Console.WriteLine(" star flare {OAPPName} = Build a OAPP."); - Console.WriteLine(" star shine {OAPPName} = Launch & activate a OAPP by shining the star's light upon it..."); - Console.WriteLine(" star dim {OAPPName} = Deactivate a OAPP."); - Console.WriteLine(" star seed {OAPPName} = Deploy a OAPP."); - Console.WriteLine(" star twinkle {OAPPName} = Deactivate a OAPP."); - Console.WriteLine(" star dust {OAPPName} = Delete a OAPP."); - Console.WriteLine(" star radiate {OAPPName} = Highlight the OAPP in the OAPP Store (StarNET). *Admin Only*"); - Console.WriteLine(" star emit {OAPPName} = Show how much light the OAPP is emitting into the solar system (StarNET/HoloNET)"); - Console.WriteLine(" star reflect {OAPPName} = Show stats of the OAPP."); - Console.WriteLine(" star evolve {OAPPName} = Upgrade/update a OAPP)."); - Console.WriteLine(" star mutate {OAPPName} = Import/Export hApp, dApp & others."); - Console.WriteLine(" star love {OAPPName} = Send/Receive Love."); + Console.WriteLine(" star flare {OAPPName/OAPPId} = Build a OAPP."); + Console.WriteLine(" star shine {OAPPName/OAPPId} = Launch & activate a OAPP by shining the star's light upon it..."); + Console.WriteLine(" star dim {OAPPName/OAPPId} = Deactivate a OAPP."); + Console.WriteLine(" star seed {OAPPName/OAPPId} = Deploy/Publish a OAPP."); + Console.WriteLine(" star unseed {OAPPName/OAPPId} = UnDeploy/UnPublish a OAPP."); + Console.WriteLine(" star twinkle {OAPPName/OAPPId} = Deactivate a OAPP."); + Console.WriteLine(" star dust {OAPPName/OAPPId} = Delete a OAPP."); + Console.WriteLine(" star radiate {OAPPName/OAPPId} = Highlight the OAPP in the OAPP Store (StarNET). *Admin Only*"); + Console.WriteLine(" star emit {OAPPName/OAPPId} = Show how much light the OAPP is emitting into the solar system (StarNET/HoloNET)"); + Console.WriteLine(" star reflect {OAPPName/OAPPId} = Show stats of the OAPP."); + Console.WriteLine(" star evolve {OAPPName/OAPPId} = Upgrade/update a OAPP)."); + Console.WriteLine(" star mutate {OAPPName/OAPPId} = Import/Export hApp, dApp & others."); + Console.WriteLine(" star love {OAPPName/OAPPId} = Send/Receive Love."); Console.WriteLine(" star burst = View network stats/management/settings."); Console.WriteLine(" star super - Reserved For Future Use..."); Console.WriteLine(" star listoapps {searchAll} - List all OAPPs (contains zomes and holons) that have been generated. If {searchAll} is omitted it will list only your OAPP's otherwise it will list all public/shared OAPP's."); diff --git a/NextGenSoftware.OASIS.STAR/CelestialBodies/CelestialBody.cs b/NextGenSoftware.OASIS.STAR/CelestialBodies/CelestialBody.cs index e4f752f93..59dc61956 100644 --- a/NextGenSoftware.OASIS.STAR/CelestialBodies/CelestialBody.cs +++ b/NextGenSoftware.OASIS.STAR/CelestialBodies/CelestialBody.cs @@ -413,7 +413,7 @@ public OASISResult> SaveZomes(bool saveChildren = true, bool //} // Build - public CoronalEjection Flare() + public ICoronalEjection Flare() { return new CoronalEjection(); // return Star.Flare(this); diff --git a/NextGenSoftware.OASIS.STAR/CelestialBodies/WormHole.cs b/NextGenSoftware.OASIS.STAR/CelestialBodies/WormHole.cs index 3c95a025e..ef6ab6dbe 100644 --- a/NextGenSoftware.OASIS.STAR/CelestialBodies/WormHole.cs +++ b/NextGenSoftware.OASIS.STAR/CelestialBodies/WormHole.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using NextGenSoftware.OASIS.API.Core.Enums; using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; diff --git a/NextGenSoftware.OASIS.STAR/Interfaces/ICoronalEjection.cs b/NextGenSoftware.OASIS.STAR/Interfaces/ICoronalEjection.cs new file mode 100644 index 000000000..ef6e977ea --- /dev/null +++ b/NextGenSoftware.OASIS.STAR/Interfaces/ICoronalEjection.cs @@ -0,0 +1,14 @@ +//using System.Collections.Generic; +//using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; +//using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects; + +//namespace NextGenSoftware.OASIS.STAR.Interfaces +//{ +// public interface ICoronalEjection +// { +// ICelestialBody CelestialBody { get; set; } +// ICelestialSpace CelestialSpace { get; set; } +// IOAPPDNA OAPPDNA { get; set; } +// IEnumerable Zomes { get; set; } +// } +//} \ No newline at end of file diff --git a/NextGenSoftware.OASIS.STAR/NextGenSoftware.OASIS.STAR.csproj b/NextGenSoftware.OASIS.STAR/NextGenSoftware.OASIS.STAR.csproj index b467f2945..349988203 100644 --- a/NextGenSoftware.OASIS.STAR/NextGenSoftware.OASIS.STAR.csproj +++ b/NextGenSoftware.OASIS.STAR/NextGenSoftware.OASIS.STAR.csproj @@ -80,10 +80,6 @@ - - - - diff --git a/NextGenSoftware.OASIS.STAR/Objects/CoronalEjection.cs b/NextGenSoftware.OASIS.STAR/Objects/CoronalEjection.cs new file mode 100644 index 000000000..af7188f59 --- /dev/null +++ b/NextGenSoftware.OASIS.STAR/Objects/CoronalEjection.cs @@ -0,0 +1,15 @@ +//using System.Collections.Generic; +//using NextGenSoftware.OASIS.STAR.Interfaces; +//using NextGenSoftware.OASIS.API.Core.Interfaces.STAR; +//using NextGenSoftware.OASIS.API.ONode.Core.Interfaces.Objects; + +//namespace NextGenSoftware.OASIS.API.Core.Objects +//{ +// public class CoronalEjection : ICoronalEjection +// { +// public IEnumerable Zomes { get; set; } //Will only be set if GenesisType is ZomesAndHolonsOnly. +// public ICelestialBody CelestialBody { get; set; } //Will be null if GenesisType is ZomesAndHolonsOnly. +// public ICelestialSpace CelestialSpace { get; set; } //Will be null if GenesisType is ZomesAndHolonsOnly. +// public IOAPPDNA OAPPDNA { get; set; } +// } +//} diff --git a/NextGenSoftware.OASIS.STAR/Star.cs b/NextGenSoftware.OASIS.STAR/Star.cs index 84cd99736..6a1fb675c 100644 --- a/NextGenSoftware.OASIS.STAR/Star.cs +++ b/NextGenSoftware.OASIS.STAR/Star.cs @@ -27,7 +27,6 @@ using static NextGenSoftware.OASIS.API.Core.Events.EventDelegates; using NextGenSoftware.OASIS.Common; using NextGenSoftware.Utilities; -using NextGenSoftware.OASIS.API.ONode.Core.Enums; namespace NextGenSoftware.OASIS.STAR { @@ -261,7 +260,7 @@ public static OASISAPI OASISAPI //public delegate void DataReceived(object sender, DataReceivedEventArgs e); //public static event DataReceived OnDataReceived; - public static async Task> IgniteStarAsync(string STARDNAPath = STAR_DNA_DEFAULT_PATH, string OASISDNAPath = OASIS_DNA_DEFAULT_PATH, string starId = null) + public static async Task> IgniteStarAsync(string STARDNAPath = STAR_DNA_DEFAULT_PATH, string OASISDNAPath = OASIS_DNA_DEFAULT_PATH, string starId = null, ProviderType providerType = ProviderType.Default) { OASISResult result = new OASISResult(); Status = StarStatus.Igniting; @@ -335,7 +334,7 @@ public static async Task> IgniteStarAsync(string STARDNAP return result; } - public static OASISResult IgniteStar(string STARDNAPath = STAR_DNA_DEFAULT_PATH, string OASISDNAPath = OASIS_DNA_DEFAULT_PATH, string starId = null) + public static OASISResult IgniteStar(string STARDNAPath = STAR_DNA_DEFAULT_PATH, string OASISDNAPath = OASIS_DNA_DEFAULT_PATH, string starId = null, ProviderType providerType = ProviderType.Default) { OASISResult result = new OASISResult(); Status = StarStatus.Igniting; @@ -456,7 +455,7 @@ private static void InnerStar_OnHolonsLoaded(object sender, HolonsLoadedEventArg OnHolonsLoaded?.Invoke(sender, e); } - public static OASISResult CreateAvatar(string title, string firstName, string lastName, string email, string username, string password, ConsoleColor cliColour = ConsoleColor.Green, ConsoleColor favColour = ConsoleColor.Green) + public static OASISResult CreateAvatar(string title, string firstName, string lastName, string email, string username, string password, ConsoleColor cliColour = ConsoleColor.Green, ConsoleColor favColour = ConsoleColor.Green, ProviderType providerType = ProviderType.Default) { if (!IsStarIgnited) IgniteStar(); @@ -464,7 +463,7 @@ public static OASISResult CreateAvatar(string title, string firstName, return OASISAPI.Avatar.Register(title, firstName, lastName, email, password, username, AvatarType.User, OASISType.STARCLI, cliColour, favColour); } - public static async Task> CreateAvatarAsync(string title, string firstName, string lastName, string email, string username, string password, ConsoleColor cliColour = ConsoleColor.Green, ConsoleColor favColour = ConsoleColor.Green) + public static async Task> CreateAvatarAsync(string title, string firstName, string lastName, string email, string username, string password, ConsoleColor cliColour = ConsoleColor.Green, ConsoleColor favColour = ConsoleColor.Green, ProviderType providerType = ProviderType.Default) { if (!IsStarIgnited) await IgniteStarAsync(); @@ -472,7 +471,7 @@ public static async Task> CreateAvatarAsync(string title, s return await OASISAPI.Avatar.RegisterAsync(title, firstName, lastName, email, password, username, AvatarType.User, OASISType.STARCLI, cliColour, favColour); } - public static async Task> BeamInAsync(string username, string password) + public static async Task> BeamInAsync(string username, string password, ProviderType providerType = ProviderType.Default) { string hostName = Dns.GetHostName(); string IPAddress = Dns.GetHostEntry(hostName).AddressList[0].ToString(); @@ -499,7 +498,7 @@ public static async Task> BeamInAsync(string username, stri return result; } - public static OASISResult BeamIn(string username, string password) + public static OASISResult BeamIn(string username, string password, ProviderType providerType = ProviderType.Default) { string IPAddress = ""; string hostName = Dns.GetHostName(); @@ -527,84 +526,64 @@ public static OASISResult BeamIn(string username, string password) return result; } - public static OASISResult Light(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "") + public static OASISResult Light(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ProviderType providerType = ProviderType.Default) { - return Light(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)null); + return Light(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)null, providerType); } - public static OASISResult Light(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IStar starToAddPlanetTo = null) - { - return Light(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)starToAddPlanetTo); - } - - //public static OASISResult Light(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid starIdToAddPlanetTo = Guid.Empty) + //public static OASISResult Light(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IStar starToAddPlanetTo = null, ProviderType providerType = ProviderType.Default) //{ - // return LightInternalAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, starIdToAddPlanetTo).Result; + // return Light(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)starToAddPlanetTo, providerType); //} - public static OASISResult Light(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IPlanet planetToAddMoonTo = null) - { - return Light(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)planetToAddMoonTo); - } - - //public static OASISResult Light(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid planetIdToAddMoonTo = Guid.Empty) + //public static OASISResult Light(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IPlanet planetToAddMoonTo = null, ProviderType providerType = ProviderType.Default) //{ - // return LightInternalAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, planetIdToAddMoonTo).Result; + // return Light(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)planetToAddMoonTo, providerType); //} - public static OASISResult Light(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ICelestialBody celestialBodyParent = null) + public static OASISResult Light(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ICelestialBody celestialBodyParent = null, ProviderType providerType = ProviderType.Default) { - return LightAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, celestialBodyParent).Result; + return LightAsync(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, celestialBodyParent, providerType).Result; } - public static OASISResult Light(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid celestialBodyParentId = new Guid()) + public static OASISResult Light(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid celestialBodyParentId = new Guid(), ProviderType providerType = ProviderType.Default) { - return LightInternalAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, celestialBodyParentId).Result; + return LightInternalAsync(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, celestialBodyParentId, providerType).Result; } - public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "") + public static async Task> LightAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ProviderType providerType = ProviderType.Default) { - return await LightAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)null); + return await LightAsync(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)null, providerType); } - public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IStar starToAddPlanetTo = null) - { - return await LightAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)starToAddPlanetTo); - } - - //public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid starIdToAddPlanetTo = Guid.Empty) + //public static async Task> LightAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IStar starToAddPlanetTo = null, ProviderType providerType = ProviderType.Default) //{ - // return await LightAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, starIdToAddPlanetTo); + // return await LightAsync(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)starToAddPlanetTo, providerType); //} - public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IPlanet planetToAddMoonTo = null) - { - return await LightAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)planetToAddMoonTo); - } - - //public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid planetIdToAddMoonTo = Guid.Empty) + //public static async Task> LightAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", IPlanet planetToAddMoonTo = null, ProviderType providerType = ProviderType.Default) //{ - // return await LightAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, planetIdToAddMoonTo); + // return await LightAsync(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, (ICelestialBody)planetToAddMoonTo, providerType); //} - public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, string zomeAndHolonDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "") + public static async Task> LightAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, string zomeAndHolonDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ProviderType providerType = ProviderType.Default) { - return await LightAsync(oAPPName, OAPPType, GenesisType.ZomesAndHolonsOnly, zomeAndHolonDNAFolder, genesisFolder, genesisNameSpace); + return await LightAsync(OAPPName, OAPPDescription, OAPPType, GenesisType.ZomesAndHolonsOnly, zomeAndHolonDNAFolder, genesisFolder, genesisNameSpace, providerType); } - public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid celestialBodyParentId = new Guid()) + public static async Task> LightAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", Guid celestialBodyParentId = new Guid(), ProviderType providerType = ProviderType.Default) { - return await LightInternalAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, celestialBodyParentId); + return await LightInternalAsync(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, null, celestialBodyParentId, providerType); } - public static async Task> LightAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ICelestialBody celestialBodyParent = null) + public static async Task> LightAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ICelestialBody celestialBodyParent = null, ProviderType providerType = ProviderType.Default) { - return await LightInternalAsync(oAPPName, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, celestialBodyParent); + return await LightInternalAsync(OAPPName, OAPPDescription, OAPPType, genesisType, celestialBodyDNAFolder, genesisFolder, genesisNameSpace, celestialBodyParent, Guid.Empty, providerType); } - private static async Task> LightInternalAsync(string oAPPName, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ICelestialBody celestialBodyParent = null, Guid celestialBodyParentId = new Guid()) + private static async Task> LightInternalAsync(string OAPPName, string OAPPDescription, OAPPType OAPPType, GenesisType genesisType, string celestialBodyDNAFolder = "", string genesisFolder = "", string genesisNameSpace = "", ICelestialBody celestialBodyParent = null, Guid celestialBodyParentId = new Guid(), ProviderType providerType = ProviderType.Default) { - //OASISResult result = new OASISResult(); + OASISResult result = new OASISResult(new CoronalEjection()); ICelestialBody newBody = null; bool holonReached = false; string zomeBufferCsharp = ""; @@ -625,18 +604,25 @@ public static async Task> LightAsync(string oAPPNam string OAPPFolder = ""; List holonNames = new List(); string firstStringProperty = ""; + string errorMessage = "Error Occured In STAR.LightInternalAsync. Reason: "; if (BeamedInAvatarDetail == null) - return new OASISResult() { IsError = true, Message = "Avatar is not logged in. Please log in before calling this command." }; + { + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Avatar is not logged in. Please log in before calling this command."); + return result; + } if (BeamedInAvatarDetail.Level < 77 && genesisType == GenesisType.Star) - return new OASISResult() { IsError = true, Message = "Avatar must have reached level 77 before they can create stars. Please create a planet or moon instead..." }; + { + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Avatar must have reached level 77 before they can create stars. Please create a planet or moon instead..."); + return result; + } if (BeamedInAvatarDetail.Level < 33 && genesisType == GenesisType.Planet) - return new OASISResult() { IsError = true, Message = "Avatar must have reached level 33 before they can create planets. Please create a moon instead..." }; - - //if (celestialBodyParent == null && type == GenesisType.Moon) - // return new OASISResult() { IsError = true, Message = "You must specify the planet to add the moon to." }; + { + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Avatar must have reached level 33 before they can create planets. Please create a moon instead..."); + return result; + } if (!IsStarIgnited) await IgniteStarAsync(); @@ -652,8 +638,8 @@ public static async Task> LightAsync(string oAPPNam if (DefaultStar == null) { - OASISResult result = new OASISResult(); - result = await IgniteInnerStarAsync(result); + OASISResult igniteResult = new OASISResult(); + igniteResult = await IgniteInnerStarAsync(igniteResult); if (result.IsError) return new OASISResult() { IsError = true, Message = string.Concat("Error Igniting Inner Star. Reason: ", result.Message) }; @@ -712,12 +698,12 @@ public static async Task> LightAsync(string oAPPNam genesisNameSpace = $"{STARDNA.BasePath}\\{STARDNA.GenesisNamespace}"; if (string.IsNullOrEmpty(genesisNameSpace)) - genesisNameSpace = string.Concat(oAPPName, "OAPP"); + genesisNameSpace = string.Concat(OAPPName, "OAPP"); //Setup the OApp files from the relevant template. if (OAPPType != OAPPType.GeneratedCodeOnly) { - OAPPFolder = string.Concat(genesisFolder, "\\", oAPPName, " OAPP"); + OAPPFolder = string.Concat(genesisFolder, "\\", OAPPName, " OAPP"); if (Directory.Exists(OAPPFolder)) Directory.Delete(OAPPFolder, true); @@ -870,7 +856,8 @@ public static async Task> LightAsync(string oAPPNam { newBody.Id = Guid.NewGuid(); newBody.IsNewHolon = true; //This was commented out, not sure why? - newBody.Name = oAPPName; + newBody.Name = OAPPName; + newBody.Description = OAPPDescription; newBody.OnCelestialBodySaved += NewBody_OnCelestialBodySaved; newBody.OnCelestialBodyError += NewBody_OnCelestialBodyError; newBody.OnZomeSaved += NewBody_OnZomeSaved; @@ -1065,7 +1052,7 @@ public static async Task> LightAsync(string oAPPNam celestialBodyBufferCsharp = celestialBodyBufferCsharp.Replace(STARDNA.TemplateNamespace, genesisNameSpace); celestialBodyBufferCsharp = celestialBodyBufferCsharp.Replace("NAMESPACE", genesisNameSpace); celestialBodyBufferCsharp = celestialBodyBufferCsharp.Replace("ID", newBody.Id.ToString()); - celestialBodyBufferCsharp = celestialBodyBufferCsharp.Replace("CelestialBodyDNATemplate", oAPPName.ToPascalCase()); + celestialBodyBufferCsharp = celestialBodyBufferCsharp.Replace("CelestialBodyDNATemplate", OAPPName.ToPascalCase()); celestialBodyBufferCsharp = celestialBodyBufferCsharp.Replace("CELESTIALBODY", Enum.GetName(typeof(GenesisType), genesisType)); celestialBodyBufferCsharp = celestialBodyBufferCsharp.Insert(celestialBodyBufferCsharp.Length - 7, string.Concat(loadHolonTemplateCsharp, "\n")); celestialBodyBufferCsharp = celestialBodyBufferCsharp.Insert(celestialBodyBufferCsharp.Length - 7, string.Concat(saveHolonTemplateCsharp, "\n")); @@ -1116,34 +1103,29 @@ public static async Task> LightAsync(string oAPPNam // Remove any white space from the name. if (genesisType != GenesisType.ZomesAndHolonsOnly) - File.WriteAllText(string.Concat(genesisFolder, "\\CSharp\\CelestialBodies\\", Regex.Replace(oAPPName, @"\s+", ""), Enum.GetName(typeof(GenesisType), genesisType), ".cs"), celestialBodyBufferCsharp); + File.WriteAllText(string.Concat(genesisFolder, "\\CSharp\\CelestialBodies\\", Regex.Replace(OAPPName, @"\s+", ""), Enum.GetName(typeof(GenesisType), genesisType), ".cs"), celestialBodyBufferCsharp); // Currently the OApp Name is the same as the CelestialBody name (each CelestialBody is a seperate OApp), but in future a OApp may be able to contain more than one celestialBody... // TODO: Currently the OApp templates only contain sample load/save for one holon... this may change in future... likely will... ;-) Want to show for every zome/holon inside the celestialbody... if (holonNames.Count > 0) - ApplyOAPPTemplate(genesisType, OAPPFolder, genesisNameSpace, oAPPName, oAPPName, holonNames[0], firstStringProperty); + ApplyOAPPTemplate(genesisType, OAPPFolder, genesisNameSpace, OAPPName, OAPPName, holonNames[0], firstStringProperty); else - ApplyOAPPTemplate(genesisType, OAPPFolder, genesisNameSpace, oAPPName, oAPPName, "", firstStringProperty); + ApplyOAPPTemplate(genesisType, OAPPFolder, genesisNameSpace, OAPPName, OAPPName, "", firstStringProperty); //Generate any native code for the current provider. //TODO: Add option to pass into STAR which providers to generate native code for (can be more than one provider). ((IOASISSuperStar)ProviderManager.Instance.CurrentStorageProvider).NativeCodeGenesis(newBody); - //TODO: Need to save this to the StarNET store (still to be made!) (Will of course be written on top of the HDK/ODK... - //This will be private on the store until the user publishes via the Star.Seed() command. - switch (genesisType) { case GenesisType.ZomesAndHolonsOnly: { - OASISResult result = new OASISResult(new CoronalEjection()); - foreach (IZome zome in zomes) { OASISResult saveZomeResult = await zome.SaveAsync(); if (!(saveZomeResult != null && saveZomeResult.Result != null && !saveZomeResult.IsError)) - OASISErrorHandling.HandleError(ref result, $"Error occured saving zome {LoggingHelper.GetHolonInfoForLogging(zome, "zome")}. Reason: {saveZomeResult.Message}.", true); + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Error occured saving zome {LoggingHelper.GetHolonInfoForLogging(zome, "zome")}. Reason: {saveZomeResult.Message}.", true); } if (!result.IsError) @@ -1152,8 +1134,7 @@ public static async Task> LightAsync(string oAPPNam result.Message = $"Some errors occured saving zomes and holons: {OASISResultHelper.BuildInnerMessageError(result.InnerMessages)}"; result.Result.Zomes = new List(zomes); - return result; - } + }break; case GenesisType.Moon: { @@ -1162,48 +1143,57 @@ public static async Task> LightAsync(string oAPPNam if (celestialBodyParent.ParentStar == null) celestialBodyParent.ParentStar = new Star(celestialBodyParent.ParentStarId); - OASISResult result = await ((StarCore)celestialBodyParent.ParentStar.CelestialBodyCore).AddMoonAsync(newBody.ParentPlanet, (IMoon)newBody); + OASISResult addMoonresult = await ((StarCore)celestialBodyParent.ParentStar.CelestialBodyCore).AddMoonAsync(newBody.ParentPlanet, (IMoon)newBody); - if (result != null) + if (addMoonresult != null) { - if (result.IsError) - return new OASISResult() { IsError = true, Message = result.Message, Result = new CoronalEjection() { CelestialBody = result.Result } }; + if (addMoonresult.IsError) + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Error Occured Calling AddMoonAsync. Reason: {addMoonresult.Message}"); else - return new OASISResult() { IsError = false, Message = "Moon Successfully Created.", Result = new CoronalEjection() { CelestialBody = result.Result } }; + { + result.Result.CelestialBody = addMoonresult.Result; + result.Message = "Moon Successfully Created."; + } } else - return new OASISResult() { IsError = true, Message = "Unknown Error Occured Creating Moon." }; - } + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Unknown Error Occured Creating Moon."); + }break; case GenesisType.Planet: { - OASISResult result = await ((StarCore)celestialBodyParent.CelestialBodyCore).AddPlanetAsync((IPlanet)newBody); + OASISResult addPlanetResult = await ((StarCore)celestialBodyParent.CelestialBodyCore).AddPlanetAsync((IPlanet)newBody); - if (result != null) + if (addPlanetResult != null) { - if (result.IsError) - return new OASISResult() { IsError = true, Message = result.Message, Result = new CoronalEjection() { CelestialBody = result.Result } }; + if (addPlanetResult.IsError) + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Error Occured Calling AddPlanetAsync. Reason: {addPlanetResult.Message}"); else - return new OASISResult() { IsError = false, Message = "Planet Successfully Created.", Result = new CoronalEjection() { CelestialBody = result.Result } }; + { + result.Result.CelestialBody = addPlanetResult.Result; + result.Message = "Planet Successfully Created."; + } } else - return new OASISResult() { IsError = true, Message = "Unknown Error Occured Creating Planet." }; - } + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Unknown Error Occured Creating Planet."); + }break; case GenesisType.Star: { - OASISResult result = await ((ISuperStarCore)celestialBodyParent.CelestialBodyCore).AddStarAsync((IStar)newBody); + OASISResult starResult = await ((ISuperStarCore)celestialBodyParent.CelestialBodyCore).AddStarAsync((IStar)newBody); - if (result != null) + if (starResult != null) { - if (result.IsError) - return new OASISResult() { IsError = true, Message = result.Message, Result = new CoronalEjection() { CelestialBody = result.Result } }; + if (starResult.IsError) + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Error Occured Calling AddStarAsync. Reason: {starResult.Message}"); else - return new OASISResult() { IsError = false, Message = "Star Successfully Created.", Result = new CoronalEjection() { CelestialBody = result.Result } }; + { + result.Result.CelestialBody = starResult.Result; + result.Message = "Star Successfully Created."; + } } else - return new OASISResult() { IsError = true, Message = "Unknown Error Occured Creating Star." }; - } + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Unknown Error Occured Creating Star."); + }break; //case GenesisType.SoloarSystem: // { @@ -1256,8 +1246,20 @@ public static async Task> LightAsync(string oAPPNam // } default: - return new OASISResult() { IsError = true, Message = "Unknown Error Occured.", Result = new CoronalEjection() { CelestialBody = newBody } }; + OASISErrorHandling.HandleError(ref result, $"{errorMessage} Unknown Error Occured, GenesisType {Enum.GetName(typeof(GenesisType), genesisType)} Not Recognised!"); + break; } + + + //Finally, save this to the STARNET App Store. This will be private on the store until the user publishes via the Star.Seed() command. + OASISResult OAPPResult = await OASISAPI.OAPPs.CreateOAPPAsync(OAPPName, OAPPDescription, OAPPType, genesisType, BeamedInAvatar.AvatarId, newBody, zomes); + + if (OAPPResult != null && !OAPPResult.IsError && OAPPResult.Result != null) + result.Result.OAPPDNA = OAPPResult.Result; + else + OASISErrorHandling.HandleError(ref result, $"{errorMessage} An Error Occured Calling OASISAPI.OAPPs.CreateOAPPAsync. Reason: {OAPPResult.Message}"); + + return result; } public static void ShowStatusMessage(StarStatusMessageType messageType, string message) @@ -1399,15 +1401,25 @@ public static void Dim(string bodyName) } - //Deploy - public static void Seed(ICelestialBody body) + //Publish + public static async Task> SeedAsync(Guid OAPPId, string fullPathToOAPP, bool registerOnSTARNET = true, ProviderType providerType = ProviderType.Default) { + return await OASISAPI.OAPPs.PublishOAPPAsync(OAPPId, fullPathToOAPP, BeamedInAvatar.AvatarId, registerOnSTARNET, providerType); + } + public static OASISResult Seed(Guid OAPPId, string fullPathToOAPP, bool registerOnSTARNET = true, ProviderType providerType = ProviderType.Default) + { + return OASISAPI.OAPPs.PublishOAPP(OAPPId, fullPathToOAPP, BeamedInAvatar.AvatarId, registerOnSTARNET, providerType); } - public static void Seed(string bodyName) + public static async Task> UnSeedAsync(Guid OAPPId, string fullPathToOAPP, bool registerOnSTARNET = true, ProviderType providerType = ProviderType.Default) { + return await OASISAPI.OAPPs.UnPublishOAPPAsync(OAPPId, providerType); + } + public static OASISResult UnSeed(Guid OAPPId, string fullPathToOAPP, bool registerOnSTARNET = true, ProviderType providerType = ProviderType.Default) + { + return OASISAPI.OAPPs.UnPublishOAPP(OAPPId, providerType); } // Run Tests