diff --git a/src/Moryx.Runtime.Maintenance/Contracts/MaintenanceModuleConfig.cs b/src/Moryx.Runtime.Maintenance/Contracts/MaintenanceModuleConfig.cs
index 63a3a46b8..95326dd87 100644
--- a/src/Moryx.Runtime.Maintenance/Contracts/MaintenanceModuleConfig.cs
+++ b/src/Moryx.Runtime.Maintenance/Contracts/MaintenanceModuleConfig.cs
@@ -4,7 +4,9 @@
using System.Runtime.Serialization;
using Moryx.Configuration;
using Moryx.Modules;
+#if USE_WCF
using Moryx.Tools.Wcf;
+#endif
namespace Moryx.Runtime.Maintenance
{
@@ -18,11 +20,29 @@ public abstract class MaintenancePluginConfig : UpdatableEntry, IPluginConfig
/// Name of the plugin.
///
public abstract string PluginName { get; }
-
+
///
/// Endpoint which the plugin provides.
///
[DataMember]
public HostConfig ProvidedEndpoint { get; set; }
}
+
+#if !USE_WCF
+ ///
+ /// Config clone for compatibility
+ ///
+ public class HostConfig
+ {
+ public string Endpoint { get; set; }
+
+ public string BindingType { get; set; }
+
+ public bool RequiresAuthentification { get; set; }
+
+ public bool MetadataEnabled { get; set; }
+
+ public bool HelpEnabled { get; set; }
+ }
+#endif
}
diff --git a/src/Moryx.Runtime.Maintenance/Contracts/MaintenancePluginBase.cs b/src/Moryx.Runtime.Maintenance/Contracts/MaintenancePluginBase.cs
index 1eaeab678..99f1c8dde 100644
--- a/src/Moryx.Runtime.Maintenance/Contracts/MaintenancePluginBase.cs
+++ b/src/Moryx.Runtime.Maintenance/Contracts/MaintenancePluginBase.cs
@@ -2,7 +2,9 @@
// Licensed under the Apache License, Version 2.0
using Moryx.Communication.Endpoints;
+#if USE_WCF
using Moryx.Tools.Wcf;
+#endif
namespace Moryx.Runtime.Maintenance
{
diff --git a/src/Moryx.Runtime.Maintenance/Moryx.Runtime.Maintenance.csproj b/src/Moryx.Runtime.Maintenance/Moryx.Runtime.Maintenance.csproj
index c1c6c8af0..128dd83ca 100644
--- a/src/Moryx.Runtime.Maintenance/Moryx.Runtime.Maintenance.csproj
+++ b/src/Moryx.Runtime.Maintenance/Moryx.Runtime.Maintenance.csproj
@@ -1,22 +1,33 @@
- net45
+ net45;net5.0
true
Core module to configure and control MORYX based applications
true
MORYX;Runtime;Server;Configuration;UI
+
+ USE_WCF
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Moryx.Runtime.Maintenance/Plugins/Common/CommonMaintenanceConfig.cs b/src/Moryx.Runtime.Maintenance/Plugins/Common/CommonMaintenanceConfig.cs
index d89eb181a..85ba1a5fc 100644
--- a/src/Moryx.Runtime.Maintenance/Plugins/Common/CommonMaintenanceConfig.cs
+++ b/src/Moryx.Runtime.Maintenance/Plugins/Common/CommonMaintenanceConfig.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0
using System.Runtime.Serialization;
-using Moryx.Tools.Wcf;
namespace Moryx.Runtime.Maintenance.Plugins.Common
{
@@ -24,8 +23,7 @@ public CommonMaintenanceConfig()
{
ProvidedEndpoint = new HostConfig
{
- Endpoint = "common",
- BindingType = ServiceBindingType.WebHttp,
+ Endpoint = CommonMaintenance.Endpoint
};
}
}
diff --git a/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/CommonMaintenance.cs b/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/CommonMaintenance.cs
index ba20ab2c2..fbefd0c9d 100644
--- a/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/CommonMaintenance.cs
+++ b/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/CommonMaintenance.cs
@@ -14,8 +14,10 @@ namespace Moryx.Runtime.Maintenance.Plugins.Common
///
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, IncludeExceptionDetailInFaults = true)]
[Plugin(LifeCycle.Transient, typeof(ICommonMaintenance))]
- internal class CommonMaintenance : ICommonMaintenance
+ public class CommonMaintenance : ICommonMaintenance
{
+ public const string Endpoint = "common";
+
///
/// Get the current server time.
///
diff --git a/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/ICommonMaintenance.cs b/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/ICommonMaintenance.cs
index 0a6032a39..e802c2878 100644
--- a/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/ICommonMaintenance.cs
+++ b/src/Moryx.Runtime.Maintenance/Plugins/Common/Wcf/ICommonMaintenance.cs
@@ -2,8 +2,10 @@
// Licensed under the Apache License, Version 2.0
using System.Net;
+#if USE_WCF
using System.ServiceModel;
using System.ServiceModel.Web;
+#endif
using Moryx.Communication.Endpoints;
namespace Moryx.Runtime.Maintenance.Plugins.Common
@@ -11,58 +13,69 @@ namespace Moryx.Runtime.Maintenance.Plugins.Common
///
/// Service contract for the common maintenance.
///
+#if USE_WCF
[ServiceContract]
[Endpoint(Name = nameof(ICommonMaintenance), Version = "3.0.0.0")]
+#endif
internal interface ICommonMaintenance
{
///
/// Get the server time.
///
/// The current server time.
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "time", Method = WebRequestMethods.Http.Get,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
ServerTimeResponse GetServerTime();
///
/// Get information about the application
///
- ///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "info/application", Method = WebRequestMethods.Http.Get,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
ApplicationInformationResponse GetApplicationInfo();
///
/// Get information about the host
///
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "info/system", Method = WebRequestMethods.Http.Get,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
HostInformationResponse GetHostInfo();
///
/// Get information about the system load
///
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "info/system/load", Method = WebRequestMethods.Http.Get,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
SystemLoadResponse GetSystemLoad();
///
/// Get information about the application load
///
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "info/application/load", Method = WebRequestMethods.Http.Get,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
ApplicationLoadResponse GetApplicationLoad();
}
}
diff --git a/src/Moryx.Runtime.Maintenance/Plugins/Databases/DatabaseConfig.cs b/src/Moryx.Runtime.Maintenance/Plugins/Databases/DatabaseConfig.cs
index e6e587a01..1497e3919 100644
--- a/src/Moryx.Runtime.Maintenance/Plugins/Databases/DatabaseConfig.cs
+++ b/src/Moryx.Runtime.Maintenance/Plugins/Databases/DatabaseConfig.cs
@@ -4,7 +4,6 @@
using System.ComponentModel;
using System.Runtime.Serialization;
using Moryx.Serialization;
-using Moryx.Tools.Wcf;
namespace Moryx.Runtime.Maintenance.Plugins.Databases
{
@@ -12,7 +11,7 @@ namespace Moryx.Runtime.Maintenance.Plugins.Databases
/// Configuration for the database maintenance plugin.
///
[DataContract]
- internal class DatabaseConfig : MaintenancePluginConfig
+ public class DatabaseConfig : MaintenancePluginConfig
{
///
/// Name of the plugin.
@@ -26,8 +25,7 @@ public DatabaseConfig()
{
ProvidedEndpoint = new HostConfig
{
- BindingType = ServiceBindingType.WebHttp,
- Endpoint = "databases",
+ Endpoint = DatabaseMaintenance.Endpoint,
MetadataEnabled = true
};
}
diff --git a/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/DatabaseMaintenance.cs b/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/DatabaseMaintenance.cs
index 3ebadcf25..d4caee7a8 100644
--- a/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/DatabaseMaintenance.cs
+++ b/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/DatabaseMaintenance.cs
@@ -4,20 +4,35 @@
using System;
using System.IO;
using System.Linq;
-using System.ServiceModel;
using System.Text.RegularExpressions;
+using Moryx.Communication.Endpoints;
using Moryx.Container;
using Moryx.Logging;
using Moryx.Model;
using Moryx.Model.Configuration;
+#if USE_WCF
+using System.ServiceModel;
+#else
+using Microsoft.AspNetCore.Mvc;
+#endif
+
namespace Moryx.Runtime.Maintenance.Plugins.Databases
{
+#if USE_WCF
[Plugin(LifeCycle.Singleton, typeof(IDatabaseMaintenance))]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, IncludeExceptionDetailInFaults = true)]
internal class DatabaseMaintenance : IDatabaseMaintenance
+#else
+ [ApiController, Route(Endpoint)]
+ [Produces("application/json")]
+ [Endpoint(Name = nameof(IDatabaseMaintenance), Version = "3.0.0")]
+ public class DatabaseMaintenance : Controller, IDatabaseMaintenance
+#endif
{
- #region Dependencies
+ public const string Endpoint = "databases";
+
+#region Dependencies
///
/// Global component for database contexts
@@ -35,18 +50,27 @@ internal class DatabaseMaintenance : IDatabaseMaintenance
///
public DatabaseConfig Config { get; set; }
- #endregion
+#endregion
+#if !USE_WCF
+ [HttpGet]
+#endif
public DataModel[] GetAll()
{
return DbContextManager.Contexts.Select(Convert).ToArray();
}
+#if !USE_WCF
+ [HttpGet("model/{targetModel}")]
+#endif
public DataModel GetModel(string targetModel)
{
return Convert(DbContextManager.Contexts.FirstOrDefault(context => TargetModelName(context) == targetModel));
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/config")]
+#endif
public void SetDatabaseConfig(string targetModel, DatabaseConfigModel config)
{
var match = GetTargetConfigurator(targetModel);
@@ -59,6 +83,9 @@ public void SetDatabaseConfig(string targetModel, DatabaseConfigModel config)
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/config/test")]
+#endif
public TestConnectionResponse TestDatabaseConfig(string targetModel, DatabaseConfigModel config)
{
var targetConfigurator = GetTargetConfigurator(targetModel);
@@ -72,12 +99,18 @@ public TestConnectionResponse TestDatabaseConfig(string targetModel, DatabaseCon
return new TestConnectionResponse { Result = result };
}
+#if !USE_WCF
+ [HttpPost("createall")]
+#endif
public InvocationResponse CreateAll()
{
var bulkResult = BulkOperation(mc => mc.CreateDatabase(mc.Config), "Creation");
return string.IsNullOrEmpty(bulkResult) ? new InvocationResponse() : new InvocationResponse(bulkResult);
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/create")]
+#endif
public InvocationResponse CreateDatabase(string targetModel, DatabaseConfigModel config)
{
var targetConfigurator = GetTargetConfigurator(targetModel);
@@ -100,12 +133,18 @@ public InvocationResponse CreateDatabase(string targetModel, DatabaseConfigModel
}
}
+#if !USE_WCF
+ [HttpDelete("/")]
+#endif
public InvocationResponse EraseAll()
{
var bulkResult = BulkOperation(mc => mc.DeleteDatabase(mc.Config), "Deletion");
return string.IsNullOrEmpty(bulkResult) ? new InvocationResponse() : new InvocationResponse(bulkResult);
}
+#if !USE_WCF
+ [HttpDelete("model/{targetModel}")]
+#endif
public InvocationResponse EraseDatabase(string targetModel, DatabaseConfigModel config)
{
var targetConfigurator = GetTargetConfigurator(targetModel);
@@ -126,6 +165,9 @@ public InvocationResponse EraseDatabase(string targetModel, DatabaseConfigModel
}
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/dump")]
+#endif
public InvocationResponse DumpDatabase(string targetModel, DatabaseConfigModel config)
{
var targetConfigurator = GetTargetConfigurator(targetModel);
@@ -143,6 +185,9 @@ public InvocationResponse DumpDatabase(string targetModel, DatabaseConfigModel c
return new InvocationResponse();
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/restore")]
+#endif
public InvocationResponse RestoreDatabase(string targetModel, RestoreDatabaseRequest request)
{
var targetConfigurator = GetTargetConfigurator(targetModel);
@@ -156,6 +201,9 @@ public InvocationResponse RestoreDatabase(string targetModel, RestoreDatabaseReq
return new InvocationResponse();
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/{migrationName}/migrate")]
+#endif
public DatabaseUpdateSummary MigrateDatabaseModel(string targetModel, string migrationName, DatabaseConfigModel configModel)
{
var targetConfigurator = GetTargetConfigurator(targetModel);
@@ -166,6 +214,9 @@ public DatabaseUpdateSummary MigrateDatabaseModel(string targetModel, string mig
return targetConfigurator.MigrateDatabase(config, migrationName);
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/rollback")]
+#endif
public InvocationResponse RollbackDatabase(string targetModel, DatabaseConfigModel config)
{
var targetConfigurator = GetTargetConfigurator(targetModel);
@@ -178,6 +229,9 @@ public InvocationResponse RollbackDatabase(string targetModel, DatabaseConfigMod
return rollbackResult ? new InvocationResponse() : new InvocationResponse("Error while rollback!");
}
+#if !USE_WCF
+ [HttpPost("model/{targetModel}/setup")]
+#endif
public InvocationResponse ExecuteSetup(string targetModel, ExecuteSetupRequest request)
{
var contextType = DbContextManager.Contexts.First(c => TargetModelName(c) == targetModel);
diff --git a/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/IDatabaseMaintenance.cs b/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/IDatabaseMaintenance.cs
index f600679b4..9427738e6 100644
--- a/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/IDatabaseMaintenance.cs
+++ b/src/Moryx.Runtime.Maintenance/Plugins/Databases/Wcf/IDatabaseMaintenance.cs
@@ -2,8 +2,10 @@
// Licensed under the Apache License, Version 2.0
using System.Net;
+#if USE_WCF
using System.ServiceModel;
using System.ServiceModel.Web;
+#endif
using Moryx.Communication.Endpoints;
using Moryx.Model.Configuration;
using Moryx.Web;
@@ -13,133 +15,161 @@ namespace Moryx.Runtime.Maintenance.Plugins.Databases
///
/// Service contracts for database operations.
///
+#if USE_WCF
[ServiceContract]
[Endpoint(Name = nameof(IDatabaseMaintenance), Version = "3.0.0.0")]
+#endif
internal interface IDatabaseMaintenance
{
///
/// Get all database configs
///
/// The fetched DataModels.
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "/", Method = WebRequestMethods.Http.Get,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
DataModel[] GetAll();
///
/// Drop all data models
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "/", Method = WebRequestMethodsExtension.Http.Delete,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse EraseAll();
///
/// Get all database config
///
/// The fetched DataModel.
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}", Method = WebRequestMethods.Http.Get,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
DataModel GetModel(string targetModel);
///
/// Set database config
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/config", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
void SetDatabaseConfig(string targetModel, DatabaseConfigModel config);
///
/// Test a new config
///
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/config/test", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
TestConnectionResponse TestDatabaseConfig(string targetModel, DatabaseConfigModel config);
///
/// Create all datamodels with current config
///
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "createall", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse CreateAll();
///
/// Create a new database matching the model
///
/// True if database could be created
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/create", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse CreateDatabase(string targetModel, DatabaseConfigModel config);
///
/// Erases the database given by the model
///
/// True if erased successful
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}", Method = WebRequestMethodsExtension.Http.Delete,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse EraseDatabase(string targetModel, DatabaseConfigModel config);
///
/// Dumps the database matching the model to create a restoreable backup
///
/// True if async dump is in progress
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/dump", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse DumpDatabase(string targetModel, DatabaseConfigModel config);
///
/// Restores the database.
///
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/restore", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse RestoreDatabase(string targetModel, RestoreDatabaseRequest request);
///
/// Updates database model to the specified update.
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/{migrationName}/migrate", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
DatabaseUpdateSummary MigrateDatabaseModel(string targetModel, string migrationName, DatabaseConfigModel config);
///
/// Rollback of all migrations made
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/rollback", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse RollbackDatabase(string targetModel, DatabaseConfigModel config);
///
/// Execute setup for this config
///
+#if USE_WCF
[OperationContract]
[WebInvoke(UriTemplate = "model/{targetModel}/setup", Method = WebRequestMethods.Http.Post,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
+#endif
InvocationResponse ExecuteSetup(string targetModel, ExecuteSetupRequest request);
}
}