//Open and choose a folder where the downloads will go to private void ChooseDownloadFolder() { try { using (FolderBrowserDialog fbd = new FolderBrowserDialog()) { //Venster openen DialogResult result = fbd.ShowDialog(); //Nakijken of dat venster succesvol is geopend en pad is gekozen if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) { //Pad opslaan if (fbd.SelectedPath.Last() != '\\') { fbd.SelectedPath += @"\\";//2 backslashen toegevoegd. Niet 1 } DownloadFolder = fbd.SelectedPath; Console.WriteLine("Downloadpad veranderd naar: " + fbd.SelectedPath); FeedbackColor = "White"; FeedbackList.Add("Downloadpad veranderd naar " + fbd.SelectedPath); } } } catch (Exception ex) { FeedbackColor = "Red"; FeedbackList.Add("Failed to open folder: " + ex.Message); } }
/// <summary> /// Feedback geven op de afgelopen sessie /// </summary> /// <param name="feedbacktxt">feedback tekst</param> /// <param name="gebruiker">Gebruiker Object</param> public void FeedbackGeven(string feedbacktxt, Gebruiker gebruiker, int score) { if (StatusSessie != StatusSessie.Gesloten) { throw new FeedbackException("Je kan geen feedback geven op een niet afgelopen sessie."); } if (gebruiker.StatusGebruiker != StatusGebruiker.Actief) { throw new GeenActieveGebruikerException("Je moet een actieve gebruiker zijn om feedback te kunnen geven"); } if (score < 1 || score > 5) { throw new FeedbackException("Score moet tussen 1 en 5 liggen"); } foreach (Feedback f in FeedbackList) { if (f.Auteur == gebruiker) { throw new FeedbackException("Gebruiker heeft al feedback gegeven."); } } if (gebruiker.Aanwezig(this)) { Feedback feedback = new Feedback(gebruiker, feedbacktxt, DateTime.Now, score); FeedbackList.Add(feedback); } else { throw new AanwezigException("Gebruiker was niet aanwezig of niet ingeschreven en kan dus geen feedback geven!"); } }
public EVERadioVM() { EVERadioSessions = new List <EVERadioSession>(); //Alle sessies ophalen en tonen GetAllSessions(); //Feedback invullen FeedbackList.Add("Hello I'm feedback. Please press 'Download All' to start"); FeedbackColor = "White"; }
public bool AddFeedBack(string stdname, string CourseN, string Desc) { try { IFeedback thefb = UserFactory.GetFeedback(stdname, CourseN, Desc); FeedbackList.Add(thefb); DataLayer.addNewFeedBackToDB(thefb); return(true); } catch (System.Exception excep) { return(false); } }
//Start downloaden van een bestand private async Task DownloadFileAsync(string url, string naam) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; try { using (WebClient wc = new WebClient()) { wc.DownloadProgressChanged += Client_DownLoadProcessChanged; //Om tussentijdse feedback te kunnen geven. wc.DownloadFileCompleted += Client_DownloadProcessComplete; //Om feedback te kunnen geven bij voltooing //Make instance off class library DownloadEVERadioSessions downloadEVERadioSessionsClassLib = new DownloadEVERadioSessions(); if (UseProxy) //Use a proxy if the user wants to { GetProxyModel proxyinfo = downloadEVERadioSessionsClassLib.GetRandomProxy(); //Get a random proxy wc.Proxy = new WebProxy(proxyinfo.Ip, proxyinfo.Port); //Proxy instellen } //timer per download starten EVERadioSession evers = EVERadioSessions.Find(f => f.FileName == naam.Split('\\').Last()); evers.StopWatch.Start(); //Extra informatie per download bijhouden. evers.TimeStarted = DateTime.Now; await wc.DownloadFileTaskAsync(new Uri(url), naam); } } catch (Exception ex) { Console.WriteLine(ex.Message); if (ex.Message == "Unable to connect to the remote server") { FeedbackList.Add("Error, try again with Proxy enabled"); } else { FeedbackList.Add("Bestand: " + naam.Split('\\').Last() + " - Something went wrong, maybe this helps: " + ex.Message); } FeedbackColor = "Red"; } }
//Download de geselecteerde sessies private void DownloadSelected() { try { //Sessies ophalen die geselecteerd zijn foreach (EVERadioSession sessie in EVERadioSessions.Where(item => item.IsSelected)) { HandleSession(sessie); } } catch (Exception ex) { Console.WriteLine("Foutboodschap: " + ex.Message); FeedbackColor = "Red"; FeedbackList.Add("DownloadSelected failed: " + ex.Message); } }
//Open Filezilla private void OpenFileZilla() { try { //Gaat in regedit zoeken naar het pad aan de hand van onderstaande waarde //(onderstaande waarde heb ik zelf in regedit opgezocht om dit te weten voor filezilla) //Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\filezilla.exe Process pcss = new Process(); pcss.StartInfo.Arguments = "--local=" + _downloadfolder + " --site=0/Thuis"; pcss.StartInfo.FileName = "Filezilla.exe"; pcss.Start(); //Process.Start("Filezilla.exe"); } catch (Exception ex) { FeedbackColor = "Red"; FeedbackList.Add("Filezilla niet geopend: " + ex.Message); } }
//Get all the sessions and show them in the overviewlist private void GetAllSessions() { try { using (WebClient client = new WebClient()) { //We downloaden de EVE-Radio pagina string htmlCode = client.DownloadString("https://gamingnow.net/gn_rewind/rewind/"); //We splitsen de herbeluister divs op basis van hun ID string[] stringSeperators = new string[] { "<div class='parentPresent' style='display:none;'>" }; string[] rewinds = htmlCode.Split(stringSeperators, StringSplitOptions.None).Skip(1).ToArray();//Het eerste dat we eruit halen is rommel. //Nu gaan we voor elk van de gevonden rewinds de starturl opzoeken foreach (string rewind in rewinds) { //We vinden de startpositie van de tekst die we willen, de eindpositie, en halen daar de lengte uit. int startPos = rewind.IndexOf("Listen from: <a href='#' onclick=\"javascript:doCmd({rewind:'") + "Listen from: <a href='#' onclick=\"javascript:doCmd({rewind:'".Length; int length = rewind.IndexOf("'}); return false;\">Start") - startPos; string downloadUrl = rewind.Substring(startPos, length); string bestandsnaam = downloadUrl.Split('/').Last(); //Starten met downloadsnelheidsberekening Stopwatch sw = new Stopwatch(); EVERadioSessions.Add(new EVERadioSession() { FilePath = downloadUrl, FileName = bestandsnaam, StopWatch = sw, IsDownloading = false }); } } } catch (Exception ex) { Console.WriteLine(ex.Message); FeedbackColor = "Red"; FeedbackList.Add("Failed getting all sessions. Maybe this helps: " + ex.Message); } }
//Download all the sessions private void DownloadAll() { try { //Give feedback to user FeedbackList.Add("We started downloading ALL THE SONGS"); FeedbackColor = "Green"; //We overlopen alle EVE Radio sessies die we willen downloaden foreach (EVERadioSession sessie in EVERadioSessions) { HandleSession(sessie); } } catch (Exception ex) { Console.WriteLine("Foutboodschap: " + ex.Message); FeedbackColor = "Red"; FeedbackList.Add("DownloadAll failed: " + ex.Message); } }
/// <summary> /// Checks if a session is downloading /// Starts downloading session if not already downloading /// </summary> /// <param name="sessie"></param> private void HandleSession(EVERadioSession sessie) { string localpath = _downloadfolder + sessie.FileName; if (sessie.IsDownloading)//Als het bestand aan het downloaden is, gaan we het niet onderbreken { FeedbackList.Add("Song " + sessie.FileName + " is already downloading."); } else { if (!IsFullSession(localpath))//Als het een volledig bestand is moeten we het niet opnieuw downloaden { sessie.IsDownloading = true; sessie.Achtergrondkleur = "Orange"; DownloadFileAsync(sessie.FilePath, localpath);//Aanzetten om bestanden te downloaden } else { sessie.IsDownloading = false; sessie.Achtergrondkleur = "GreenYellow"; sessie.Progress = 100; } } }
//Feedback-------------------------------------------------------------------------------// void Feedback_Save() { FeedbackList newList = new FeedbackList(); newList.Listname = "Feedbacks"; FeedbackController fbC = gameController.transform.FindChild("FeedBackController").GetComponent<FeedbackController>(); if (fbC.archivedListOfFeedbacks.Count != 0) { for (int i = 0; i < fbC.archivedListOfFeedbacks.Count; i++) { newList.Add(fbC.archivedListOfFeedbacks[i]); } } System.Type[] sheet = { typeof(FeedBack) }; XmlSerializer serializer = new XmlSerializer(typeof(FeedbackList), sheet); FileStream fs = new FileStream(fullPath + feedbackPath, FileMode.Create); serializer.Serialize(fs, newList); fs.Close(); newList = null; }