Merge branch 'vnext' of github.com:pazof/yavsc into vnext
commit
df9ba5bbc5
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MailKit.Net.Smtp;
|
||||||
|
using MimeKit;
|
||||||
|
using MailKit.Security;
|
||||||
|
using System;
|
||||||
|
using Yavsc.Models.Messaging;
|
||||||
|
using Yavsc.Models;
|
||||||
|
using Yavsc.Models.Google.Messaging;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Yavsc.Models.Haircut;
|
||||||
|
using Yavsc.Interfaces.Workflow;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Yavsc.Server.Helpers;
|
||||||
|
using Yavsc.Abstract.Manage;
|
||||||
|
using Microsoft.AspNet.Identity;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.OptionsModel;
|
||||||
|
|
||||||
|
namespace Yavsc.Services
|
||||||
|
{
|
||||||
|
// This class is used by the application to send Email and SMS
|
||||||
|
// when you turn on two-factor authentication in ASP.NET Identity.
|
||||||
|
// For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.OptionsModel;
|
||||||
|
using Microsoft.AspNet.Builder;
|
||||||
|
using Microsoft.AspNet.Hosting;
|
||||||
|
using Microsoft.AspNet.Razor;
|
||||||
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
|
using Yavsc;
|
||||||
|
using Yavsc.Models;
|
||||||
|
using Yavsc.Services;
|
||||||
|
using Microsoft.Data.Entity;
|
||||||
|
using Microsoft.AspNet.Authentication;
|
||||||
|
using Microsoft.Extensions.WebEncoders;
|
||||||
|
using Yavsc.Lib;
|
||||||
|
|
||||||
|
namespace test
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public string ConnectionString
|
||||||
|
{
|
||||||
|
get ; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SiteSettings SiteSetup { get; private set; }
|
||||||
|
public static SmtpSettings SmtpSettup { get; private set; }
|
||||||
|
public static IConfiguration Configuration { get; set; }
|
||||||
|
|
||||||
|
public static string HostingFullName { get; private set; }
|
||||||
|
|
||||||
|
ILogger logger;
|
||||||
|
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
||||||
|
{
|
||||||
|
var devtag = env.IsDevelopment()?"D":"";
|
||||||
|
var prodtag = env.IsProduction()?"P":"";
|
||||||
|
var stagetag = env.IsStaging()?"S":"";
|
||||||
|
|
||||||
|
HostingFullName = $"{appEnv.RuntimeFramework.FullName} [{env.EnvironmentName}:{prodtag}{devtag}{stagetag}]";
|
||||||
|
// Set up configuration sources.
|
||||||
|
|
||||||
|
var builder = new ConfigurationBuilder()
|
||||||
|
.AddEnvironmentVariables()
|
||||||
|
.AddJsonFile("appsettings.json")
|
||||||
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
|
||||||
|
Configuration = builder.Build();
|
||||||
|
ConnectionString = Configuration["Data:DefaultConnection:ConnectionString"];
|
||||||
|
AppDomain.CurrentDomain.SetData("YAVSC_CONNECTION", ConnectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConfigureServices (IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddOptions();
|
||||||
|
var siteSettingsconf = Configuration.GetSection("Site");
|
||||||
|
services.Configure<SiteSettings>(siteSettingsconf);
|
||||||
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
||||||
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
||||||
|
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
|
||||||
|
services.AddTransient(typeof(IEmailSender), typeof(MailSender));
|
||||||
|
services.AddEntityFramework().AddNpgsql().AddDbContext<ApplicationDbContext>();
|
||||||
|
services.AddTransient((s) => new RazorTemplateEngine(s.GetService<RazorEngineHost>()));
|
||||||
|
services.AddLogging();
|
||||||
|
services.AddTransient<EMailer>();
|
||||||
|
services.AddLocalization(options =>
|
||||||
|
{
|
||||||
|
options.ResourcesPath = "Resources";
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddEntityFramework()
|
||||||
|
.AddNpgsql()
|
||||||
|
.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,
|
||||||
|
IOptions<SiteSettings> siteSettings, ILoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue