コード例 #1
0
ファイル: GetData.cs プロジェクト: kiranmath/PcanRepository
        public VinReportParam GetActionReportRow()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["PCanRepository"].ConnectionString;
            // string sql = "SELECT CustomerID,CustomerName, Bus, BusOwner,Vin,VinID from dbo.VehiclesVw with(nolock) where VinID=@VinID";
            string sql = "select ID,vinID, ProcessDate,WeekNumber, YearNumber, ReportPeriod  from DataSystem_SummaryTable_DataReportGeneration with(nolock)  where ID = ( select min(ID) from DataSystem_SummaryTable_DataReportGeneration with(nolock) where ReportProduced = 0 )";
            VinReportParam r = new VinReportParam();

            using (SqlConnection con = new SqlConnection(connectionString))
            {

                SqlCommand cmd = new SqlCommand(sql, con);
                //cmd.Parameters.Add("@VinID", SqlDbType.Int);
                //cmd.Parameters["@VinID"].Value = VinID;
                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        r.ReportID = int.Parse(reader["ID"].ToString());
                        r.VinID = int.Parse(reader["VinID"].ToString());
                        r.ProcessDate = reader["ProcessDate"].ToString();
                        r.WeekNumber = reader["WeekNumber"].ToString();
                        r.YearNumber = reader["YearNumber"].ToString();
                        r.ReportPeriod = reader["ReportPeriod"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                return r;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kiranmath/PcanRepository
        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);
                    }
               }

            }
        }