public BotSelenium(IWebDriver driver, String url, List <string> listQuartier, Bloc_Fenetre fenetre, String mail, String mdp) { this.driver = driver; listUserDepartment = listQuartier; this.listInscription = new List <Inscription>(); this.fenetre = fenetre; gestionInterval = new Gestion_Interval_User(); this.url = url; Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); numeroSemaine = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear( fenetre.list_bloc_jour[0].date_jour, DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek); listInterval = gestionInterval.Set_List_Interval_User(fenetre, listInscription); this.mail = mail; this.mdp = mdp; Login(); MoveToPlanning(); PlanningPage(); }
public void Get_Shifts() { Ajout_Log("Lancement méthode get shift"); tempsGetShifts = Stopwatch.StartNew(); shiftComplet = true; bool scheduleFounded = false; if (sub_ok) { try { list_shifts = new List <Shifts>(); for (int i = 0; i < bloc_location.list_fenetre.Count; i++) { if (bloc_location.list_fenetre[i].recherche_en_cours && bloc_location.list_fenetre[i].schedule != null) { Ajout_Text(false, "Recuperation des shifts en cours"); listInterval = gestion_interval.Set_List_Interval_User(bloc_location.list_fenetre[i], list_incriptions); bool finPage = false; int currentPageApi = 1; scheduleFounded = true; Shift_API_return apiInfos = Get_Shift_API("schedules/" + bloc_location.list_fenetre[i].schedule.Id + "/shifts.json" + String_Department_API(bloc_location.list_fenetre[i]) + "&page=" + currentPageApi); currentPageApi++; if (shiftComplet && !apiInfos.shiftComplet) { shiftComplet = false; } finPage = apiInfos.finPage; if (apiInfos.presenceHeaderPage) { if (apiInfos.pagesMax > 1) { Ajout_Log("Lancement des threads shifts, nombre : " + (apiInfos.pagesMax - 1)); Thread[] arrayThreads = new Thread[apiInfos.pagesMax - 1]; for (int j = 0; j < arrayThreads.Length; j++) { String p = currentPageApi.ToString(); arrayThreads[j] = new Thread(() => Shift_API_Thread("schedules/" + bloc_location.list_fenetre[i].schedule.Id + "/shifts.json" + String_Department_API(bloc_location.list_fenetre[i]) + "&page=" + p)); arrayThreads[j].Start(); currentPageApi++; } bool threadRunning = true; while (threadRunning) { foreach (Thread t in arrayThreads) { if (t.IsAlive) { threadRunning = true; break; } else { threadRunning = false; } } } } Ajout_Text(false, "Tout les shifts recupérés"); } else { while (!finPage) { apiInfos = Get_Shift_API("schedules/" + bloc_location.list_fenetre[i].schedule.Id + "/shifts.json" + String_Department_API(bloc_location.list_fenetre[i]) + "&page=" + currentPageApi); currentPageApi++; if (shiftComplet && !apiInfos.shiftComplet) { shiftComplet = false; } finPage = apiInfos.finPage; } } break; } else if (bloc_location.list_fenetre[i].recherche_en_cours) { Ajout_Text(false, "Pas de planning pour " + bloc_location.list_fenetre[i].location.Name); } } } catch { Ajout_Text(false, "Probleme de connexion"); } } else { Ajout_Text(false, "Vous etes pas abonné, nous ne pouvons pas vous inscrire"); } tempsGetShifts.Stop(); if (shiftComplet && scheduleFounded) { procedureShiftsComplet = true; Ajout_Text(false, "Tout les shifts sont complets - Fin de la procédure d'inscription"); } if (scheduleFounded) { Bilan_Log_Shifts_Get(); Ajout_Text(false, "Temps recuperation shifts : " + tempsGetShifts.ElapsedMilliseconds.ToString() + " ms"); } }