Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string ReportFolderPath = @"\\bus.local\files\Engineering\_UnifiedData\VehicleSummaryReports";
            string TempFolderPath = @"C:\Reports\Temp";
            string ImageFolderPath = @"C:\Reports\Images";
            string WebAddress = "http://localhost/ChartGenerator/";
            string VinID = String.Empty;
            string Vin = String.Empty;
            string ReportPeriod = String.Empty;
            string CustomerName = String.Empty;
            string ProcessDate = String.Empty;
            string WeekNumber = String.Empty;
            string YearNumber = String.Empty;
            int ReportID = 0;

            string GenerationMode = "Auto";

            if (args == null)
            {
                Console.WriteLine("args is null"); // Check for null array
                GenerationMode = "Auto";
            }
            else
            {

                if (args.Length > 0)
                {
                    GenerationMode = "Manual";
                }
                else
                {
                    GenerationMode = "Auto";
                }

                Console.Write("args length is ");
                Console.WriteLine(args.Length); // Write array length
                for (int i = 0; i < args.Length; i++) // Loop through array
                {
                    string argument = args[i];
                    //Console.Write("args index ");
                    //Console.Write(i); // Write index
                    //Console.Write(" is [");
                    //Console.Write(argument); // Write string
                    //Console.WriteLine("]");

                    if (i == 0)
                    {
                        VinID = argument;
                    }

                    if (i == 1)
                    {
                        ReportPeriod = argument;
                    }

                     if (i == 2)
                    {
                        if (IsDate(argument))
                        {

                            ProcessDate = argument;
                        }
                        else
                        {
                            WeekNumber = argument;
                        }
                    }

                     if (i == 3)
                     {
                         YearNumber = argument;
                     }

                }
            }

            //Console.Write("VinID  " + VinID);
            //Console.Write("  ProcessDate  " + ProcessDate);

            if (GenerationMode == "Auto")
            {
                VinReportParam rp = new VinReportParam();

                 GetData VinRptData = new GetData();
                  rp = VinRptData.GetActionReportRow();

                  ProcessDate = rp.ProcessDate;
                  VinID = rp.VinID.ToString();
                  WeekNumber = rp.WeekNumber;
                  YearNumber = rp.YearNumber;
                  ReportPeriod = rp.ReportPeriod;
                  ReportID = rp.ReportID;

            }

            if (ReportPeriod=="DailyBatteryAllCust")
            {

               // CheckFolderPath(ReportFolderPath, TempFolderPath, Vin, CustomerName, ReportPeriod);
                string FolderName = "DailyBatteryAllCust";
                CheckFolderPathWithFoldName(ReportFolderPath, TempFolderPath, FolderName);
                CreateReportImage(WebAddress, TempFolderPath, FolderName, ProcessDate, ReportPeriod, WeekNumber, YearNumber);
                CreateReportBatteryAllCustPdf(ReportFolderPath, TempFolderPath, ImageFolderPath, Vin, ProcessDate, CustomerName, ReportPeriod, WeekNumber, YearNumber,
                         ReportID);
            }

            if (VinID != String.Empty && ReportPeriod != "DailyBatteryAllCust")
            {
                GetVehicleDetails(VinID, ref Vin, ref CustomerName);

                if (string.IsNullOrEmpty(CustomerName) == false)
                {
                    CheckFolderPath(ReportFolderPath,TempFolderPath, Vin, CustomerName,ReportPeriod);

                    Boolean CheckData = GetData.CheckDataExists(VinID, ProcessDate, ReportPeriod, WeekNumber, YearNumber);

                    if (ReportPeriod == "DailyBattery")
                    {
                        CheckData  = true;
                    }

                    if (CheckData  == true)
                    {
                        CreateReportImage(WebAddress, TempFolderPath, Vin, VinID, ProcessDate, CustomerName, ReportPeriod, WeekNumber, YearNumber);
                        CreateReportPdf(ReportFolderPath, TempFolderPath, ImageFolderPath, Vin, ProcessDate, CustomerName, ReportPeriod, WeekNumber, YearNumber,
                            ReportID);
                    }
               }

            }
        }
Ejemplo n.º 2
0
        private static void CreateReportBatteryAllCustPdf(string ReportFolderPath, string TempFolderPath, string ImageFolderPath, string Vin, string ProcessDate, string CustomerName, string ReportPeriod, string WeekNumber, string YearNumber, int ReportID)
        {
            string ImageFileName = Path.Combine(ImageFolderPath, "splash.png");
            string RptImageFolder = Path.Combine(TempFolderPath,"DailyBatteryAllCust");

            CreateReports CrtPdf = new CreateReports();
            Random r = new Random();
            int rano = r.Next(1000, 9999);
            string PdfFolder = Path.Combine(ReportFolderPath, "DailyBatteryAllCust");
            string ReportFileName = String.Empty;

            ReportFileName = Path.Combine(PdfFolder, "DailyBatteryReport_AllCust" + "_" + ProcessDate.Replace("/", "") + "_" + rano + ".pdf");

            CrtPdf.SetUp(ReportFileName, Vin, ProcessDate, ReportPeriod, WeekNumber, YearNumber);
            CrtPdf.GenPdfDailyBatteryAllCust(RptImageFolder, ImageFileName, ReportPeriod,ProcessDate);
            //   CrtPdf.getImage(VinId, ProcessDate, WebAddress, ImageFolder);
            CrtPdf.TearDown();

            GetData VinRptData = new GetData();
            VinRptData.UdpdateReportLog(ReportID);
        }
Ejemplo n.º 3
0
        private static void GetVehicleDetails(string VinID, ref string Vin,  ref string CustomerName)
        {
            //var dataConnect = ConfigurationManager.ConnectionStrings["PCanRepository"].ConnectionString;

            int intVinID;
            bool IsVinNumeric = int.TryParse(VinID, out intVinID);
            Vehicles Vehicle = new Vehicles();
            if (IsVinNumeric == true)
            {
                  GetData VinData = new GetData();
                  Vehicle = VinData.GetVinInfo(intVinID);
                  Vin = Vehicle.Vin;
                  CustomerName = Vehicle.CustomerName;

                  Console.Write("Vin   " + Vehicle.Vin);
                  Console.Write("Customer   " + Vehicle.CustomerName);

            }
        }
Ejemplo n.º 4
0
        private void getImageDailyBatteryAllCust(string ProcessDate, string WebAddress, string ImageFolder, string ReportPeriod, string WeekNumber, string YearNumber)
        {
            //  throw new NotImplementedException();

            //string WebParam;
            //Uri WebUrl;
            //string ImagePath;
            //Uri websiteName = new Uri(WebAddress);
            string CustomerId = string.Empty;

            DataTable dtCust = new DataTable();
               DataTable dtVin = new DataTable();
               GetData gd = new GetData();
               dtCust = gd.DtGetCustomerInfo(DateTime.Parse(ProcessDate));

               int i = 0;
               int j = 0;
               foreach (DataRow dRow in dtCust.Rows)
               {

               i++;
               j = 0;
               CustomerId = dRow["CustomerId"].ToString();
               dtVin = gd.DtGetCustomerVehicleInfo(int.Parse(CustomerId), DateTime.Parse(ProcessDate));

               foreach (DataRow vRow in dtVin.Rows)
               {

                   j++;
                   getImageDailyBatteryByVin(vRow["VinID"].ToString(), ProcessDate, WebAddress, ImageFolder, ReportPeriod, WeekNumber, YearNumber);
               }

               }
        }
Ejemplo n.º 5
0
        private static PdfPTable GenerateBatteryVinDashboard(string ProcessDate,int VinID)
        {
            BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);

            Font times = new Font(bfTimes, 12, Font.ITALIC, Color.RED);
            Font fontTinyItalic = FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.ITALIC, Color.GRAY);

            PdfPTable table = new PdfPTable(7);

            table.WidthPercentage = (70.0f);

            //relative col widths in proportions - 1/3 and 2/3

            //   float[] widths = new float[] { 1f, 2f };
            float[] colWidths = { 120, 70, 70, 70, 70, 70,70 };

            table.SetWidths(colWidths);

            table.HorizontalAlignment = 1;

            //leave a gap before and after the table

            table.SpacingBefore = 20f;

            table.SpacingAfter = 30f;
            table.DefaultCell.HorizontalAlignment = 2;
            //table.DefaultCell.Border = (PdfPCell.BOTTOM_BORDER);
            table.DefaultCell.GrayFill = 1;
            table.DefaultCell.Border = (PdfPCell.RECTANGLE);
            table.DefaultCell.BorderColor = new iTextSharp.text.Color(255, 255, 255);
            table.DefaultCell.BorderColorBottom = new iTextSharp.text.Color(255, 255, 255);
            table.DefaultCell.Padding = 4;

            Color headRowColor = new Color(0, 0, 0);
            Color headRowFontColor = new Color(255, 255, 255);
            iTextSharp.text.Font fontIstRow = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.WHITE);
            // iTextSharp.text.Cell c1 = new iTextSharp.text.Cell("");
            string c1Text = "Battery Pack";
            PdfPCell cell1 = new PdfPCell(new Phrase(c1Text, fontIstRow));
            cell1.HorizontalAlignment = 1;
            cell1.Border = 0;
            cell1.GrayFill = 1;
            cell1.BackgroundColor = headRowColor;
            table.AddCell(cell1);

            //c1.UseBorderPadding = false;

            string c2Text = "dSoC";
            PdfPCell cell2 = new PdfPCell(new Phrase(c2Text, fontIstRow));
            cell2.HorizontalAlignment = 1;
            cell2.Border = 0;
            cell2.GrayFill = 1;
            cell2.BackgroundColor = headRowColor;
            table.AddCell(cell2);

            string c3Text = "I_MIN(A)";
            PdfPCell cell3 = new PdfPCell(new Phrase(c3Text, fontIstRow));
            cell3.HorizontalAlignment = 1;
            cell3.Border = 0;
            cell3.GrayFill = 1;
            cell3.BackgroundColor = headRowColor;
            table.AddCell(cell3);

            string c6Text = "I_MAX(A)";
            PdfPCell cell6 = new PdfPCell(new Phrase(c6Text, fontIstRow));
            cell6.HorizontalAlignment = 1;
            cell6.Border = 0;
            cell6.GrayFill = 1;
            cell6.BackgroundColor = headRowColor;
            table.AddCell(cell6);

            string c7Text = "T_MIN(C)";
            PdfPCell cell7 = new PdfPCell(new Phrase(c7Text, fontIstRow));
            cell7.HorizontalAlignment = 1;
            cell7.Border = 0;
            cell7.GrayFill = 1;
            cell7.BackgroundColor = headRowColor;
            table.AddCell(cell7);

            string c8Text = "T_MAX(C)";
            PdfPCell cell8 = new PdfPCell(new Phrase(c8Text, fontIstRow));
            cell8.HorizontalAlignment = 1;
            cell8.Border = 0;

            cell8.GrayFill = 1;
            cell8.BackgroundColor = headRowColor;
            table.AddCell(cell8);

            string c9Text = "SoC Range";
            PdfPCell cell9 = new PdfPCell(new Phrase(c9Text, fontIstRow));
            cell9.HorizontalAlignment = 1;
            cell9.Border = 0;

            cell9.GrayFill = 1;
            cell9.BackgroundColor = headRowColor;
            table.AddCell(cell9);

            DateTime dtProcessDate;
            bool IsProcessDate = DateTime.TryParse(ProcessDate, out dtProcessDate);

            iTextSharp.text.Font fontDynmaicRows = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK);
            iTextSharp.text.Font fontDynmaicRowsRed = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.RED);
            iTextSharp.text.Font fontDynmaicRowsNormal = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLACK);
            iTextSharp.text.Font fontDynmaicRowsRedNormal = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.RED);
            GetData gd = new GetData();
            DataTable dataTable_TempData = new DataTable();
            dataTable_TempData = gd.GetDashBoardDataTabular(VinID,dtProcessDate,"");
            table.HeaderRows = 1;
            table.DefaultCell.BorderWidth = 1;
            Color altRow = new Color(242, 242, 242);

            int i = 0;
            foreach (DataRow dRow in dataTable_TempData.Rows)
            {

                i++;

                    PdfPCell Cell1Hdr = new PdfPCell(new Phrase(dRow[1].ToString().ToUpper(), fontDynmaicRows));
                    Cell1Hdr.HorizontalAlignment = Element.ALIGN_LEFT;
                    if (i % 2 == 1)
                    {
                        Cell1Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell1Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell1Hdr);

                    PdfPCell Cell4Hdr = new PdfPCell(new Phrase(dRow[2].ToString(), fontDynmaicRowsNormal));
                    Cell4Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell4Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell4Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell4Hdr);

                    PdfPCell Cell5Hdr = new PdfPCell(new Phrase(dRow[3].ToString(), fontDynmaicRowsNormal));
                    Cell5Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell5Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell5Hdr.BackgroundColor = Color.WHITE;
                    }

                    table.AddCell(Cell5Hdr);

                    PdfPCell Cell6Hdr = new PdfPCell(new Phrase(dRow[4].ToString(), fontDynmaicRowsNormal));
                    Cell6Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell6Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell6Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell6Hdr);

                    PdfPCell Cell7Hdr = new PdfPCell(new Phrase(dRow[5].ToString(), fontDynmaicRowsNormal));
                    Cell7Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell7Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell7Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell7Hdr);

                    PdfPCell Cell8Hdr = new PdfPCell(new Phrase(dRow[6].ToString(), fontDynmaicRowsNormal));
                    Cell8Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell8Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell8Hdr.BackgroundColor = Color.WHITE;
                    }

                    table.AddCell(Cell8Hdr);

                    PdfPCell Cell9Hdr = new PdfPCell(new Phrase(dRow[7].ToString(), fontDynmaicRowsNormal));
                    Cell9Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell9Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell9Hdr.BackgroundColor = Color.WHITE;
                    }

                    table.AddCell(Cell9Hdr);

            }
            return table;
        }
Ejemplo n.º 6
0
        private static PdfPTable GenerateBatteryAllCustDashboard(string ProcessDate)
        {
            BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);

            Font times = new Font(bfTimes, 12, Font.ITALIC, Color.RED);
            Font fontTinyItalic = FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.ITALIC, Color.GRAY);

            PdfPTable table = new PdfPTable(6);

            //actual width of table in points

            //table.TotalWidth = 216f;

            //fix the absolute width of the table

            // table.LockedWidth = true;

            table.WidthPercentage = (90.0f);

            //relative col widths in proportions - 1/3 and 2/3

            //   float[] widths = new float[] { 1f, 2f };
            float[] colWidths = {  70, 70, 70, 70, 70, 70 };

            table.SetWidths(colWidths);

            table.HorizontalAlignment = 1;

            //leave a gap before and after the table

            table.SpacingBefore = 20f;

            table.SpacingAfter = 30f;
            table.DefaultCell.HorizontalAlignment = 2;
            //table.DefaultCell.Border = (PdfPCell.BOTTOM_BORDER);
            table.DefaultCell.GrayFill = 1;
            table.DefaultCell.Border = (PdfPCell.RECTANGLE);
            table.DefaultCell.BorderColor = new iTextSharp.text.Color(255, 255, 255);
            table.DefaultCell.BorderColorBottom = new iTextSharp.text.Color(255, 255, 255);
            table.DefaultCell.Padding = 4;

            //PdfPCell cell = new PdfPCell(new Phrase("Products","Test"));

            //cell.Colspan = 2;

            //cell.Border = 0;

            //cell.HorizontalAlignment = 1;

            //table.AddCell(cell);

            //Creating First Row that will contain the Title

              //  table.AddCell("");

            Color headRowColor = new Color(0, 0, 0);
            Color headRowFontColor = new Color(255, 255, 255);
            iTextSharp.text.Font fontIstRow = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.WHITE);
            // iTextSharp.text.Cell c1 = new iTextSharp.text.Cell("");
            string c1Text = "VEHICLE";
            PdfPCell cell1 = new PdfPCell(new Phrase(c1Text, fontIstRow));
            cell1.HorizontalAlignment = 1;
            cell1.Border = 0;
            cell1.GrayFill = 1;
            cell1.BackgroundColor = headRowColor;
            table.AddCell(cell1);

            //c1.UseBorderPadding = false;

            string c2Text = "I_MIN(A)";
            PdfPCell cell2 = new PdfPCell(new Phrase(c2Text, fontIstRow));
            cell2.HorizontalAlignment = 1;
            cell2.Border = 0;
            cell2.GrayFill = 1;
            cell2.BackgroundColor = headRowColor;
            table.AddCell(cell2);

            string c3Text = "I_MAX(A)";
            PdfPCell cell3 = new PdfPCell(new Phrase(c3Text, fontIstRow));
            cell3.HorizontalAlignment = 1;
            cell3.Border = 0;
            cell3.GrayFill = 1;
            cell3.BackgroundColor = headRowColor;
            table.AddCell(cell3);

            string c6Text = "TEMP(C)";
            PdfPCell cell6 = new PdfPCell(new Phrase(c6Text, fontIstRow));
            cell6.HorizontalAlignment = 1;
            cell6.Border = 0;
            cell6.GrayFill = 1;
            cell6.BackgroundColor = headRowColor;
            table.AddCell(cell6);

            string c7Text = "SOC(%)";
            PdfPCell cell7 = new PdfPCell(new Phrase(c7Text, fontIstRow));
            cell7.HorizontalAlignment = 1;
            cell7.Border = 0;
            cell7.GrayFill = 1;
            cell7.BackgroundColor = headRowColor;
            table.AddCell(cell7);

            string c8Text = "Drive(Hr)";
            PdfPCell cell8 = new PdfPCell(new Phrase(c8Text, fontIstRow));
            cell8.HorizontalAlignment = 1;
            cell8.Border = 0;

            cell8.GrayFill = 1;
            cell8.BackgroundColor = headRowColor;
            table.AddCell(cell8);

            //table.AddCell("Drive_h");
            //table.AddCell("Temp");
            //table.AddCell("Soc");
            //table.AddCell("Drive_h");
            DateTime dtProcessDate;
            bool IsProcessDate = DateTime.TryParse(ProcessDate, out dtProcessDate);

            iTextSharp.text.Font fontDynmaicRows = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8,iTextSharp.text.Font.BOLD,iTextSharp.text.Color.BLACK);
            iTextSharp.text.Font fontDynmaicRowsRed = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.RED);
            iTextSharp.text.Font fontDynmaicRowsNormal = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLACK);
            iTextSharp.text.Font fontDynmaicRowsRedNormal = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.RED);
            GetData gd = new GetData();
            DataTable dataTable_TempData = new DataTable();
            dataTable_TempData = gd.Dt_DailyGrab_GetBatteryDashAllCust(dtProcessDate, 0);
            table.HeaderRows = 1;
            table.DefaultCell.BorderWidth = 1;
            Color altRow = new Color(242, 242, 242);

            int i = 0;
            foreach (DataRow dRow in dataTable_TempData.Rows)
            {

                i++;
                if (i % 2 == 1)
                {
                    table.DefaultCell.BackgroundColor = altRow;
                }
                else
                {
                    table.DefaultCell.BackgroundColor = Color.WHITE;
                }

                if (dRow[9].ToString() == "1")
                {
                  //  table.AddCell(new Phrase(dRow[0].ToString(), fontDynmaicRowsRed));

                    PdfPCell Cell1Hdr = new PdfPCell(new Phrase(dRow[1].ToString().ToUpper(), fontDynmaicRows));
                    Cell1Hdr.HorizontalAlignment = Element.ALIGN_LEFT;
                    if (i % 2 == 1)
                    {
                        Cell1Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell1Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell1Hdr);

                    //PdfPCell Cell2Hdr = new PdfPCell(new Phrase(dRow[2].ToString(), fontDynmaicRowsNormal));
                    //Cell2Hdr.HorizontalAlignment = Element.ALIGN_LEFT;
                    //table.AddCell(Cell2Hdr);

                    //PdfPCell Cell3Hdr = new PdfPCell(new Phrase(dRow[3].ToString(), fontDynmaicRows));
                    //Cell3Hdr.HorizontalAlignment = Element.ALIGN_LEFT;
                    //table.AddCell(Cell3Hdr);

                    PdfPCell Cell4Hdr = new PdfPCell(new Phrase(dRow[4].ToString(), fontDynmaicRowsRed));
                    Cell4Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell4Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell4Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell4Hdr);

                    PdfPCell Cell5Hdr = new PdfPCell(new Phrase(dRow[5].ToString(), fontDynmaicRowsRedNormal));
                    Cell5Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell5Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell5Hdr.BackgroundColor = Color.WHITE;
                    }

                    table.AddCell(Cell5Hdr);

                    PdfPCell Cell6Hdr = new PdfPCell(new Phrase(dRow[6].ToString(), fontDynmaicRowsRedNormal));
                    Cell6Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell6Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell6Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell6Hdr);

                    PdfPCell Cell7Hdr = new PdfPCell(new Phrase(dRow[7].ToString(), fontDynmaicRowsRedNormal));
                    Cell7Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell7Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell7Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell7Hdr);

                    PdfPCell Cell8Hdr = new PdfPCell(new Phrase(dRow[8].ToString(), fontDynmaicRowsRedNormal));
                    Cell8Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell8Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell8Hdr.BackgroundColor = Color.WHITE;
                    }

                    table.AddCell(Cell8Hdr);

                    //table.AddCell(new Phrase(dRow[1].ToString(), fontDynmaicRowsRed));

                    //table.AddCell(new Phrase(dRow[4].ToString(), fontDynmaicRowsRed));
                    //table.AddCell(new Phrase(dRow[5].ToString(), fontDynmaicRowsRed));

                    //table.AddCell(new Phrase(dRow[6].ToString(), fontDynmaicRowsRed));
                    //table.AddCell(new Phrase(dRow[7].ToString(), fontDynmaicRowsRed));
                    //table.AddCell(new Phrase(dRow[8].ToString(), fontDynmaicRowsRed));
                }
                else
                {
                  //  table.AddCell(new Phrase(dRow[0].ToString(), fontDynmaicRows));

                    PdfPCell Cell1Hdr = new PdfPCell(new Phrase(dRow[1].ToString().ToUpper(), fontDynmaicRows));
                    Cell1Hdr.HorizontalAlignment = Element.ALIGN_LEFT;
                    if (i % 2 == 1)
                    {
                        Cell1Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell1Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell1Hdr);

                    //PdfPCell Cell2Hdr = new PdfPCell(new Phrase(dRow[2].ToString(), fontDynmaicRowsNormal));
                    //Cell2Hdr.HorizontalAlignment = Element.ALIGN_LEFT;
                    //table.AddCell(Cell2Hdr);

                    //PdfPCell Cell3Hdr = new PdfPCell(new Phrase(dRow[3].ToString(), fontDynmaicRows));
                    //Cell3Hdr.HorizontalAlignment = Element.ALIGN_LEFT;
                    //table.AddCell(Cell3Hdr);

                    PdfPCell Cell4Hdr = new PdfPCell(new Phrase(dRow[4].ToString(), fontDynmaicRowsNormal));
                    Cell4Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell4Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell4Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell4Hdr);

                    PdfPCell Cell5Hdr = new PdfPCell(new Phrase(dRow[5].ToString(), fontDynmaicRowsNormal));
                    Cell5Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell5Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell5Hdr.BackgroundColor = Color.WHITE;
                    }

                    table.AddCell(Cell5Hdr);

                    PdfPCell Cell6Hdr = new PdfPCell(new Phrase(dRow[6].ToString(), fontDynmaicRowsNormal));
                    Cell6Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell6Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell6Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell6Hdr);

                    PdfPCell Cell7Hdr = new PdfPCell(new Phrase(dRow[7].ToString(), fontDynmaicRowsNormal));
                    Cell7Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell7Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell7Hdr.BackgroundColor = Color.WHITE;
                    }
                    table.AddCell(Cell7Hdr);

                    PdfPCell Cell8Hdr = new PdfPCell(new Phrase(dRow[8].ToString(), fontDynmaicRowsNormal));
                    Cell8Hdr.HorizontalAlignment = Element.ALIGN_RIGHT;
                    if (i % 2 == 1)
                    {
                        Cell8Hdr.BackgroundColor = altRow;
                    }
                    else
                    {
                        Cell8Hdr.BackgroundColor = Color.WHITE;
                    }

                    table.AddCell(Cell8Hdr);

                   // table.AddCell(new Phrase(dRow[1].ToString(), fontDynmaicRows));

                    //table.AddCell(new Phrase(dRow[4].ToString(), fontDynmaicRowsNormal));
                    //table.AddCell(new Phrase(dRow[5].ToString(), fontDynmaicRowsNormal));

                    //table.AddCell(new Phrase(dRow[6].ToString(), fontDynmaicRowsNormal));
                    //table.AddCell(new Phrase(dRow[7].ToString(), fontDynmaicRowsNormal));
                    //table.AddCell(new Phrase(dRow[8].ToString(), fontDynmaicRowsNormal));
                }

            }
            return table;
        }
Ejemplo n.º 7
0
        private void GenerateBatteryChartByCustVin(string TempFolderPath, string ProcessDate)
        {
            Paragraph para = new Paragraph();
            Section sec = new Section();
            string CustomerId = string.Empty;
            string CustomerName = string.Empty;
            string Vin = string.Empty;
            int VinId = 0;
            string Bus = string.Empty;

            DataTable dtCust = new DataTable();
            DataTable dtVin = new DataTable();
            GetData gd = new GetData();
            dtCust = gd.DtGetCustomerInfo(DateTime.Parse(ProcessDate));

            int i = 0;
            int j = 0;
            foreach (DataRow dRow in dtCust.Rows)
            {

                i++;
                j = 0;
                CustomerId = dRow["CustomerId"].ToString();
                CustomerName = dRow["CustomerName"].ToString();

                dtVin = gd.DtGetCustomerVehicleInfo(int.Parse(CustomerId), DateTime.Parse(ProcessDate));

                _doc.NewPage();

                //para = new Paragraph(CustomerName);
                //Chapter chap = new Chapter(para, i);
                //Section section1 = chap.AddSection(20f, "Section 1.1", 1);
                //_doc.Add(chap);

                foreach (DataRow vRow in dtVin.Rows)
                {

                    j++;
                    Vin = string.Empty;

                    Vin = vRow["Vin"].ToString();
                    Bus = vRow["Bus"].ToString();
                    VinId = int.Parse(vRow["VinID"].ToString());

                    if (j > 1)
                    {
                        _doc.NewPage();
                    }
                    //Dashboard//
                    //  sec = chap.AddSection(20f, Vin, j);
                    //PdfPTable tableHeader = GenerateBatteryAllCustHeader(ProcessDate, CustomerName, Vin, Bus);
                    //_doc.Add(tableHeader);
                    para = new Paragraph(Bus.ToUpper());
                    Chapter chap = new Chapter(para, j);
                    _doc.Add(chap);
                    string imageURL_VinDash = Path.Combine(TempFolderPath, string.Format("VinDashboard_{0}.png", vRow["VinID"].ToString()));

                    //iTextSharp.text.Image jpg_VinDash = iTextSharp.text.Image.GetInstance(imageURL_VinDash);
                    ////Resize image depend upon your need
                    ////jpg.ScaleToFit(chartWidth, chartHeight);
                    //// jpg_VinHist.ScaleToFit(600f, 250f);
                    //jpg_VinDash.ScalePercent(75f);

                    ////Give space before image
                    //jpg_VinDash.SpacingBefore = 10f;
                    ////Give some space after the image
                    //jpg_VinDash.SpacingAfter = 1f;
                    //jpg_VinDash.Alignment = Element.ALIGN_CENTER;
                    //_doc.Add(jpg_VinDash);

                    PdfPTable tablebat = GenerateBatteryVinDashboard(ProcessDate, VinId);
                    _doc.Add(tablebat);

                    //TMaxByPacks//
                    string imageURL_TMaxByPacks = Path.Combine(TempFolderPath, string.Format("TMaxByPacks_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_TMaxByPacks = iTextSharp.text.Image.GetInstance(imageURL_TMaxByPacks);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_TMaxByPacks.ScalePercent(60f);

                    //Give space before image
                    jpg_TMaxByPacks.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_TMaxByPacks.SpacingAfter = 1f;
                    jpg_TMaxByPacks.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_TMaxByPacks);

                    //CurrentByPacks//
                    string imageURL_CurrentByPacks = Path.Combine(TempFolderPath, string.Format("CurrentByPacks_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_CurrentByPacks = iTextSharp.text.Image.GetInstance(imageURL_CurrentByPacks);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_CurrentByPacks.ScalePercent(60f);

                    //Give space before image
                    jpg_CurrentByPacks.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_CurrentByPacks.SpacingAfter = 1f;
                    jpg_CurrentByPacks.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_CurrentByPacks);

                    //SoCByPacks_Min//
                    string imageURL_SoCByPacks_Min = Path.Combine(TempFolderPath, string.Format("SoCByPacks_Min_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_SoCByPacks_Min = iTextSharp.text.Image.GetInstance(imageURL_SoCByPacks_Min);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_SoCByPacks_Min.ScalePercent(60f);

                    //Give space before image
                    jpg_SoCByPacks_Min.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_SoCByPacks_Min.SpacingAfter = 1f;
                    jpg_SoCByPacks_Min.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_SoCByPacks_Min);

                    //SoCByPacks_Max//
                    string imageURL_SoCByPacks_Max = Path.Combine(TempFolderPath, string.Format("SoCByPacks_Max_{0}.png", vRow["VinID"].ToString()));

                    iTextSharp.text.Image jpg_SoCByPacks_Max = iTextSharp.text.Image.GetInstance(imageURL_SoCByPacks_Max);
                    //Resize image depend upon your need
                    //jpg.ScaleToFit(chartWidth, chartHeight);
                    // jpg_VinHist.ScaleToFit(600f, 250f);
                    jpg_SoCByPacks_Max.ScalePercent(60f);

                    //Give space before image
                    jpg_SoCByPacks_Max.SpacingBefore = 10f;
                    //Give some space after the image
                    jpg_SoCByPacks_Max.SpacingAfter = 1f;
                    jpg_SoCByPacks_Max.Alignment = Element.ALIGN_CENTER;
                    _doc.Add(jpg_SoCByPacks_Max);

                    //CurrentByPacks

                }

            }
        }