2024-08-04 18:44:33 -05:00
|
|
|
|
using LANCommander.Server.Data;
|
|
|
|
|
|
using LANCommander.Server.Data.Models;
|
|
|
|
|
|
using LANCommander.Server.Models;
|
2023-01-26 20:42:33 -06:00
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
2023-01-15 03:11:51 -06:00
|
|
|
|
|
2024-08-04 18:44:33 -05:00
|
|
|
|
namespace LANCommander.Server.Services
|
2023-01-15 03:11:51 -06:00
|
|
|
|
{
|
|
|
|
|
|
public class ScriptService : BaseDatabaseService<Script>
|
|
|
|
|
|
{
|
|
|
|
|
|
public ScriptService(DatabaseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2023-01-26 20:42:33 -06:00
|
|
|
|
|
|
|
|
|
|
public static IEnumerable<Snippet> GetSnippets()
|
|
|
|
|
|
{
|
|
|
|
|
|
var files = Directory.GetFiles(@"Snippets", "*.ps1", SearchOption.AllDirectories);
|
|
|
|
|
|
|
|
|
|
|
|
return files.Select(f =>
|
|
|
|
|
|
{
|
2023-12-04 18:30:34 +01:00
|
|
|
|
var split = f.Split(Path.DirectorySeparatorChar);
|
2023-01-26 20:42:33 -06:00
|
|
|
|
|
|
|
|
|
|
return new Snippet()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = Path.GetFileNameWithoutExtension(f),
|
|
|
|
|
|
Group = split[1],
|
|
|
|
|
|
Content = File.ReadAllText(f)
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2023-01-15 03:11:51 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|