示例#1
0
        private void getImageForecast(ItExecutionPlanShopModel itExecutionPlanShopModel)
        {
            Bitmap bitmap = new Bitmap(240, 150);

            using (Graphics graphic = Graphics.FromImage(bitmap))
            {
                Font       font      = new Font("Arial", 23);
                SolidBrush drawBrush = new SolidBrush(Color.Gray);

                float x = 40;
                float y = 0;

                graphic.Clear(Color.White);
                graphic.DrawString("Прогноз", font, drawBrush, x, y);

                Pen pen = new Pen(Color.Gray, 3);

                Point[] points =
                {
                    new Point(45,   20),
                    new Point(5,    20),
                    new Point(5,   145),
                    new Point(235, 145),
                    new Point(235,  20),
                    new Point(165, 20)
                };
                graphic.DrawLines(pen, points);

                Decimal decPercentForForecast = 0;

                if (itExecutionPlanShopModel != null)
                {
                    decPercentForForecast = Convert.ToDecimal(itExecutionPlanShopModel.PercentForecast);
                }

                string percentForForecast = $"{Math.Round(decPercentForForecast, 1)}%";

                font = new Font("Arial", 50);

                if (decPercentForForecast < 100)
                {
                    drawBrush = new SolidBrush(Color.Red);
                }

                if (decPercentForForecast >= 100)
                {
                    drawBrush = new SolidBrush(Color.Green);
                }

                x = 10;
                y = 50;

                graphic.DrawString(percentForForecast, font, drawBrush, x, y);
            }
            bitmap.Save("PlanForecast.png", System.Drawing.Imaging.ImageFormat.Png);
        }
示例#2
0
        public async Task getImagePerForecast(int stockId)
        {
            stockId = FirstShop(stockId);

            ItExecutionPlanShop itExecutionPlanShop = await _iitExecutionPlanShopRepository.getInfoForStockId(stockId);

            ItExecutionPlanShopModel itExecutionPlanShopModel = _mapper.Map <ItExecutionPlanShop, ItExecutionPlanShopModel>(itExecutionPlanShop);

            getImageForecast(itExecutionPlanShopModel);
        }
示例#3
0
        private Bitmap getImagePlanDay(ItExecutionPlanShopModel itExecutionPlanShopModel)
        {
            Bitmap bitmap = new Bitmap(450, 150);

            using (Graphics graphic = Graphics.FromImage(bitmap))
            {
                int nDigitsFactDay = 0;
                int nDigitsPlanDay = 0;

                if (itExecutionPlanShopModel != null)
                {
                    nDigitsFactDay = nDigits(itExecutionPlanShopModel.FactDay);
                    nDigitsPlanDay = nDigits(itExecutionPlanShopModel.PlanDay);
                }

                if (nDigitsFactDay == 0)
                {
                    nDigitsFactDay++;
                }

                if (nDigitsPlanDay == 0)
                {
                    nDigitsPlanDay++;
                }
                Font       font      = new Font("Arial", 23);
                SolidBrush drawBrush = new SolidBrush(Color.Gray);

                float x = 40;
                float y = 0;

                graphic.Clear(Color.White);
                graphic.DrawString("Сегодня", font, drawBrush, x, y);

                Pen pen = new Pen(Color.Gray, 3);

                Point[] points =
                {
                    new Point(45,   20),
                    new Point(5,    20),
                    new Point(5,   145),
                    new Point(445, 145),
                    new Point(445,  20),
                    new Point(165, 20)
                };
                graphic.DrawLines(pen, points);

                Decimal decPercentForDay = 0;

                if (itExecutionPlanShopModel != null)
                {
                    decPercentForDay = Convert.ToDecimal(itExecutionPlanShopModel.PercentForDay);
                }

                string percentForDay = $"{Math.Round(decPercentForDay, 1)}%";

                font = new Font("Arial", 50);

                if (decPercentForDay < 100)
                {
                    drawBrush = new SolidBrush(Color.Red);
                }

                if (decPercentForDay >= 100)
                {
                    drawBrush = new SolidBrush(Color.Green);
                }

                x = 20;
                y = 50;

                graphic.DrawString(percentForDay, font, drawBrush, x, y);

                string f = $"Ф:";
                font      = new Font("Arial", 28);
                drawBrush = new SolidBrush(Color.Gray);
                x         = 250;
                y         = 40;

                graphic.DrawString(f, font, drawBrush, x, y);

                Decimal decFactDay = 0;

                if (itExecutionPlanShopModel != null)
                {
                    decFactDay = Convert.ToDecimal(itExecutionPlanShopModel.FactDay);
                }

                string formatFactDay = formatDecimal(decFactDay);
                string factDay       = $"{formatFactDay}";

                font      = new Font("Arial", 28);
                drawBrush = new SolidBrush(Color.Gray);
                x         = 450 - (nDigitsFactDay * 25) - 10;
                y         = 40;

                graphic.DrawString(factDay, font, drawBrush, x, y);

                string p = $"П:";
                font      = new Font("Arial", 28);
                drawBrush = new SolidBrush(Color.Gray);
                x         = 250;
                y         = 90;

                graphic.DrawString(p, font, drawBrush, x, y);

                Decimal decPlanDay = 0;

                if (itExecutionPlanShopModel != null)
                {
                    decPlanDay = Convert.ToDecimal(itExecutionPlanShopModel.PlanDay);
                }

                string formatPlanDay = formatDecimal(decPlanDay);
                string planDay       = $"{formatPlanDay}";

                font      = new Font("Arial", 28);
                drawBrush = new SolidBrush(Color.Gray);
                x         = 450 - (nDigitsPlanDay * 25) - 10;
                y         = 90;

                graphic.DrawString(planDay, font, drawBrush, x, y);
            }
            bitmap.Save("PlanDay.png", System.Drawing.Imaging.ImageFormat.Png);

            return(bitmap);
        }