예제 #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);
                    }
               }

            }
        }