2022-05-04 15:02:12 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
2022-09-08 12:05:56 +05:00
|
|
|
|
using AsbCloudInfrastructure.Services.Email;
|
2022-05-04 15:02:12 +05:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure
|
|
|
|
|
{
|
2023-04-18 16:22:53 +05:00
|
|
|
|
|
2023-04-13 15:34:16 +05:00
|
|
|
|
class DrillingMailBodyFactory : BaseFactory
|
2022-09-08 12:05:56 +05:00
|
|
|
|
{
|
2022-05-18 11:07:39 +05:00
|
|
|
|
private readonly string platformName;
|
2022-05-04 15:02:12 +05:00
|
|
|
|
private readonly string platformUrl;
|
|
|
|
|
|
2022-09-08 12:05:56 +05:00
|
|
|
|
public DrillingMailBodyFactory(IConfiguration configuration)
|
|
|
|
|
: base(configuration)
|
2022-05-04 15:02:12 +05:00
|
|
|
|
{
|
|
|
|
|
platformName = configuration.GetValue("email:platformName", "Цифровое бурение");
|
2022-05-20 09:01:39 +05:00
|
|
|
|
platformUrl = configuration.GetValue("email:platformUrl", "https://cloud.digitaldrilling.ru/");
|
2022-05-04 15:02:12 +05:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-08 12:05:56 +05:00
|
|
|
|
public override string MakeSubject(WellDto well, string action)
|
2022-05-04 15:02:12 +05:00
|
|
|
|
{
|
|
|
|
|
var subj = $"{well.Deposit}, {well.Cluster}, {well.Caption}. Программа бурения. {action}";
|
|
|
|
|
return subj;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
public string MakeMailBodyForNewPublisher(WellDto well, string publisherName, string documentCategory)
|
2022-05-04 15:02:12 +05:00
|
|
|
|
{
|
|
|
|
|
var drillingProgramHref = MakeDrillingProgramHref(well);
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
|
2022-05-04 15:02:12 +05:00
|
|
|
|
$"На портале {platformName} началось создание программы бурения скважины {drillingProgramHref}," +
|
|
|
|
|
$" куст {well.Cluster}, месторождение {well.Deposit}." +
|
|
|
|
|
$"<br><br>От вас ожидается загрузка на портал документа «{documentCategory}» в формате excel (*.xlsx)." +
|
|
|
|
|
MakeSignatue() +
|
|
|
|
|
$"</body></html>";
|
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
public string MakeMailBodyForApproverNewFile(WellDto well, string approverName, int idFile, string fileName)
|
2022-05-04 15:02:12 +05:00
|
|
|
|
{
|
|
|
|
|
var drillingProgramHref = MakeDrillingProgramHref(well);
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
var body = $"<html><body><h2>Здравствуйте, {approverName}.</h2>" +
|
|
|
|
|
$"На портал {platformName} загружен документ {fileName}" +
|
2022-05-04 15:02:12 +05:00
|
|
|
|
$" для согласования при создании программы бурения скважины {drillingProgramHref}, куст ({well.Cluster})" +
|
|
|
|
|
$", месторождение ({well.Deposit}).<br>" +
|
|
|
|
|
MakeSignatue() +
|
|
|
|
|
$"</body></html>";
|
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
public string MakeMailBodyForPublisherOnReject(WellDto well, string publisherName, int idFile, string fileName, FileMarkDto fileMark)
|
2022-05-04 15:02:12 +05:00
|
|
|
|
{
|
|
|
|
|
var drillingProgramHref = MakeDrillingProgramHref(well);
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
|
|
|
|
|
$"На портале {platformName} отклонен загруженный вами документ {fileName} " +
|
2022-05-04 15:02:12 +05:00
|
|
|
|
$" по программе бурения скважины {drillingProgramHref}," +
|
|
|
|
|
$" куст {well.Cluster}, месторождение {well.Deposit}." +
|
2022-05-18 11:07:39 +05:00
|
|
|
|
$" Комментарий согласующего ({fileMark.User?.Name} {fileMark.User?.Surname}):<br>{fileMark.Comment}" +
|
2022-05-04 15:02:12 +05:00
|
|
|
|
MakeSignatue() +
|
|
|
|
|
$"</body></html>";
|
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
public string MakeMailBodyForPublisherOnFullAccept(WellDto well, string publisherName, int idFile, string fileName)
|
2022-05-04 15:02:12 +05:00
|
|
|
|
{
|
|
|
|
|
var drillingProgramHref = MakeDrillingProgramHref(well);
|
|
|
|
|
|
2022-05-18 11:07:39 +05:00
|
|
|
|
var body = $"<html><body><h2>Здравствуйте, {publisherName}.</h2>" +
|
|
|
|
|
$"На портале {platformName} полностью согласован документ {fileName} " +
|
2022-05-04 15:02:12 +05:00
|
|
|
|
$" по программе бурения скважины {drillingProgramHref}," +
|
|
|
|
|
$" куст {well.Cluster}, месторождение {well.Deposit}." +
|
|
|
|
|
MakeSignatue() +
|
|
|
|
|
$"</body></html>";
|
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string MakeDrillingProgramHref(WellDto well)
|
|
|
|
|
{
|
2022-05-18 11:07:39 +05:00
|
|
|
|
var drillingProgramUrl = $"{platformUrl}/well/{well.Id}/drillingProgram";
|
2022-05-04 15:02:12 +05:00
|
|
|
|
var drillingProgramHref = MakeHref(drillingProgramUrl, well.Caption);
|
|
|
|
|
return drillingProgramHref;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-18 16:22:53 +05:00
|
|
|
|
|
2022-05-04 15:02:12 +05:00
|
|
|
|
}
|