コード例 #1
0
        public IActionResult GetReportChartTimeLine([FromBody] ReportChart aYear)
        {
            IList <BookingTimeChartModelView> _LstBookingTimeModelViews = new List <BookingTimeChartModelView>();
            //Get the Availability tb for current vehicle(List) in the current date..
            IQueryable <VehicleAvailability> _VehicleAvailability = _context.VehicleAvailabilities.Where(e => e.Date == aYear.Date);

            foreach (var _vehicleAvailability in _VehicleAvailability)
            {
                //Get the booking row from db
                string _MyBookedTime = _vehicleAvailability.BookingTime;
                //Split to string
                string[] _MyBookedTimeArrayStr = _MyBookedTime.Split(",");
                //Remove the white or empty index
                _MyBookedTimeArrayStr = _MyBookedTimeArrayStr.Where(x => !string.IsNullOrEmpty(x)).ToArray();
                _MyBookedTimeArrayStr = _MyBookedTimeArrayStr.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
                //sort it
                // Array.Sort(_MyBookedTimeArrayStr);
                Queue <int> q = new Queue <int>();
                //convert to int list
                for (int i = 0; i < _MyBookedTimeArrayStr.Length; i++)
                {
                    q.Enqueue(Convert.ToInt32(_MyBookedTimeArrayStr[i]));
                }
                while (q.Count() > 0)
                {
                    BookingTimeChartModelView _bookingtime = new BookingTimeChartModelView()
                    {
                        //Get the first time slid
                        VehicleId   = _vehicleAvailability.VehicleId,
                        Date        = _vehicleAvailability.Date,
                        PickUpTime  = q.Dequeue(),
                        DropOffTime = q.Dequeue()
                    };
                    //Add to the main list
                    _LstBookingTimeModelViews.Add(_bookingtime);
                }
            }

            //joing with vehicle to get the model of the car...
            var result = from lst in _LstBookingTimeModelViews
                         join ve in _context.Vehicles on lst.VehicleId equals ve.Id
                         select new
            {
                registration = ve.Registration,
                date         = lst.Date,
                pickuptime   = lst.PickUpTime,
                dropofftime  = lst.DropOffTime
            };


            var chartData = new object[result.Count()];
            int j         = 0;

            foreach (var i in result)
            {
                chartData[j] = new object[] { i.registration.ToString(), i.date, i.pickuptime, i.dropofftime };
                j++;
            }
            return(Ok(chartData));
        }
コード例 #2
0
        public IActionResult GetReportChart([FromBody] ReportChart aYear)
        {
            int Year         = Convert.ToInt32(aYear.aYear);
            var _Reservation = _context.Reservations.Where(re => re.CreateTime.Year == Year);
            var ResG         = _Reservation.GroupBy(l => l.CreateTime.Month)
                               .Select(c1 => new Reservation {
                CreateTime = c1.First().CreateTime, Id = c1.Count()
            }).ToList();
            var chartData = new object[ResG.Count() + 1];

            chartData[0] = new object[] {
                "Monthly",
                "Booking"
            };

            int j = 0;

            foreach (var i in ResG)
            {
                j++;
                chartData[j] = new object[] { CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i.CreateTime.Month), i.Id };
            }



            return(Ok(chartData));
        }
コード例 #3
0
        public ChartViewModel(ReportChart chartData)
        {
            _chartData = chartData;
            _json      = JsonConvert.SerializeObject(chartData, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                ContractResolver  = new CamelCasePropertyNamesContractResolver()
            });

            _json = _json.Replace("scatterData", "data");
        }
コード例 #4
0
ファイル: ChartBuilder.cs プロジェクト: OwenSteele/LocalParks
        public ChartBuilder(ChartType type)
        {
            _chart      = new();
            _chart.Data = new();

            _chart.Type = type.ToString();
            _type       = type;

            _hasDataset = false;
            _hasLabels  = false;
        }
コード例 #5
0
        public static ActionResult SVGify(ReportChart chart)
        {
            var byteArray = Encoding.ASCII.GetBytes(chart.Chart);

            using (var stream = new MemoryStream(byteArray))
            {
                var      svgDocument = SvgDocument.Open(stream);
                var      bitmap      = svgDocument.Draw();
                byte[]   arr         = ToByteArray(bitmap, ImageFormat.Bmp);
                WebImage image       = new WebImage(arr);
                var      imgfile     = image.GetBytes("image/jpeg");
                //return File(imgfile, "image/jpeg");
                return(null);
            }
        }
コード例 #6
0
        /// <summary>
        /// 查询指定时间段范围内各个产品的数量
        /// </summary>
        /// <param name="status"></param>
        /// <param name="storageNum"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public List <ReportChart> GetChartTop(int status, string storageNum, DateTime beginTime, DateTime endTime)
        {
            List <ReportChart> listSource = this.OutStorage.GetChartTop(status, storageNum, beginTime, endTime);
            List <ReportChart> listResult = new List <ReportChart>();

            if (!listSource.IsNullOrEmpty())
            {
                listSource = listSource.OrderByDescending(a => a.Num).ToList();
                if (listSource.Count > 9)
                {
                    listResult = listSource.Take(9).ToList();
                    ReportChart chart = new ReportChart();
                    chart.ProductName = "其他";
                    chart.Num         = listResult.Skip(9).Sum(a => a.Num);
                    listResult.Add(chart);
                }
                else
                {
                    listResult = listSource.Take(9).ToList();
                }
            }
            return(listResult);
        }
コード例 #7
0
 public static ReportChart WithTitle(this ReportChart reportChart, String title)
 {
     reportChart.Title = title;
     return(reportChart);
 }
コード例 #8
0
 public static ReportChart WithReport(this ReportChart reportChart, Report report)
 {
     reportChart.Report = report;
     return(reportChart);
 }
コード例 #9
0
 public static ReportChart WithCategoryReportItemCode(this ReportChart reportChart, Guid categoryReportItemCode)
 {
     reportChart.CategoryReportItemCode = categoryReportItemCode;
     return(reportChart);
 }
コード例 #10
0
 public static ReportChart WithReportCode(this ReportChart reportChart, Guid reportCode)
 {
     reportChart.ReportCode = reportCode;
     return(reportChart);
 }
コード例 #11
0
 public void SetUp()
 {
     _testEntity    = new ReportChart();
     _privateObject = new PrivateObject(_testEntity);
 }
コード例 #12
0
 public static ReportChart WithChartStyle(this ReportChart reportChart, String chartStyle)
 {
     reportChart.ChartStyle = chartStyle;
     return(reportChart);
 }
コード例 #13
0
 public static ReportChartSery WithReportChart(this ReportChartSery reportChartSery, ReportChart reportChart)
 {
     reportChartSery.ReportChart = reportChart;
     return(reportChartSery);
 }
コード例 #14
0
        public static void ReadFromXML(TableReport report, string xmlFileName)
        {
            var       usCulture = new CultureInfo("en-US");
            XDocument doc       = XDocument.Load(xmlFileName);

            if (doc.Root.Attribute("Title") != null)
            {
                report.Title = doc.Root.Attribute("Title").Value;
            }

            var chart = doc.Descendants("Chart").FirstOrDefault();

            if (chart != null)
            {
                var reportChart = new ReportChart();

                if (chart.Attribute("XAxisField") != null)
                {
                    reportChart.XAxisFieldName = chart.Attribute("XAxisField").Value;
                }

                if (chart.Attribute("XAxisLabelField") != null)
                {
                    reportChart.XAxisLabelFieldName = chart.Attribute("XAxisLabelField").Value;
                }

                if (chart.Attribute("LegendLabelFieldName") != null)
                {
                    reportChart.LegendLabelFieldName = chart.Attribute("LegendLabelFieldName").Value;
                }

                if (chart.Attribute("YAxisField") != null)
                {
                    reportChart.YAxisFieldName = chart.Attribute("YAxisField").Value;
                }

                if (chart.Attribute("Width") != null)
                {
                    reportChart.Height = float.Parse(chart.Attribute("Width").Value, usCulture);
                }

                if (chart.Attribute("Height") != null)
                {
                    reportChart.Height = float.Parse(chart.Attribute("Height").Value, usCulture);
                }

                if (chart.Attribute("Title") != null)
                {
                    reportChart.Title = chart.Attribute("Title").Value;
                }

                if (chart.Attribute("Type") != null)
                {
                    reportChart.ChartType = chart.Attribute("Type").Value;
                }

                if (chart.Attribute("ShowLegend") != null)
                {
                    reportChart.ShowLegend = bool.Parse(chart.Attribute("ShowLegend").Value);
                }

                report.Chart = reportChart;
            }

            var columns = doc.Descendants("Column");

            foreach (var column in columns)
            {
                var tableColumn = new TableDataColumn();

                if (column.Attribute("Field") != null)
                {
                    tableColumn.FieldName = column.Attribute("Field").Value;
                }

                if (column.Attribute("HeaderText") != null)
                {
                    tableColumn.HeaderText = column.Attribute("HeaderText").Value;
                }

                if (column.Attribute("Width") != null)
                {
                    tableColumn.Width = float.Parse(column.Attribute("Width").Value, usCulture);
                }

                if (column.Attribute("TextAlign") != null)
                {
                    tableColumn.TextAlign = column.Attribute("TextAlign").Value;
                }

                if (column.Attribute("Format") != null)
                {
                    tableColumn.Format = column.Attribute("Format").Value;
                }

                report.Columns.Add(tableColumn);
            }

            var footers = doc.Descendants("Footer");

            foreach (var footer in footers)
            {
                var tableFooter = new TableDataFooterRow();
                var cell1       = new TableDataFooterCell();
                cell1.TextAlign = "Right";
                cell1.ColSpan   = columns.Count() - 1;

                if (footer.Attribute("LabelSpan") != null)
                {
                    int span = Convert.ToInt32(footer.Attribute("LabelSpan").Value);
                    cell1.ColSpan = span;
                }

                if (footer.Attribute("Label") != null)
                {
                    cell1.Value = footer.Attribute("Label").Value;
                }

                tableFooter.FooterCells.Add(cell1);

                for (int x = 0; x < 20; x++)
                {
                    var cell2 = new TableDataFooterCell();
                    cell2.TextAlign = "Right";
                    cell2.Format    = "N2";

                    string indexStr = "";

                    if (x > 0)
                    {
                        indexStr = Convert.ToString(x + 1);
                    }

                    if (footer.Attribute("Format" + indexStr) != null)
                    {
                        cell2.Format = footer.Attribute("Format" + indexStr).Value;
                    }

                    if (footer.Attribute("Content" + indexStr) != null)
                    {
                        cell2.Value = footer.Attribute("Content" + indexStr).Value;
                        tableFooter.FooterCells.Add(cell2);
                    }
                    else
                    {
                        break;
                    }
                }
                report.FooterRows.Add(tableFooter);
            }

            var group1 = doc.Descendants("Group1").FirstOrDefault();

            if (group1 != null)
            {
                if (group1.Attribute("Field") != null)
                {
                    report.GroupByField1 = group1.Attribute("Field").Value;
                }

                if (group1.Attribute("Header") != null)
                {
                    report.GroupByRowContent1 = group1.Attribute("Header").Value;
                }

                if (group1.Attribute("SortBy") != null)
                {
                    report.GroupBy1SortField = group1.Attribute("SortBy").Value;
                }

                if (group1.Attribute("SortDescending") != null)
                {
                    report.GroupBy1SortDescending = Convert.ToBoolean(group1.Attribute("SortDescending").Value);
                }

                if (group1.Attribute("FooterLabel") != null && group1.Attribute("FooterContent") != null)
                {
                    TableDataFooterRow groupFooterRow = new TableDataFooterRow();

                    TableDataFooterCell cell1 = new TableDataFooterCell();
                    cell1.ColSpan = columns.Count() - 1;

                    if (group1.Attribute("FooterLabelSpan") != null)
                    {
                        int span = Convert.ToInt32(group1.Attribute("FooterLabelSpan").Value);
                        cell1.ColSpan = span;
                    }

                    cell1.Value = group1.Attribute("FooterLabel").Value;
                    groupFooterRow.FooterCells.Add(cell1);

                    for (int x = 0; x < 20; x++)
                    {
                        string indexStr = "";

                        if (x > 0)
                        {
                            indexStr = Convert.ToString(x + 1);
                        }

                        if (group1.Attribute("FooterContent" + indexStr) != null)
                        {
                            TableDataFooterCell cell2 = new TableDataFooterCell();
                            cell2.Value  = group1.Attribute("FooterContent" + indexStr).Value;
                            cell2.Format = "N2";

                            if (group1.Attribute("Format" + indexStr) != null)
                            {
                                cell2.Format = group1.Attribute("Format" + indexStr).Value;
                            }

                            groupFooterRow.FooterCells.Add(cell2);
                        }
                        else
                        {
                            break;
                        }
                    }

                    report.GroupFooterRows1.Add(groupFooterRow);
                }
            }

            var group2 = doc.Descendants("Group2").FirstOrDefault();

            if (group2 != null)
            {
                if (group2.Attribute("Field") != null)
                {
                    report.GroupByField2 = group2.Attribute("Field").Value;
                }

                if (group2.Attribute("Header") != null)
                {
                    report.GroupByRowContent2 = group2.Attribute("Header").Value;
                }

                if (group2.Attribute("SortBy") != null)
                {
                    report.GroupBy2SortField = group2.Attribute("SortBy").Value;
                }

                if (group2.Attribute("SortDescending") != null)
                {
                    report.GroupBy2SortDescending = Convert.ToBoolean(group2.Attribute("SortDescending").Value);
                }

                if (group2.Attribute("FooterLabel") != null && group2.Attribute("FooterContent") != null)
                {
                    TableDataFooterRow groupFooterRow = new TableDataFooterRow();

                    TableDataFooterCell cell1 = new TableDataFooterCell();
                    cell1.ColSpan = columns.Count() - 1;

                    if (group2.Attribute("FooterLabelSpan") != null)
                    {
                        int span = Convert.ToInt32(group2.Attribute("FooterLabelSpan").Value);
                        cell1.ColSpan = span;
                    }

                    cell1.Value = group2.Attribute("FooterLabel").Value;
                    groupFooterRow.FooterCells.Add(cell1);

                    for (int x = 0; x < 20; x++)
                    {
                        string indexStr = "";

                        if (x > 0)
                        {
                            indexStr = Convert.ToString(x + 1);
                        }

                        if (group2.Attribute("FooterContent" + indexStr) != null)
                        {
                            TableDataFooterCell cell2 = new TableDataFooterCell();
                            cell2.Value  = group2.Attribute("FooterContent" + indexStr).Value;
                            cell2.Format = "N2";

                            if (group2.Attribute("Format" + indexStr) != null)
                            {
                                cell2.Format = group2.Attribute("Format" + indexStr).Value;
                            }

                            groupFooterRow.FooterCells.Add(cell2);
                        }
                        else
                        {
                            break;
                        }
                    }


                    report.GroupFooterRows2.Add(groupFooterRow);
                }
            }
        }
コード例 #15
0
 public static ReportChart WithCode(this ReportChart reportChart, Guid code)
 {
     reportChart.Code = code;
     return(reportChart);
 }
コード例 #16
0
        private void GenerateReport(String file, ReportChart report)
        {
            File.WriteAllText(file, "");
            return;

            object misValue = Missing.Value;

            var xlApp = new Excel.Application();
            var xlWorkBook = xlApp.Workbooks.Add(misValue);

            var xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            xlWorkSheet.Cells[1, 1] = "Category name";
            xlWorkSheet.Cells[1, 2] = "Category name";

            xlWorkBook.SaveAs(file, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            ReleaseObject(xlWorkSheet);
            ReleaseObject(xlWorkBook);
            ReleaseObject(xlApp);
        }
コード例 #17
0
 public static ReportChart WithSortOrder(this ReportChart reportChart, Int32 sortOrder)
 {
     reportChart.SortOrder = sortOrder;
     return(reportChart);
 }
コード例 #18
0
 public static ReportChart WithChartType(this ReportChart reportChart, String chartType)
 {
     reportChart.ChartType = chartType;
     return(reportChart);
 }
コード例 #19
0
 public static ReportChart WithDescription(this ReportChart reportChart, String description)
 {
     reportChart.Description = description;
     return(reportChart);
 }
コード例 #20
0
 public static ReportChart WithReportItem(this ReportChart reportChart, ReportItem reportItem)
 {
     reportChart.ReportItem = reportItem;
     return(reportChart);
 }
コード例 #21
0
 public static ReportChart WithReportChartSeries(this ReportChart reportChart, ICollection <ReportChartSery> reportChartSeries)
 {
     reportChart.ReportChartSeries = reportChartSeries;
     return(reportChart);
 }