From 290b40fe1c682aa7651817f0a23ed70f5e7b139d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Thu, 14 Dec 2023 01:48:08 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=D1=8E=20=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormsProject/AppView/PluginsConvention.cs | 94 +++++++++++------- WinFormsProject/Plugins/AppView.dll | Bin 31232 -> 31232 bytes .../WinFormsAppByPlugins/FormMain.cs | 50 ++++++---- 3 files changed, 91 insertions(+), 53 deletions(-) diff --git a/WinFormsProject/AppView/PluginsConvention.cs b/WinFormsProject/AppView/PluginsConvention.cs index ee80b67..86006b5 100644 --- a/WinFormsProject/AppView/PluginsConvention.cs +++ b/WinFormsProject/AppView/PluginsConvention.cs @@ -146,73 +146,99 @@ namespace AppView public bool CreateWordDocument(PluginsConventionSaveDocument saveDocument) { - ImageClass info = new ImageClass(); + try + { + ImageClass info = new ImageClass(); - var images = _providerStorage.GetFullList().Select(x => x.Logo).ToList(); + var images = _providerStorage.GetFullList().Select(x => x.Logo).ToList(); - info.Title = "Images"; - info.Path = saveDocument.FileName; - info.Files = images; + info.Title = "Images"; + info.Path = saveDocument.FileName; + info.Files = images; - documentWithImage1.CreateDocument(info); - return true; + documentWithImage1.CreateDocument(info); + MessageBox.Show("Готово"); + return true; + } + catch(Exception e) + { + MessageBox.Show(e.Message, "Ошибка"); + return false; + } } public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument) { - System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + try + { + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); - List columnDefinitionsUp = new List { + List columnDefinitionsUp = new List { new ColumnDefinition{Header = "#", PropertyName = "Id", Weight = 30}, new ColumnDefinition{Header = "Информация", PropertyName = "NumberType", Weight = 30}, new ColumnDefinition{Header = "", PropertyName = "NumberType", Weight = 30}, new ColumnDefinition{Header = "Номер телефона", PropertyName = "Number", Weight = 30}, }; - List columnDefinitionsDown = new List { + List columnDefinitionsDown = new List { new ColumnDefinition{Header = "#", PropertyName = "Id", Weight = 30}, new ColumnDefinition{Header = "Название", PropertyName = "Name", Weight = 30}, new ColumnDefinition{Header = "Тип изделия", PropertyName = "Type", Weight = 30}, new ColumnDefinition{Header = "-", PropertyName = "Number", Weight = 30}, }; - var providers = _providerStorage.GetFullList(); + var providers = _providerStorage.GetFullList(); - List mergedColums = new() { new int[] { 1, 2 } }; + List mergedColums = new() { new int[] { 1, 2 } }; - BigTable info = new(saveDocument.FileName, "Table", columnDefinitionsUp, columnDefinitionsDown, providers, mergedColums); + BigTable info = new(saveDocument.FileName, "Table", columnDefinitionsUp, columnDefinitionsDown, providers, mergedColums); - table2column1.CreateTable(info); - MessageBox.Show("Готово"); - return true; + table2column1.CreateTable(info); + MessageBox.Show("Готово"); + return true; + } + catch(Exception e) + { + MessageBox.Show(e.Message, "Ошибка"); + return false; + } } public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument) { - var providers = _providerStorage.GetFullList(); - - var uniqueTypes = providers.Select(p => p.Type).Distinct(); - - List data = new List(); - - foreach (var uniqueType in uniqueTypes) + try { - var typeProviders = providers.Where(p => p.Type == uniqueType).ToList(); + var providers = _providerStorage.GetFullList(); - var dataList = new List(); + var uniqueTypes = providers.Select(p => p.Type).Distinct(); - // Используем Count() для подсчета общего количества поставщиков каждого типа - int totalCount = typeProviders.Count(); + List data = new List(); - ChartData chData = new ChartData(); - chData.SeriesName = uniqueType; - chData.Data = new double[] { totalCount }; + foreach (var uniqueType in uniqueTypes) + { + var typeProviders = providers.Where(p => p.Type == uniqueType).ToList(); - data.Add(chData); + var dataList = new List(); + + // Используем Count() для подсчета общего количества поставщиков каждого типа + int totalCount = typeProviders.Count(); + + ChartData chData = new ChartData(); + chData.SeriesName = uniqueType; + chData.Data = new double[] { totalCount }; + + data.Add(chData); + } + + gistograma1.GenerateExcelChartDocument(saveDocument.FileName, "Сводка по типам изделия.", "Количество поставщиков для товаров каждого типа", WinFormsLibrary.not_visual.LegendPosition.Bottom, data); + MessageBox.Show("Готово"); + return true; + } + catch(Exception e) + { + MessageBox.Show(e.Message, "Ошибка"); + return false; } - - gistograma1.GenerateExcelChartDocument(saveDocument.FileName, "Сводка по типам изделия.", "Количество поставщиков для товаров каждого типа", WinFormsLibrary.not_visual.LegendPosition.Bottom, data); - return true; } diff --git a/WinFormsProject/Plugins/AppView.dll b/WinFormsProject/Plugins/AppView.dll index 2246454291caa94c2761aa4637c7b7fb91a976ed..5cb2a4c6606305d04425d80988805b9b547c3bf1 100644 GIT binary patch delta 2955 zcmZWrYj6|S89jHUy{m_fkc1^68^^MYEy+)8gB|=1CKQKa9U}O;T_!gl8746G_J4*mYd?CPBqyozO0hb9n2|0ihh?N00oBnt~b==N- zZvZ{fN>ad0(PI(G9-^?&n{n2g32U^UNN-Xl`Jj+J z8E0XMfXx=B7$UYd?&S8(Jiz&vRnw1`SWHDuTZ{UkrdY=n*ayV?PdUFi$cdeLmE z$cQx(x>cvDZ?$B_)y%ZN-Xxjen#CGx7HPB6S3*}f%~2I7{+dNMKkIjEaBBCtqzs%q z0<=&|#39;6{R5-ZPvJe&Ih4qirZZav8D`xYbx232yFGLpH&+*b2cdPK(prCoYYyBo3#=JFuRd z&G$I9r^lkJghn;d)o~HgBWS0w^qI4EYl&u!mJ0C`rH@9l(XUsjU%mez@L8g3M0)09 zbX%!Mw21Bg9$BeJ)(E2xDOiU1+pvo!iC*3P5Byc6GW}#IC-^1JY2)Ida`4bKVu=b` zeYb#6rnudI=~}qV@s(KH6QT`ggEw?jZwMBwq<#76p-9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R#^Ys>ivzq&j4?xSd7= z-cc%z4bEx30lD<}18I1z1(b^_bqMd@cr_9P~R$@eA zIBUvL+I~6C&na!eduDDgi)41!IgR8-OlA1*hvgxh**i&h;=wi zY{uKf6}U*eTlz_KtMvW2Ojew@0uSL6qJy}VTHiF{%84r{jz^JW8&dwT@`sf_On%gM z7!_1Msd&kx91cwS7L(E`S8 zdTG-u$x?3sKjKZqxAIzu+k7jDCGIui!&qOzjQ$Rn4~qo7kJa(1=vy9QGveU#IPqT; z8^YfbD#+)jow9(I&mQ^W-j+~uMt{*IE!E1*&FCL`zUckg{Y7uX{Lj4E3G|U!&uoVo zJw>n1&+l+{eZFzmyPu7IY-(b`f?J_P;2fSL{ YL6IJq&deM9kFNE!W?Vb3vviH|KVMf0$N&HU diff --git a/WinFormsProject/WinFormsAppByPlugins/FormMain.cs b/WinFormsProject/WinFormsAppByPlugins/FormMain.cs index 4fd4907..6813cf0 100644 --- a/WinFormsProject/WinFormsAppByPlugins/FormMain.cs +++ b/WinFormsProject/WinFormsAppByPlugins/FormMain.cs @@ -183,38 +183,50 @@ namespace WinFormsAppByPlugins private void CreateSimpleDoc() { - SaveFileDialog saveFileDialog = new() + try { - Filter = "Word Files|*.docx" - }; - if (saveFileDialog.ShowDialog() == DialogResult.OK) - { - _plugins[_selectedPlugin].CreateWordDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); + SaveFileDialog saveFileDialog = new() + { + Filter = "Word Files|*.docx" + }; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + _plugins[_selectedPlugin].CreateWordDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); - } + } + } + catch(Exception ex) { MessageBox.Show(ex.Message, " ."); } } private void CreateTableDoc() { - SaveFileDialog saveFileDialog = new() + try { - Filter = "PDF Files|*.pdf" - }; - if (saveFileDialog.ShowDialog() == DialogResult.OK) - { - _plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); + SaveFileDialog saveFileDialog = new() + { + Filter = "PDF Files|*.pdf" + }; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + _plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); + } } + catch (Exception ex) { MessageBox.Show(ex.Message, " ."); } } private void CreateChartDoc() { - SaveFileDialog saveFileDialog = new() + try { - Filter = "Excel Files|*.xlsx" - }; - if (saveFileDialog.ShowDialog() == DialogResult.OK) - { - _plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); + SaveFileDialog saveFileDialog = new() + { + Filter = "Excel Files|*.xlsx" + }; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + _plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }); + } } + catch (Exception ex) { MessageBox.Show(ex.Message, " ."); } } private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus();