aboutsummaryrefslogtreecommitdiff
path: root/src/PriceListTools/MergeTool.cs
blob: b9673e76bcb11a6415daa2f609b3e53a495386cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using RhSolutions.Interface;
using System;
using System.Collections.Generic;
using System.Linq;

namespace RhSolutions.PriceListTools
{
    internal class MergeTool : AbstractTool
    {
        private List<SourcePriceList> SourceFiles { get; set; }

        public MergeTool()
        {
            string[] files = Dialog.GetMultiplyFiles();

            if (files != null)
            {
                SourceFiles = SourcePriceList.GetSourceLists(files);
            }

            else
            {
                throw new Exception("Не выбраны файлы");
            }
        }

        public override void FillTarget()
        {
            using (ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(x => x.PositionAmount.Count)))
            using (ResultBar = new ResultBar())
            {
                foreach (SourcePriceList source in SourceFiles)
                {
                    foreach (var kvp in source.PositionAmount)
                    {
                        FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
                        ProgressBar.Update();
                    }
                }

                FilterByAmount();
                ResultBar.Update();
            }
        }
    }
}