This commit is contained in:
1yuee 2023-09-07 23:55:57 +04:00 committed by devil_1nc
parent 4ff793b507
commit 33556278cf
16 changed files with 89 additions and 81 deletions

3
.gitignore vendored
View File

@ -14,6 +14,9 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# dll files
*.dll
# Mono auto generated files
mono_crash.*

View File

@ -20,5 +20,7 @@ namespace AbstractSoftwareInstallationContracts.BindingModels
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
}
public int Id => throw new NotImplementedException();
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace AbstractSoftwareInstallationDataModels.Models
{
public interface IMessageInfoModel
public interface IMessageInfoModel : IId
{
string MessageId { get; }
int? ClientId { get; }

View File

@ -16,7 +16,7 @@ optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-QA8P9OJ;Initial Catalog=SoftwareInstallation1;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DANYAXREN\SQLEXPRESS;Initial Catalog=SoftwareInstallation1;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -21,4 +21,8 @@
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -56,5 +56,7 @@ namespace AbstractSoftwareInstallationDatabaseImplement.Models
SenderName = SenderName,
DateDelivery = DateDelivery,
};
}
public int Id => throw new NotImplementedException();
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -11,4 +11,8 @@
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -11,4 +11,8 @@
<ProjectReference Include="..\AbstractSoftwareInstallationDataModels\AbstractSoftwareInstallationDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace AbstractSoftwareInstallationListImplement
{
public class FileImplementationExtension : IImplementationExtension
public class ListImplementationExtension : IImplementationExtension
{
public int Priority => 1;

View File

@ -1,4 +1,5 @@
using SoftwareInstallation;

using SoftwareInstallation;
namespace SoftwareInstallationView
{

View File

@ -117,6 +117,16 @@ namespace SoftwareInstallationView
{
var form = DependencyManager.Instance.Resolve<FormPackages>();
form.ShowDialog();
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SavePackagesToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void clientToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -1,5 +1,6 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.DI;
using AbstractSoftwareInstallationContracts.SearchModels;
using AbstractSoftwareInstallationDataModels.Models;
using Microsoft.Extensions.Logging;
@ -79,31 +80,27 @@ namespace SoftwareInstallationView
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPackageSoftware));
if (service is FormPackageSoftware form)
var form = DependencyManager.Instance.Resolve<FormPackageSoftware>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
if (form.SoftwareModel == null)
{
if (form.SoftwareModel == null)
{
return;
}
_logger.LogInformation("Добавление нового ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
if (_packageSoftwares.ContainsKey(form.Id))
{
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
}
else
{
_packageSoftwares.Add(form.Id, (form.SoftwareModel, form.Count));
}
LoadData();
return;
}
_logger.LogInformation("Добавление нового ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
if (_packageSoftwares.ContainsKey(form.Id))
{
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
}
else
{
_packageSoftwares.Add(form.Id, (form.SoftwareModel, form.Count));
}
LoadData();
}
}
@ -111,25 +108,22 @@ namespace SoftwareInstallationView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPackageSoftware));
var form = DependencyManager.Instance.Resolve<FormPackageSoftware>();
if (service is FormPackageSoftware form)
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _packageSoftwares[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _packageSoftwares[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
if (form.SoftwareModel == null)
{
if (form.SoftwareModel == null)
{
return;
}
_logger.LogInformation("Изменение ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
LoadData();
return;
}
_logger.LogInformation("Изменение ПО: { SoftwareName} - { Count}", form.SoftwareModel.SoftwareName, form.Count);
_packageSoftwares[form.Id] = (form.SoftwareModel, form.Count);
LoadData();
}
}
}

View File

@ -1,5 +1,6 @@
using AbstractSoftwareInstallationContracts.BindingModels;
using AbstractSoftwareInstallationContracts.BusinessLogicsContracts;
using AbstractSoftwareInstallationContracts.DI;
using Microsoft.Extensions.Logging;
using SoftwareInstallation;
@ -24,14 +25,7 @@ namespace SoftwareInstallationView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["PackageSoftware"].Visible = false;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка пакетов");
}
catch (Exception ex)
@ -42,14 +36,10 @@ namespace SoftwareInstallationView
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
if (service is FormPackage form)
var form = DependencyManager.Instance.Resolve<FormPackage>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
@ -90,16 +80,13 @@ namespace SoftwareInstallationView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPackage));
var form = DependencyManager.Instance.Resolve<FormPackage>();
if (service is FormPackage form)
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
}

View File

@ -109,6 +109,7 @@
this.Controls.Add(this.buttonAdd);
this.Name = "FormSoftwares";
this.Text = "Программные обеспечения";
this.Load += new System.EventHandler(this.FormSoftwares_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);

View File

@ -14,6 +14,8 @@ namespace SoftwareInstallationView
{
InitializeComponent();
LoadData();
_logger = logger;
_logic = logic;
}
private void FormSoftwares_Load(object sender, EventArgs e)
@ -79,16 +81,13 @@ namespace SoftwareInstallationView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSoftware));
var form = DependencyManager.Instance.Resolve<FormSoftware>();
if (service is FormSoftware form)
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
}

View File

@ -17,10 +17,6 @@ namespace SoftwareInstallation
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -54,9 +50,10 @@ namespace SoftwareInstallation
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
private static void InitDependency()
{
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
@ -82,7 +79,7 @@ namespace SoftwareInstallation
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(isSingle: true);
DependencyManager.Instance.RegisterType<FormMails>();
DependencyManager.Instance.RegisterType<FormImplementers>();