Exemple #1
0
        public static ChartModel GetChartListBS(ChartInput input)
        {
            ChartModel response = new ChartModel();

            input.lstAreaId    = input.AreaId.Split(',').ToList();
            input.lstCountryId = input.CountryId.Split(',').ToList();
            input.lstProductId = input.ProductId.Split(',').ToList();

            response = ChartListDSForPJ.GetBarChartListDS(input);
            return(response);
        }
Exemple #2
0
 public void DrawGaugeArea(SKCanvas canvas, ChartInput input, float radius, int cx, int cy, float strokeWidth)
 {
     using (var paint = new SKPaint
     {
         Style = SKPaintStyle.Stroke,
         StrokeWidth = strokeWidth,
         Color = input.Color.WithAlpha(LineAreaAlpha),
         IsAntialias = true,
     })
     {
         canvas.DrawCircle(cx, cy, radius, paint);
     }
 }
Exemple #3
0
        public ChartInputModelView(Action drawChartAction)
        {
            this.drawChart = drawChartAction;

            chartInput = new ChartInput
            {
                filesPaths      = "values_matrix.txt;xGrid.txt;yGrid.txt",
                numberOfRows    = 512,
                numberOfColumns = 125,
                xRes            = 2,
                yRes            = 1.5,
                xResValues      = new List <double>(),
                yResValues      = new List <double>(),
                xLabel          = "X Label",
                yLabel          = "Y Label"
            };
        }
Exemple #4
0
 public void DrawGauge(SKCanvas canvas, ChartInput input, float radius, int cx, int cy, float strokeWidth)
 {
     using (var paint = new SKPaint
     {
         Style = SKPaintStyle.Stroke,
         StrokeWidth = strokeWidth,
         StrokeCap = SKStrokeCap.Round,
         Color = input.Color,
         IsAntialias = true,
     })
     {
         using (SKPath path = new SKPath())
         {
             var sweepAngle = AnimationProgress * 360 * (Math.Abs(input.Value) - AbsoluteMinimum) / ValueRange;
             path.AddArc(SKRect.Create(cx - radius, cy - radius, 2 * radius, 2 * radius), StartAngle, sweepAngle);
             canvas.DrawPath(path, paint);
         }
     }
 }
Exemple #5
0
        public static ChartModel GetBarChartListDS(ChartInput input)
        {
            ChartModel response = new ChartModel();
            string     countryName = "";
            string     productName = "";
            int        productID, countryID = 0;

            using (PJEntities entity = new PJEntities())
            {
                var patientJourneyData       = from r in entity.Patient_Journey select r;
                var patientJourneystagesData = from r in entity.Patient_Journey_Stages.OrderBy(x => x.Stage_Display_Order) select r;
                var countryData      = from r in entity.Country_Master select r;
                var brandData        = from r in entity.Brand_Master select r;
                var stageMasterData  = from r in entity.Stage_Master select r;
                var statusMasterData = from r in entity.Status_Master select r;

                List <TimeStatisticsProduct> timeStatsWithProd = new List <TimeStatisticsProduct>();

                for (int j = 0; j < input.lstProductId.Count; j++)
                {
                    List <TimeStatistics> listWithCountry       = new List <TimeStatistics>();
                    TimeStatisticsProduct timeStatisticsProduct = new TimeStatisticsProduct();
                    productID = Convert.ToInt32(input.lstProductId[j]);
                    for (int i = 0; i < input.lstCountryId.Count; i++)
                    {
                        TimeStatistics timeStatistics = new BusinessModel.TimeStatistics();
                        countryID = Convert.ToInt32(input.lstCountryId[i]);

                        int patientJourneyId = 0;

                        patientJourneyId = patientJourneyData.Where(x => x.Country_Master_Id == countryID &&
                                                                    x.Brand_Master_Id == productID && x.Year == input.Year && x.Status_Master_Id == 3).
                                           Select(x => x.Patient_Journey_Id).FirstOrDefault();

                        if (patientJourneyId == 0)
                        {
                            patientJourneyId = patientJourneyData.Where(x => x.Country_Master_Id == countryID &&
                                                                        x.Brand_Master_Id == productID && x.Year == input.Year && x.Status_Master_Id == 7).
                                               Select(x => x.Patient_Journey_Id).FirstOrDefault();
                        }

                        response.BarchartList = (from kd in patientJourneystagesData
                                                 join c in stageMasterData on kd.Stage_Master_Id equals c.Stage_Master_Id
                                                 where kd.Patient_Journey_Id == patientJourneyId
                                                 select new BarChartData()
                        {
                            ID = kd.Patient_Journey_Stages_Id,
                            GroupName = c.Stage_Name,
                            StageName = c.Stage_Name,
                            Value = kd.Time_Statistics,
                            PopulationValue = (kd.Population_Statistics / 100),
                            StageDisplayOrder = kd.Stage_Display_Order
                        }).ToList();

                        countryName = countryData.FirstOrDefault(ci => ci.Country_Master_Id == countryID).Country_Name;

                        timeStatistics.country      = countryName;
                        timeStatistics.countryId    = countryID;
                        timeStatistics.BarchartList = response.BarchartList;
                        listWithCountry.Add(timeStatistics);
                    }
                    productName = brandData.FirstOrDefault(ci => ci.Brand_Master_Id == productID).Brand_Name;
                    timeStatisticsProduct.ProductName   = productName;
                    timeStatisticsProduct.ProductId     = productID;
                    timeStatisticsProduct.timeStatsList = listWithCountry;
                    timeStatsWithProd.Add(timeStatisticsProduct);
                }
                //country - colours mapping
                //only for 5 countries
                List <CountryColour> countryColourList = new List <CountryColour>();
                string[]             coloursArry       = new string[] { "#84BD00", "#6699C9", "#F49D45", "#996699", "#F2594B" };
                for (int i = 0; i < input.lstCountryId.Count; i++)
                {
                    CountryColour countryColour = new CountryColour();
                    countryColour.Colour = coloursArry[i];
                    int countryIDColour = Convert.ToInt32(input.lstCountryId[i]);
                    countryColour.CountryID   = countryIDColour;
                    countryName               = countryData.FirstOrDefault(ci => ci.Country_Master_Id == countryIDColour).Country_Name;
                    countryColour.CountryName = countryName;
                    countryColourList.Add(countryColour);
                }
                response.countryColourList         = countryColourList;
                response.timeStatisticsProductData = timeStatsWithProd;
            }
            return(response);
        }
Exemple #6
0
        public ChartOutput Loc(ChartInput input)
        {
            var result = new ChartOutput();
            var data   = new List <ChartOutputItem>();

            var    fields       = input.fields.Split(new string[] { "##" }, StringSplitOptions.None);
            var    fieldsLength = fields.Length;
            var    values       = input.values.Split(new string[] { "##" }, StringSplitOptions.None);
            string function     = "";
            var    tuNgay       = string.IsNullOrEmpty(input.tuNgay) ? DateTime.MinValue : DateTime.ParseExact(input.tuNgay, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            var    denNgay      = string.IsNullOrEmpty(input.denNgay) ? DateTime.MaxValue : DateTime.ParseExact(input.denNgay, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            var listVanBan = new List <VanBan>();

            using (var db = new BCDHContext())
            {
                var vanBan = db.VanBan.
                             Where(x => x.PhanMem == input.maPhanMem &&
                                   (x.DonViXuLyChinh == input.maDonVi ||
                                    x.DonViXuLyChinh == input.maDonVi)
                                   )
                             .ToList();

                //vanBan = vanBan.Where(
                //    x => (DateTime.ParseExact(HttpUtility.UrlDecode(x.NgayGiao), "dd/MM/yyyy", CultureInfo.InvariantCulture) >= tuNgay)
                //    && (DateTime.ParseExact(HttpUtility.UrlDecode(x.NgayGiao), "dd/MM/yyyy", CultureInfo.InvariantCulture) <= denNgay))
                //    .ToList();

                foreach (var item in vanBan)
                {
                    string ngayGiao = HttpUtility.UrlDecode(item.NgayGiao);

                    if (string.IsNullOrEmpty(ngayGiao))
                    {
                        continue;
                    }

                    if (DateTime.ParseExact(ngayGiao, "dd/MM/yyyy", CultureInfo.InvariantCulture) >= tuNgay &&
                        DateTime.ParseExact(ngayGiao, "dd/MM/yyyy", CultureInfo.InvariantCulture) <= denNgay)
                    {
                        listVanBan.Add(item);
                    }
                }

                vanBan.Clear();
                vanBan.AddRange(listVanBan);

                for (int i = 0; i < fieldsLength; i++)
                {
                    if (fields[i] == "TrangThaiChung")
                    {
                        if (i == fieldsLength - 1)
                        {
                            if (values[i] == "null")
                            {
                                var listTrangThaiChung = db.TrangThaiChung.ToList();
                                foreach (var item in listTrangThaiChung)
                                {
                                    var value           = vanBan.Where(x => x.MaTrangThaiChung == item.Ma).Count();
                                    var chartOutputItem = new ChartOutputItem
                                    {
                                        title = item.Ten,
                                        code  = item.Ma,
                                        value = value
                                    };

                                    data.Add(chartOutputItem);
                                }
                                result.type     = "cot";
                                result.title    = "Biểu đồ theo trạng thái";
                                result.function = function + "TrangThaiChung";
                            }
                            else
                            {
                                var maTrangThaiChung = values[i];
                                var trangThaiChung   = db.TrangThaiChung.Where(x => x.Ma == maTrangThaiChung).FirstOrDefault();
                                var value            = vanBan.Where(x => x.MaTrangThaiChung == maTrangThaiChung).ToList().Count();

                                var charOutputItem = new ChartOutputItem
                                {
                                    title = trangThaiChung.Ten,
                                    code  = maTrangThaiChung,
                                    value = value
                                };

                                data.Add(charOutputItem);

                                result.type     = "cot";
                                result.title    = "Biểu đồ theo trạng thái";
                                result.function = function + "TrangThaiChung";
                            }
                        }
                        else
                        {
                            var trangThai = values[i];
                            vanBan    = vanBan.Where(x => x.MaTrangThaiChung == trangThai).ToList();
                            function += fields[i] + "##";
                        }
                    }

                    if (fields[i] == "TinhTrang")
                    {
                        if (i == fieldsLength - 1)
                        {
                            if (values[i] == "null")
                            {
                                var listTinhTrang = db.TinhTrang.ToList();

                                foreach (var item in listTinhTrang)
                                {
                                    var value = vanBan.Where(x => x.MaTinhTrang == item.Ma).Count();

                                    var chartOutputItem = new ChartOutputItem
                                    {
                                        title = item.Ten,
                                        code  = item.Ma,
                                        value = value
                                    };

                                    data.Add(chartOutputItem);
                                }

                                result.type     = "cot";
                                result.title    = "Biểu đồ theo tình trạng xử lý";
                                result.function = function + "TinhTrang";
                            }
                            else
                            {
                                var maTinhTrang = values[i];
                                var tinhTrang   = db.TinhTrang.Where(x => x.Ma == maTinhTrang).FirstOrDefault();
                                var value       = vanBan.Where(x => x.MaTinhTrang == maTinhTrang).ToList().Count();

                                var charOutputItem = new ChartOutputItem
                                {
                                    title = tinhTrang.Ten,
                                    code  = maTinhTrang,
                                    value = value
                                };

                                data.Add(charOutputItem);

                                result.type     = "cot";
                                result.title    = "Biểu đồ theo tình trạng xử lý";
                                result.function = function + "TinhTrang";
                            }
                        }
                        else
                        {
                            var tinhTrang = values[i];
                            vanBan    = vanBan.Where(x => x.MaTinhTrang == tinhTrang).ToList();
                            function += fields[i] + "##";
                        }
                    }

                    if (fields[i] == "TrangThaiPhanMem")
                    {
                        if (i == fieldsLength)
                        {
                            if (values[i] == "null")
                            {
                                var listTrangThaiPhanMem = db.TrangThaiPhanMem.ToList();
                                foreach (var item in listTrangThaiPhanMem)
                                {
                                    var value = vanBan.Where(x => x.MaTrangThaiPhanMem == item.Ma).Count();

                                    var chartOutputItem = new ChartOutputItem
                                    {
                                        title = item.Ten,
                                        code  = item.Ma,
                                        value = value
                                    };

                                    data.Add(chartOutputItem);
                                }

                                result.type     = "cot";
                                result.title    = "Biểu đồ theo trạng thái phần mềm";
                                result.function = function + "TrangThaiPhanMem";
                            }
                            else
                            {
                                var maTrangThaiPhanMem = values[i];
                                var trangThaiPhanMem   = db.TrangThaiPhanMem.Where(x => x.Ma == maTrangThaiPhanMem).FirstOrDefault();
                                var value = vanBan.Where(x => x.MaTrangThaiPhanMem == maTrangThaiPhanMem).ToList().Count();

                                var charOutputItem = new ChartOutputItem
                                {
                                    title = trangThaiPhanMem.Ten,
                                    code  = maTrangThaiPhanMem,
                                    value = value
                                };

                                data.Add(charOutputItem);

                                result.type     = "cot";
                                result.title    = "Biểu đồ theo trạng thái phần mềm";
                                result.function = function + "TrangThaiPhanMem";
                            }
                        }

                        else
                        {
                            var trangThaiPhanMem = values[i];
                            vanBan    = vanBan.Where(x => x.MaTrangThaiPhanMem == trangThaiPhanMem).ToList();
                            function += fields[i] + "##";
                        }
                    }
                }

                var listAvailable = new List <string> {
                    "TrangThaiChung", "TinhTrang", "TrangThaiPhanMem"
                };
                var available = "";

                foreach (var item in listAvailable)
                {
                    if (!input.fields.Contains(item))
                    {
                        available += item + "##";
                    }
                }

                result.data      = data;
                result.available = available;
                return(result);
            }
        }
 public ChartOutput Loc(ChartInput input)
 {
     throw new NotImplementedException();
 }