Esempio n. 1
0
 public UOMapMake()
 {
     this.Load          += new EventHandler(this.Form1_Load);
     this.iLogger        = new LoggerForm();
     this.i_RandomStatic = true;
     this.InitializeComponent();
 }
        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();
            }
        }
Esempio n. 3
0
        public Mul2Bmp()
        {
            Mul2Bmp mul2Bmp = this;

            base.Load   += new EventHandler(mul2Bmp.Mul2Bmp_Load);
            this.iLogger = new LoggerForm();
            this.InitializeComponent();
        }
Esempio n. 4
0
 public AltImagePrep()
 {
     this.Load     += new EventHandler(this.AltImagePrep_Load);
     this.iTerrain  = new ClsTerrainTable();
     this.iAltitude = new ClsAltitudeTable();
     this.iLogger   = new LoggerForm();
     this.InitializeComponent();
 }
 public DragonConv()
 {
     this.Load     += new EventHandler(this.DragonConv_Load);
     this.iTerrain  = new ClsTerrainTable();
     this.iAltitude = new ClsAltitudeTable();
     this.iDragon   = new ClsDragonTable();
     this.iLogger   = new LoggerForm();
     this.InitializeComponent();
 }
        public CreateFacet()
        {
            CreateFacet uOMapMake = this;

            base.Load          += new EventHandler(uOMapMake.Form1_Load);
            this.iLogger        = new LoggerForm();
            this.i_RandomStatic = true;
            InitializeComponent();
        }
        public CreateBitmaps()
        {
            CreateBitmaps makeMapImage = this;

            base.Load     += new EventHandler(makeMapImage.MakeMapImage_Load);
            this.iTerrain  = new ClsTerrainTable();
            this.iAltitude = new ClsElevationTable();
            this.iLogger   = new LoggerForm();
            InitializeComponent();
        }
        public CreateElevationBitmap()
        {
            CreateElevationBitmap altImagePrep = this;

            base.Load     += new EventHandler(altImagePrep.AltImagePrep_Load);
            this.iTerrain  = new ClsTerrainTable();
            this.iAltitude = new ClsElevationTable();
            this.iLogger   = new LoggerForm();
            InitializeComponent();
        }
        public MakeMapImage()
        {
            MakeMapImage makeMapImage = this;

            base.Load     += new EventHandler(makeMapImage.MakeMapImage_Load);
            this.iTerrain  = new ClsTerrainTable();
            this.iAltitude = new ClsAltitudeTable();
            this.iLogger   = new LoggerForm();
            this.InitializeComponent();
        }
Esempio n. 10
0
        public DragonConv()
        {
            DragonConv dragonConv = this;

            base.add_Load(new EventHandler(dragonConv, dragonConv.DragonConv_Load));
            this.iTerrain  = new ClsTerrainTable();
            this.iAltitude = new ClsAltitudeTable();
            this.iDragon   = new ClsDragonTable();
            this.iLogger   = new LoggerForm();
            this.InitializeComponent();
        }
Esempio n. 11
0
        public CompileYourNewMap()
        {
            MaximizeBox = false;
            MinimizeBox = false;
            CompileYourNewMap uOMapMake = this;

            base.Load          += new EventHandler(uOMapMake.Form1_Load);
            this.iLogger        = new LoggerForm();
            this.i_RandomStatic = true;
            InitializeComponent();
        }
        public GenerateMapTemplate()
        {
            MaximizeBox = false;
            MinimizeBox = false;
            GenerateMapTemplate makeMapImage = this;

            base.Load     += new EventHandler(makeMapImage.MakeMapImage_Load);
            this.iTerrain  = new ClsTerrainTable();
            this.iAltitude = new ClsAltitudeTable();
            this.iLogger   = new LoggerForm();
            InitializeComponent();
        }
        public EncodeAltitudeBitmap()
        {
            MaximizeBox = false;
            MinimizeBox = false;
            EncodeAltitudeBitmap altImagePrep = this;

            base.Load     += new EventHandler(altImagePrep.AltImagePrep_Load);
            this.iTerrain  = new ClsTerrainTable();
            this.iAltitude = new ClsAltitudeTable();
            this.iLogger   = new LoggerForm();
            InitializeComponent();
        }
Esempio n. 14
0
        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());
        }
Esempio n. 15
0
 public abstract void SetWorkingHours(LoggerForm logger);
Esempio n. 16
0
 public Mul2Bmp()
 {
     this.Load   += new EventHandler(this.Mul2Bmp_Load);
     this.iLogger = new LoggerForm();
     this.InitializeComponent();
 }
Esempio n. 17
0
        private void Make()
        {
            short           altID = 0;
            string          str;
            byte            num = 0;
            int             num1;
            int             num2;
            int             num3;
            int             num4;
            IEnumerator     enumerator      = null;
            TransitionTable transitionTable = new TransitionTable();
            DateTime        now             = DateTime.Now;

            this.iLogger.StartTask();
            this.iLogger.LogMessage("Loading Terrain Image.");
            try
            {
                str = string.Format("{0}\\{1}", this.ProjectPath.Text, this.TerrainFile.Text);
                this.iLogger.LogMessage(str);
                this.i_Terrain = new Bitmap(str);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                this.iLogger.LogMessage("Problem with Loading Terrain Image.");
                this.iLogger.LogMessage(exception.Message);
                ProjectData.ClearProjectError();
                return;
            }
            this.iLogger.LogMessage("Loading Altitude Image.");
            try
            {
                str = string.Format("{0}\\{1}", this.ProjectPath.Text, this.AltitudeFile.Text);
                this.iLogger.LogMessage(str);
                this.i_Altitude = new Bitmap(str);
            }
            catch (Exception exception3)
            {
                ProjectData.SetProjectError(exception3);
                Exception exception2 = exception3;
                this.iLogger.LogMessage("Problem with Loading Altitude Image.");
                this.iLogger.LogMessage(exception2.Message);
                ProjectData.ClearProjectError();
                return;
            }
            //this.iLogger.EndTask();
            this.iLogger.LogTimeStamp();
            this.iLogger.LogMessage("Preparing Image Files.");
            this.iLogger.StartTask();
            int        width       = this.i_Terrain.Width;
            int        height      = this.i_Terrain.Height;
            Rectangle  rectangle   = new Rectangle(0, 0, width, height);
            BitmapData bitmapDatum = this.i_Terrain.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
            IntPtr     scan0       = bitmapDatum.Scan0;
            int        width1      = checked (bitmapDatum.Width * bitmapDatum.Height);

            byte[] numArray = new byte[checked (checked (width1 - 1) + 1)];
            Marshal.Copy(scan0, numArray, 0, width1);
            BitmapData bitmapDatum1 = this.i_Altitude.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
            IntPtr     intPtr       = bitmapDatum1.Scan0;
            int        width2       = checked (bitmapDatum1.Width * bitmapDatum1.Height);

            byte[] numArray1 = new byte[checked (checked (width2 - 1) + 1)];
            Marshal.Copy(intPtr, numArray1, 0, width2);
            //this.iLogger.EndTask();
            this.iLogger.LogTimeStamp();
            this.iLogger.LogMessage("Creating Master Terrian Table.");
            this.iLogger.StartTask();
            MapCell[,] mapCell = new MapCell[checked (width + 1), checked (height + 1)];
            ClsAltitudeTable clsAltitudeTable = new ClsAltitudeTable();

            clsAltitudeTable.Load();
            try
            {
                int num5 = checked (width - 1);
                for (int i = 0; i <= num5; i++)
                {
                    int num6 = checked (height - 1);
                    for (int j = 0; j <= num6; j++)
                    {
                        int         num7        = checked (checked (j * width) + i);
                        ClsAltitude getAltitude = clsAltitudeTable.GetAltitude(numArray1[num7]);
                        mapCell[i, j] = new MapCell(numArray[num7], getAltitude.GetAltitude);
                    }
                }
            }
            catch (Exception exception4)
            {
                ProjectData.SetProjectError(exception4);
                this.iLogger.LogMessage("Altitude image needs to be rebuilt");
                ProjectData.ClearProjectError();
                return;
            }
            this.i_Terrain.Dispose();
            this.i_Altitude.Dispose();
            this.iLogger.LogTimeStamp();
            width--;
            height--;
            int num8 = checked ((int)Math.Round((double)width / 8 - 1));
            int num9 = checked ((int)Math.Round((double)height / 8 - 1));

            this.iLogger.LogMessage("Load Transition Tables.");
            this.iLogger.StartTask();
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            #region Data Directory Modification

            baseDirectory = string.Concat(baseDirectory, "Data\\Engine\\Transitions\\");

            #endregion

            if (Directory.Exists(baseDirectory))
            {
                transitionTable.MassLoad(baseDirectory);
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("Preparing Static Tables");
                Collection[,] collections = new Collection[checked (num8 + 1), checked (num9 + 1)];
                int num10 = num8;
                for (int k = 0; k <= num10; k++)
                {
                    int num11 = num9;
                    for (int l = 0; l <= num11; l++)
                    {
                        collections[k, l] = new Collection();
                    }
                }
                this.iLogger.LogMessage("Applying Transition Tables.");
                this.iLogger.StartTask();
                this.ProgressBar1.Maximum = width;
                ClsTerrainTable clsTerrainTable = new ClsTerrainTable();
                clsTerrainTable.Load();
                MapTile mapTile = new MapTile();
                Transition.Transition transition = new Transition.Transition();
                short[] numArray2 = new short[16];
                short   num12     = checked ((short)width);
                for (short m = 0; m <= num12; m = checked ((short)(m + 1)))
                {
                    num1 = (m != 0 ? checked (m - 1) : width);
                    num2 = (m != width ? checked (m + 1) : 0);
                    short num13 = checked ((short)height);
                    for (short n = 0; n <= num13; n = checked ((short)(n + 1)))
                    {
                        num4 = (n != 0 ? checked (n - 1) : height);
                        num3 = (n != height ? checked (n + 1) : 0);
                        object[] groupID = new object[] { mapCell[num1, num4].GroupID, mapCell[m, num4].GroupID, mapCell[num2, num4].GroupID, mapCell[num1, n].GroupID, mapCell[m, n].GroupID, mapCell[num2, n].GroupID, mapCell[num1, num3].GroupID, mapCell[m, num3].GroupID, mapCell[num2, num3].GroupID };
                        string   str1    = string.Format("{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}", groupID);
                        try
                        {
                            transition = (Transition.Transition)(transitionTable.GetTransitionTable[str1]);

                            if (transition == null)
                            {
                                ClsTerrain terrianGroup = clsTerrainTable.TerrianGroup(mapCell[m, n].GroupID);
                                mapCell[m, n].TileID = terrianGroup.TileID;
                                mapCell[m, n].AltID  = altID;
                                terrianGroup         = null;
                            }
                            else
                            {
                                altID   = mapCell[m, n].AltID;
                                mapTile = transition.GetRandomMapTile();
                                if (mapTile == null)
                                {
                                    ClsTerrain clsTerrain = clsTerrainTable.TerrianGroup(mapCell[m, n].GroupID);
                                    mapCell[m, n].TileID = clsTerrain.TileID;
                                    mapCell[m, n].ChangeAltID((short)clsTerrain.AltID);
                                    clsTerrain = null;
                                }
                                else
                                {
                                    MapTile mapTile1 = mapTile;
                                    mapCell[m, n].TileID = mapTile1.TileID;
                                    mapCell[m, n].ChangeAltID(mapTile1.AltIDMod);
                                    mapTile1 = null;
                                }
                                transition.GetRandomStaticTiles(m, n, altID, collections, this.i_RandomStatic);
                            }
                            if (mapCell[m, n].GroupID == 254)
                            {
                                mapCell[m, n].TileID = 1078;
                                mapCell[m, n].AltID  = 0;
                            }
                        }
                        catch (Exception exception6)
                        {
                            ProjectData.SetProjectError(exception6);
                            Exception  exception5 = exception6;
                            LoggerForm loggerForm = this.iLogger;
                            groupID = new object[] { m, n, altID, str1 };
                            loggerForm.LogMessage(string.Format("\r\nLocation: X:{0}, Y:{1}, Z:{2} Hkey:{3}", groupID));
                            this.iLogger.LogMessage(exception5.ToString());
                            ProjectData.ClearProjectError();
                            return;
                        }
                    }
                    this.ProgressBar1.Value = m;
                }
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("Second Pass.");
                this.iLogger.StartTask();
                short[]   altID1    = new short[9];
                RoughEdge roughEdge = new RoughEdge();
                short     num14     = checked ((short)width);
                for (short o = 0; o <= num14; o = checked ((short)(o + 1)))
                {
                    num1 = (o != 0 ? checked (o - 1) : width);
                    num2 = (o != width ? checked (o + 1) : 0);
                    short num15 = checked ((short)height);
                    for (short p = 0; p <= num15; p = checked ((short)(p + 1)))
                    {
                        num4 = (p != 0 ? checked (p - 1) : height);
                        num3 = (p != height ? checked (p + 1) : 0);
                        mapCell[o, p].ChangeAltID(roughEdge.CheckCorner(mapCell[num1, num4].TileID));
                        mapCell[o, p].ChangeAltID(roughEdge.CheckLeft(mapCell[num1, p].TileID));
                        mapCell[o, p].ChangeAltID(roughEdge.CheckTop(mapCell[o, num4].TileID));
                        if (mapCell[o, p].GroupID == 20)
                        {
                            altID1[0] = mapCell[num1, num4].AltID;
                            altID1[1] = mapCell[o, num4].AltID;
                            altID1[2] = mapCell[num2, num4].AltID;
                            altID1[3] = mapCell[num1, p].AltID;
                            altID1[4] = mapCell[o, p].AltID;
                            altID1[5] = mapCell[num2, p].AltID;
                            altID1[6] = mapCell[num1, num3].AltID;
                            altID1[7] = mapCell[o, num3].AltID;
                            altID1[8] = mapCell[num2, num3].AltID;
                            Array.Sort(altID1);
                            float single = 10f * VBMath.Rnd();
                            if (single == 0f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] - 4)));
                            }
                            else if (single >= 1f && single <= 2f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] - 2)));
                            }
                            else if (single >= 3f && single <= 7f)
                            {
                                mapCell[o, p].AltID = altID1[8];
                            }
                            else if (single >= 8f && single <= 9f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] + 2)));
                            }
                            else if (single == 10f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] + 4)));
                            }
                        }

                        if (clsTerrainTable.TerrianGroup(mapCell[o, p].GroupID).RandAlt)
                        {
                            float single1 = 10f * VBMath.Rnd();
                            if (single1 == 0f)
                            {
                                mapCell[o, p].ChangeAltID(-4);
                            }
                            else if (single1 >= 1f && single1 <= 2f)
                            {
                                mapCell[o, p].ChangeAltID(-2);
                            }
                            else if (single1 >= 8f && single1 <= 9f)
                            {
                                mapCell[o, p].ChangeAltID(2);
                            }
                            else if (single1 == 10f)
                            {
                                mapCell[o, p].ChangeAltID(4);
                            }
                        }
                    }
                    this.ProgressBar1.Value = o;
                }
                this.iLogger.LogTimeStamp();
                int num16 = 1;
                int num17 = width;
                if (num17 == 6143)
                {
                    num = 0;
                }
                else if (num17 == 2303)
                {
                    num = 2;
                }
                else if (num17 == 2559)
                {
                    num = 3;
                }
                this.iLogger.LogMessage("\r\n");
                this.iLogger.LogMessage("Load . . . . . Import Tiles.");
                this.iLogger.StartTask();
                ImportTiles importTile = new ImportTiles(collections, this.ProjectPath.Text);
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("\r\n");
                this.iLogger.LogMessage("Write Mul Files.");
                this.iLogger.StartTask();
                str = string.Format("{0}/Map{1}.mul", this.ProjectPath.Text, num);
                this.iLogger.LogMessage(str);
                FileStream   fileStream   = new FileStream(str, FileMode.Create);
                BinaryWriter binaryWriter = new BinaryWriter(fileStream);
                int          num18        = width;
                for (int q = 0; q <= num18; q = checked (q + 8))
                {
                    int num19 = height;
                    for (int r = 0; r <= num19; r = checked (r + 8))
                    {
                        binaryWriter.Write(num16);
                        int num20 = 0;
                        do
                        {
                            int num21 = 0;
                            do
                            {
                                mapCell[checked (q + num21), checked (r + num20)].WriteMapMul(binaryWriter);
                                num21++;
                            }while (num21 <= 7);
                            num20++;
                        }while (num20 <= 7);
                    }
                }
                binaryWriter.Close();
                fileStream.Close();
                str = string.Format("{0}/StaIdx{1}.mul", this.ProjectPath.Text, num);
                FileStream fileStream1 = new FileStream(str, FileMode.Create);
                this.iLogger.LogMessage(str);
                str = string.Format("{0}/Statics{1}.mul", this.ProjectPath.Text, num);
                FileStream fileStream2 = new FileStream(str, FileMode.Create);
                this.iLogger.LogMessage(str);
                BinaryWriter binaryWriter1 = new BinaryWriter(fileStream1);
                BinaryWriter binaryWriter2 = new BinaryWriter(fileStream2);
                int          num22         = num8;
                for (int s = 0; s <= num22; s++)
                {
                    int num23 = num9;
                    for (int t = 0; t <= num23; t++)
                    {
                        int num24    = 0;
                        int position = checked ((int)binaryWriter2.BaseStream.Position);
                        try
                        {
                            enumerator = collections[s, t].GetEnumerator();
                            while (enumerator.MoveNext())
                            {
                                ((StaticCell)enumerator.Current).Write(binaryWriter2);
                                num24 = checked (num24 + 7);
                            }
                        }
                        finally
                        {
                            if (enumerator is IDisposable)
                            {
                                ((IDisposable)enumerator).Dispose();
                            }
                        }
                        if (num24 == 0)
                        {
                            position = -1;
                        }
                        binaryWriter1.Write(position);
                        binaryWriter1.Write(num24);
                        binaryWriter1.Write(num16);
                    }
                }
                binaryWriter2.Close();
                binaryWriter1.Close();
                fileStream2.Close();
                fileStream1.Close();
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("Done.");
            }
            else
            {
                this.iLogger.LogMessage("Unable to find Transition Data files in the following path: ");
                this.iLogger.LogMessage(baseDirectory);
            }
        }
Esempio n. 18
0
        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();
            }
        }
Esempio n. 19
0
 public abstract void TestConnection(LoggerForm logger, string connectionString, string login, string password);