예제 #1
0
        public override int ParseDataToDatabase()
        {
            int recordsCount = 0;

            var PVCGroup         = _dbContext.PolymerGroups.Find(1);  // PVC
            var PVCColdGroup     = _dbContext.PolymerGroups.Find(10); // PVC Cold
            var PVCTermGroup     = _dbContext.PolymerGroups.Find(11); //PVC term
            var PVCLSGroup       = _dbContext.PolymerGroups.Find(6);  //PVC LS
            var PVCLSLTxGroup    = _dbContext.PolymerGroups.Find(7);  //PVC LSLTx
            var PESelfExtinguish = _dbContext.PolymerGroups.Find(12); //PE self extinguish

            var polymerGroups = new List <PolymerGroup> {
                PVCGroup, PVCColdGroup, PVCTermGroup, PVCLSGroup
            };
            var polymerGroupsLTx = new List <PolymerGroup> {
                PVCLSLTxGroup
            };
            var polymerGroupsPE = new List <PolymerGroup> {
                PESelfExtinguish
            };
            var polymerGroupsFull = new List <PolymerGroup> {
                PVCGroup, PVCColdGroup, PVCTermGroup, PVCLSGroup, PESelfExtinguish
            };

            var TU2  = _dbContext.TechnicalConditions.Find(1);
            var TU30 = _dbContext.TechnicalConditions.Find(35);
            var TU49 = _dbContext.TechnicalConditions.Find(20);

            var noFireProtectClass    = _dbContext.FireProtectionClasses.Find(1);  //О1.8.2.5.4
            var LSFireProtectClass    = _dbContext.FireProtectionClasses.Find(8);  //П1б.8.2.2.2
            var LSLTxFireProtectClass = _dbContext.FireProtectionClasses.Find(28); //П1б.8.2.1.2

            var PolymerGroupFireClassDict = new Dictionary <PolymerGroup, FireProtectionClass>()
            {
                { PVCGroup, noFireProtectClass },
                { PVCColdGroup, noFireProtectClass },
                { PVCTermGroup, noFireProtectClass },
                { PVCLSGroup, LSFireProtectClass },
                { PVCLSLTxGroup, LSLTxFireProtectClass },
                { PESelfExtinguish, noFireProtectClass }
            };

            var climaticModUHL = _dbContext.ClimaticMods.Find(3);

            var redColor   = _dbContext.Colors.Find(1);
            var blackColor = _dbContext.Colors.Find(2);

            var cableBrandName = _dbContext.CableBrandNames.Find(6);            // КПСВ(Э)

            var operatingVoltage        = _dbContext.OperatingVoltages.Find(6); // 300В 50Гц, постоянка - до 500В
            var operatingVoltageLoutoks = _dbContext.OperatingVoltages.Find(5); // 300В 50Гц

            var twistedElementType = _dbContext.TwistedElementTypes.Find(2);    //pair

            CablePropertySet?cablePropSimple   = null;
            CablePropertySet?cablePropShield   = CablePropertySet.HasFoilShield;
            CablePropertySet?cablePropKG       = CablePropertySet.HasArmourBraid;
            CablePropertySet?cablePropKGShield = CablePropertySet.HasFoilShield | CablePropertySet.HasArmourBraid;
            CablePropertySet?cablePropK        = CablePropertySet.HasArmourBraid | CablePropertySet.HasArmourTube;
            CablePropertySet?cablePropKShield  = CablePropertySet.HasFoilShield | CablePropertySet.HasArmourBraid | CablePropertySet.HasArmourTube;
            CablePropertySet?cablePropB        = CablePropertySet.HasArmourTape | CablePropertySet.HasArmourTube;
            CablePropertySet?cablePropBShield  = CablePropertySet.HasFoilShield | CablePropertySet.HasArmourTape | CablePropertySet.HasArmourTube;

            var configStart10 = new TableParserConfigurator(3, 2, 10, 5, 2, 1);
            var configStart8  = new TableParserConfigurator(3, 2, 8, 5, 2, 1);
            var configMid10   = new TableParserConfigurator(8, 2, 10, 5, 2, 1);
            var configMid8    = new TableParserConfigurator(8, 2, 8, 5, 2, 1);
            var configLTx1    = new TableParserConfigurator(3, 2, 9, 5, 2, 1);
            var configLTx2    = new TableParserConfigurator(9, 2, 9, 5, 8, 1);
            var configLTx3    = new TableParserConfigurator(15, 2, 9, 5, 14, 1);
            var configLTx4    = new TableParserConfigurator(21, 2, 9, 5, 20, 1);

            var configSet1  = (props : cablePropSimple, tu : TU2, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (0, configStart10), (1, configStart8)
            }, polymerGroups : polymerGroups);
            var configSet2  = (props : cablePropShield, tu : TU2, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (0, configMid10), (1, configMid8)
            }, polymerGroups : polymerGroups);
            var configSet3  = (props : cablePropSimple, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (3, configStart10), (4, configStart8)
            }, polymerGroups : polymerGroupsPE);
            var configSet4  = (props : cablePropShield, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (3, configMid10), (4, configMid8)
            }, polymerGroups : polymerGroupsPE);
            var configSet5  = (props : cablePropSimple, tu : TU49, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (2, configLTx1), (2, configLTx2)
            }, polymerGroups : polymerGroupsLTx);
            var configSet6  = (props : cablePropShield, tu : TU49, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (2, configLTx3), (2, configLTx4)
            }, polymerGroups : polymerGroupsLTx);
            var configSet7  = (props : cablePropKG, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (5, configStart10), (6, configStart8)
            }, polymerGroups : polymerGroupsFull);
            var configSet8  = (props : cablePropKGShield, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (5, configMid10), (6, configMid8)
            }, polymerGroups : polymerGroupsFull);
            var configSet9  = (props : cablePropK, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (7, configStart10), (8, configStart8)
            }, polymerGroups : polymerGroupsFull);
            var configSet10 = (props : cablePropKShield, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (7, configMid10), (8, configMid8)
            }, polymerGroups : polymerGroupsFull);
            var configSet11 = (props : cablePropB, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (9, configStart10)
            }, polymerGroups : polymerGroupsFull);
            var configSet12 = (props : cablePropBShield, tu : TU30, configure : new List <(int tableIndex, TableParserConfigurator config)> {
                (9, configMid10)
            }, polymerGroups : polymerGroupsFull);

            var mainConfigArray = new[]
            { configSet1, configSet2, configSet3, configSet4, configSet5, configSet6, configSet7, configSet8, configSet9, configSet10, configSet11, configSet12 };

            var billets = _dbContext.InsulatedBillets.Where(b => b.CableBrandNameId == 6)
                          .Include(p => p.Conductor)
                          .Include(p => p.PolymerGroup)
                          .ToList();

            _wordTableParser = new XceedWordTableParser();
            _wordTableParser.OpenWordDocument(_mSWordFile);

            var cablePresenter = new CablePresenter {
                ClimaticModId = climaticModUHL.Id, TwistedElementTypeId = twistedElementType.Id
            };

            var optionsCount = 1.0;

            _provider.OpenConnection();
            try
            {
                foreach (var option in mainConfigArray)
                {
                    var tableDataCommon = new List <TableCellData>();
                    foreach (var(tableIndex, config) in option.configure)
                    {
                        tableDataCommon.AddRange(_wordTableParser.GetCableCellsCollection(tableIndex, config));
                    }

                    foreach (var polymerGroup in option.polymerGroups)
                    {
                        var insulationPolymerGroup     = polymerGroup == PVCColdGroup || polymerGroup == PESelfExtinguish ? PVCGroup : polymerGroup;
                        var currentPolymerGroupBillets = (from b in billets
                                                          where b.PolymerGroup == insulationPolymerGroup
                                                          select b);
                        foreach (var tableCellData in tableDataCommon)
                        {
                            cablePresenter.CoverPolimerGroupId = polymerGroup.Id;
                            cablePresenter.TechCondId          = option.tu.Id;
                            cablePresenter.CoverColorId        = polymerGroup == PVCColdGroup ? blackColor.Id : redColor.Id;
                            cablePresenter.OperatingVoltageId  = operatingVoltage.Id;
                            cablePresenter.FireProtectionId    = PolymerGroupFireClassDict[polymerGroup].Id;
                            ParseTableCellData(cablePresenter, tableCellData, currentPolymerGroupBillets, option.props, _splitter);
                            recordsCount++;
                        }
                    }
                    OnParseReport(optionsCount / mainConfigArray.Length);
                    optionsCount++;
                }
            }
            finally
            {
                _wordTableParser.CloseWordApp();
                _provider.CloseConnection();
            }
            return(recordsCount);
        }
예제 #2
0
        public override int ParseDataToDatabase()
        {
            int recordsCount = 0;
            var nameBuilder  = new KunrsNameBuider();
            var configurator = new TableParserConfigurator().SetDataColumnsCount(4)
                               .SetDataRowsCount(8)
                               .SetColumnHeadersRowIndex(2)
                               .SetRowHeadersColumnIndex(1)
                               .SetDataStartColumnIndex(2)
                               .SetDataStartRowIndex(3);

            _wordTableParser = new XceedWordTableParser();

            var cablePropsList = new List <CablePropertySet?>
            {
                null,
                CablePropertySet.HasFoilShield,
                CablePropertySet.HasArmourBraid | CablePropertySet.HasArmourTube,
                CablePropertySet.HasFoilShield | CablePropertySet.HasArmourBraid | CablePropertySet.HasArmourTube
            };

            var polymerGroupIdList = new List <int> {
                6, 4, 5
            };

            var powerColorsDict = new Dictionary <decimal, PowerWiresColorScheme[]>
            {
                { 2m, new [] { PowerWiresColorScheme.N } },
                { 3m, new [] { PowerWiresColorScheme.PEN, PowerWiresColorScheme.none } },
                { 4m, new [] { PowerWiresColorScheme.N, PowerWiresColorScheme.PE } },
                { 5m, new [] { PowerWiresColorScheme.PEN, PowerWiresColorScheme.none } }
            };

            var billets = _dbContext.InsulatedBillets.Where(b => b.CableBrandName.BrandName == "КУНРС")
                          .Include(b => b.Conductor)
                          .ToList();

            var kunrs = new CablePresenter
            {
                TwistedElementTypeId = 1,
                TechCondId           = 25,
                OperatingVoltageId   = 1,
                ClimaticModId        = 3
            };

            PowerWiresColorScheme[] powerColorSchemeArray;

            _wordTableParser.OpenWordDocument(_mSWordFile);
            _provider.OpenConnection();
            try
            {
                var parsePartNumber = 1d;
                foreach (var prop in cablePropsList)
                {
                    var tableData = _wordTableParser.GetCableCellsCollection(0, configurator);
                    foreach (var tableCellData in tableData)
                    {
                        if (decimal.TryParse(tableCellData.ColumnHeaderData, NumberStyles.Any, _cultureInfo, out decimal elementsCount) &&
                            decimal.TryParse(tableCellData.CellData, NumberStyles.Any, _cultureInfo, out decimal maxCoverDiameter) &&
                            decimal.TryParse(tableCellData.RowHeaderData, NumberStyles.Any, _cultureInfo, out decimal conductorAreaInSqrMm))
                        {
                            foreach (var polymerGroupId in polymerGroupIdList)
                            {
                                powerColorSchemeArray = powerColorsDict[elementsCount];
                                foreach (var powerColorScheme in powerColorSchemeArray)
                                {
                                    var cableProps = CablePropertySet.HasFilling;
                                    if (prop.HasValue)
                                    {
                                        cableProps |= prop.Value;
                                    }

                                    kunrs.ElementsCount       = elementsCount;
                                    kunrs.MaxCoverDiameter    = maxCoverDiameter;
                                    kunrs.FireProtectionId    = polymerGroupId == 6 ? 18 : 23;
                                    kunrs.CoverPolimerGroupId = polymerGroupId;
                                    kunrs.CoverColorId        = polymerGroupId == 5 ? 8 : 2;
                                    var billet = (from b in billets
                                                  where b.Conductor.AreaInSqrMm == conductorAreaInSqrMm
                                                  select b).Single();
                                    kunrs.Title = nameBuilder.GetCableName(kunrs, conductorAreaInSqrMm, cableProps, powerColorScheme);
                                    var cableId = _cableTableProvider.AddItem(kunrs);

                                    _listCableBilletsProvider.AddItem(new ListCableBilletsPresenter {
                                        CableId = cableId, BilletId = billet.Id
                                    });
                                    _listCablePowerColorProvider.AddItem(new ListCablePowerColorPresenter {
                                        CableId = cableId, PowerColorSchemeId = (int)powerColorScheme
                                    });

                                    var intProp = 0b_0000000001;

                                    for (int m = 0; m < cablePropertiesCount; m++)
                                    {
                                        var Prop = (CablePropertySet)intProp;

                                        if ((cableProps & Prop) == Prop)
                                        {
                                            var propertyObj = cablePropertiesList.Where(p => p.BitNumber == intProp).First();
                                            _listCablePropertiesProvider.AddItem(new ListCablePropertiesPresenter {
                                                PropertyId = propertyObj.Id, CableId = cableId
                                            });
                                        }
                                        intProp <<= 1;
                                    }
                                    recordsCount++;
                                }
                            }
                        }
                    }
                    OnParseReport(parsePartNumber / cablePropsList.Count);
                    configurator.DataStartRowIndex += configurator.DataRowsCount;
                    parsePartNumber++;
                }
            }
            finally
            {
                _wordTableParser.CloseWordApp();
                _provider.CloseConnection();
            }
            return(recordsCount);
        }
예제 #3
0
        public override int ParseDataToDatabase()
        {
            _recordsCount = 0;

            var configuratorTSimpleAndKG  = new TableParserConfigurator(3, 2, 9, 6, 2, 1);
            var configuratorTSimpleAndKGS = new TableParserConfigurator(9, 2, 9, 6, 2, 1);
            var configuratorK             = new TableParserConfigurator(3, 2, 7, 6, 2, 1);
            var configuratorKS            = new TableParserConfigurator(9, 2, 7, 6, 2, 1);

            var techCond = _dbContext.TechnicalConditions.Where(c => c.Title == "ТУ 16.К99-037-2009").First();

            var voltage = _dbContext.OperatingVoltages.Find(5);

            var climaticModUHL = _dbContext.ClimaticMods.Where(c => c.Title == "УХЛ").First();
            var climaticModV   = _dbContext.ClimaticMods.Where(c => c.Title == "В").First();

            var colorOrange = _dbContext.Colors.Where(c => c.Title == "orange").First();
            var colorBlack  = _dbContext.Colors.Where(c => c.Title == "black").First();

            _fireFRLS = _dbContext.FireProtectionClasses.Find(18);
            _fireFRHF = _dbContext.FireProtectionClasses.Find(23);

            var polymerLS = _dbContext.PolymerGroups.Find(6);
            var polymerHF = _dbContext.PolymerGroups.Find(4);

            var pair = _dbContext.TwistedElementTypes.Find(2);

            var cablePropertiesSetList = new List <CablePropertySet?>
            {
                CablePropertySet.HasFoilShield,
                CablePropertySet.HasFoilShield | CablePropertySet.HasMicaWinding,
                CablePropertySet.HasFoilShield | CablePropertySet.HasArmourBraid,
                CablePropertySet.HasFoilShield | CablePropertySet.HasArmourBraid | CablePropertySet.HasMicaWinding,
                CablePropertySet.HasFoilShield | CablePropertySet.HasArmourBraid | CablePropertySet.HasArmourTube,
                CablePropertySet.HasFoilShield | CablePropertySet.HasArmourBraid | CablePropertySet.HasArmourTube | CablePropertySet.HasMicaWinding,
            };

            _coverPolymerGroups = new[] { polymerLS, polymerHF };

            _billets = _dbContext.InsulatedBillets.Where(b => b.CableBrandName.BrandName == "КСБ")
                       .Include(b => b.Conductor)
                       .ToList();

            _nameBuilder = new KsbgNameBuilder();

            _wordTableParser = new XceedWordTableParser();
            _wordTableParser.OpenWordDocument(_mSWordFile);

            var tableDataCommon = new List <TableCellData>();
            var cablePresenter  = new CablePresenter
            {
                TechCondId         = techCond.Id,
                OperatingVoltageId = voltage.Id,
                ClimaticModId      = climaticModUHL.Id,
            };

            _provider.OpenConnection();

            try
            {
            }
            finally
            {
                _wordTableParser.CloseWordApp();
                _provider.CloseConnection();
            }

            return(_recordsCount);
        }
예제 #4
0
        public override int ParseDataToDatabase()
        {
            int recordsCount = 0;

            var techCond = _dbContext.TechnicalConditions.Where(c => c.Title == "ТУ 16.К99-061-2013").First();

            var voltage250 = _dbContext.OperatingVoltages.Find(2);
            var voltage660 = _dbContext.OperatingVoltages.Find(3);

            var climaticModUHL = _dbContext.ClimaticMods.Find(3);
            var climaticModV   = _dbContext.ClimaticMods.Find(7);

            var colorBlack = _dbContext.Colors.Find(2);
            var colorBlue  = _dbContext.Colors.Find(3);

            var skabPropertiesList = new List <CablePropertySet?>
            {
                CablePropertySet.HasFilling | CablePropertySet.HasBraidShield,
                CablePropertySet.HasWaterBlockStripe | CablePropertySet.HasFilling | CablePropertySet.HasBraidShield,
                CablePropertySet.HasBraidShield,
                CablePropertySet.HasWaterBlockStripe | CablePropertySet.HasBraidShield,
                CablePropertySet.HasFilling,
                CablePropertySet.HasWaterBlockStripe | CablePropertySet.HasFilling,
                null,
                CablePropertySet.HasWaterBlockStripe
            };

            var operatingVoltages = new List <OperatingVoltage> {
                voltage250, voltage660
            };                                                                             // 1 - СКАБ 250, 2 - СКАБ 660

            var skabArmorPropertiesList = new List <CablePropertySet?>
            {
                null,
                CablePropertySet.HasArmourBraid,
                CablePropertySet.HasArmourBraid | CablePropertySet.HasArmourTube
            };

            var insulationTypes = new List <int> {
                0, 1
            };                                            //1 = rubber, 0 = others

            var single = _dbContext.TwistedElementTypes.Find(1);
            var pair   = _dbContext.TwistedElementTypes.Find(2);
            var triple = _dbContext.TwistedElementTypes.Find(3);

            var fireLS    = _dbContext.FireProtectionClasses.Find(8);
            var fireHF    = _dbContext.FireProtectionClasses.Find(13);
            var fireFRLS  = _dbContext.FireProtectionClasses.Find(18);
            var fireFRHF  = _dbContext.FireProtectionClasses.Find(23);
            var fireCFRHF = _dbContext.FireProtectionClasses.Find(25);

            var polymerLS     = _dbContext.PolymerGroups.Find(6);
            var polymerHF     = _dbContext.PolymerGroups.Find(4);
            var polymerRubber = _dbContext.PolymerGroups.Find(3);
            var polymerPUR    = _dbContext.PolymerGroups.Find(5);

            var configurator = new TableParserConfigurator().SetDataRowsCount(5)
                               .SetDataStartColumnIndex(3)
                               .SetRowHeadersColumnIndex(2);

            var twistParamsList = new List <(TwistedElementType twistMode, CablePropertySet?hasIndividualFoilSHields, TableParserConfigurator configurator)>
            {
                (single, null, new TableParserConfigurator(3, 2, 13, 5, 2, 1)),
                (pair, null, new TableParserConfigurator(10, 2, 14, 5, 9, 1)),
                (triple, null, new TableParserConfigurator(15, 2, 14, 5, 9, 1)),
                (pair, CablePropertySet.HasIndividualFoilShields, new TableParserConfigurator(21, 2, 13, 5, 20, 1)),
                (triple, CablePropertySet.HasIndividualFoilShields, new TableParserConfigurator(26, 2, 13, 5, 20, 1))
            };

            var plasticInsParams = new List <(FireProtectionClass fireClass, PolymerGroup insPolymerGroup, PolymerGroup coverPolymerGroup)>
            {
                (fireLS, polymerLS, polymerLS), (fireHF, polymerHF, polymerHF)
            };

            var rubberInsParams = new List <(FireProtectionClass fireClass, PolymerGroup insPolymerGroup, PolymerGroup coverPolymerGroup)>
            {
                (fireFRLS, polymerRubber, polymerLS), (fireFRHF, polymerRubber, polymerHF), (fireCFRHF, polymerRubber, polymerPUR)
            };

            var exiProperties = new List <CablePropertySet?> {
                null, CablePropertySet.SparkSafety
            };

            var billets = _dbContext.InsulatedBillets.Where(b => b.CableBrandName.BrandName == "СКАБ")
                          .Include(b => b.Conductor)
                          .Include(b => b.PolymerGroup)
                          .Include(b => b.OperatingVoltage)
                          .ToList();

            _wordTableParser = new XceedWordTableParser();
            _wordTableParser.OpenWordDocument(_mSWordFile);

            var maxDiamTableCount = _wordTableParser.DocumentTablesCount / 2;

            var cablePresenter = new CablePresenter {
                TechCondId = techCond.Id
            };
            var nameBuilder = new SkabNameBuilder();

            _provider.OpenConnection();
            var tableNumber = 0;

            try
            {
                while (tableNumber < maxDiamTableCount)
                {
                    foreach (var mod in skabPropertiesList)
                    {
                        foreach (var voltage in operatingVoltages)
                        {
                            foreach (var insType in insulationTypes)
                            {
                                foreach (var armourType in skabArmorPropertiesList)
                                {
                                    foreach (var twistTypeParams in twistParamsList)
                                    {
                                        var tableData = _wordTableParser.GetCableCellsCollection(tableNumber, twistTypeParams.configurator);

                                        foreach (var tableCellData in tableData)
                                        {
                                            if (decimal.TryParse(tableCellData.ColumnHeaderData, NumberStyles.Any, _cultureInfo, out decimal elementsCount) &&
                                                decimal.TryParse(tableCellData.CellData, NumberStyles.Any, _cultureInfo, out decimal maxCoverDiameter) &&
                                                decimal.TryParse(tableCellData.RowHeaderData, NumberStyles.Any, _cultureInfo, out decimal conductorAreaInSqrMm))
                                            {
                                                var materialParams = insType == 0 ? plasticInsParams : rubberInsParams;
                                                foreach (var matParam in materialParams)
                                                {
                                                    foreach (var exiParam in exiProperties)
                                                    {
                                                        var cableProps = CablePropertySet.HasFoilShield;
                                                        if (twistTypeParams.hasIndividualFoilSHields.HasValue)
                                                        {
                                                            cableProps |= twistTypeParams.hasIndividualFoilSHields.Value;
                                                        }
                                                        if (mod.HasValue)
                                                        {
                                                            cableProps |= mod.Value;
                                                        }
                                                        if (armourType.HasValue)
                                                        {
                                                            cableProps |= armourType.Value;
                                                        }
                                                        if (exiParam.HasValue)
                                                        {
                                                            cableProps |= exiParam.Value;
                                                        }

                                                        var billet = billets.Where(b => b.OperatingVoltage == voltage &&
                                                                                   b.PolymerGroup == matParam.insPolymerGroup &&
                                                                                   b.Conductor.AreaInSqrMm == conductorAreaInSqrMm)
                                                                     .First();

                                                        cablePresenter.ElementsCount        = elementsCount;
                                                        cablePresenter.OperatingVoltageId   = voltage.Id;
                                                        cablePresenter.TwistedElementTypeId = twistTypeParams.twistMode.Id;
                                                        cablePresenter.MaxCoverDiameter     = maxCoverDiameter;
                                                        cablePresenter.FireProtectionId     = matParam.fireClass.Id;
                                                        cablePresenter.CoverPolimerGroupId  = matParam.coverPolymerGroup.Id;
                                                        cablePresenter.CoverColorId         = (exiParam.HasValue && (!armourType.HasValue || (armourType.Value & CablePropertySet.HasArmourTube) != CablePropertySet.HasArmourTube)) ? colorBlue.Id : colorBlack.Id;
                                                        cablePresenter.ClimaticModId        = matParam.coverPolymerGroup.Id == 6 ? climaticModUHL.Id : climaticModV.Id;

                                                        cablePresenter.Title = nameBuilder.GetCableName(cablePresenter, conductorAreaInSqrMm, cableProps);
                                                        var cablePresenterId = _cableTableProvider.AddItem(cablePresenter);

                                                        _listCableBilletsProvider.AddItem(new ListCableBilletsPresenter {
                                                            CableId = cablePresenterId, BilletId = billet.Id
                                                        });

                                                        var intProp = 0b_0000000001;

                                                        for (int j = 0; j < cablePropertiesCount; j++)
                                                        {
                                                            var Prop = (CablePropertySet)intProp;

                                                            if ((cableProps & Prop) == Prop)
                                                            {
                                                                var propertyObj = cablePropertiesList.Where(p => p.BitNumber == intProp).First();
                                                                _listCablePropertiesProvider.AddItem(new ListCablePropertiesPresenter {
                                                                    PropertyId = propertyObj.Id, CableId = cablePresenterId
                                                                });
                                                            }
                                                            intProp <<= 1;
                                                        }
                                                        recordsCount++;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                throw new Exception($"Не удалось распарсить ячейку таблицы №{tableNumber}!");
                                            }
                                        }
                                    }
                                    OnParseReport((double)(tableNumber + 1) / maxDiamTableCount);
                                    tableNumber++;
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                _wordTableParser.CloseWordApp();
                _provider.CloseConnection();
            }
            return(recordsCount);
        }
    }
}
예제 #5
0
        public override int ParseDataToDatabase()
        {
            _recordsCount = 0;

            var configuratorTop           = new TableParserConfigurator(3, 2, 9, 7, 2, 1);
            var configuratorBottom        = new TableParserConfigurator(11, 2, 9, 7, 10, 1);
            var configuratorSingleBillets = new TableParserConfigurator(4, 1, 2, 7, 3, 0);

            var techCond = _dbContext.TechnicalConditions.Where(c => c.Title == "ТУ 16.К99-036-2007").First();

            var voltage = _dbContext.OperatingVoltages.Find(5);

            var climaticModUHL = _dbContext.ClimaticMods.Find(3);

            var colorOrange = _dbContext.Colors.Find(8);

            _fireFRLS = _dbContext.FireProtectionClasses.Find(18);
            _fireFRHF = _dbContext.FireProtectionClasses.Find(23);

            var polymerLS = _dbContext.PolymerGroups.Find(6);
            var polymerHF = _dbContext.PolymerGroups.Find(4);


            var single = _dbContext.TwistedElementTypes.Find(1);
            var pair   = _dbContext.TwistedElementTypes.Find(2);

            var cablePropertiesSetList = new List <CablePropertySet?>
            {
                CablePropertySet.HasFoilShield,
                null,
                CablePropertySet.HasFoilShield | CablePropertySet.HasMicaWinding,
                CablePropertySet.HasMicaWinding
            };

            _coverPolymerGroups = new[] { polymerLS, polymerHF };

            _billets = _dbContext.InsulatedBillets.Where(b => b.CableBrandName.BrandName == "КПС(Э)")
                       .Include(b => b.Conductor)
                       .ToList();

            _nameBuilder = new KpseNameBuilder();

            _wordTableParser = new XceedWordTableParser();
            _wordTableParser.OpenWordDocument(_mSWordFile);

            var tableDataCommon = new List <TableCellData>();
            var cablePresenter  = new CablePresenter
            {
                TechCondId         = techCond.Id,
                OperatingVoltageId = voltage.Id,
                ClimaticModId      = climaticModUHL.Id,
                CoverColorId       = colorOrange.Id
            };

            _provider.OpenConnection();

            try
            {
                var tableIndex = 0;
                foreach (var cableProps in cablePropertiesSetList)
                {
                    tableDataCommon.AddRange(_wordTableParser.GetCableCellsCollection(tableIndex, configuratorTop));
                    tableDataCommon.AddRange(_wordTableParser.GetCableCellsCollection(tableIndex, configuratorBottom));

                    cablePresenter.TwistedElementTypeId = pair.Id;
                    InsertCablesFromTableCellData(tableDataCommon, cablePresenter, cableProps);
                    tableDataCommon.Clear();

                    tableDataCommon.AddRange(_wordTableParser.GetCableCellsCollection(4, configuratorSingleBillets));
                    cablePresenter.TwistedElementTypeId = single.Id;
                    InsertCablesFromTableCellData(tableDataCommon, cablePresenter, cableProps);
                    tableDataCommon.Clear();
                    configuratorSingleBillets.DataStartColumnIndex += (tableIndex + 1) % 2 == 0 ? -2 : 4;

                    OnParseReport((double)(tableIndex + 1) / cablePropertiesSetList.Count);
                    tableIndex++;
                }
            }
            finally
            {
                _wordTableParser.CloseWordApp();
                _provider.CloseConnection();
            }

            return(_recordsCount);
        }