public static void SetLaborIntensityOfProducts(LoggerForm logger)
        {
            try
            {
                logger.DefaultBoldText("Подготовка к работе.");
                var worksheet = (Worksheet)Globals.ThisAddIn.Application.ActiveSheet;
                var usedRange = (object[, ])worksheet.UsedRange.get_Value(Type.Missing);
                var settings  = Properties.Settings.Default.LaborIntensityOfProductsSetting.Split().Select((x, i) => (Value: int.Parse(x), Group: i / 4))
                                .GroupBy(x => x.Group).Where(x => x.All(x => x.Value > 0)).Select(x => x.Select(y => y.Value).ToArray()).ToArray();
                if (settings.Length <= 0 || !settings.All(x => x.Max() < usedRange.GetLength(1)))
                {
                    logger.ErrorText(" ⚠ НАСТРОЙКИ НЕ КОРРЕКТНЫ\r\n");
                    return;
                }
                logger.SuccessText(" ✓ ВЫПОЛНЕНО\r\n\r\n");

                logger.DefaultBoldText($"Сбор данных:\r\n");
                var laborIntensityList = LoadLaborIntensityList(logger, Properties.Settings.Default.LIPMainDirectoryPath
                                                                , Properties.Settings.Default.LIPExcelFileName);
                logger.SuccessText($"Загружено {laborIntensityList.Count} записей\r\n\r\n");
                if (logger.IsClosed)
                {
                    return;
                }

                logger.DefaultBoldText($"Заполнение таблицы:\r\n");
                int rowCount = usedRange.GetLength(0);
                for (int row = 1; row <= rowCount; row++)
                {
                    foreach (var setting in settings)
                    {
                        // 0 - заказ, 1 - марка, 2 - норма/часы, 3 - норма/чвсы (без сварки)
                        if (usedRange[row, setting[0]] != null && usedRange[row, setting[1]] != null)
                        {
                            var laborIntensity = laborIntensityList.FirstOrDefault(x => x.Order == usedRange[row, setting[0]].ToString() &&
                                                                                   x.Mark == usedRange[row, setting[1]].ToString());
                            if (laborIntensity != null)
                            {
                                worksheet.Cells[row, setting[2]] = laborIntensity.HoursRate;
                                worksheet.Cells[row, setting[3]] = laborIntensity.HoursRateWithoutWelds;

                                logger.DefaultText($"[ст. {row}] - заказ {usedRange[row, setting[0]]}, марка {usedRange[row, setting[1]]}  ");
                                logger.DefaultBoldText($"(Н/ч = {laborIntensity.HoursRate}; Н/ч (без сварки) = {laborIntensity.HoursRateWithoutWelds}))\r\n");
                            }
                        }
                    }
                }

                logger.DefaultBoldText($"\r\nВыполнение завершено.\r\n");
            }
            catch (Exception ex)
            {
                logger.ExceptionText(ex);
            }
            finally
            {
                logger.Complete();
            }
        }
        private static List <LaborIntensity> LoadLaborIntensityList(LoggerForm logger, string path, string name)
        {
            var taskContainerList = Directory.GetDirectories(path)
                                    .Select(x => x + "\\" + name).Where(x => File.Exists(x))
                                    .Select(x => (Task: new Task <LaborIntensity[]>(() => LoadExcelWorksheetLists(x, 1).First().Skip(8)
                                                                                    .Where(y => y.Length >= 27 && !string.IsNullOrWhiteSpace(y[0]))
                                                                                    .Select(x => new LaborIntensity(x)).ToArray()), Path: x)).ToList();

            taskContainerList.ForEach(x => x.Task.Start());
            var completed = new List <Task <LaborIntensity[]> >();

            do
            {
                foreach (var taskContainer in taskContainerList)
                {
                    if (!completed.Contains(taskContainer.Task))
                    {
                        switch (taskContainer.Task.Status)
                        {
                        case TaskStatus.RanToCompletion:
                            logger.DefaultText($"{taskContainer.Path} ");
                            logger.DefaultBoldText($"(Получено {taskContainer.Task.Result.Count()})\r\n");
                            completed.Add(taskContainer.Task);
                            break;

                        case TaskStatus.Faulted:
                            logger.DefaultText($"{taskContainer.Path}\r\n");
                            logger.ErrorText($"Ошибка: {taskContainer.Task.Exception.InnerException.Message}\r\n");
                            completed.Add(taskContainer.Task);
                            break;
                        }
                    }
                }
                Thread.Sleep(50);
                if (logger.IsClosed)
                {
                    return(new List <LaborIntensity>());
                }
            }while (!taskContainerList.All(x => x.Task.IsCompleted));

            return(taskContainerList.Where(x => x.Task.Status == TaskStatus.RanToCompletion).SelectMany(x => x.Task.Result).ToList());
        }
        public static void SetWeldedAssembliesList(LoggerForm logger)
        {
            try
            {
                logger.DefaultBoldText("Подготовка к работе.");
                var worksheet = (Worksheet)Globals.ThisAddIn.Application.ActiveSheet;
                var usedRange = (object[, ])worksheet.UsedRange.get_Value(Type.Missing);
                var settings  = Properties.Settings.Default.WeldedAssembliesSetting.Split().Select((x, i) => (Value: int.Parse(x), Group: i / 4))
                                .GroupBy(x => x.Group).Where(x => x.All(x => x.Value > 0)).Select(x => x.Select(y => y.Value).ToArray()).ToArray();
                if (settings.Length <= 0 || !settings.All(x => x.Max() < usedRange.GetLength(1)))
                {
                    logger.ErrorText(" ⚠ НАСТРОЙКИ НЕ КОРРЕКТНЫ\r\n");
                    return;
                }
                logger.SuccessText(" ✓ ВЫПОЛНЕНО\r\n\r\n");

                logger.DefaultBoldText($"Сбор данных:\r\n");
                var laborIntensityList = LoadLaborIntensityList(logger, Properties.Settings.Default.WAMainDirectoryPath
                                                                , Properties.Settings.Default.WAExcelFileName);
                logger.SuccessText($"Загружено {laborIntensityList.Count} записей\r\n\r\n");
                if (logger.IsClosed)
                {
                    return;
                }

                logger.DefaultBoldText($"Заполнение таблицы:\r\n");
                int rowCount = usedRange.GetLength(0);
                for (int row = 1; row <= rowCount; row++)
                {
                    foreach (var setting in settings)
                    {
                        // 0 - заказ, 1 - марка, 2 - группа, 3 - норма
                        // if (setting.All(x => usedRange[row, x] != null))
                        if (usedRange[row, setting[0]] != null && usedRange[row, setting[1]] != null && usedRange[row, setting[2]] != null)
                        {
                            var laborIntensity = laborIntensityList.FirstOrDefault(x => x.Order == usedRange[row, setting[0]].ToString() &&
                                                                                   x.Mark == usedRange[row, setting[1]].ToString());
                            if (laborIntensity != null)
                            {
                                double?value = worksheet.Cells[row, setting[3]] = (usedRange[row, setting[2]].ToString()) switch
                                {
                                    "НО" => laborIntensity.NO1,
                                    "НО1" => laborIntensity.NO1,
                                    "НО1.1" => laborIntensity.NO11,
                                    "НО2" => laborIntensity.NO2,
                                    "НО2.1" => laborIntensity.NO21,
                                    "ГО1" => laborIntensity.GO1,
                                    "ГО2" => laborIntensity.GO2,
                                    "ГО1.1" => laborIntensity.GO11,
                                    "ГО1.2" => laborIntensity.GO12,
                                    _ => null,
                                };

                                logger.DefaultText($"[ст. {row}] - заказ {usedRange[row, setting[0]]}, марка {usedRange[row, setting[1]]}  ");

                                if (value.HasValue)
                                {
                                    logger.DefaultBoldText($"({usedRange[row, setting[2]]} = {value})\r\n");
                                }
                                else
                                {
                                    logger.ErrorText($"(Нет данных о группе [{usedRange[row, setting[2]]}]) \r\n");
                                }
                            }
                        }
                    }
                }

                logger.DefaultBoldText($"\r\nВыполнение завершено.\r\n");
            }
            catch (Exception ex)
            {
                logger.ExceptionText(ex);
            }
            finally
            {
                logger.Complete();
            }
        }