Compare commits
2 Commits
a7b6812a9f
...
85c1a88c19
Author | SHA1 | Date | |
---|---|---|---|
|
85c1a88c19 | ||
|
d54625220a |
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||||
|
<PackageReference Include="MailKit" Version="4.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -8,8 +8,8 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage;
|
using BankBusinessLogic.OfficePackage;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
|
||||||
namespace BankBusinessLogic.BusinessLogics
|
namespace BankBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
|
66
Bank/BankBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
66
Bank/BankBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public abstract class AbstractMailWorker
|
||||||
|
{
|
||||||
|
protected string _mailLogin = string.Empty;
|
||||||
|
|
||||||
|
protected string _mailPassword = string.Empty;
|
||||||
|
|
||||||
|
protected string _smtpClientHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _smtpClientPort;
|
||||||
|
|
||||||
|
protected string _popHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _popPort;
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public AbstractMailWorker(ILogger<AbstractMailWorker> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MailConfig(MailConfigBindingModel config)
|
||||||
|
{
|
||||||
|
_mailLogin = config.MailLogin;
|
||||||
|
_mailPassword = config.MailPassword;
|
||||||
|
_smtpClientHost = config.SmtpClientHost;
|
||||||
|
_smtpClientPort = config.SmtpClientPort;
|
||||||
|
_popHost = config.PopHost;
|
||||||
|
_popPort = config.PopPort;
|
||||||
|
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
||||||
|
await SendMailAsync(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
||||||
|
}
|
||||||
|
}
|
47
Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
47
Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using BankContracts.BindingModels;
|
||||||
|
using BankContracts.BusinessLogicsContracts;
|
||||||
|
using MailKit.Net.Pop3;
|
||||||
|
using MailKit.Security;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BankBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public class MailKitWorker : AbstractMailWorker
|
||||||
|
{
|
||||||
|
public MailKitWorker(ILogger<MailKitWorker> logger) : base(logger) { }
|
||||||
|
|
||||||
|
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
using var objMailMessage = new MailMessage();
|
||||||
|
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objMailMessage.From = new MailAddress(_mailLogin);
|
||||||
|
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||||
|
objMailMessage.Subject = info.Subject;
|
||||||
|
objMailMessage.Body = info.Text;
|
||||||
|
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||||
|
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||||
|
objMailMessage.Attachments.Add(new Attachment(info.Attachment, info.FileName, "application/pdf"));
|
||||||
|
|
||||||
|
objSmtpClient.UseDefaultCredentials = false;
|
||||||
|
objSmtpClient.EnableSsl = true;
|
||||||
|
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||||
|
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||||
|
|
||||||
|
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage
|
namespace BankBusinessLogic.OfficePackage
|
||||||
{
|
{
|
||||||
public abstract class AbstractSaveToExcel
|
public abstract class AbstractSaveToExcel
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage
|
namespace BankBusinessLogic.OfficePackage
|
||||||
{
|
{
|
||||||
public abstract class AbstractSaveToPdf
|
public abstract class AbstractSaveToPdf
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage
|
namespace BankBusinessLogic.OfficePackage
|
||||||
{
|
{
|
||||||
public abstract class AbstractSaveToWord
|
public abstract class AbstractSaveToWord
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperEnums
|
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||||
{
|
{
|
||||||
public enum ExcelStyleInfoType
|
public enum ExcelStyleInfoType
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperEnums
|
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||||
{
|
{
|
||||||
public enum PdfParagraphAlignmentType
|
public enum PdfParagraphAlignmentType
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperEnums
|
namespace BankBusinessLogic.OfficePackage.HelperEnums
|
||||||
{
|
{
|
||||||
public enum WordJustificationType
|
public enum WordJustificationType
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelCellParameters
|
public class ExcelCellParameters
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelInfo
|
public class ExcelInfo
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelMergeParameters
|
public class ExcelMergeParameters
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfInfo
|
public class PdfInfo
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfParagraph
|
public class PdfParagraph
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfRowParameters
|
public class PdfRowParameters
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordInfo
|
public class WordInfo
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordParagraph
|
public class WordParagraph
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
namespace BankBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordTextProperties
|
public class WordTextProperties
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
@ -11,7 +11,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
|
namespace BankBusinessLogic.OfficePackage.Implements
|
||||||
{
|
{
|
||||||
public class SaveToExcel : AbstractSaveToExcel
|
public class SaveToExcel : AbstractSaveToExcel
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||||
using MigraDoc.DocumentObjectModel;
|
using MigraDoc.DocumentObjectModel;
|
||||||
using MigraDoc.DocumentObjectModel.Tables;
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
using MigraDoc.Rendering;
|
using MigraDoc.Rendering;
|
||||||
@ -9,7 +9,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
|
namespace BankBusinessLogic.OfficePackage.Implements
|
||||||
{
|
{
|
||||||
public class SaveToPdf : AbstractSaveToPdf
|
public class SaveToPdf : AbstractSaveToPdf
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
using BankBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
using BankBusinessLogic.OfficePackage.HelperModels;
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
using DocumentFormat.OpenXml;
|
using DocumentFormat.OpenXml;
|
||||||
@ -9,7 +9,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
|
namespace BankBusinessLogic.OfficePackage.Implements
|
||||||
{
|
{
|
||||||
public class SaveToWord : AbstractSaveToWord
|
public class SaveToWord : AbstractSaveToWord
|
||||||
{
|
{
|
||||||
|
23
Bank/BankContracts/BindingModels/MailConfigBindingModel.cs
Normal file
23
Bank/BankContracts/BindingModels/MailConfigBindingModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MailConfigBindingModel
|
||||||
|
{
|
||||||
|
public string MailLogin { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string MailPassword { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string SmtpClientHost { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int SmtpClientPort { get; set; }
|
||||||
|
|
||||||
|
public string PopHost { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int PopPort { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
Bank/BankContracts/BindingModels/MailSendInfoBindingModel.cs
Normal file
18
Bank/BankContracts/BindingModels/MailSendInfoBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BankContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
public string MailAddress { get; set; } = string.Empty;
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
public MemoryStream Attachment { get; set; } = new MemoryStream();
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
using BankContracts.BindingModels;
|
using BankBusinessLogic.MailWorker;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
using BankContracts.BusinessLogicsContracts;
|
using BankContracts.BusinessLogicsContracts;
|
||||||
using BankContracts.SearchModels;
|
using BankContracts.SearchModels;
|
||||||
using BankContracts.ViewModels;
|
using BankContracts.ViewModels;
|
||||||
using BankDatabaseImplement.Models;
|
using BankDatabaseImplement.Models;
|
||||||
using BankDataModels.Models;
|
using BankDataModels.Models;
|
||||||
|
using MailKit;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using OperatorApp.Models;
|
using OperatorApp.Models;
|
||||||
@ -19,8 +21,9 @@ namespace OperatorApp.Controllers
|
|||||||
private readonly ITransferLogic _transferLogic;
|
private readonly ITransferLogic _transferLogic;
|
||||||
private readonly IOperatorLogic _operatorLogic;
|
private readonly IOperatorLogic _operatorLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic)
|
public HomeController(ILogger<HomeController> logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic, AbstractMailWorker mailWorker)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_dealLogic = dealLogic;
|
_dealLogic = dealLogic;
|
||||||
@ -28,6 +31,7 @@ namespace OperatorApp.Controllers
|
|||||||
_transferLogic = transferLogic;
|
_transferLogic = transferLogic;
|
||||||
_operatorLogic = operatorLogic;
|
_operatorLogic = operatorLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
|
_mailWorker = mailWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -229,7 +233,8 @@ namespace OperatorApp.Controllers
|
|||||||
{
|
{
|
||||||
if (APIClient.Operator == null)
|
if (APIClient.Operator == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
Response.WriteAsync($"<script language=\"javascript\">alert('You need to login!');</script>");
|
||||||
|
Response.Redirect("/Home/Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Payments = _paymentLogic.ReadList(new PaymentSearchModel { OperatorId = APIClient.Operator.Id });
|
ViewBag.Payments = _paymentLogic.ReadList(new PaymentSearchModel { OperatorId = APIClient.Operator.Id });
|
||||||
return View();
|
return View();
|
||||||
@ -269,10 +274,26 @@ namespace OperatorApp.Controllers
|
|||||||
return View(new ReportBindingModel());
|
return View(new ReportBindingModel());
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult TransfersReport(DateTime dateFrom, DateTime dateTo)
|
public void TransfersReport(DateTime dateFrom, DateTime dateTo)
|
||||||
{
|
{
|
||||||
MemoryStream report = _reportLogic.SaveTransferPurchaseToPDF(new ReportBindingModel { DateFrom = dateFrom, DateTo = dateTo });
|
MemoryStream report = _reportLogic.SaveTransferPurchaseToPDF(new ReportBindingModel { DateFrom = dateFrom, DateTo = dateTo });
|
||||||
return File(report, "application/pdf", "test.pdf");
|
try
|
||||||
|
{
|
||||||
|
_mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
Subject = "Отчёт о закупках",
|
||||||
|
Text = "От банка \"Вы банкрот\"",
|
||||||
|
MailAddress = "",
|
||||||
|
FileName = "test.pdf",
|
||||||
|
Attachment = report
|
||||||
|
});
|
||||||
|
Response.Redirect("/");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Response.WriteAsync($"<script language=\"javascript\">alert('{ex.Message}');</script>");
|
||||||
|
Response.Redirect("/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,9 +2,11 @@ using BankBusinessLogic.BusinessLogics;
|
|||||||
using BankContracts.BusinessLogicsContracts;
|
using BankContracts.BusinessLogicsContracts;
|
||||||
using BankContracts.StoragesContracts;
|
using BankContracts.StoragesContracts;
|
||||||
using BankDatabaseImplement.Implements;
|
using BankDatabaseImplement.Implements;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage;
|
using BankBusinessLogic.OfficePackage;
|
||||||
using ConfectioneryBusinessLogic.OfficePackage.Implements;
|
using BankBusinessLogic.OfficePackage.Implements;
|
||||||
using OperatorApp;
|
using OperatorApp;
|
||||||
|
using BankBusinessLogic.MailWorker;
|
||||||
|
using BankContracts.BindingModels;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -22,6 +24,7 @@ builder.Services.AddTransient<ICurrencyStorage, CurrencyStorage>();
|
|||||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IDealLogic, DealLogic>();
|
builder.Services.AddTransient<IDealLogic, DealLogic>();
|
||||||
builder.Services.AddTransient<IPaymentLogic, PaymentLogic>();
|
builder.Services.AddTransient<IPaymentLogic, PaymentLogic>();
|
||||||
@ -31,6 +34,25 @@ builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||||
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
|
{
|
||||||
|
MailLogin = builder.Configuration["MailLogin"] ?? string.Empty,
|
||||||
|
MailPassword = builder.Configuration["MailPassword"] ?? string.Empty,
|
||||||
|
SmtpClientHost = builder.Configuration["SmtpClientHost"] ?? string.Empty,
|
||||||
|
SmtpClientPort = Convert.ToInt32(builder.Configuration["SmtpClientPort"]),
|
||||||
|
PopHost = builder.Configuration["PopHost"] ?? string.Empty,
|
||||||
|
PopPort = Convert.ToInt32(builder.Configuration["PopPort"])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var logger = app.Services.GetService<ILogger>();
|
||||||
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
|
}
|
||||||
|
|
||||||
APIClient.Connect(builder.Configuration);
|
APIClient.Connect(builder.Configuration);
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["Title"] = "CreatePayment";
|
ViewData["Title"] = "CreateTransfer";
|
||||||
}
|
}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Создание зачисления</h2>
|
<h2 class="display-4">Создание зачисления</h2>
|
||||||
|
@ -6,5 +6,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"IPAddress": "http://localhost:5225"
|
"IPAddress": "http://localhost:5225",
|
||||||
|
"SmtpClientHost": "smtp.gmail.com",
|
||||||
|
"SmtpClientPort": "587",
|
||||||
|
"PopHost": "pop.gmail.com",
|
||||||
|
"PopPort": "995",
|
||||||
|
"MailLogin": "rpplab7@gmail.com",
|
||||||
|
"MailPassword": "edjc dmsf pqne gxwy"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user