Implemented website order
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Moonlight.App.Models.Forms;
|
||||
|
||||
public class WebsiteDataModel
|
||||
{
|
||||
[Required(ErrorMessage = "You need a domain")]
|
||||
[Required(ErrorMessage = "You need to enter a domain")]
|
||||
[RegularExpression(@"([a-z0-9|-]+\.)*[a-z0-9|-]+\.[a-z]+", ErrorMessage = "You need to enter a valid domain")]
|
||||
public string BaseDomain { get; set; } = "";
|
||||
}
|
||||
10
Moonlight/App/Models/Forms/WebsiteOrderDataModel.cs
Normal file
10
Moonlight/App/Models/Forms/WebsiteOrderDataModel.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.App.Models.Forms;
|
||||
|
||||
public class WebsiteOrderDataModel
|
||||
{
|
||||
[Required(ErrorMessage = "You need to enter a domain")]
|
||||
[RegularExpression(@"([a-z0-9|-]+\.)*[a-z0-9|-]+\.[a-z]+", ErrorMessage = "You need to enter a valid domain")]
|
||||
public string BaseDomain { get; set; } = "";
|
||||
}
|
||||
@@ -6,12 +6,18 @@ namespace Moonlight.App.Services;
|
||||
public class SmartDeployService
|
||||
{
|
||||
private readonly NodeRepository NodeRepository;
|
||||
private readonly PleskServerRepository PleskServerRepository;
|
||||
private readonly WebsiteService WebsiteService;
|
||||
private readonly NodeService NodeService;
|
||||
|
||||
public SmartDeployService(NodeRepository nodeRepository, NodeService nodeService)
|
||||
public SmartDeployService(
|
||||
NodeRepository nodeRepository,
|
||||
NodeService nodeService, PleskServerRepository pleskServerRepository, WebsiteService websiteService)
|
||||
{
|
||||
NodeRepository = nodeRepository;
|
||||
NodeService = nodeService;
|
||||
PleskServerRepository = pleskServerRepository;
|
||||
WebsiteService = websiteService;
|
||||
}
|
||||
|
||||
public async Task<Node?> GetNode()
|
||||
@@ -32,6 +38,21 @@ public class SmartDeployService
|
||||
return data.MaxBy(x => x.Value).Key;
|
||||
}
|
||||
|
||||
public async Task<PleskServer?> GetPleskServer()
|
||||
{
|
||||
var result = new List<PleskServer>();
|
||||
|
||||
foreach (var pleskServer in PleskServerRepository.Get().ToArray())
|
||||
{
|
||||
if (await WebsiteService.IsHostUp(pleskServer))
|
||||
{
|
||||
result.Add(pleskServer);
|
||||
}
|
||||
}
|
||||
|
||||
return result.FirstOrDefault();
|
||||
}
|
||||
|
||||
private async Task<double> GetUsageScore(Node node)
|
||||
{
|
||||
var score = 0;
|
||||
|
||||
Reference in New Issue
Block a user