Merge pull request #19 from schebotar/dev

Dev
This commit is contained in:
Serghei Cebotari 2022-04-03 12:51:08 +03:00 committed by GitHub
commit e7d590bd23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 79 additions and 86 deletions

View File

@ -1,11 +1,24 @@
using Microsoft.Office.Interop.Excel; using ExcelDna.Integration;
using Microsoft.Office.Interop.Excel;
using System;
namespace RehauSku.Interface namespace RehauSku.Interface
{ {
internal abstract class AbstractBar internal abstract class AbstractBar : IDisposable
{ {
protected Application Excel = AddIn.Excel; protected Application Excel = AddIn.Excel;
public abstract void Update(); public abstract void Update();
[ExcelFunction]
public static void ResetStatusBar()
{
AddIn.Excel.StatusBar = false;
}
public void Dispose()
{
AddIn.Excel.OnTime(DateTime.Now + new TimeSpan(0, 0, 5), "ResetStatusBar");
}
} }
} }

View File

@ -16,16 +16,7 @@
public override void Update() public override void Update()
{ {
double percent = (++CurrentProgress / TaskWeight) * 100; double percent = (++CurrentProgress / TaskWeight) * 100;
if (percent < 100)
{
Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %"; Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %";
} }
else
{
Excel.StatusBar = false;
}
}
} }
} }

View File

@ -1,4 +1,5 @@
using System.Text; using System;
using System.Text;
namespace RehauSku.Interface namespace RehauSku.Interface
{ {

View File

@ -93,6 +93,7 @@ namespace RehauSku.Interface
"Ошибка", "Ошибка",
MessageBoxButtons.OK, MessageBoxButtons.OK,
MessageBoxIcon.Information); MessageBoxIcon.Information);
AddIn.Excel.StatusBar = false;
return; return;
} }
} }

View File

@ -3,7 +3,6 @@ using RehauSku.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Dialog = RehauSku.Interface.Dialog; using Dialog = RehauSku.Interface.Dialog;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
@ -27,11 +26,11 @@ namespace RehauSku.PriceListTools
} }
} }
public override async void FillTarget() public override void FillTarget()
{
using (ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count)))
using (ResultBar = new ResultBar())
{ {
ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count));
ResultBar = new ResultBar();
foreach (SourcePriceList source in SourceFiles) foreach (SourcePriceList source in SourceFiles)
{ {
TargetFile.Sheet.Columns[TargetFile.AmountCell.Column] TargetFile.Sheet.Columns[TargetFile.AmountCell.Column]
@ -51,9 +50,7 @@ namespace RehauSku.PriceListTools
FilterByAmount(); FilterByAmount();
ResultBar.Update(); ResultBar.Update();
}
await Task.Delay(new TimeSpan(0, 0, 5));
ExcelApp.StatusBar = false;
} }
} }
} }

View File

@ -1,6 +1,4 @@
using RehauSku.Interface; using RehauSku.Interface;
using System;
using System.Threading.Tasks;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
{ {
@ -13,11 +11,11 @@ namespace RehauSku.PriceListTools
Current = new SourcePriceList(ExcelApp.ActiveWorkbook); Current = new SourcePriceList(ExcelApp.ActiveWorkbook);
} }
public override async void FillTarget() public override void FillTarget()
{
using (ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count))
using (ResultBar = new ResultBar())
{ {
ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count);
ResultBar = new ResultBar();
foreach (var kvp in Current.PositionAmount) foreach (var kvp in Current.PositionAmount)
{ {
FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column); FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
@ -26,9 +24,7 @@ namespace RehauSku.PriceListTools
FilterByAmount(); FilterByAmount();
ResultBar.Update(); ResultBar.Update();
}
await Task.Delay(new TimeSpan(0, 0, 5));
ExcelApp.StatusBar = false;
} }
} }
} }

View File

@ -2,7 +2,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using RehauSku.Interface; using RehauSku.Interface;
using System.Threading.Tasks;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
{ {
@ -22,11 +21,11 @@ namespace RehauSku.PriceListTools
} }
} }
public override async void FillTarget() public override void FillTarget()
{
using (ProgressBar = new ProgressBar("Заполняю строки...", PositionAmount.Count))
using (ResultBar = new ResultBar())
{ {
ProgressBar = new ProgressBar("Заполняю строки...", PositionAmount.Count);
ResultBar = new ResultBar();
foreach (var kvp in PositionAmount) foreach (var kvp in PositionAmount)
{ {
FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column); FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
@ -35,9 +34,7 @@ namespace RehauSku.PriceListTools
FilterByAmount(); FilterByAmount();
ResultBar.Update(); ResultBar.Update();
}
await Task.Delay(new TimeSpan(0, 0, 5));
ExcelApp.StatusBar = false;
} }
private void GetSelected() private void GetSelected()

View File

@ -2,7 +2,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace RehauSku.PriceListTools namespace RehauSku.PriceListTools
{ {
@ -25,11 +24,11 @@ namespace RehauSku.PriceListTools
} }
} }
public override async void FillTarget() public override void FillTarget()
{
using (ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(x => x.PositionAmount.Count)))
using (ResultBar = new ResultBar())
{ {
ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(x => x.PositionAmount.Count));
ResultBar = new ResultBar();
foreach (SourcePriceList source in SourceFiles) foreach (SourcePriceList source in SourceFiles)
{ {
foreach (var kvp in source.PositionAmount) foreach (var kvp in source.PositionAmount)
@ -41,9 +40,7 @@ namespace RehauSku.PriceListTools
FilterByAmount(); FilterByAmount();
ResultBar.Update(); ResultBar.Update();
}
await Task.Delay(new TimeSpan(0, 0, 5));
ExcelApp.StatusBar = false;
} }
} }
} }

View File

@ -77,9 +77,9 @@ namespace RehauSku.PriceListTools
for (int row = AmountCell.Row + 1; row <= Sheet.Cells[Sheet.Rows.Count, AmountCell.Column].End[XlDirection.xlUp].Row; row++) for (int row = AmountCell.Row + 1; row <= Sheet.Cells[Sheet.Rows.Count, AmountCell.Column].End[XlDirection.xlUp].Row; row++)
{ {
object amount = Sheet.Cells[row, AmountCell.Column].Value2; double? amount = Sheet.Cells[row, AmountCell.Column].Value2 as double?;
if (amount != null && (double)amount != 0) if (amount != null && amount.Value != 0)
{ {
object group = Sheet.Cells[row, GroupCell.Column].Value2; object group = Sheet.Cells[row, GroupCell.Column].Value2;
object name = Sheet.Cells[row, NameCell.Column].Value2; object name = Sheet.Cells[row, NameCell.Column].Value2;
@ -95,12 +95,12 @@ namespace RehauSku.PriceListTools
if (PositionAmount.ContainsKey(p)) if (PositionAmount.ContainsKey(p))
{ {
PositionAmount[p] += (double)amount; PositionAmount[p] += amount.Value;
} }
else else
{ {
PositionAmount.Add(p, (double)amount); PositionAmount.Add(p, amount.Value);
} }
} }
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4.2")] [assembly: AssemblyVersion("1.0.4.3")]
[assembly: AssemblyFileVersion("1.0.4.2")] [assembly: AssemblyFileVersion("1.0.4.3")]