private void CommandBinding_ScanFolder(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(SVR_ImportFolder)) { SVR_ImportFolder fldr = (SVR_ImportFolder)obj; ShokoServer.ScanFolder(fldr.ImportFolderID); MessageBox.Show(Shoko.Commons.Properties.Resources.Server_ScanFolder, Shoko.Commons.Properties.Resources.Success, MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void InitCulture() { try { string currentCulture = ServerSettings.Culture; cboLanguages.ItemsSource = UserCulture.SupportedLanguages; for (int i = 0; i < cboLanguages.Items.Count; i++) { UserCulture ul = cboLanguages.Items[i] as UserCulture; if (ul.Culture.Trim().ToUpper() == currentCulture.Trim().ToUpper()) { cboLanguages.SelectedIndex = i; break; } } if (cboLanguages.SelectedIndex < 0) { cboLanguages.SelectedIndex = 0; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { //ServerInfo.Instance.RefreshImportFolders(); if (ServerSettings.MinimizeOnStartup) { MinimizeToTray(); } tabControl1.SelectedIndex = 6; // setup if (ServerSettings.AniDB_Username.Equals("jonbaby", StringComparison.InvariantCultureIgnoreCase) || ServerSettings.AniDB_Username.Equals("jmediamanager", StringComparison.InvariantCultureIgnoreCase)) { btnUploadAzureCache.Visibility = System.Windows.Visibility.Visible; } logger.Info("Clearing Cache..."); Utils.ClearAutoUpdateCache(); ShowDatabaseSetup(); logger.Info("Initializing DB..."); ShokoServer.RunWorkSetupDB(); ShokoServer.Instance.CheckForUpdates(); ShokoServer.Instance.UpdateAvailable += (s, args) => new UpdateForm { Owner = Instance }.ShowDialog(); }
public Dictionary <string, XmlDocument> GetFullSeriesInfo(int seriesID) { try { Init(); string url = string.Format(Shoko.Server.Constants.TvDBURLs.urlFullSeriesData, urlMirror, Shoko.Server.Constants.TvDBURLs.apiKey, seriesID, ServerSettings.TvDB_Language); logger.Trace("GetFullSeriesInfo: {0}", url); Stream data = Utils.DownloadWebBinary(url); if (data != null) { // this will get following xml files: en.xml, actors.xml, banners.xml return(DecompressZipToXmls(data)); } else { logger.Trace("GetFullSeriesInfo: data was null"); } } catch (Exception ex) { logger.Error(ex, "Error in TVDBHelper.GetFullSeriesInfo: " + ex.ToString()); } return(null); }
public XmlDocument GetSeriesBannersOnline(int seriesID) { try { Init(); string url = string.Format(Shoko.Server.Constants.TvDBURLs.urlBannersXML, urlMirror, Shoko.Server.Constants.TvDBURLs.apiKey, seriesID); logger.Trace("GetSeriesBannersOnline: {0}", url); // Search for a series string xmlSeries = Utils.DownloadWebPage(url); XmlDocument docBanners = new XmlDocument(); docBanners.LoadXml(xmlSeries); return(docBanners); } catch (Exception ex) { logger.Error(ex, "Error in TVDBHelper.GetSeriesBannersOnline: " + ex.ToString()); } return(null); }
void btnLogs_Click(object sender, RoutedEventArgs e) { try { string logPath = Path.Combine(ServerSettings.ApplicationPath, "logs"); Process.Start(new ProcessStartInfo(logPath)); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
/* * public static bool ConfirmTvDBOnline() * { * TvDB_Series tvser = GetSeriesInfoOnline(73255); * if (tvser == null) * return false; * else * return true; * } */ public static TvDB_Series GetSeriesInfoOnline(int seriesID) { try { //Init(); string url = string.Format(Shoko.Server.Constants.TvDBURLs.urlSeriesBaseXML, URLMirror, Shoko.Server.Constants.TvDBURLs.apiKey, seriesID, ServerSettings.TvDB_Language); logger.Trace("GetSeriesInfo: {0}", url); // Search for a series string xmlSeries = Utils.DownloadWebPage(url); logger.Trace("GetSeriesInfo RESULT: {0}", xmlSeries); if (xmlSeries.Trim().Length == 0) { return(null); } XmlDocument docSeries = new XmlDocument(); docSeries.LoadXml(xmlSeries); TvDB_Series tvSeries = null; if (docSeries != null) { tvSeries = RepoFactory.TvDB_Series.GetByTvDBID(seriesID); if (tvSeries == null) { tvSeries = new TvDB_Series(); } tvSeries.PopulateFromSeriesInfo(docSeries); RepoFactory.TvDB_Series.Save(tvSeries); } return(tvSeries); } catch (Exception ex) { logger.Error(ex, "Error in TVDBHelper.GetSeriesInfoOnline: " + ex.ToString()); } return(null); }
void btnApplyServerPort_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtServerPort.Text)) { MessageBox.Show(Shoko.Commons.Properties.Resources.Server_EnterAnyValue, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); txtServerPort.Focus(); return; } ushort port = 0; bool success = ushort.TryParse(txtServerPort.Text, out port); if (!success || port <= 0 || port > 65535) { MessageBox.Show(Shoko.Commons.Properties.Resources.Server_EnterCertainValue, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); txtServerPort.Focus(); return; } if (!Utils.IsAdministrator()) { MessageBox.Show(Shoko.Commons.Properties.Resources.Settings_ChangeServerPortFail, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } try { this.Cursor = Cursors.Wait; if (!ShokoServer.Instance.SetNancyPort(port)) { MessageBox.Show(Shoko.Commons.Properties.Resources.Settings_ChangeServerPortFail, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } this.Cursor = Cursors.Arrow; } catch (Exception ex) { logger.Error(ex, ex.ToString()); MessageBox.Show(ex.Message, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } }
/* * public List<TvDB_ImageFanart> GetFanart(int seriesID, bool forceRefresh) * { * List<TvDB_ImageFanart> fanarts = new List<TvDB_ImageFanart>(); * * if (forceRefresh) * { * fanarts = GetFanartOnline(seriesID); * } * else * { * TvDB_ImageFanartRepository repFanart = new TvDB_ImageFanartRepository(); * fanarts = repFanart.GetBySeriesID(seriesID); * if (fanarts.Count == 0) * fanarts = GetFanartOnline(seriesID); * } * * return fanarts; * } * * public List<TvDB_ImageFanart> GetFanartOnline(int seriesID) * { * List<TvDB_ImageFanart> fanarts = new List<TvDB_ImageFanart>(); * * XmlDocument doc = GetSeriesBannersOnline(seriesID); * List<object> banners = ParseBanners(seriesID, doc); * * foreach (object obj in banners) * { * if (obj.GetType() == typeof(TvDB_ImageFanart)) * fanarts.Add((TvDB_ImageFanart)obj); * } * * return fanarts; * } * * public List<TvDB_ImageWideBanner> GetWideBannersOnline(int seriesID) * { * List<TvDB_ImageWideBanner> wideBanners = new List<TvDB_ImageWideBanner>(); * * XmlDocument doc = GetSeriesBannersOnline(seriesID); * List<object> banners = ParseBanners(seriesID, doc); * * foreach (object obj in banners) * { * if (obj.GetType() == typeof(TvDB_ImageWideBanner)) * wideBanners.Add((TvDB_ImageWideBanner)obj); * } * * return wideBanners; * } * * public List<TvDB_ImagePoster> GetPostersOnline(int seriesID) * { * //BaseConfig.MyAnimeLog.Write("Getting posters online: {0}", seriesID); * List<TvDB_ImagePoster> posters = new List<TvDB_ImagePoster>(); * * XmlDocument doc = GetSeriesBannersOnline(seriesID); * List<object> banners = ParseBanners(seriesID, doc); * * foreach (object obj in banners) * { * if (obj.GetType() == typeof(TvDB_ImagePoster)) * posters.Add((TvDB_ImagePoster)obj); * } * * return posters; * } */ public List <TvDB_Language> GetLanguages() { List <TvDB_Language> languages = new List <TvDB_Language>(); try { Init(); string url = string.Format(Shoko.Server.Constants.TvDBURLs.urlLanguagesXML, urlMirror, Shoko.Server.Constants.TvDBURLs.apiKey); logger.Trace("GetLanguages: {0}", url); // Search for a series string xmlSeries = Utils.DownloadWebPage(url, Encoding.UTF8); XmlDocument docLanguages = new XmlDocument(); docLanguages.LoadXml(xmlSeries); XmlNodeList lanItems = docLanguages["Languages"].GetElementsByTagName("Language"); //BaseConfig.MyAnimeLog.Write("Found {0} banner nodes", bannerItems.Count); if (lanItems.Count <= 0) { return(languages); } foreach (XmlNode node in lanItems) { TvDB_Language lan = new TvDB_Language(); lan.Name = node["name"].InnerText.Trim(); lan.Abbreviation = node["abbreviation"].InnerText.Trim(); languages.Add(lan); } } catch (Exception ex) { logger.Error(ex, "Error in TVDBHelper.GetSeriesBannersOnline: " + ex.ToString()); } return(languages); }
private void Init() { try { if (initialised) { return; } // 01. try and download the list of mirrors string xmlMirrors = Utils.DownloadWebPage(urlMirrorsList); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlMirrors); XmlNodeList mirrorItems = xmlDoc["Mirrors"].GetElementsByTagName("Mirror"); if (mirrorItems.Count <= 0) { return; } string id = mirrorItems[0]["id"].InnerText; urlMirror = mirrorItems[0]["mirrorpath"].InnerText; string typemask = mirrorItems[0]["typemask"].InnerText; logger.Info("TVDB Mirror: {0}", urlMirror); // 02. get the server time string xmlServerTime = Utils.DownloadWebPage(urlServerTime); XmlDocument docServer = new XmlDocument(); docServer.LoadXml(xmlServerTime); serverTime = docServer["Items"]["Time"].InnerText; logger.Info("serverTime: {0}", serverTime); initialised = true; } catch (Exception ex) { logger.Error(ex, "Error in TVDBHelper.Init: " + ex.ToString()); } }
public List <TVDB_Series_Search_Response> SearchSeries(string criteria) { List <TVDB_Series_Search_Response> results = new List <TVDB_Series_Search_Response>(); try { Init(); if (!initialised) { return(results); } // Search for a series string url = string.Format(Shoko.Server.Constants.TvDBURLs.urlSeriesSearch, criteria); logger.Trace("Search TvDB Series: {0}", url); string xmlSeries = Utils.DownloadWebPage(url); XmlDocument docSeries = new XmlDocument(); docSeries.LoadXml(xmlSeries); bool hasData = docSeries["Data"].HasChildNodes; if (hasData) { XmlNodeList seriesItems = docSeries["Data"].GetElementsByTagName("Series"); foreach (XmlNode series in seriesItems) { TVDB_Series_Search_Response searchResult = new TVDB_Series_Search_Response(); searchResult.Populate(series); results.Add(searchResult); } } } catch (Exception ex) { logger.Error(ex, "Error in SearchSeries: " + ex.ToString()); } return(results); }
private void SetCulture() { if (cboLanguages.SelectedItem == null) { return; } UserCulture ul = cboLanguages.SelectedItem as UserCulture; bool isLanguageChanged = ServerSettings.Culture != ul.Culture; System.Windows.Forms.DialogResult result; try { CultureInfo ci = new CultureInfo(ul.Culture); CultureInfo.DefaultThreadCurrentUICulture = ci; CultureManager.UICulture = ci; ServerSettings.Culture = ul.Culture; if (isLanguageChanged) { result = System.Windows.Forms.MessageBox.Show(Shoko.Commons.Properties.Resources.Language_Info, Shoko.Commons.Properties.Resources.Language_Switch, System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Information); if (result != System.Windows.Forms.DialogResult.OK) { return; } System.Windows.Forms.Application.Restart(); ShokoServer.Instance.ApplicationShutdown(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static List <int> GetUpdatedSeriesList(string serverTime) { List <int> seriesList = new List <int>(); try { string url = string.Format(Shoko.Server.Constants.TvDBURLs.urlUpdatesList, URLMirror, serverTime); // Search for a series string xmlUpdateList = Utils.DownloadWebPage(url); //BaseConfig.MyAnimeLog.Write("GetSeriesInfo RESULT: {0}", xmlSeries); XmlDocument docUpdates = new XmlDocument(); docUpdates.LoadXml(xmlUpdateList); XmlNodeList nodes = docUpdates["Items"].GetElementsByTagName("Series"); foreach (XmlNode node in nodes) { string sid = node.InnerText; int id = -1; int.TryParse(sid, out id); if (id > 0) { seriesList.Add(id); } //BaseConfig.MyAnimeLog.Write("Updated series: {0}", sid); } return(seriesList); } catch (Exception ex) { logger.Error(ex, "Error in GetUpdatedSeriesList: " + ex.ToString()); return(seriesList); } }
void btnHasherClear_Click(object sender, RoutedEventArgs e) { try { this.Cursor = Cursors.Wait; ShokoService.CmdProcessorHasher.Stop(); // wait until the queue stops while (ShokoService.CmdProcessorHasher.ProcessingCommands) { Thread.Sleep(200); } Thread.Sleep(200); RepoFactory.CommandRequest.Delete(RepoFactory.CommandRequest.GetAllCommandRequestHasher()); ShokoService.CmdProcessorHasher.Init(); } catch (Exception ex) { Utils.ShowErrorMessage(ex.Message); } this.Cursor = Cursors.Arrow; }