bump sdk to net-9
This commit is contained in:
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"dotnet-test-explorer.testProjectPath": "**/*Tests.@(csproj|vbproj|fsproj)",
|
||||||
"sqltools.connections": [
|
"sqltools.connections": [
|
||||||
{
|
{
|
||||||
"previewLimit": 50,
|
"previewLimit": 50,
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"sdk": {
|
|
||||||
"runtime": "dotnet",
|
|
||||||
"version": "8.0.405"
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,8 +26,6 @@ namespace Yavsc.Abstract.Templates
|
|||||||
public virtual void Init() {
|
public virtual void Init() {
|
||||||
_buffer = new StringBuilder();
|
_buffer = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Task ExecuteAsync();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using RazorEngine.Templating;
|
||||||
using Yavsc.Attributes.Validation;
|
using Yavsc.Attributes.Validation;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
using Yavsc.Models.Calendar;
|
using Yavsc.Models.Calendar;
|
||||||
@ -8,7 +9,7 @@ using Yavsc.Server.Models.Calendar;
|
|||||||
|
|
||||||
namespace Yavsc.Server.Models.EMailing
|
namespace Yavsc.Server.Models.EMailing
|
||||||
{
|
{
|
||||||
public class MailingTemplate : ITrackedEntity
|
public class MailingTemplate : ITrackedEntity, ITemplateSource
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Date Created
|
/// Date Created
|
||||||
@ -41,7 +42,6 @@ namespace Yavsc.Server.Models.EMailing
|
|||||||
[EmailAddress()]
|
[EmailAddress()]
|
||||||
public string ReplyToAddress { get; set; }
|
public string ReplyToAddress { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public Periodicity ToSend { get; set; }
|
public Periodicity ToSend { get; set; }
|
||||||
|
|
||||||
public string UserCreated
|
public string UserCreated
|
||||||
@ -55,5 +55,13 @@ namespace Yavsc.Server.Models.EMailing
|
|||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Template => Body;
|
||||||
|
public string TemplateFile { get => Id; }
|
||||||
|
|
||||||
|
public TextReader GetTemplateReader()
|
||||||
|
{
|
||||||
|
return new StringReader(Body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,174 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
// // EMailer.cs
|
|
||||||
// /*
|
|
||||||
// paul 26/06/2018 12:18 20182018 6 26
|
|
||||||
// */
|
|
||||||
using Yavsc.Templates;
|
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
|
||||||
using Microsoft.CodeAnalysis.Emit;
|
|
||||||
|
|
||||||
using Yavsc.Models;
|
|
||||||
using Yavsc.Services;
|
|
||||||
using System.Reflection;
|
|
||||||
using Yavsc.Abstract.Templates;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using RazorEngine.Configuration;
|
|
||||||
using Yavsc.Interface;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Yavsc.Lib
|
|
||||||
{
|
|
||||||
public class EMailer
|
|
||||||
{
|
|
||||||
const string DefaultBaseClassName = "ATemplate";
|
|
||||||
const string DefaultBaseClass = nameof(UserOrientedTemplate);
|
|
||||||
ISet<string> Namespaces = new System.Collections.Generic.HashSet<string> {
|
|
||||||
"System",
|
|
||||||
"Yavsc.Templates" ,
|
|
||||||
"Yavsc.Models",
|
|
||||||
"Yavsc.Models.Identity"};
|
|
||||||
|
|
||||||
readonly IStringLocalizer<EMailer> stringLocalizer;
|
|
||||||
readonly ApplicationDbContext dbContext;
|
|
||||||
|
|
||||||
readonly ILogger logger;
|
|
||||||
|
|
||||||
public EMailer(ApplicationDbContext context,
|
|
||||||
IStringLocalizer<EMailer> localizer,
|
|
||||||
ILoggerFactory loggerFactory)
|
|
||||||
{
|
|
||||||
stringLocalizer = localizer;
|
|
||||||
|
|
||||||
logger = loggerFactory.CreateLogger<EMailer>();
|
|
||||||
|
|
||||||
|
|
||||||
var templateServiceConfig = new TemplateServiceConfiguration()
|
|
||||||
{
|
|
||||||
BaseTemplateType = typeof(UserOrientedTemplate),
|
|
||||||
Language = RazorEngine.Language.CSharp,
|
|
||||||
Namespaces = Namespaces
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendMonthlyEmail(string templateCode, string baseclassName = DefaultBaseClassName)
|
|
||||||
{
|
|
||||||
string className = "Generated" + baseclassName;
|
|
||||||
|
|
||||||
string subtemp = stringLocalizer["MonthlySubjectTemplate"].Value;
|
|
||||||
|
|
||||||
logger.LogInformation($"Generating {subtemp}[{className}]");
|
|
||||||
|
|
||||||
|
|
||||||
var templateInfo = dbContext.MailingTemplate.FirstOrDefault(t => t.Id == templateCode);
|
|
||||||
var templatekey = RazorEngine.Engine.Razor.GetKey(templateInfo.Id);
|
|
||||||
|
|
||||||
|
|
||||||
logger.LogInformation($"Using code: {templateCode}, subject: {subtemp} ");
|
|
||||||
logger.LogInformation("And body:\n" + templateInfo.Body);
|
|
||||||
using (StringReader reader = new StringReader(templateInfo.Body))
|
|
||||||
{
|
|
||||||
|
|
||||||
// Generate code for the template
|
|
||||||
using (var rzcode = new MemoryStream())
|
|
||||||
{
|
|
||||||
using (var writter = new StreamWriter(rzcode))
|
|
||||||
{
|
|
||||||
RazorEngine.Engine.Razor.Run(templatekey, writter);
|
|
||||||
rzcode.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(Encoding.Default.GetString(rzcode.ToArray()));
|
|
||||||
|
|
||||||
|
|
||||||
logger.LogInformation("CSharp parsed");
|
|
||||||
List<MetadataReference> references = new List<MetadataReference>();
|
|
||||||
|
|
||||||
foreach (var type in new Type[] {
|
|
||||||
typeof(object),
|
|
||||||
typeof(Enumerable),
|
|
||||||
typeof(IdentityUser),
|
|
||||||
typeof(ApplicationUser),
|
|
||||||
typeof(Template),
|
|
||||||
typeof(UserOrientedTemplate),
|
|
||||||
typeof(System.Threading.Tasks.TaskExtensions)
|
|
||||||
})
|
|
||||||
{
|
|
||||||
var location = type.Assembly.Location;
|
|
||||||
if (!string.IsNullOrWhiteSpace(location))
|
|
||||||
{
|
|
||||||
references.Add(
|
|
||||||
MetadataReference.CreateFromFile(location)
|
|
||||||
);
|
|
||||||
logger.LogInformation($"Assembly for {type.Name} found at {location}");
|
|
||||||
}
|
|
||||||
else logger.LogWarning($"Assembly Not found for {type.Name}");
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.LogInformation("Compilation creation ...");
|
|
||||||
|
|
||||||
var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
|
|
||||||
.WithAllowUnsafe(true).WithOptimizationLevel(OptimizationLevel.Debug)
|
|
||||||
.WithOutputKind(OutputKind.DynamicallyLinkedLibrary).WithPlatform(Platform.AnyCpu)
|
|
||||||
.WithUsings("Yavsc.Templates")
|
|
||||||
;
|
|
||||||
string assemblyName = "EMailSenderTemplate";
|
|
||||||
CSharpCompilation compilation = CSharpCompilation.Create(
|
|
||||||
assemblyName,
|
|
||||||
syntaxTrees: new[] { syntaxTree },
|
|
||||||
references: references,
|
|
||||||
options: compilationOptions
|
|
||||||
);
|
|
||||||
|
|
||||||
using (var ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
logger.LogInformation("Emitting result ...");
|
|
||||||
EmitResult result = compilation.Emit(ms);
|
|
||||||
foreach (Diagnostic diagnostic in result.Diagnostics.Where(diagnostic =>
|
|
||||||
diagnostic.Severity < DiagnosticSeverity.Error && !diagnostic.IsWarningAsError))
|
|
||||||
{
|
|
||||||
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
|
||||||
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
|
||||||
}
|
|
||||||
if (!result.Success)
|
|
||||||
{
|
|
||||||
|
|
||||||
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(diagnostic =>
|
|
||||||
diagnostic.IsWarningAsError ||
|
|
||||||
diagnostic.Severity == DiagnosticSeverity.Error);
|
|
||||||
foreach (Diagnostic diagnostic in failures)
|
|
||||||
{
|
|
||||||
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
|
||||||
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
ms.Seek(0, SeekOrigin.Begin);
|
|
||||||
Assembly assembly = Assembly.Load(ms.ToArray());
|
|
||||||
|
|
||||||
Type type = assembly.GetType(Namespaces + "." + className);
|
|
||||||
var generatedtemplate = (UserOrientedTemplate)Activator.CreateInstance(type);
|
|
||||||
foreach (var user in dbContext.ApplicationUser.Where(
|
|
||||||
u => u.AllowMonthlyEmail
|
|
||||||
))
|
|
||||||
{
|
|
||||||
logger.LogInformation("Generation for " + user.UserName);
|
|
||||||
generatedtemplate.Init();
|
|
||||||
generatedtemplate.User = user;
|
|
||||||
generatedtemplate.ExecuteAsync();
|
|
||||||
logger.LogInformation(generatedtemplate.GeneratedText);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
171
src/Yavsc.Server/Services/YavscTemplateEngine.cs
Normal file
171
src/Yavsc.Server/Services/YavscTemplateEngine.cs
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
using System.Text;
|
||||||
|
// // EMailer.cs
|
||||||
|
// /*
|
||||||
|
// paul 26/06/2018 12:18 20182018 6 26
|
||||||
|
// */
|
||||||
|
using Yavsc.Templates;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
using Microsoft.CodeAnalysis.Emit;
|
||||||
|
|
||||||
|
using Yavsc.Models;
|
||||||
|
using Yavsc.Services;
|
||||||
|
using System.Reflection;
|
||||||
|
using Yavsc.Abstract.Templates;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using RazorEngine.Configuration;
|
||||||
|
using Yavsc.Interface;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using RazorEngine.Compilation.ImpromptuInterface.Optimization;
|
||||||
|
using RazorEngine.Compilation.ImpromptuInterface;
|
||||||
|
|
||||||
|
namespace Yavsc.Lib
|
||||||
|
{
|
||||||
|
public class YavscTemplateEngine
|
||||||
|
{
|
||||||
|
ISet<string> Namespaces = new System.Collections.Generic.HashSet<string> {
|
||||||
|
"System",
|
||||||
|
"Yavsc.Templates" ,
|
||||||
|
"Yavsc.Models",
|
||||||
|
"Yavsc.Models.Identity"};
|
||||||
|
|
||||||
|
readonly IStringLocalizer<YavscTemplateEngine> stringLocalizer;
|
||||||
|
readonly ApplicationDbContext dbContext;
|
||||||
|
|
||||||
|
readonly ILogger logger;
|
||||||
|
|
||||||
|
public YavscTemplateEngine(ApplicationDbContext dbContext,
|
||||||
|
IStringLocalizer<YavscTemplateEngine> localizer,
|
||||||
|
ILoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
stringLocalizer = localizer;
|
||||||
|
this.dbContext = dbContext;
|
||||||
|
|
||||||
|
logger = loggerFactory.CreateLogger<YavscTemplateEngine>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string RunUserTemplate(string templateCode)
|
||||||
|
{
|
||||||
|
|
||||||
|
string subtemp = stringLocalizer["MonthlySubjectTemplate"].Value;
|
||||||
|
|
||||||
|
logger.LogInformation($"Generating SendMonthlyEmail {templateCode}");
|
||||||
|
|
||||||
|
|
||||||
|
var templateInfo = dbContext.MailingTemplate.FirstOrDefault(t => t.Id == templateCode);
|
||||||
|
Debug.Assert (templateInfo != null);
|
||||||
|
var templatekey = RazorEngine.Engine.Razor.GetKey(templateInfo.Id);
|
||||||
|
|
||||||
|
logger.LogInformation($"Using code: {templateCode}, subject: {subtemp} ");
|
||||||
|
logger.LogInformation("And body:\n" + templateInfo.Body);
|
||||||
|
|
||||||
|
|
||||||
|
// Generate code for the template
|
||||||
|
using (var inMemoryCsharpCode = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (var writter = new StreamWriter(inMemoryCsharpCode))
|
||||||
|
{
|
||||||
|
RazorEngine.Engine.Razor.Run(templatekey, writter);
|
||||||
|
inMemoryCsharpCode.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(Encoding.Default.GetString(inMemoryCsharpCode.ToArray()));
|
||||||
|
|
||||||
|
logger.LogInformation("CSharp parsed");
|
||||||
|
List<MetadataReference> references = new List<MetadataReference>();
|
||||||
|
|
||||||
|
foreach (var type in new Type[] {
|
||||||
|
typeof(object),
|
||||||
|
typeof(Enumerable),
|
||||||
|
typeof(IdentityUser),
|
||||||
|
typeof(ApplicationUser),
|
||||||
|
typeof(Template),
|
||||||
|
typeof(UserOrientedTemplate),
|
||||||
|
typeof(System.Threading.Tasks.TaskExtensions)
|
||||||
|
})
|
||||||
|
{
|
||||||
|
var location = type.Assembly.Location;
|
||||||
|
if (!string.IsNullOrWhiteSpace(location))
|
||||||
|
{
|
||||||
|
references.Add(
|
||||||
|
MetadataReference.CreateFromFile(location)
|
||||||
|
);
|
||||||
|
logger.LogInformation($"Assembly for {type.Name} found at {location}");
|
||||||
|
}
|
||||||
|
else logger.LogWarning($"Assembly Not found for {type.Name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Compilation creation ...");
|
||||||
|
|
||||||
|
var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
|
||||||
|
.WithAllowUnsafe(true).WithOptimizationLevel(OptimizationLevel.Debug)
|
||||||
|
.WithOutputKind(OutputKind.DynamicallyLinkedLibrary).WithPlatform(Platform.AnyCpu)
|
||||||
|
.WithUsings("Yavsc.Templates")
|
||||||
|
;
|
||||||
|
string assemblyName = "EMailSenderTemplate";
|
||||||
|
CSharpCompilation compilation = CSharpCompilation.Create(
|
||||||
|
assemblyName,
|
||||||
|
syntaxTrees: new[] { syntaxTree },
|
||||||
|
references: references,
|
||||||
|
options: compilationOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
using (var inMemoryAssembly = new MemoryStream())
|
||||||
|
{
|
||||||
|
logger.LogInformation("Emitting result ...");
|
||||||
|
EmitResult result = compilation.Emit(inMemoryAssembly);
|
||||||
|
foreach (Diagnostic diagnostic in result.Diagnostics.Where(diagnostic =>
|
||||||
|
diagnostic.Severity < DiagnosticSeverity.Error && !diagnostic.IsWarningAsError))
|
||||||
|
{
|
||||||
|
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
||||||
|
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
||||||
|
}
|
||||||
|
if (!result.Success)
|
||||||
|
{
|
||||||
|
|
||||||
|
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(diagnostic =>
|
||||||
|
diagnostic.IsWarningAsError ||
|
||||||
|
diagnostic.Severity == DiagnosticSeverity.Error);
|
||||||
|
foreach (Diagnostic diagnostic in failures)
|
||||||
|
{
|
||||||
|
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
||||||
|
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var user in dbContext.ApplicationUser.Where(
|
||||||
|
u => u.AllowMonthlyEmail
|
||||||
|
))
|
||||||
|
{
|
||||||
|
|
||||||
|
var template = result.CallActLike<UserOrientedTemplate>(user);
|
||||||
|
return template.GeneratedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* result.CallActLike<>
|
||||||
|
|
||||||
|
inMemoryAssembly.Seek(0, SeekOrigin.Begin);
|
||||||
|
Assembly assembly = Assembly.Load(inMemoryAssembly.ToArray());
|
||||||
|
// UserOrientedTemplate userOrientedTemplate = (UserOrientedTemplate)
|
||||||
|
// FIXME Activator.CreateInstance(Type.GetType(templateInfo.TemplateType));
|
||||||
|
|
||||||
|
foreach (var user in dbContext.ApplicationUser.Where(
|
||||||
|
u => u.AllowMonthlyEmail
|
||||||
|
))
|
||||||
|
{
|
||||||
|
logger.LogInformation("Generation for " + user.UserName);
|
||||||
|
userOrientedTemplate.Init();
|
||||||
|
userOrientedTemplate.User = user; */
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,8 +5,11 @@ using Yavsc.Models;
|
|||||||
|
|
||||||
namespace Yavsc.Templates
|
namespace Yavsc.Templates
|
||||||
{
|
{
|
||||||
public abstract class UserOrientedTemplate: Template
|
public class UserOrientedTemplate: Template
|
||||||
{
|
{
|
||||||
public ApplicationUser User { get; set; }
|
public ApplicationUser User { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"env": [],
|
|
||||||
"build" :{
|
|
||||||
|
|
||||||
},
|
|
||||||
"prepare": {
|
|
||||||
"make": {}
|
|
||||||
},
|
|
||||||
"post_build": {
|
|
||||||
"yavsc": {
|
|
||||||
"type": "make",
|
|
||||||
"source" : {
|
|
||||||
"github": "pazof/yavsc",
|
|
||||||
"branch": "vnext"
|
|
||||||
},
|
|
||||||
"args": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"emails": []
|
|
||||||
}
|
|
@ -11,6 +11,13 @@ namespace cli
|
|||||||
{
|
{
|
||||||
public class SendMailCommandProvider : ICommander
|
public class SendMailCommandProvider : ICommander
|
||||||
{
|
{
|
||||||
|
EMailer emailer;
|
||||||
|
private ILogger<SendMailCommandProvider> logger;
|
||||||
|
public SendMailCommandProvider(EMailer emailer, ILoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
this.emailer = emailer;
|
||||||
|
this.logger = loggerFactory.CreateLogger<SendMailCommandProvider>();
|
||||||
|
}
|
||||||
public CommandLineApplication Integrate(CommandLineApplication rootApp)
|
public CommandLineApplication Integrate(CommandLineApplication rootApp)
|
||||||
{
|
{
|
||||||
CommandArgument critCommandArg = null;
|
CommandArgument critCommandArg = null;
|
||||||
@ -40,12 +47,10 @@ namespace cli
|
|||||||
.UseServer("cli")
|
.UseServer("cli")
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.Build();
|
.Build();
|
||||||
var app = hostengnine.Start();
|
|
||||||
var mailer = app.Services.GetService<EMailer>();
|
|
||||||
var loggerFactory = app.Services.GetService<ILoggerFactory>();
|
|
||||||
var logger = loggerFactory.CreateLogger<Program>();
|
|
||||||
logger.LogInformation("Starting emailling");
|
logger.LogInformation("Starting emailling");
|
||||||
mailer.SendEmailFromCriteria(critCommandArg.Value);
|
emailer.SendEmailFromCriteria(critCommandArg.Value);
|
||||||
logger.LogInformation("Finished emailling");
|
logger.LogInformation("Finished emailling");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
SOURCE_DIR=../..
|
|
||||||
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make
|
|
||||||
MSBUILD=msbuild
|
|
||||||
|
|
||||||
all: $(BINTARGETPATH)
|
|
||||||
|
|
||||||
include $(MAKEFILE_DIR)/dnx.mk
|
|
||||||
|
|
||||||
# makes version
|
|
||||||
include $(MAKEFILE_DIR)/versioning.mk
|
|
||||||
|
|
||||||
msbuild-restore:
|
|
||||||
$(MSBUILD) $(PRJNAME).csproj /t:Restore
|
|
||||||
|
|
||||||
check: run
|
|
||||||
|
|
||||||
: project.lock.json
|
|
||||||
@dnu build --configuration=$(CONFIGURATION)
|
|
||||||
|
|
||||||
run: $(BINTARGETPATH)
|
|
||||||
ASPNET_ENV=$(ASPNET_ENV) dnx --configuration=$(CONFIGURATION) run send monthly
|
|
||||||
|
|
||||||
info:
|
|
||||||
@echo $(PRJNAME) : $(BINTARGETPATH) $(version)
|
|
||||||
|
|
||||||
# Due to NJsonSchema.CodeGeneration.CSharp package:
|
|
||||||
.PHONY: $(BINTARGETPATH)
|
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace Yavsc.Server
|
|
||||||
{
|
|
||||||
public class CliServerFactory : IServerFactory
|
|
||||||
{
|
|
||||||
public IFeatureCollection Initialize(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
FeatureCollection featureCollection = new FeatureCollection();
|
|
||||||
return featureCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDisposable Start(IFeatureCollection serverFeatures, Func<IFeatureCollection, Task> application)
|
|
||||||
{
|
|
||||||
var task = application(serverFeatures);
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,141 +1,2 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
using System;
|
Console.WriteLine("Hello, World!");
|
||||||
using System.Runtime.Versioning;
|
|
||||||
using cli.Commands;
|
|
||||||
using Microsoft.AspNetCore.Builder.Internal;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.Dnx.Runtime;
|
|
||||||
using Microsoft.Extensions.CommandLineUtils;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.OptionsModel;
|
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Yavsc;
|
|
||||||
|
|
||||||
namespace cli
|
|
||||||
{
|
|
||||||
public class CliAppEnv : IApplicationEnvironment
|
|
||||||
{
|
|
||||||
public CliAppEnv(IApplicationEnvironment defaultEnv)
|
|
||||||
{
|
|
||||||
var envAppVar = Environment.GetEnvironmentVariable("ASPNET_ENV");
|
|
||||||
Configuration = envAppVar ?? defaultEnv.Configuration;
|
|
||||||
ApplicationName = defaultEnv.ApplicationName;
|
|
||||||
ApplicationVersion = defaultEnv.ApplicationVersion;
|
|
||||||
ApplicationBasePath = defaultEnv.ApplicationBasePath;
|
|
||||||
RuntimeFramework = defaultEnv.RuntimeFramework;
|
|
||||||
}
|
|
||||||
public string ApplicationName { get; private set; }
|
|
||||||
|
|
||||||
public string ApplicationVersion { get; private set; }
|
|
||||||
|
|
||||||
public string ApplicationBasePath { get; private set; }
|
|
||||||
|
|
||||||
public string Configuration { get; private set; }
|
|
||||||
|
|
||||||
public FrameworkName RuntimeFramework { get; private set; }
|
|
||||||
|
|
||||||
public object GetData(string name)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetData(string name, object value)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class Program
|
|
||||||
{
|
|
||||||
private static IApplicationEnvironment appEnv;
|
|
||||||
public static IHostingEnvironment HostingEnvironment { get; private set; }
|
|
||||||
|
|
||||||
public Program()
|
|
||||||
{
|
|
||||||
appEnv = new CliAppEnv(PlatformServices.Default.Application);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes the application by
|
|
||||||
/// </summary>
|
|
||||||
private static ApplicationBuilder ConfigureApplication()
|
|
||||||
{
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += OnUnHandledException;
|
|
||||||
|
|
||||||
var services = new ServiceCollection();
|
|
||||||
// create a service provider with the HostEnvironment.
|
|
||||||
HostingEnvironment = new HostingEnvironment
|
|
||||||
{
|
|
||||||
EnvironmentName = appEnv.Configuration
|
|
||||||
};
|
|
||||||
|
|
||||||
var startup = new Startup(HostingEnvironment, appEnv);
|
|
||||||
startup.ConfigureServices(services);
|
|
||||||
services.AddInstance<IHostingEnvironment>(HostingEnvironment);
|
|
||||||
var serviceProvider = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var app = new ApplicationBuilder(serviceProvider)
|
|
||||||
{
|
|
||||||
ApplicationServices = serviceProvider
|
|
||||||
};
|
|
||||||
|
|
||||||
var siteSettings = serviceProvider.GetRequiredService<IOptions<SiteSettings>>();
|
|
||||||
var cxSettings = serviceProvider.GetRequiredService<IOptions<ConnectionSettings>>();
|
|
||||||
var userCxSettings = serviceProvider.GetRequiredService<IOptions<UserConnectionSettings>>();
|
|
||||||
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
|
|
||||||
|
|
||||||
startup.Configure(cxSettings, userCxSettings, loggerFactory);
|
|
||||||
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnUnHandledException(object sender, UnhandledExceptionEventArgs e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Unhandled Exception occured:");
|
|
||||||
Console.WriteLine(JsonConvert.SerializeObject(e.ExceptionObject));
|
|
||||||
}
|
|
||||||
|
|
||||||
[STAThread]
|
|
||||||
public static int Main(string[] args)
|
|
||||||
{
|
|
||||||
CommandLineApplication cliapp = new CommandLineApplication(false)
|
|
||||||
{
|
|
||||||
Name = "cli",
|
|
||||||
FullName = "Yavsc command line interface",
|
|
||||||
Description = "Dnx console app for yavsc server side",
|
|
||||||
ShortVersionGetter = () => "v1.0",
|
|
||||||
LongVersionGetter = () => "version 1.0 (stable)"
|
|
||||||
};
|
|
||||||
|
|
||||||
// calling a Startup sequence
|
|
||||||
var appBuilder = ConfigureApplication();
|
|
||||||
var loggerFactory = appBuilder.ApplicationServices.GetRequiredService<ILoggerFactory>();
|
|
||||||
var cxSettings = appBuilder.ApplicationServices.GetRequiredService<IOptions<ConnectionSettings>>();
|
|
||||||
var usercxSettings = appBuilder.ApplicationServices.GetRequiredService<IOptions<UserConnectionSettings>>();
|
|
||||||
|
|
||||||
CommandOption rootCommandHelpOption = cliapp.HelpOption("-? | -h | --help");
|
|
||||||
|
|
||||||
new SendMailCommandProvider().Integrate(cliapp);
|
|
||||||
new GenerateJsonSchema().Integrate(cliapp);
|
|
||||||
new AuthCommander(loggerFactory).Integrate(cliapp);
|
|
||||||
new GenerationCommander().Integrate(cliapp);
|
|
||||||
new Streamer(loggerFactory, cxSettings, usercxSettings ).Integrate(cliapp);
|
|
||||||
new UserListCleanUp().Integrate(cliapp);
|
|
||||||
|
|
||||||
if (args.Length == 0)
|
|
||||||
{
|
|
||||||
cliapp.ShowHint();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
var result = cliapp.Execute(args);
|
|
||||||
|
|
||||||
if (cliapp.RemainingArguments.Count > 0)
|
|
||||||
{
|
|
||||||
cliapp.ShowHint();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
136
src/cli/Program.old.cs
Normal file
136
src/cli/Program.old.cs
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
using cli.Commands;
|
||||||
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Yavsc;
|
||||||
|
|
||||||
|
namespace cli
|
||||||
|
{
|
||||||
|
public class CliAppEnv : IApplicationEnvironment
|
||||||
|
{
|
||||||
|
public CliAppEnv(IApplicationEnvironment defaultEnv)
|
||||||
|
{
|
||||||
|
var envAppVar = Environment.GetEnvironmentVariable("ASPNET_ENV");
|
||||||
|
Configuration = envAppVar ?? defaultEnv.Configuration;
|
||||||
|
ApplicationName = defaultEnv.ApplicationName;
|
||||||
|
ApplicationVersion = defaultEnv.ApplicationVersion;
|
||||||
|
ApplicationBasePath = defaultEnv.ApplicationBasePath;
|
||||||
|
RuntimeFramework = defaultEnv.RuntimeFramework;
|
||||||
|
}
|
||||||
|
public string ApplicationName { get; private set; }
|
||||||
|
|
||||||
|
public string ApplicationVersion { get; private set; }
|
||||||
|
|
||||||
|
public string ApplicationBasePath { get; private set; }
|
||||||
|
|
||||||
|
public string Configuration { get; private set; }
|
||||||
|
|
||||||
|
public FrameworkName RuntimeFramework { get; private set; }
|
||||||
|
|
||||||
|
public object GetData(string name)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetData(string name, object value)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public partial class Program
|
||||||
|
{
|
||||||
|
private static IApplicationEnvironment appEnv;
|
||||||
|
public static IHostingEnvironment HostingEnvironment { get; private set; }
|
||||||
|
|
||||||
|
public Program()
|
||||||
|
{
|
||||||
|
appEnv = new CliAppEnv(PlatformServices.Default.Application);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the application by
|
||||||
|
/// </summary>
|
||||||
|
private static ApplicationBuilder ConfigureApplication()
|
||||||
|
{
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += OnUnHandledException;
|
||||||
|
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
// create a service provider with the HostEnvironment.
|
||||||
|
HostingEnvironment = new HostingEnvironment
|
||||||
|
{
|
||||||
|
EnvironmentName = appEnv.Configuration
|
||||||
|
};
|
||||||
|
|
||||||
|
var startup = new Startup(HostingEnvironment, appEnv);
|
||||||
|
startup.ConfigureServices(services);
|
||||||
|
services.AddInstance<IHostingEnvironment>(HostingEnvironment);
|
||||||
|
var serviceProvider = services.BuildServiceProvider();
|
||||||
|
|
||||||
|
var app = new ApplicationBuilder(serviceProvider)
|
||||||
|
{
|
||||||
|
ApplicationServices = serviceProvider
|
||||||
|
};
|
||||||
|
|
||||||
|
var siteSettings = serviceProvider.GetRequiredService<IOptions<SiteSettings>>();
|
||||||
|
var cxSettings = serviceProvider.GetRequiredService<IOptions<ConnectionSettings>>();
|
||||||
|
var userCxSettings = serviceProvider.GetRequiredService<IOptions<UserConnectionSettings>>();
|
||||||
|
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
|
||||||
|
|
||||||
|
startup.Configure(cxSettings, userCxSettings, loggerFactory);
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnUnHandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unhandled Exception occured:");
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(e.ExceptionObject));
|
||||||
|
}
|
||||||
|
|
||||||
|
[STAThread]
|
||||||
|
public static int Main(string[] args)
|
||||||
|
{
|
||||||
|
CommandLineApplication cliapp = new CommandLineApplication(false)
|
||||||
|
{
|
||||||
|
Name = "cli",
|
||||||
|
FullName = "Yavsc command line interface",
|
||||||
|
Description = "Dnx console app for yavsc server side",
|
||||||
|
ShortVersionGetter = () => "v1.0",
|
||||||
|
LongVersionGetter = () => "version 1.0 (stable)"
|
||||||
|
};
|
||||||
|
|
||||||
|
// calling a Startup sequence
|
||||||
|
var appBuilder = ConfigureApplication();
|
||||||
|
var loggerFactory = appBuilder.ApplicationServices.GetRequiredService<ILoggerFactory>();
|
||||||
|
var cxSettings = appBuilder.ApplicationServices.GetRequiredService<IOptions<ConnectionSettings>>();
|
||||||
|
var usercxSettings = appBuilder.ApplicationServices.GetRequiredService<IOptions<UserConnectionSettings>>();
|
||||||
|
var emailer = appBuilder.ApplicationServices.GetService<Emailer>();
|
||||||
|
CommandOption rootCommandHelpOption = cliapp.HelpOption("-? | -h | --help");
|
||||||
|
|
||||||
|
new SendMailCommandProvider().Integrate(cliapp);
|
||||||
|
new GenerateJsonSchema().Integrate(cliapp);
|
||||||
|
new AuthCommander(loggerFactory).Integrate(cliapp);
|
||||||
|
new GenerationCommander().Integrate(cliapp);
|
||||||
|
new Streamer(loggerFactory, cxSettings, usercxSettings ).Integrate(cliapp);
|
||||||
|
new UserListCleanUp().Integrate(cliapp);
|
||||||
|
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
cliapp.ShowHint();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
var result = cliapp.Execute(args);
|
||||||
|
|
||||||
|
if (cliapp.RemainingArguments.Count > 0)
|
||||||
|
{
|
||||||
|
cliapp.ShowHint();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,191 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
|
||||||
using Microsoft.CodeAnalysis.Emit;
|
|
||||||
using Microsoft.AspNetCore.Razor;
|
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.AspNetCore.Identity.EntityFramework;
|
|
||||||
|
|
||||||
using Yavsc.Models;
|
|
||||||
using Yavsc.Templates;
|
|
||||||
using Yavsc.Abstract.Templates;
|
|
||||||
using Yavsc.Services;
|
|
||||||
using Yavsc.Abstract.Manage;
|
|
||||||
using Yavsc.Server.Settings;
|
|
||||||
|
|
||||||
namespace cli.Services
|
|
||||||
{
|
|
||||||
public class NoMaillingTemplateException : Exception
|
|
||||||
{
|
|
||||||
public NoMaillingTemplateException(string templateCode) : base ($"No template found under id {templateCode}.")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class EMailer
|
|
||||||
{
|
|
||||||
const string DefaultBaseClassName = "ATemplate";
|
|
||||||
const string DefaultBaseClass = nameof(UserOrientedTemplate);
|
|
||||||
const string DefaultNamespace = "CompiledRazorTemplates";
|
|
||||||
readonly RazorTemplateEngine razorEngine;
|
|
||||||
readonly IStringLocalizer<EMailer> stringLocalizer;
|
|
||||||
readonly ILogger logger;
|
|
||||||
readonly ApplicationDbContext dbContext;
|
|
||||||
readonly IEmailSender mailSender;
|
|
||||||
readonly RazorEngineHost host;
|
|
||||||
|
|
||||||
public EMailer(ApplicationDbContext context, IEmailSender sender, IStringLocalizer<EMailer> localizer, ILoggerFactory loggerFactory)
|
|
||||||
{
|
|
||||||
stringLocalizer = localizer;
|
|
||||||
mailSender = sender;
|
|
||||||
|
|
||||||
logger = loggerFactory.CreateLogger<EMailer>();
|
|
||||||
|
|
||||||
var language = new CSharpRazorCodeLanguage();
|
|
||||||
|
|
||||||
host = new RazorEngineHost(language)
|
|
||||||
{
|
|
||||||
DefaultBaseClass = DefaultBaseClass,
|
|
||||||
DefaultClassName = DefaultBaseClassName,
|
|
||||||
DefaultNamespace = DefaultNamespace
|
|
||||||
};
|
|
||||||
|
|
||||||
host.NamespaceImports.Add("System");
|
|
||||||
host.NamespaceImports.Add("Yavsc.Templates");
|
|
||||||
host.NamespaceImports.Add("Yavsc.Models");
|
|
||||||
host.NamespaceImports.Add("Yavsc.Models.Identity");
|
|
||||||
host.NamespaceImports.Add("Microsoft.AspNet.Identity.EntityFramework");
|
|
||||||
host.InstrumentedSourceFilePath = ".";
|
|
||||||
host.StaticHelpers = true;
|
|
||||||
dbContext = context;
|
|
||||||
razorEngine = new RazorTemplateEngine(host);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void SendEmailFromCriteria(string templateCode)
|
|
||||||
{
|
|
||||||
string className = "GeneratedTemplate";
|
|
||||||
|
|
||||||
string subtemp = stringLocalizer["MonthlySubjectTemplate"].Value;
|
|
||||||
|
|
||||||
Func<ApplicationUser,bool> criteria = UserPolicies.Criterias[templateCode];
|
|
||||||
|
|
||||||
logger.LogInformation($"Generating {subtemp}[{className}]");
|
|
||||||
|
|
||||||
var templateInfo = dbContext.MailingTemplate.FirstOrDefault(t => t.Id == templateCode);
|
|
||||||
|
|
||||||
if (templateInfo==null) throw new NoMaillingTemplateException(templateCode);
|
|
||||||
logger.LogInformation($"Using code: {templateCode}, subject: {subtemp} ");
|
|
||||||
logger.LogInformation("And body:\n"+templateInfo.Body);
|
|
||||||
using (StringReader reader = new StringReader(templateInfo.Body))
|
|
||||||
{
|
|
||||||
|
|
||||||
// Generate code for the template
|
|
||||||
var razorResult = razorEngine.GenerateCode(reader, className, DefaultNamespace, DefaultNamespace+".cs");
|
|
||||||
|
|
||||||
logger.LogInformation("Razor exited " + (razorResult.Success ? "Ok" : "Ko") + ".");
|
|
||||||
|
|
||||||
logger.LogInformation(razorResult.GeneratedCode);
|
|
||||||
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(razorResult.GeneratedCode);
|
|
||||||
logger.LogInformation("CSharp parsed");
|
|
||||||
List<MetadataReference> references = new List<MetadataReference>();
|
|
||||||
|
|
||||||
foreach (var type in new Type[] {
|
|
||||||
typeof(object),
|
|
||||||
typeof(Enumerable),
|
|
||||||
typeof(IdentityUser),
|
|
||||||
typeof(ApplicationUser),
|
|
||||||
typeof(Template),
|
|
||||||
typeof(UserOrientedTemplate),
|
|
||||||
typeof(System.Threading.Tasks.TaskExtensions)
|
|
||||||
} )
|
|
||||||
{
|
|
||||||
var location = type.Assembly.Location;
|
|
||||||
if (!string.IsNullOrWhiteSpace(location)) {
|
|
||||||
references.Add(
|
|
||||||
MetadataReference.CreateFromFile(location)
|
|
||||||
);
|
|
||||||
logger.LogInformation($"Assembly for {type.Name} found at {location}");
|
|
||||||
} else logger.LogWarning($"Assembly Not found for {type.Name}");
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.LogInformation("Compilation creation ...");
|
|
||||||
|
|
||||||
var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
|
|
||||||
.WithAllowUnsafe(true).WithOptimizationLevel(OptimizationLevel.Debug)
|
|
||||||
.WithOutputKind(OutputKind.DynamicallyLinkedLibrary).WithPlatform(Platform.AnyCpu)
|
|
||||||
.WithUsings("Yavsc.Templates")
|
|
||||||
;
|
|
||||||
string assemblyName = DefaultNamespace;
|
|
||||||
CSharpCompilation compilation = CSharpCompilation.Create(
|
|
||||||
assemblyName,
|
|
||||||
syntaxTrees: new[] { syntaxTree },
|
|
||||||
references: references,
|
|
||||||
options: compilationOptions
|
|
||||||
);
|
|
||||||
|
|
||||||
using (var ms = new MemoryStream())
|
|
||||||
{
|
|
||||||
logger.LogInformation("Emitting result ...");
|
|
||||||
EmitResult result = compilation.Emit(ms);
|
|
||||||
foreach (Diagnostic diagnostic in result.Diagnostics.Where(diagnostic =>
|
|
||||||
diagnostic.Severity < DiagnosticSeverity.Error && !diagnostic.IsWarningAsError))
|
|
||||||
{
|
|
||||||
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
|
||||||
logger.LogWarning("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
|
||||||
}
|
|
||||||
if (!result.Success)
|
|
||||||
{
|
|
||||||
logger.LogInformation(razorResult.GeneratedCode);
|
|
||||||
IEnumerable<Diagnostic> failures = result.Diagnostics.Where(diagnostic =>
|
|
||||||
diagnostic.IsWarningAsError ||
|
|
||||||
diagnostic.Severity == DiagnosticSeverity.Error);
|
|
||||||
foreach (Diagnostic diagnostic in failures)
|
|
||||||
{
|
|
||||||
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
|
|
||||||
logger.LogCritical("{0}: {1}", diagnostic.Id, diagnostic.Location.GetLineSpan());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.LogInformation(razorResult.GeneratedCode);
|
|
||||||
ms.Seek(0, SeekOrigin.Begin);
|
|
||||||
Assembly assembly = Assembly.Load(ms.ToArray());
|
|
||||||
|
|
||||||
Type type = assembly.GetType(DefaultNamespace + "." + className);
|
|
||||||
var generatedtemplate = (UserOrientedTemplate) Activator.CreateInstance(type);
|
|
||||||
if (generatedtemplate==null) {
|
|
||||||
logger.LogError("No generated template ... exiting.");
|
|
||||||
throw new InvalidOperationException("No generated template");
|
|
||||||
}
|
|
||||||
foreach (var user in dbContext.ApplicationUser.Where(
|
|
||||||
u => criteria(u)
|
|
||||||
))
|
|
||||||
{
|
|
||||||
logger.LogInformation("Generation for " + user.UserName);
|
|
||||||
generatedtemplate.Init();
|
|
||||||
generatedtemplate.User = user;
|
|
||||||
generatedtemplate.ExecuteAsync();
|
|
||||||
logger.LogInformation(generatedtemplate.GeneratedText);
|
|
||||||
EmailSentViewModel mailSentInfo = this.mailSender.SendEmailAsync
|
|
||||||
(user.UserName, user.Email, $"monthly email", generatedtemplate.GeneratedText).Result;
|
|
||||||
if (mailSentInfo==null)
|
|
||||||
logger.LogError("No info on sending");
|
|
||||||
else if (!mailSentInfo.Sent)
|
|
||||||
logger.LogError($"{mailSentInfo.ErrorMessage}");
|
|
||||||
else
|
|
||||||
logger.LogInformation($"mailId:{mailSentInfo?.MessageId} \nto:{user.UserName}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace cli
|
namespace cli
|
||||||
{
|
{
|
||||||
public class YaRazorEngineHost: RazorEngineHost
|
public class YaRazorEngineHost
|
||||||
{
|
{
|
||||||
public YaRazorEngineHost(): base()
|
public YaRazorEngineHost()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Razor;
|
|
||||||
using Microsoft.Data.Entity;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.OptionsModel;
|
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
|
||||||
using Microsoft.Extensions.WebEncoders;
|
|
||||||
using Microsoft.Dnx.Compilation;
|
|
||||||
using Yavsc;
|
using Yavsc;
|
||||||
using Yavsc.Models;
|
|
||||||
using Yavsc.Services;
|
|
||||||
using cli.Services;
|
using cli.Services;
|
||||||
using cli.Settings;
|
using cli.Settings;
|
||||||
using Microsoft.Extensions.CodeGeneration;
|
|
||||||
using Microsoft.Dnx.Runtime.Compilation;
|
|
||||||
using Microsoft.Dnx.Runtime;
|
|
||||||
using Microsoft.Dnx.Compilation.Caching;
|
|
||||||
using Microsoft.Dnx.Host;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.Extensions.CodeGeneration.EntityFramework;
|
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.AspNetCore.Identity.EntityFramework;
|
|
||||||
|
|
||||||
namespace cli
|
namespace cli
|
||||||
{
|
{
|
||||||
@ -43,15 +19,14 @@ namespace cli
|
|||||||
|
|
||||||
public static UserConnectionSettings UserConnectionSettings { get; set; }
|
public static UserConnectionSettings UserConnectionSettings { get; set; }
|
||||||
|
|
||||||
public static IConfiguration Configuration { get; set; }
|
|
||||||
|
|
||||||
public static string HostingFullName { get; private set; }
|
public static string HostingFullName { get; private set; }
|
||||||
|
|
||||||
public static IServiceCollection Services { get; private set; }
|
|
||||||
|
|
||||||
public static string EnvironmentName { get; private set; }
|
public static string EnvironmentName { get; private set; }
|
||||||
public static Microsoft.Extensions.Logging.ILogger Logger { get; private set; }
|
public static Microsoft.Extensions.Logging.ILogger Logger { get; private set; }
|
||||||
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
public Startup()
|
||||||
{
|
{
|
||||||
var devtag = env.IsDevelopment() ? "D" : "";
|
var devtag = env.IsDevelopment() ? "D" : "";
|
||||||
var prodtag = env.IsProduction() ? "P" : "";
|
var prodtag = env.IsProduction() ? "P" : "";
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
# TODO
|
|
||||||
|
|
||||||
## Refabrications
|
|
||||||
|
|
||||||
* Créer Yavsc.Client.Console et Yavsc.Client.Gui (Eto.Platform.Gtk3), en laissant un Yavsc.Client en lieu et place de ce projet
|
|
||||||
|
|
||||||
|
|
24
src/cli/cli.csproj
Normal file
24
src/cli/cli.csproj
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.36" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.3" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Yavsc.Abstract\Yavsc.Abstract.csproj" />
|
||||||
|
<ProjectReference Include="..\Yavsc.Server\Yavsc.Server.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
|
||||||
<id>cli</id>
|
|
||||||
<title>Yavsc - cli</title>
|
|
||||||
<version>$version$</version>
|
|
||||||
<authors>Paul Schneider</authors>
|
|
||||||
<owners>Paul Schneider</owners>
|
|
||||||
<License>https://github.com/pazof/yavsc/blob/vnext/LICENSE</License>
|
|
||||||
<projectUrl>https://github.com/pazof/yavsc/blob/vnext/README.md</projectUrl>
|
|
||||||
<iconUrl>http://pschneider.fr:84/images/yavsc.png</iconUrl>
|
|
||||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
|
||||||
<description>A command line interface to Yavsc server API's</description>
|
|
||||||
<tags></tags>
|
|
||||||
<dependencies>
|
|
||||||
<dependency id="Yavsc.Server" version="$version$"></dependency>
|
|
||||||
</dependencies>
|
|
||||||
</metadata>
|
|
||||||
<files>
|
|
||||||
<file src="bin/$config$/dnx451/cli.dll" target="lib/portable-net45+win8+wp8+wpa81+Xamarin.Mac+MonoAndroid10+MonoTouch10+Xamarin.iOS10" />
|
|
||||||
</files>
|
|
||||||
</package>
|
|
@ -1,96 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
||||||
"title": "CiBuildSettings",
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": [
|
|
||||||
"build"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"env": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"build": {
|
|
||||||
"minLength": 1,
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/Command"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"prepare": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "null"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/Command"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"post_build": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "null"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/Command"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"emails": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"definitions": {
|
|
||||||
"Command": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": [
|
|
||||||
"path"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"path": {
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"args": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"working_dir": {
|
|
||||||
"type": [
|
|
||||||
"null",
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
|
|
||||||
<package id="Microsoft.AspNet.Server.Kestrel" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="EntityFramework.Relational.Design" version="7.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.AspNet.Hosting" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.AspNet.Hosting.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
|
|
||||||
<package id="EntityFramework.Core" version="7.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="EntityFramework.Relational" version="7.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.AspNet.Identity.EntityFramework" version="3.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.AspNet.Mvc" version="6.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.AspNet.Mvc.Razor" version="6.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.AspNet.Mvc.Razor.Host" version="6.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
|
|
||||||
<package id="Microsoft.Extensions.Localization" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Localization.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.0.0" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.CodeAnalysis.Common" version="1.1.0-rc1" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.CodeAnalysis.CSharp" version="1.1.0-rc1" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Dnx.Compilation.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Dnx.Compilation.CSharp.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Dnx.Compilation.CSharp.Common" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Caching.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Caching.Memory" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Configuration" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Configuration.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Configuration.FileExtensions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Configuration.Json" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.DependencyInjection" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Logging" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.MemoryPool" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.OptionsModel" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.PlatformAbstractions" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Extensions.Primitives" version="1.0.0-rc1-final" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Framework.ConfigurationModel" version="1.0.0-beta4" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Framework.ConfigurationModel.Interfaces" version="1.0.0-beta4" targetFramework="net451" />
|
|
||||||
<package id="Microsoft.Framework.ConfigurationModel.Json" version="1.0.0-beta4" targetFramework="net451" />
|
|
||||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
|
|
||||||
<package id="Remotion.Linq" version="2.0.1" targetFramework="net451" />
|
|
||||||
<package id="System.Collections" version="4.0.11" targetFramework="net451" />
|
|
||||||
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net451" />
|
|
||||||
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net451" />
|
|
||||||
<package id="System.Diagnostics.DiagnosticSource" version="4.0.0-beta-23516" targetFramework="net451" />
|
|
||||||
<package id="System.Diagnostics.Tracing" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="System.Globalization" version="4.0.11" targetFramework="net451" />
|
|
||||||
<package id="System.IO" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="System.Linq" version="4.1.0" targetFramework="net451" />
|
|
||||||
<package id="System.Reflection" version="4.1.0" targetFramework="net451" />
|
|
||||||
<package id="System.Reflection.Extensions" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="System.Reflection.Metadata" version="1.1.0" targetFramework="net451" />
|
|
||||||
<package id="System.Reflection.Primitives" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net451" />
|
|
||||||
<package id="System.Runtime" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net451" />
|
|
||||||
<package id="System.Runtime.InteropServices" version="4.1.0" targetFramework="net451" />
|
|
||||||
<package id="System.Text.Encoding" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="System.Text.Encoding.Extensions" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="System.Threading" version="4.0.0" targetFramework="net451" />
|
|
||||||
<package id="Yavsc.Abstract" version="1.0.5-rc9" targetFramework="net451" />
|
|
||||||
<package id="Yavsc.Server" version="1.0.5-rc9" targetFramework="net451" />
|
|
||||||
</packages>
|
|
@ -1,96 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
||||||
"title": "CiBuildSettings",
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": [
|
|
||||||
"build"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"env": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"build": {
|
|
||||||
"minLength": 1,
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/Command"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"prepare": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "null"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/Command"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"post_build": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"type": "null"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/Command"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"emails": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"definitions": {
|
|
||||||
"Command": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": [
|
|
||||||
"path"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"path": {
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
},
|
|
||||||
"args": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"type": [
|
|
||||||
"array",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"working_dir": {
|
|
||||||
"type": [
|
|
||||||
"null",
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "1.0.6-*",
|
|
||||||
"commands": {
|
|
||||||
"run": "run"
|
|
||||||
},
|
|
||||||
"resource": "Resources/**/*.resx",
|
|
||||||
"buildOptions": {
|
|
||||||
"debugType": "full",
|
|
||||||
"emitEntryPoint": true,
|
|
||||||
"compile": {
|
|
||||||
"include": "*.cs",
|
|
||||||
"exclude": [
|
|
||||||
"contrib"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"embed": [
|
|
||||||
"Resources/**/*.resx"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"EntityFramework7.Npgsql": "3.1.0-rc1-3",
|
|
||||||
"MailKit": "1.12.0",
|
|
||||||
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.AspNet.Identity": "3.0.0-rc1-*",
|
|
||||||
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
|
||||||
"Microsoft.AspNet.Mvc": "6.0.0-rc1-*",
|
|
||||||
"Microsoft.AspNet.SignalR.Client": "2.2.1",
|
|
||||||
"Microsoft.CodeAnalysis": "1.1.0-rc1-20151109-01",
|
|
||||||
"Microsoft.Extensions.CodeGeneration": "1.0.0-beta5",
|
|
||||||
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Configuration.Abstractions": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.CommandLineUtils": "1.1.1",
|
|
||||||
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Globalization.CultureInfoCache": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Localization": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Localization.Abstractions": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.Options": "0.0.1-alpha",
|
|
||||||
"Microsoft.Extensions.WebEncoders": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Extensions.WebEncoders.Core": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
|
|
||||||
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
|
|
||||||
"Newtonsoft.Json": "7.0.1",
|
|
||||||
"NJsonSchema.CodeGeneration.CSharp": "10.0.27",
|
|
||||||
"Yavsc": {
|
|
||||||
"target": "project"
|
|
||||||
},
|
|
||||||
"Microsoft.Dnx.Host": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Dnx.Runtime": "1.0.0-rc1-final",
|
|
||||||
"Microsoft.Dnx.DesignTimeHost": "1.0.0-rc1-final",
|
|
||||||
"YamlDotNet": "8.0.0"
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"dnx451": {
|
|
||||||
"System.Net": {},
|
|
||||||
"System.Xml": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"postrestore": [
|
|
||||||
"grep -v '\\.\\.dll' project.lock.json > new.project.lock.json",
|
|
||||||
"mv new.project.lock.json project.lock.json"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
||||||
# yarn lockfile v1
|
|
||||||
|
|
||||||
|
|
||||||
entities@^1.1.1:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56"
|
|
||||||
integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==
|
|
@ -1,25 +1,18 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.Dnx.Compilation.CSharp;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
|
||||||
using Xunit.Abstractions;
|
|
||||||
|
|
||||||
namespace yavscTests
|
namespace yavscTests
|
||||||
{
|
{
|
||||||
public class BaseTestContext {
|
public class BaseTestContext {
|
||||||
|
|
||||||
protected IApplicationEnvironment applicationEnvironment = null;
|
|
||||||
protected IServiceProvider serviceProvider = null;
|
protected IServiceProvider serviceProvider = null;
|
||||||
protected IConfigurationRoot configurationRoot;
|
protected IConfigurationRoot configurationRoot;
|
||||||
protected BeforeCompileContext beforeCompileContext;
|
|
||||||
protected IServiceProvider provider;
|
protected IServiceProvider provider;
|
||||||
protected IConfigurationRoot configuration;
|
protected IConfigurationRoot configuration;
|
||||||
protected readonly ITestOutputHelper _output;
|
|
||||||
protected ServerSideFixture _serverFixture;
|
protected ServerSideFixture _serverFixture;
|
||||||
|
|
||||||
public BaseTestContext(ITestOutputHelper output, ServerSideFixture serverFixture)
|
public BaseTestContext( ServerSideFixture serverFixture)
|
||||||
{
|
{
|
||||||
this._output = output;
|
|
||||||
this._serverFixture = serverFixture;
|
this._serverFixture = serverFixture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
CONFIGURATION=Debug
|
|
||||||
BINTARGET=bin/$(CONFIGURATION)/dnx451/test.dll
|
|
||||||
SOURCE_DIR=../..
|
|
||||||
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make
|
|
||||||
MSBUILD=msbuild
|
|
||||||
YAVSCSRC=../../src
|
|
||||||
|
|
||||||
all: test
|
|
||||||
|
|
||||||
include $(MAKEFILE_DIR)/dnx.mk
|
|
||||||
|
|
||||||
$(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll:
|
|
||||||
make -C $(YAVSCSRC)/Yavsc
|
|
||||||
|
|
||||||
$(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll:
|
|
||||||
make -C $(YAVSCSRC)/Yavsc.Abstract
|
|
||||||
|
|
||||||
$(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll:
|
|
||||||
make -C $(YAVSCSRC)/Yavsc.Server
|
|
||||||
|
|
||||||
$(BINTARGET): project.lock.json $(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll $(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll $(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll
|
|
||||||
dnu build --configuration $(CONFIGURATION)
|
|
||||||
|
|
||||||
non-regression: $(BINTARGET)
|
|
||||||
ASPNET_ENV=Development dnx test -maxthreads 1 -trait regression=non
|
|
||||||
|
|
||||||
all-tests: $(BINTARGET)
|
|
||||||
ASPNET_ENV=Testing dnx test -maxthreads 1
|
|
||||||
|
|
||||||
regression: $(BINTARGET)
|
|
||||||
ASPNET_ENV=Testing dnx test -maxthreads 1 -trait regression=oui
|
|
||||||
|
|
||||||
test: all-tests
|
|
||||||
|
|
||||||
testdev: $(BINTARGET)
|
|
||||||
ASPNET_ENV=Development dnx test -maxthreads 1 -trait dev=wip
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf bin obj testingrepo
|
|
||||||
|
|
||||||
.PHONY: test
|
|
@ -64,7 +64,7 @@ namespace yavscTests
|
|||||||
public static string ApiKey { get; private set; }
|
public static string ApiKey { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
public Startup(IHostingEnvironment env)
|
||||||
{
|
{
|
||||||
var devtag = env.IsDevelopment() ? "D" : "";
|
var devtag = env.IsDevelopment() ? "D" : "";
|
||||||
var prodtag = env.IsProduction() ? "P" : "";
|
var prodtag = env.IsProduction() ? "P" : "";
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace Yavsc.Server
|
|
||||||
{
|
|
||||||
public class CliServerFactory : IServerFactory
|
|
||||||
{
|
|
||||||
public IFeatureCollection Initialize(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
FeatureCollection featureCollection = new FeatureCollection();
|
|
||||||
return featureCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDisposable Start(IFeatureCollection serverFeatures, Func<IFeatureCollection, Task> application)
|
|
||||||
{
|
|
||||||
var task = application(serverFeatures);
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,10 +8,12 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.3.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.3" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="xunit" Version="2.9.3" />
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Reference in New Issue
Block a user