Aggiunta preliminare progetto DATA
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33213.308
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StockMan.CORE", "StockMan.CORE\StockMan.CORE.csproj", "{3D23F328-E6B6-4EDB-B2DE-00E39E953757}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockMan.Data", "StockMan.Data\StockMan.Data.csproj", "{5C4C9C5C-9478-424A-B68C-C3C04C5E2165}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3D23F328-E6B6-4EDB-B2DE-00E39E953757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3D23F328-E6B6-4EDB-B2DE-00E39E953757}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3D23F328-E6B6-4EDB-B2DE-00E39E953757}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3D23F328-E6B6-4EDB-B2DE-00E39E953757}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5C4C9C5C-9478-424A-B68C-C3C04C5E2165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5C4C9C5C-9478-424A-B68C-C3C04C5E2165}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5C4C9C5C-9478-424A-B68C-C3C04C5E2165}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5C4C9C5C-9478-424A-B68C-C3C04C5E2165}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3FB1DC7D-579E-4165-9A0A-8E6D8C12FC75}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,68 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit.Text;
|
||||
using MimeKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Smtp;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
|
||||
namespace StockMan.Data
|
||||
{
|
||||
/// Implementazione interfaccia email con pacchetto MailKIT
|
||||
///
|
||||
/// https://www.ryadel.com/en/asp-net-core-send-email-messages-smtp-mailkit/
|
||||
/// </summary>
|
||||
public class MailKitEmailSender : IEmailSender
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MailKitEmailSender(IOptions<MailKitEmailSenderOptions> options)
|
||||
{
|
||||
this.Options = options.Value;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public MailKitEmailSenderOptions Options { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Task Execute(string to, string subject, string message)
|
||||
{
|
||||
// create message
|
||||
var email = new MimeMessage();
|
||||
email.Sender = MailboxAddress.Parse(Options.Sender_EMail);
|
||||
if (!string.IsNullOrEmpty(Options.Sender_Name))
|
||||
email.Sender.Name = Options.Sender_Name;
|
||||
email.From.Add(email.Sender);
|
||||
email.To.Add(MailboxAddress.Parse(to));
|
||||
email.Subject = subject;
|
||||
email.Body = new TextPart(TextFormat.Html) { Text = message };
|
||||
|
||||
// send email
|
||||
using (var smtp = new SmtpClient())
|
||||
{
|
||||
smtp.Connect(Options.Host_Address, Options.Host_Port, Options.Host_SecureSocketOptions);
|
||||
smtp.Authenticate(Options.Host_Username, Options.Host_Password);
|
||||
smtp.Send(email);
|
||||
smtp.Disconnect(true);
|
||||
}
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public Task SendEmailAsync(string email, string subject, string message)
|
||||
{
|
||||
return Execute(email, subject, message);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using MailKit.Security;
|
||||
|
||||
namespace StockMan.Data
|
||||
{
|
||||
public class MailKitEmailSenderOptions
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MailKitEmailSenderOptions()
|
||||
{
|
||||
Host_SecureSocketOptions = SecureSocketOptions.Auto;
|
||||
Host_Address = "127.0.0.1";
|
||||
Host_Password = "";
|
||||
Host_Username = "";
|
||||
Sender_EMail = "info@steamware.net";
|
||||
Sender_Name = "Info Steamware";
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string Host_Address { get; set; }
|
||||
|
||||
public string Host_Password { get; set; }
|
||||
public int Host_Port { get; set; }
|
||||
|
||||
public SecureSocketOptions Host_SecureSocketOptions { get; set; }
|
||||
public string Host_Username { get; set; }
|
||||
public string Sender_EMail { get; set; }
|
||||
|
||||
public string Sender_Name { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace StockMan.Data
|
||||
{
|
||||
public class QHelper
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Blazor: get query parm from the URL
|
||||
/// </summary>
|
||||
/// <param name="parmName"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetQueryParm(string fullUri, string parmName)
|
||||
{
|
||||
var uriBuilder = new UriBuilder(fullUri);
|
||||
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
return q[parmName] ?? "";
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="DbModels\" />
|
||||
<Folder Include="DTO\" />
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
|
||||
<PackageReference Include="MailKit" Version="3.4.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.13">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.13">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog" Version="5.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user