private void PdfGenerate() { counteOfChartr = 0; threadsList = new List <Thread>(); images = new Dictionary <object, System.Drawing.Image>(); parkings = new Dictionary <int, List <List <IdParking> > >(); PDfTableDictionary = new Dictionary <object, List <PdfPTable> >(); try { connectionSql.ToTime = availableTo.ConvertToUnixTimestamp(); connectionSql.FromTime = availableFrom.ConvertToUnixTimestamp(); if ((((availableTo.Value.Year - availableFrom.Value.Year) * 12) + availableTo.Value.Month - availableFrom.Value.Month) >= 12) { throw new Exception("NIe można wygenerować raportu większego niż 1 rok"); } } catch { MessageBox.Show("Nie wybrano daty, lub data jest większa niż 1 rok"); return; } Thread thread = new Thread(WaitForAllChart); thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); MessageBox.Show("Proces może potrwać pare minut!"); foreach (var item in operationsListBox) { if (item.operation == "Ilość pojazdów") { Task.Run(async() => { threadsList.Add(new Thread(ChartSelect.TheSumOfVehicles) { Name = "1" }); await connectionSql.numberVehicle(idParkings, 1); }).Wait(); } if (item.operation == "Ilość wzbudzeń") { Task.Run(async() => { threadsList.Add(new Thread(ChartSelect.TheSumOfVehiclesInMonth) { Name = "2" }); await connectionSql.numberVehicleGroupBy(idParkings, GroupBy.MONTH, 2); }).Wait(); } if (item.operation == "Ilość wzbudzeń procentowe") { Task.Run(async() => { threadsList.Add(new Thread(ChartSelect.TheSumOfVehiclesInMonthPercent) { Name = "3" }); await connectionSql.numberVehicleGroupBy(idParkings, GroupBy.MONTH, 3); }).Wait(); } if (item.operation == "Ilośd wzbudzeń na parkingu w danym miesiącu") { Task.Run(async() => { threadsList.Add(new Thread(ChartSelect.TheSumOfVehiclesInMonthPercentOnCarPark) { Name = "4" }); await connectionSql.numberVehicleGroupBy(idParkings, GroupBy.MONTH, 4); }).Wait(); } if (item.operation == "Zestawienie godzinowe") { Task.Run(async() => { threadsList.Add(new Thread(ChartSelect.HourlySummary) { Name = "5" }); await connectionSql.numberVehicleGroupBy(idParkings, GroupBy.HOUR, 5); }).Wait(); } if (item.operation == "Zestawienie godzinowe dla każdego parkingu") { Task.Run(async() => { threadsList.Add(new Thread(ChartSelect.HourlySummaryForEachParking) { Name = "6" }); await connectionSql.numberVehicleGroupBy(idParkings, GroupBy.HOUR, 6); }).Wait(); } if (item.operation == "Zestawienie godzinowe dla każdego parkingu wzgledem miesięcy") { Task.Run(async() => { threadsList.Add(new Thread(ChartSelect.HourlySummaryForEachParkingByMonth) { Name = "7" }); await connectionSql.numberVehicleGroupByInEachHoursOfMonth(idParkings, 7); }).Wait(); } } }