servicing
This commit is contained in:
@ -68,10 +68,6 @@ namespace cli.Services
|
||||
razorEngine = new RazorTemplateEngine(host);
|
||||
}
|
||||
|
||||
public string GenerateTemplateObject(string baseclassName = DefaultBaseClassName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SendMonthlyEmail(long templateCode, string baseclassName = DefaultBaseClassName)
|
||||
{
|
||||
@ -162,7 +158,11 @@ namespace cli.Services
|
||||
Assembly assembly = Assembly.Load(ms.ToArray());
|
||||
|
||||
Type type = assembly.GetType(DefaultNamespace + "." + className);
|
||||
var generatedtemplate = (UserOrientedTemplate)Activator.CreateInstance(type);
|
||||
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 => u.AllowMonthlyEmail
|
||||
))
|
||||
@ -172,6 +172,13 @@ namespace cli.Services
|
||||
generatedtemplate.User = user;
|
||||
generatedtemplate.ExecuteAsync();
|
||||
logger.LogInformation(generatedtemplate.GeneratedText);
|
||||
var mailSentInfo = this.mailSender.SendEmailAsync
|
||||
(user.UserName, user.Email, $"monthly email", generatedtemplate.GeneratedText).Result;
|
||||
if (!mailSentInfo.Sent)
|
||||
logger.LogError($"{mailSentInfo.ErrorMessage}");
|
||||
else
|
||||
logger.LogInformation($"mailId:{mailSentInfo.MessageId} \nto:{user.UserName}");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,34 +3,21 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
// using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Builder;
|
||||
// using Microsoft.AspNet.Diagnostics;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Microsoft.AspNet.Localization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Microsoft.AspNet.Razor;
|
||||
using Microsoft.Extensions.DependencyInjection.Abstractions;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using cli.Services;
|
||||
using Yavsc;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Yavsc.Services;
|
||||
using Yavsc.Templates;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNet.Authentication;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
|
||||
namespace cli
|
||||
{
|
||||
public class Startup
|
||||
public class Startup
|
||||
{
|
||||
public string ConnectionString
|
||||
{
|
||||
@ -86,6 +73,15 @@ namespace cli
|
||||
.AddDbContext<ApplicationDbContext>(
|
||||
db => db.UseNpgsql(ConnectionString)
|
||||
);
|
||||
services.Configure<SharedAuthenticationOptions>(options =>
|
||||
{
|
||||
options.SignInScheme = "Bearer";
|
||||
});
|
||||
|
||||
services.AddTransient<Microsoft.Extensions.WebEncoders.UrlEncoder, UrlEncoder>();
|
||||
|
||||
services.AddAuthentication();
|
||||
|
||||
}
|
||||
|
||||
public void Configure (IApplicationBuilder app, IHostingEnvironment env,
|
||||
@ -95,6 +91,9 @@ namespace cli
|
||||
loggerFactory.AddDebug();
|
||||
logger = loggerFactory.CreateLogger<Startup>();
|
||||
logger.LogInformation(env.EnvironmentName);
|
||||
var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");
|
||||
var clientId = authConf.GetSection("ClientId").Value;
|
||||
var clientSecret = authConf.GetSection("ClientSecret").Value;
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,15 +44,15 @@
|
||||
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
|
||||
"Newtonsoft.Json": "9.0.1",
|
||||
"Yavsc": {
|
||||
"version": "1.0.5-rc21-beta5",
|
||||
"version": "1.0.5-rc21-beta7",
|
||||
"target": "package"
|
||||
},
|
||||
"Yavsc.Abstract": {
|
||||
"version": "1.0.5-rc21-beta5",
|
||||
"version": "1.0.5-rc21-beta7",
|
||||
"target": "package"
|
||||
},
|
||||
"Yavsc.Server": {
|
||||
"version": "1.0.5-rc21-beta5",
|
||||
"version": "1.0.5-rc21-beta7",
|
||||
"target": "package"
|
||||
},
|
||||
"Yavsc.Lib.Portable": "1.0.2"
|
||||
|
Reference in New Issue
Block a user