some done
This commit is contained in:
parent
236b87031a
commit
dc85770e0b
151
BlacksmithWorkshop/BlacksmithWorkshopView/FormMessage.Designer.cs
generated
Normal file
151
BlacksmithWorkshop/BlacksmithWorkshopView/FormMessage.Designer.cs
generated
Normal file
@ -0,0 +1,151 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelSender = new Label();
|
||||
textBoxSender = new TextBox();
|
||||
labelSubject = new Label();
|
||||
textBoxSubject = new TextBox();
|
||||
labelBody = new Label();
|
||||
textBoxBody = new TextBox();
|
||||
textBoxReply = new TextBox();
|
||||
labelReply = new Label();
|
||||
buttonSend = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelSender
|
||||
//
|
||||
labelSender.AutoSize = true;
|
||||
labelSender.Location = new Point(12, 9);
|
||||
labelSender.Name = "labelSender";
|
||||
labelSender.Size = new Size(117, 25);
|
||||
labelSender.TabIndex = 0;
|
||||
labelSender.Text = "Отправитель";
|
||||
//
|
||||
// textBoxSender
|
||||
//
|
||||
textBoxSender.Location = new Point(12, 37);
|
||||
textBoxSender.Name = "textBoxSender";
|
||||
textBoxSender.Size = new Size(347, 31);
|
||||
textBoxSender.TabIndex = 1;
|
||||
//
|
||||
// labelSubject
|
||||
//
|
||||
labelSubject.AutoSize = true;
|
||||
labelSubject.Location = new Point(12, 86);
|
||||
labelSubject.Name = "labelSubject";
|
||||
labelSubject.Size = new Size(99, 25);
|
||||
labelSubject.TabIndex = 2;
|
||||
labelSubject.Text = "Заголовок";
|
||||
//
|
||||
// textBoxSubject
|
||||
//
|
||||
textBoxSubject.Location = new Point(12, 114);
|
||||
textBoxSubject.Name = "textBoxSubject";
|
||||
textBoxSubject.Size = new Size(347, 31);
|
||||
textBoxSubject.TabIndex = 3;
|
||||
//
|
||||
// labelBody
|
||||
//
|
||||
labelBody.AutoSize = true;
|
||||
labelBody.Location = new Point(12, 167);
|
||||
labelBody.Name = "labelBody";
|
||||
labelBody.Size = new Size(152, 25);
|
||||
labelBody.TabIndex = 4;
|
||||
labelBody.Text = "Текст сообщения";
|
||||
//
|
||||
// textBoxBody
|
||||
//
|
||||
textBoxBody.Location = new Point(12, 195);
|
||||
textBoxBody.Multiline = true;
|
||||
textBoxBody.Name = "textBoxBody";
|
||||
textBoxBody.Size = new Size(347, 243);
|
||||
textBoxBody.TabIndex = 5;
|
||||
//
|
||||
// textBoxReply
|
||||
//
|
||||
textBoxReply.Location = new Point(430, 37);
|
||||
textBoxReply.Multiline = true;
|
||||
textBoxReply.Name = "textBoxReply";
|
||||
textBoxReply.Size = new Size(358, 361);
|
||||
textBoxReply.TabIndex = 6;
|
||||
//
|
||||
// labelReply
|
||||
//
|
||||
labelReply.AutoSize = true;
|
||||
labelReply.Location = new Point(430, 9);
|
||||
labelReply.Name = "labelReply";
|
||||
labelReply.Size = new Size(112, 25);
|
||||
labelReply.TabIndex = 7;
|
||||
labelReply.Text = "Текст ответа";
|
||||
//
|
||||
// buttonSend
|
||||
//
|
||||
buttonSend.Location = new Point(430, 404);
|
||||
buttonSend.Name = "buttonSend";
|
||||
buttonSend.Size = new Size(358, 34);
|
||||
buttonSend.TabIndex = 8;
|
||||
buttonSend.Text = "Отправить";
|
||||
buttonSend.UseVisualStyleBackColor = true;
|
||||
buttonSend.Click += ButtonSend_Click;
|
||||
//
|
||||
// FormMessage
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonSend);
|
||||
Controls.Add(labelReply);
|
||||
Controls.Add(textBoxReply);
|
||||
Controls.Add(textBoxBody);
|
||||
Controls.Add(labelBody);
|
||||
Controls.Add(textBoxSubject);
|
||||
Controls.Add(labelSubject);
|
||||
Controls.Add(textBoxSender);
|
||||
Controls.Add(labelSender);
|
||||
Name = "FormMessage";
|
||||
Text = "Ответ";
|
||||
Load += FormMessage_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelSender;
|
||||
private TextBox textBoxSender;
|
||||
private Label labelSubject;
|
||||
private TextBox textBoxSubject;
|
||||
private Label labelBody;
|
||||
private TextBox textBoxBody;
|
||||
private TextBox textBoxReply;
|
||||
private Label labelReply;
|
||||
private Button buttonSend;
|
||||
}
|
||||
}
|
113
BlacksmithWorkshop/BlacksmithWorkshopView/FormMessage.cs
Normal file
113
BlacksmithWorkshop/BlacksmithWorkshopView/FormMessage.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using BlacksmithWorkshopBusinessLogic.MailWorker;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormMessage : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
private string? _id;
|
||||
public string Id { set { _id = value; } }
|
||||
public FormMessage(ILogger<FormMessage> logger, IMessageInfoLogic messageInfoLogic, AbstractMailWorker abstractMailWorker, IClientLogic clientLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = messageInfoLogic;
|
||||
_clientLogic = clientLogic;
|
||||
_mailWorker = abstractMailWorker;
|
||||
}
|
||||
private void ButtonSend_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxBody.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните содержимое письма", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Отправка ответа");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new() { MessageId = _id });
|
||||
if (view != null)
|
||||
{
|
||||
var operationResult = _logic.Update(new()
|
||||
{
|
||||
MessageId = view.MessageId,
|
||||
IsRead = view.IsRead,
|
||||
ReplyText = textBoxReply.Text
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_mailWorker.MailSendAsync(new()
|
||||
{
|
||||
MailAddress = _clientLogic.ReadElement(new ClientSearchModel { Id = view.ClientId })!.Email,
|
||||
Subject = textBoxSubject.Text,
|
||||
Text = textBoxReply.Text,
|
||||
});
|
||||
MessageBox.Show("Сохранение и отправление прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void FormMessage_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_id))
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение письма");
|
||||
var view = _logic.ReadElement(new MessageInfoSearchModel
|
||||
{
|
||||
MessageId = _id
|
||||
});
|
||||
if (view == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
textBoxSender.Text = view.SenderName;
|
||||
textBoxSubject.Text = view.Subject;
|
||||
textBoxBody.Text = view.Body;
|
||||
if (!view.IsRead)
|
||||
{
|
||||
var updateResult = _logic.Update(new()
|
||||
{
|
||||
MessageId = _id,
|
||||
ReplyText = view.ReplyText,
|
||||
IsRead = true,
|
||||
});
|
||||
if (!updateResult)
|
||||
{
|
||||
throw new Exception("Ошибка при обновлении");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения письма");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
BlacksmithWorkshop/BlacksmithWorkshopView/FormMessage.resx
Normal file
120
BlacksmithWorkshop/BlacksmithWorkshopView/FormMessage.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user