public InstallationManager(Config config, DownloadListManager downloadListManager, LanguageProvider languageProvider, PictosysWebService pictosysWebService) { _config = config; _downloadListManager = downloadListManager; this.languageProvider = languageProvider; this.pictosysWebService = pictosysWebService; }
/// <summary> /// Skapar en ny instans av klassen. /// </summary> public DownloadManager(LanguageProvider languageProvider, PictosysWebService pictosysWebService) { if (languageProvider == null) { throw new NullReferenceException("Language provider cannot be null"); } this._languageProvider = languageProvider; if (pictosysWebService == null) { throw new NullReferenceException("Pictosys Web service cannot be null"); } this.pictosysWebService = pictosysWebService; }
/// <summary> /// Hämtar giltiga språk. /// </summary> public void RefreshLanguages() { try { var service = new PictosysWebService(); var languages = service.getSwedishLanguageNames(); for (var i = 0; i < languages.Length; i += 2) { languageToLocaleMapping[languages[i]] = languages[i + 1]; Console.WriteLine(languages[i]); } } catch { LogMessage("Kunde inte ansluta till server."); } }
public DownloadListManager(PictosysWebService pictosysWebService) { this.pictosysWebService = pictosysWebService; }
public void DownloadZip(string username, string password, Language language) { ProgressChanged(ProgressBarStyle.Marquee, 0, 1); StatusChanged("Laddar ner pictogramzip..."); try { /* Skapa målkatalog */ DirectoryInfo target = CreateTargetDirectory(); PictosysWebService service = new PictosysWebService(); BinaryWriter writer = null; try { string file = target.FullName + @"\pict" + language + ".zip"; LogMessage("Laddar ner zipfil till " + file + "..."); byte[] buffer = service.downloadPictogramZip(username, password, language.Code); if (buffer.Length > 0) { writer = new BinaryWriter(new FileStream(file, FileMode.OpenOrCreate)); writer.Write(buffer); } else { LogMessage("No zipfile for that language exists or insufficient rights."); } } catch (SoapException e) { LogMessage("Fel vid nedladdning av zipfil: " + e.Message); } catch (FileNotFoundException e) { LogMessage("Fel vid nedladdning av zipfil: " + e.Message); } finally { if (writer != null) { writer.Close(); } } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } ProgressChanged(ProgressBarStyle.Blocks, 0, 1); StatusChanged("Klar"); }
public void DownloadPictogramZipUrl(string username, string password, string languageName) { ProgressChanged(ProgressBarStyle.Continuous, 0, 1); StatusChanged("Hämtar pictogram-URL..."); try { PictosysWebService service = new PictosysWebService(); string locale = this._languageProvider.GetLocale(languageName); LogMessage(service.getPictogramZipDownloadUrl(username, password, locale)); } catch (Exception e) { LogMessage(e.Message); } ProgressChanged(ProgressBarStyle.Blocks, 0, 1); StatusChanged("Klar"); }
/// <summary> /// Metod för att kontrollera om inloggningsuppgifterna är giltiga. /// </summary> /// <param name="username">Användarnamn</param> /// <param name="password">Lösenord</param> /// <returns>en boolean som talar om ifall kontouppgifterna var giltiga</returns> public bool checkLogin(string username, string password) { ProgressChanged(ProgressBarStyle.Marquee, 0, 1); bool login = false; try { PictosysWebService service = new PictosysWebService(); login = service.verifyLogin(username, password); if (login) { StatusChanged("Kontouppgifterna är giltiga."); } else { StatusChanged("Kontrollera kontouppgifterna!"); } } catch { LogMessage("Kunde inte ansluta till server."); } ProgressChanged(ProgressBarStyle.Blocks, 0, 1); return login; }
/// <summary> /// Should be refactored to use proper dependency injection. /// </summary> private void createDependencyGraph() { this._languageSelection = new LanguageSelection(); this._authenticationService = new AuthenticationService(); this.categoryRepository = new CategoryRepository(); this.categoryTranslationService = new CategoryTranslationService(); this.languageProvider = new LanguageProvider(); this.pictosysWebService = new PictosysWebService(); this._config = new Config(this.categoryRepository, this.categoryTranslationService); this.downloadManager = new DownloadManager(this.languageProvider, this.pictosysWebService); this.downloadListManager = new DownloadListManager(this.pictosysWebService); this.installationManager = new InstallationManager(this._config, this.downloadListManager, this.languageProvider, this.pictosysWebService); }