예제 #1
0
    public void CreateHistoricalTicketStats()
    {
        List <int> returnedData = new List <int>();

        returnedData = ScoreCardReports.GetTotalTickets();//data gets returned as @Current,@OneToSeven, @SevenToThirty, @ThirtyToSixty,@SixtyToNinety, @OlderThenNinety

        TotalTicketsChart.Titles[0].Text = "Current Open Ticket Aging (" + returnedData.Sum() + ")";

        TotalTicketsChart.ChartAreas["caScoreCard"].AxisX.LabelStyle.Font = new System.Drawing.Font("Arial", 11);

        float total = 0;

        foreach (int value in returnedData)
        {
            total += value;
        }

        TotalTicketsChart.Series["sData"].Points.Add(Math.Round(((returnedData[0] / total) * 100), 0));
        TotalTicketsChart.Series["sData"].Points[0].LegendText = "< Day (" + Math.Round(((returnedData[0] / total) * 100), 0) + "%)";
        TotalTicketsChart.Series["sData"].Points[0].Color      = Color.Green;
        TotalTicketsChart.Series["sData"].Points[0].Label      = Math.Round(((returnedData[0] / total) * 100), 0) + "%";


        TotalTicketsChart.Series["sData"].Points.Add(Math.Round(((returnedData[1] / total) * 100), 0));
        TotalTicketsChart.Series["sData"].Points[1].LegendText = "< Week (" + Math.Round(((returnedData[1] / total) * 100), 0) + "%)";
        TotalTicketsChart.Series["sData"].Points[1].Color      = Color.DeepSkyBlue;
        TotalTicketsChart.Series["sData"].Points[1].Label      = Math.Round(((returnedData[1] / total) * 100), 0) + "%";

        TotalTicketsChart.Series["sData"].Points.Add(Math.Round(((returnedData[2] / total) * 100), 0));
        TotalTicketsChart.Series["sData"].Points[2].LegendText = "< Month (" + Math.Round(((returnedData[2] / total) * 100), 0) + "%)";
        TotalTicketsChart.Series["sData"].Points[2].Color      = Color.DodgerBlue;
        TotalTicketsChart.Series["sData"].Points[2].Label      = Math.Round(((returnedData[2] / total) * 100), 0) + "%";

        TotalTicketsChart.Series["sData"].Points.Add(Math.Round(((returnedData[3] / total) * 100), 0));
        TotalTicketsChart.Series["sData"].Points[3].LegendText = "< 60 Days (" + Math.Round(((returnedData[3] / total) * 100), 0) + "%)";
        TotalTicketsChart.Series["sData"].Points[3].Color      = Color.Orange;
        TotalTicketsChart.Series["sData"].Points[3].Label      = Math.Round(((returnedData[3] / total) * 100), 0) + "%";

        TotalTicketsChart.Series["sData"].Points.Add(Math.Round(((returnedData[4] / total) * 100), 0));
        TotalTicketsChart.Series["sData"].Points[4].LegendText = "< 90 Days (" + Math.Round(((returnedData[4] / total) * 100), 0) + "%)";
        TotalTicketsChart.Series["sData"].Points[4].Color      = Color.Red;
        TotalTicketsChart.Series["sData"].Points[4].Label      = Math.Round(((returnedData[4] / total) * 100), 0) + "%";

        TotalTicketsChart.Series["sData"].Points.Add(Math.Round(((returnedData[5] / total) * 100), 0));
        TotalTicketsChart.Series["sData"].Points[5].LegendText = "> 90 Days (" + Math.Round(((returnedData[5] / total) * 100), 0) + "%)";
        TotalTicketsChart.Series["sData"].Points[5].Color      = Color.Chocolate;
        TotalTicketsChart.Series["sData"].Points[5].Label      = Math.Round(((returnedData[5] / total) * 100), 0) + "%";

        TotalTicketsChart.DataBind();
    }
예제 #2
0
    ///// <summary>
    ///// Creates Y axis for the specified series.
    ///// </summary>
    ///// <param name="chart">Chart control.</param>
    ///// <param name="area">Original chart area.</param>
    ///// <param name="series">Series.</param>
    ///// <param name="axisOffset">New Y axis offset in relative coordinates.</param>
    ///// <param name="labelsSize">Extra space for new Y axis labels in relative coordinates.</param>
    //public void CreateYAxis(Chart chart, ChartArea area, Series series, float axisOffset, float labelsSize)
    //{
    //    // Create new chart area for original series
    //    ChartArea areaSeries = chart.ChartAreas.Add("ChartArea_" + series.Name);
    //    areaSeries.BackColor = Color.Transparent;
    //    areaSeries.BorderColor = Color.Transparent;
    //    areaSeries.Position.FromRectangleF(area.Position.ToRectangleF());
    //    areaSeries.InnerPlotPosition.FromRectangleF(area.InnerPlotPosition.ToRectangleF());
    //    areaSeries.AxisX.MajorGrid.Enabled = false;
    //    areaSeries.AxisX.MajorTickMark.Enabled = false;
    //    areaSeries.AxisX.LabelStyle.Enabled = false;
    //    areaSeries.AxisY.MajorGrid.Enabled = false;
    //    areaSeries.AxisY.MajorTickMark.Enabled = false;
    //    areaSeries.AxisY.LabelStyle.Enabled = false;
    //    areaSeries.AxisY.IsStartedFromZero = area.AxisY.IsStartedFromZero;


    //    series.ChartArea = areaSeries.Name;

    //    // Create new chart area for axis
    //    ChartArea areaAxis = chart.ChartAreas.Add("AxisY_" + series.ChartArea);
    //    areaAxis.BackColor = Color.Transparent;
    //    areaAxis.BorderColor = Color.Transparent;
    //    areaAxis.Position.FromRectangleF(chart.ChartAreas[series.ChartArea].Position.ToRectangleF());
    //    areaAxis.InnerPlotPosition.FromRectangleF(chart.ChartAreas[series.ChartArea].InnerPlotPosition.ToRectangleF());

    //    // Create a copy of specified series
    //    Series seriesCopy = chart.Series.Add(series.Name + "_Copy");
    //    seriesCopy.ChartType = series.ChartType;
    //    foreach (DataPoint point in series.Points)
    //    {
    //        seriesCopy.Points.AddXY(point.XValue, point.YValues[0]);
    //    }

    //    // Hide copied series
    //    seriesCopy.IsVisibleInLegend = false;
    //    seriesCopy.Color = Color.Transparent;
    //    seriesCopy.BorderColor = Color.Transparent;
    //    seriesCopy.ChartArea = areaAxis.Name;

    //    // Disable drid lines & tickmarks
    //    areaAxis.AxisX.LineWidth = 0;
    //    areaAxis.AxisX.MajorGrid.Enabled = false;
    //    areaAxis.AxisX.MajorTickMark.Enabled = false;
    //    areaAxis.AxisX.LabelStyle.Enabled = false;
    //    areaAxis.AxisY.MajorGrid.Enabled = false;
    //    areaAxis.AxisY.IsStartedFromZero = area.AxisY.IsStartedFromZero;
    //    areaAxis.AxisY.LabelStyle.Font = area.AxisY.LabelStyle.Font;

    //    //// Adjust area position
    //    //areaAxis.Position.X -= axisOffset;
    //    //areaAxis.InnerPlotPosition.X += labelsSize;

    //}

    protected void btnExportToExcel_Click(object sender, EventArgs e)
    {
        StringWriter   sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);


        TableRow dummie = new TableRow();

        #region Saving Charts and Image Paths
        string comparisonChartImage;
        comparisonChartImage = FileLocation.FilePath + "comparisonChartImage.jpg";
        comparisonChart.SaveImage(comparisonChartImage);

        string SixMonthTrendChartImage;
        SixMonthTrendChartImage = FileLocation.FilePath + "SixMonthTrendChartImage.jpg";
        SixMonthTrendChart.SaveImage(SixMonthTrendChartImage);

        string TicketHealthChartImage;
        TicketHealthChartImage = FileLocation.FilePath + "TicketHealthChartImage.jpg";
        TicketHealthChart.SaveImage(TicketHealthChartImage);

        string RepeatIssuesChartImage;
        RepeatIssuesChartImage = FileLocation.FilePath + "RepeatIssuesChartImage.jpg";
        RepeatIssuesChart.SaveImage(RepeatIssuesChartImage);

        string CustomerIssuesChartImage;
        CustomerIssuesChartImage = FileLocation.FilePath + "CustomerIssuesChartImage.jpg";
        CustomerIssuesChart.SaveImage(CustomerIssuesChartImage);

        string unplannedTicketsChartImage;
        unplannedTicketsChartImage = FileLocation.FilePath + "unplannedTicketsChartImage.jpg";
        unplannedTicketsChart.SaveImage(unplannedTicketsChartImage);

        string ASNIssueChartImage;
        ASNIssueChartImage = FileLocation.FilePath + "ASNIssueChartImage.jpg";
        ASNIssueChart.SaveImage(ASNIssueChartImage);

        string RealTimeChartImage;
        RealTimeChartImage = FileLocation.FilePath + "RealTimeChartImage.jpg";
        RealTimeChart.SaveImage(RealTimeChartImage);

        string HistoricleTotalsImage;
        HistoricleTotalsImage = FileLocation.FilePath + "HistoricleTotalsImage.jpg";
        TotalTicketsChart.SaveImage(HistoricleTotalsImage);


        #endregion

        Table tbl = new Table();
        tbl.Width = Unit.Pixel(100);



        //Comparison Row
        TableRow  comparisonRow = new TableRow();
        TableCell cell          = new TableCell();
        TableCell cell12        = new TableCell();
        cell.Text = "<img src='" + comparisonChartImage + @"' \>";
        comparisonRow.Cells.Add(cell);
        comparisonRow.Cells.Add(cell12);
        tbl.Rows.Add(comparisonRow);

        for (int count = 0; count <= 20; count++)
        {
            dummie = new TableRow();
            tbl.Rows.Add(dummie);
        }

        //Six Month Trend Chart
        TableRow  sixMonthTrendRow = new TableRow();
        TableCell cell1            = new TableCell();
        TableCell cell13           = new TableCell();
        cell1.Text = "<img src='" + SixMonthTrendChartImage + @"' \>";
        sixMonthTrendRow.Cells.Add(cell1);
        sixMonthTrendRow.Cells.Add(cell13);
        tbl.Rows.Add(sixMonthTrendRow);

        for (int count = 0; count <= 20; count++)
        {
            dummie = new TableRow();
            tbl.Rows.Add(dummie);
        }


        //Ticket Health Chart
        TableRow  ticketHealthRow   = new TableRow();
        TableCell cellTicketHealth  = new TableCell();
        TableCell cellTicketHealth2 = new TableCell();
        cellTicketHealth.Text = "<img src='" + SixMonthTrendChartImage + @"' \>";
        ticketHealthRow.Cells.Add(cellTicketHealth);
        ticketHealthRow.Cells.Add(cellTicketHealth2);
        tbl.Rows.Add(ticketHealthRow);

        for (int count = 0; count <= 20; count++)
        {
            dummie = new TableRow();
            tbl.Rows.Add(dummie);
        }

        //The rest of the charts have to be 2 per line to mimic the look of the webpage

        /***********
        * LINE TWO
        * *********/
        TableRow LineTwoRow = new TableRow();
        //Repeat Issues Chart
        TableCell repeatIssueCell = new TableCell();
        repeatIssueCell.Text       = "<img src='" + RepeatIssuesChartImage + @"' \>";
        repeatIssueCell.ColumnSpan = 8;
        LineTwoRow.Cells.Add(repeatIssueCell);

        //Customer Issues
        TableCell CustomerIssuesCell = new TableCell();
        CustomerIssuesCell.Text = "<img src='" + CustomerIssuesChartImage + @"' \>";
        LineTwoRow.Cells.Add(CustomerIssuesCell);

        tbl.Rows.Add(LineTwoRow);

        for (int count = 0; count <= 20; count++)
        {
            dummie = new TableRow();
            tbl.Rows.Add(dummie);
        }

        ///***********
        //* LINE THREE
        //* *********/
        TableRow LineThreeRow = new TableRow();
        //UnPlanned Issues Chart
        TableCell unPlannedCell = new TableCell();
        unPlannedCell.ColumnSpan = 8;
        unPlannedCell.Text       = "<img src='" + unplannedTicketsChartImage + @"' \>";
        LineThreeRow.Cells.Add(unPlannedCell);


        //ASN Issues
        TableCell asnIssuesCell = new TableCell();
        asnIssuesCell.Text = "<img src='" + ASNIssueChartImage + @"' \>";
        LineThreeRow.Cells.Add(asnIssuesCell);

        tbl.Rows.Add(LineThreeRow);
        for (int count = 0; count <= 20; count++)
        {
            dummie = new TableRow();
            tbl.Rows.Add(dummie);
        }

        ///***********
        //* LINE FOUR
        //* *********/
        TableRow LineFourRow = new TableRow();
        //Real Time Issues Chart
        TableCell realTimeCell = new TableCell();
        realTimeCell.ColumnSpan = 8;
        realTimeCell.Text       = "<img src='" + RealTimeChartImage + @"' \>";
        LineFourRow.Cells.Add(realTimeCell);


        //Current Open Ticket Aging  Issues Chart
        TableCell historyCell = new TableCell();
        historyCell.ColumnSpan = 8;
        historyCell.Text       = "<img src='" + HistoricleTotalsImage + @"' \>";
        LineFourRow.Cells.Add(historyCell);

        tbl.Rows.Add(LineFourRow);



        Response.Clear();
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "attachment; filename=IT-Ticket-Stats.xls;");

        DataList1.RenderControl(hw);

        tbl.RenderControl(hw);

        Response.Write(sw.ToString());
        Response.End();
    }