public void Import(string pluginName, ProgressCallback progressCallback, FeedbackCallback feedbackCallback) { try { LogMessageInArgusTV(String.Format("Guide import, using plugin {0} started.", pluginName), LogSeverity.Information); IGuideImportPlugin plugin = GetPluginByName(pluginName); if (plugin != null) { if (!plugin.IsConfigured()) { LogMessageInArgusTV(String.Format("Plugin {0} is not completely configured, check it's configuration.", pluginName), LogSeverity.Error); } else { plugin.PrepareImport(feedbackCallback, new KeepImportServiceAliveCallback(KeepImportServiceAlive)); using (GuideServiceAgent guideAgent = new GuideServiceAgent()) { guideAgent.StartGuideImport(); try { PluginSetting pluginSetting = GetPluginSetting(pluginName); plugin.Import(pluginSetting.ChannelsToSkip, new ImportDataCallback(SaveGuideDataInArgusTV), progressCallback, feedbackCallback, new KeepImportServiceAliveCallback(KeepImportServiceAlive)); } finally { guideAgent.EndGuideImport(); } } } } else { LogMessageInArgusTV(String.Format("Plugin {0} not found, check your configuration.", pluginName), LogSeverity.Error); } } catch (Exception ex) { LogMessageInArgusTV(String.Format("Guide import using plugin {0} failed, error : {1}", pluginName, ex.Message), LogSeverity.Error); throw; } finally { LogMessageInArgusTV(String.Format("Guide import using plugin {0} ended.", pluginName), LogSeverity.Information); } }
public static PluginSetting Parse(XPathNavigator navigator) { PluginSetting result = null; string pluginName = navigator.GetAttribute("Name", String.Empty); if (!String.IsNullOrEmpty(pluginName)) { XPathNodeIterator iterator = navigator.Select("ChannelsToSkip/Channel"); List<ImportGuideChannel> channelsToSkip = new List<ImportGuideChannel>(); while (iterator.MoveNext()) { string name = iterator.Current.GetAttribute("Name", String.Empty); string externalId = iterator.Current.GetAttribute("ExternalId", String.Empty); channelsToSkip.Add(new ImportGuideChannel(name, externalId)); } result = new PluginSetting(pluginName); result.ChannelsToSkip = channelsToSkip; } return result; }
public static PluginSetting Parse(XPathNavigator navigator) { PluginSetting result = null; string pluginName = navigator.GetAttribute("Name", String.Empty); if (!String.IsNullOrEmpty(pluginName)) { XPathNodeIterator iterator = navigator.Select("ChannelsToSkip/Channel"); List <ImportGuideChannel> channelsToSkip = new List <ImportGuideChannel>(); while (iterator.MoveNext()) { string name = iterator.Current.GetAttribute("Name", String.Empty); string externalId = iterator.Current.GetAttribute("ExternalId", String.Empty); channelsToSkip.Add(new ImportGuideChannel(name, externalId)); } result = new PluginSetting(pluginName); result.ChannelsToSkip = channelsToSkip; } return(result); }
private void LoadPluginSettings() { _pluginSettings.Clear(); if (File.Exists(SettingsFileName)) { using (StreamReader reader = new StreamReader(SettingsFileName, Encoding.UTF8)) { XPathDocument xpathDocument = new XPathDocument(reader); XPathNavigator navigator = xpathDocument.CreateNavigator(); XPathNodeIterator iterator = navigator.Select("/Plugins/Plugin"); while (iterator.MoveNext()) { PluginSetting pluginSetting = PluginSetting.Parse(iterator.Current); if (pluginSetting != null) { _pluginSettings.Add(pluginSetting.PluginName, pluginSetting); } } } } }