public void Initialize(UserSession session, AppInfo appSettings) { _session = session; _appSettings = appSettings; string pluginDirectory = Application.StartupPath + @"\Plugins"; AppManager am = new AppManager(_appSettings.ActiveDbConnectionKey, "FORMS", _session.AuthToken); string pluginOrder = am.GetSetting(_session.UserName + "PluginOrder", false)?.Value; List <string> plugins = new List <string>(); if (!string.IsNullOrEmpty(pluginOrder)) { plugins.AddRange(pluginOrder.Split(',').ToList()); } else if (Directory.Exists(pluginDirectory)) { PluginServices svcPlugins = new PluginServices(); //Call the find plugins routine, to search in our Plugins Folder List <string> AvailablePlugins = svcPlugins.FindPlugins(pluginDirectory); plugins.AddRange(AvailablePlugins); } foreach (string plugin in plugins) { lstPlugins.Items.Add(new ListViewItem(plugin)); } lstPlugins.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }
static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: hand2xml site file"); return; } PluginServices host = PluginServices.Instance; host.PluginDirectory = AppDomain.CurrentDomain.BaseDirectory; host.AddPlugin("HandParserInterface.IHandParser"); host.FindPlugins(); AvailablePlugins parsers = host.Plugins["HandParserInterface.IHandParser"]; foreach (AvailablePlugin plugin in parsers) { IHandParser parser = (IHandParser)plugin.Instance; if (parser.Switch == args[0]) { PokerHandXML hands = parser.ParseFile(args[1]); TextWriter output = new StreamWriter(args[1] + ".xml"); XmlSerializer serializer = new XmlSerializer(typeof(PokerHandXML)); serializer.Serialize(output, hands); output.Flush(); output.Close(); return; } } }
private static void LoadPlugins() { List <PluginServices.AvailablePlugin> pluginz = PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, typeof(IOMLPlugin).Name); // Loop through available plugins, creating instances and adding them foreach (PluginServices.AvailablePlugin oPlugin in pluginz) { OMLPlugin objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin); objPlugin.FileFound += new OMLPlugin.FileFoundEventHandler(FileFound); plugins.Add(objPlugin); } }
private void PrepareForm() { Application.DoEvents(); Cursor = Cursors.WaitCursor; List <PluginServices.AvailablePlugin> plugins = new List <PluginServices.AvailablePlugin>(); string path = FileSystemWalker.PluginsDirectory; plugins = PluginServices.FindPlugins(path, PluginTypes.MetadataPlugin); IOMLMetadataPlugin objPlugin; // Loop through available plugins, creating instances and add them if (plugins != null) { string pluginForProperty = OMLEngine.Settings.SettingsManager.MetaDataMap_PluginForProperty(_propertyName); cbDefault.Checked = String.IsNullOrEmpty(pluginForProperty); Dictionary <string, object> dataCollection = new Dictionary <string, object>(); foreach (PluginServices.AvailablePlugin oPlugin in plugins) { // Create instance to get plugin list objPlugin = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin); try { foreach (MetaDataPluginDescriptor provider in objPlugin.GetProviders) { // Create instance of the plugin for this particular provider. This would create a unique instance per provider. provider.PluginDLL = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin); // Initialise the plugin and select which provider it serves provider.PluginDLL.Initialize(provider.DataProviderName, new Dictionary <string, string>()); provider.PluginDLL.SearchForMovie(_title.Name, OMLEngine.Settings.OMLSettings.MetadataLookupResultsQty); Title title = OMLSDK.SDKUtilities.ConvertOMLSDKTitleToTitle(provider.PluginDLL.GetBestMatch()); if (title != null) { AddResult(provider, _propertyInfo.GetValue(title, null), pluginForProperty); } } } catch (Exception e) { Utilities.DebugLine("[OMLDatabaseEditor] Error loading metadata: " + e.Message); continue; } } plugins = null; } Cursor = Cursors.Default; }
private static void LoadPlugins() { if (availablePlugins.Count == 0) { List <PluginServices.AvailablePlugin> Pluginz = new List <PluginServices.AvailablePlugin>(); string path = Path.GetDirectoryName(FileSystemWalker.PluginsDirectory + @"\\Plugins"); OMLApplication.DebugLine("Path is: " + path); Pluginz = PluginServices.FindPlugins(path, "OMLSDK.IOMLPlugin"); OMLPlugin objPlugin; // Loop through available plugins, creating instances and adding them foreach (PluginServices.AvailablePlugin oPlugin in Pluginz) { objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin); availablePlugins.Add(objPlugin); } Pluginz = null; } }
private static void LoadImportPlugins(string pluginType, List <OMLPlugin> pluginList) { pluginList.Clear(); List <PluginServices.AvailablePlugin> plugins = new List <PluginServices.AvailablePlugin>(); string path = FileSystemWalker.PluginsDirectory; plugins = PluginServices.FindPlugins(path, pluginType); OMLPlugin objPlugin; // Loop through available plugins, creating instances and adding them if (plugins != null) { foreach (PluginServices.AvailablePlugin oPlugin in plugins) { objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin); pluginList.Add(objPlugin); } plugins = null; } }
private void FormPlugins_Load(object sender, EventArgs e) { plugin.FindPlugins(Properties.Settings.Default.GlobalDirectoryRoot + Properties.Settings.Default.GlobalDirectoryPlugins); foreach (AvailablePlugin <IIndicator> plug in plugin.AvailablePlugins) { Assembly pluginAssembly = Assembly.LoadFrom(plug.AssemblyPath); plug.Instance = (IIndicator)Activator.CreateInstance(pluginAssembly.GetType(plug.PlugType.ToString())); IIndicator rne = plug.Instance; TreeNode node = new TreeNode(rne.ToString()); node.Tag = plug; treePlugins.Nodes.Add(node); } if (treePlugins.Nodes.Count > 0) { selected = (AvailablePlugin <IIndicator>)treePlugins.Nodes[0].Tag; lblName.Text = selected.Instance.Name; txtAuthor.Text = selected.Instance.Author; txtDescription.Text = selected.Instance.Description; txtVersion.Text = selected.Instance.Version; } }
private static void LoadMetadataPlugins(string pluginType, List <IOMLMetadataPlugin> pluginList) { pluginList.Clear(); List <PluginServices.AvailablePlugin> plugins = new List <PluginServices.AvailablePlugin>(); string path = FileSystemWalker.PluginsDirectory; plugins = PluginServices.FindPlugins(path, pluginType); IOMLMetadataPlugin objPlugin; // Loop through available plugins, creating instances and adding them if (plugins != null) { foreach (PluginServices.AvailablePlugin oPlugin in plugins) { objPlugin = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin); pluginList.Add(objPlugin); objPlugin.Initialize(new Dictionary <string, string>()); } plugins = null; } }
private static bool ProcessCommandLine(string [] args) { OMLPlugin pluginToUse = null; string pluginName = args[0].Trim(); bool copyImages = true; string path = null; bool clearBeforeImport = false; if (args.Length > 1) { path = args[1]; } else { return(false); } for (int i = 2; i < args.Length; i++) { if (args[i].StartsWith(COPY_IMAGES_KEY, StringComparison.OrdinalIgnoreCase)) { if (!bool.TryParse(args[i].Substring(COPY_IMAGES_KEY.Length), out copyImages)) { return(false); } } else if (args[i].StartsWith(CLEAR_BEFORE_IMPORT_KEY, StringComparison.OrdinalIgnoreCase)) { if (!bool.TryParse(args[i].Substring(CLEAR_BEFORE_IMPORT_KEY.Length), out clearBeforeImport)) { return(false); } } else // command line argument not understood { return(false); } } // Loop through available plugins to find the new we need to create foreach (PluginServices.AvailablePlugin plugin in PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, "OMLSDK.IOMLPlugin")) { if (plugin.ClassName.Equals(pluginName, StringComparison.OrdinalIgnoreCase)) { pluginToUse = (OMLPlugin)PluginServices.CreateInstance(plugin); pluginToUse.FileFound += new OMLPlugin.FileFoundEventHandler(FileFound); } } if (pluginToUse == null) { Console.WriteLine(pluginName + " was not found as a plugin. The valid plugins are:"); Console.WriteLine(""); foreach (PluginServices.AvailablePlugin plugin in PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, typeof(IOMLPlugin).Name)) { Console.WriteLine(plugin.ClassName); } } else { // use the found plugin if (pluginToUse.IsSingleFileImporter() && !File.Exists(path)) { Console.WriteLine(pluginToUse.Name + " requires an import file which it can't find (" + path + ")"); } else if (!pluginToUse.IsSingleFileImporter() && !Directory.Exists(path)) { Console.WriteLine(pluginToUse.Name + " requires an import directory which can't be found (" + path + ")"); } else { if (clearBeforeImport) { Console.WriteLine("Clearing out old data before import ( this can take awhile )"); TitleCollectionManager.DeleteAllDBData(); } Console.WriteLine("Beginning to import titles..."); pluginToUse.DoWork(new string[] { path }); LoadTitlesIntoDatabase(pluginToUse, false, true); } } return(true); }
static void Main(string[] args) { args = new string[] { "ft", @"<inputhhfile>", @"<outputxmlfile>" }; if (args.Length != 3) { Console.WriteLine("Usage: hand2xml site inFile outFile"); return; } PluginServices host = PluginServices.Instance; host.PluginDirectory = AppDomain.CurrentDomain.BaseDirectory; host.AddPlugin("HandParserInterface.IHandParser"); host.FindPlugins(); AvailablePlugins parsers = host.Plugins["HandParserInterface.IHandParser"]; foreach (AvailablePlugin plugin in parsers) { IHandParser parser = (IHandParser)plugin.Instance; if (parser.Switch == args[0]) { PokerHandXML hands = parser.ParseFile(args[1]); TextWriter output = new StreamWriter(args[2]); XmlSerializer serializer = new XmlSerializer(typeof(PokerHandXML)); serializer.Serialize(output, hands); output.Flush(); output.Close(); return; } else { } } //int fileNum = 0; //String filename = "ps NLH handhq_"; //String dir = @"C:\Users\Emre Kenci\Desktop\PSTEST\"; //for (int i = 146; i < 203; i++) //{ // args = new string[] { "ps", dir+@"\"+filename+""+i+".txt", // dir+@"\"+"result"+i+".xml" }; // if (args.Length != 3) // { // Console.WriteLine("Usage: hand2xml site inFile outFile"); // return; // } // PluginServices host = PluginServices.Instance; // host.PluginDirectory = AppDomain.CurrentDomain.BaseDirectory; // host.AddPlugin("HandParserInterface.IHandParser"); // host.FindPlugins(); // AvailablePlugins parsers = host.Plugins["HandParserInterface.IHandParser"]; // foreach (AvailablePlugin plugin in parsers) // { // IHandParser parser = (IHandParser)plugin.Instance; // if (parser.Switch == args[0]) // { // PokerHandXML hands = parser.ParseFile(args[1]); // TextWriter output = new StreamWriter(args[2]); // XmlSerializer serializer = new XmlSerializer(typeof(PokerHandXML)); // serializer.Serialize(output, hands); // output.Flush(); // output.Close(); // break; // } // } //} }
public Process(System.Web.UI.Page httpPage, PluginServices pluginServices) { Plugins = pluginServices; HttpPage = httpPage; XmlData = new XmlDocument(); Plugins.FindPlugins(this, Common.CombinePaths(Root, "Bin")); XmlNode xmlNode = XmlData.CreateElement("data"); XmlData.AppendChild(xmlNode); Content = new ControlList(xmlNode); m_BasePath = httpPage.Request.ServerVariables["SERVER_PROTOCOL"].Split('/')[0].ToLower() + "://" + httpPage.Request.ServerVariables["SERVER_NAME"] + ":" + httpPage.Request.ServerVariables["SERVER_PORT"] + httpPage.Request.ApplicationPath.TrimEnd('/') + ""; Content["basepath"].InnerText = m_BasePath; Content["referrer"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_REFERER"]); Content["domain"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["SERVER_NAME"]); Content["useragent"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_USER_AGENT"]); Content["sessionid"].InnerText = httpPage.Server.UrlEncode(httpPage.Session.LCID.ToString()); Content["ip"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["REMOTE_ADDR"]); QueryData = new XmlItemList(CommonXml.GetNode(xmlNode, "query/data", EmptyNodeHandling.CreateNew)); Attributes = new XmlItemList(CommonXml.GetNode(xmlNode, "attributes", EmptyNodeHandling.CreateNew)); QueryEvents = new XmlItemList(CommonXml.GetNode(xmlNode, "query/events", EmptyNodeHandling.CreateNew)); QueryOther = new XmlItemList(CommonXml.GetNode(xmlNode, "query/other", EmptyNodeHandling.CreateNew)); processQueries(); ConfigureDebugging(); CookieLoginDuringProcessInit(httpPage); LoadBaseData(); // loads new user... if (this.QueryEvents["main"] == "login") { if (!Login(QueryData["login"], QueryData["password"])) { if (m_Settings["messages/loginerror"] != string.Empty) { httpPage.Response.Redirect(BasePath + "/login.aspx?error=" + httpPage.Server.UrlEncode(m_Settings["messages/loginerror"])); } else { httpPage.Response.Redirect(BasePath + "/login.aspx"); } } else { SetLoginCookie(httpPage); // Set session timeout to 3 hours httpPage.Session.Timeout = 180; } } else if (this.QueryEvents["main"] == "logout") { System.Web.HttpCookie loginCookie = new System.Web.HttpCookie("login_cookie", ""); httpPage.Response.SetCookie(loginCookie); Logout(); } }
public Process(Page httpPage, PluginServices pluginServices) { Plugins = pluginServices; HttpPage = httpPage; XmlData = new XmlDocument(); Plugins.FindPlugins(this, Common.Common.CombinePaths(Root, "Bin")); XmlNode xmlNode = XmlData.CreateElement("data"); XmlData.AppendChild(xmlNode); Content = new ControlList(xmlNode); if (httpPage.Request.ApplicationPath != null) { if (httpPage.Request.ServerVariables["SERVER_PORT"] == "80") { _basePath = httpPage.Request.ServerVariables["SERVER_PROTOCOL"].Split('/')[0].ToLower() + "://" + httpPage.Request.ServerVariables["SERVER_NAME"] + httpPage.Request.ApplicationPath.TrimEnd('/') + string.Empty; } else { _basePath = httpPage.Request.ServerVariables["SERVER_PROTOCOL"].Split('/')[0].ToLower() + "://" + httpPage.Request.ServerVariables["SERVER_NAME"] + ":" + httpPage.Request.ServerVariables["SERVER_PORT"] + httpPage.Request.ApplicationPath.TrimEnd('/') + string.Empty; } } Content["basepath"].InnerText = _basePath; Content["referrer"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_REFERER"]); Content["domain"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["SERVER_NAME"]); Content["useragent"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_USER_AGENT"]); Content["sessionid"].InnerText = httpPage.Server.UrlEncode(httpPage.Session.LCID.ToString(CultureInfo.InvariantCulture)); Content["ip"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["REMOTE_ADDR"]); Attributes = new XmlItemList(CommonXml.GetNode(xmlNode, "attributes", EmptyNodeHandling.CreateNew)); QueryData = new XmlItemList(CommonXml.GetNode(xmlNode, "query/data", EmptyNodeHandling.CreateNew)); QueryEvents = new XmlItemList(CommonXml.GetNode(xmlNode, "query/events", EmptyNodeHandling.CreateNew)); QueryOther = new XmlItemList(CommonXml.GetNode(xmlNode, "query/other", EmptyNodeHandling.CreateNew)); ProcessQueries(); ConfigureDebugging(); LoginByCookie(); if (QueryEvents["main"] == "login") { if (!Login(QueryData["login"], QueryData["password"])) { if (_settings != null && _settings["messages/loginerror"] != string.Empty) { httpPage.Response.Redirect(GetErrorUrl(httpPage.Server.UrlEncode(_settings["messages/loginerror"]))); } else { httpPage.Response.Redirect(GetRedirectUrl()); } } } else if (QueryEvents["main"] == "logout") { Logout(); if (QueryEvents["mainValue"] != string.Empty) { HttpPage.Response.Redirect(QueryEvents["mainValue"]); } } UpdateCookieTimeout(); LoadBaseData(); // loads new user... }
static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: hand2xml site inFile outFile [-buckets n]"); return; } int buckets = 1; #region Parse optional parameters for (int i = 0; i < args.Length; i++) { if (args[i][0] != '-') { continue; } switch (args[i]) { case "-buckets": case "-b": buckets = int.Parse(args[++i]); break; default: Console.WriteLine("Unknown parameter: {0}", args[i]); return; } } #endregion PluginServices host = PluginServices.Instance; host.PluginDirectory = AppDomain.CurrentDomain.BaseDirectory; host.AddPlugin("HandParserInterface.IHandParser"); host.FindPlugins(); AvailablePlugins parsers = host.Plugins["HandParserInterface.IHandParser"]; IHandParser parser = null; foreach (AvailablePlugin plugin in parsers) { IHandParser curParser = (IHandParser)plugin.Instance; if (curParser.Switch == args[0]) { parser = curParser; break; } } #region Validate parameters if (parser == null) { Console.WriteLine("Unknown parser type: {0}", args[0]); return; } if (!File.Exists(args[1]) && !Directory.Exists(args[1])) { Console.WriteLine("Unknown file or directory: {0}", args[1]); return; } if (buckets < 1) { Console.WriteLine("Invalid bucket count. Must have at least one bucket."); return; } #endregion PokerHandXML result; // get the file attributes for file or directory FileAttributes attr = File.GetAttributes(args[1]); //detect whether its a directory or file if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { List <PokerHand> hands = new List <PokerHand>(); foreach (string filename in Directory.GetFiles(args[1])) { hands.AddRange(parser.ParseFile(filename).Hands); } result = new PokerHandXML() { Hands = hands.ToArray() }; } else { result = parser.ParseFile(args[1]); } string outfile = args[2]; int handsPerFile = result.Hands.Length / buckets; for (int i = 0; i < buckets; i++) { int start = handsPerFile * i; int end = start + handsPerFile; if (i == (buckets - 1)) { end = result.Hands.Length; } var subset = new PokerHandXML() { Hands = result.Hands.Where((h, idx) => idx >= start && idx < end).ToArray() }; SaveHands(subset, outfile + i + ".xml"); } }
/// <summary> /// Init Plugin /// </summary> public static void InitPlugin() { service.FindPlugins(); }
public Process(Page httpPage, PluginServices pluginServices) { _currentProcess = String.Empty; Plugins = pluginServices; HttpPage = httpPage; XmlData = new XmlDocument(); Plugins.FindPlugins(this, Common.Common.CombinePaths(Root, "Bin")); XmlNode xmlNode = XmlData.CreateElement("data"); XmlData.AppendChild(xmlNode); Content = new ControlList(xmlNode); _basePath = GetBasePath(httpPage); Content["basepath"].InnerText = _basePath; String referrer = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_REFERER"]); Content["referrer"].InnerText = referrer ?? String.Empty; String domain = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["SERVER_NAME"]); Content["domain"].InnerText = domain ?? String.Empty; String useragent = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_USER_AGENT"]); Content["useragent"].InnerText = useragent ?? String.Empty; String sessionid = httpPage.Server.UrlEncode(httpPage.Session.LCID.ToString(CultureInfo.InvariantCulture)); Content["sessionid"].InnerText = sessionid ?? String.Empty; String ip = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["REMOTE_ADDR"]); Content["ip"].InnerText = ip ?? String.Empty; Attributes = new XmlItemList(CommonXml.GetNode(xmlNode, "attributes", EmptyNodeHandling.CreateNew)); QueryData = new XmlItemList(CommonXml.GetNode(xmlNode, "query/data", EmptyNodeHandling.CreateNew)); QueryEvents = new XmlItemList(CommonXml.GetNode(xmlNode, "query/events", EmptyNodeHandling.CreateNew)); QueryOther = new XmlItemList(CommonXml.GetNode(xmlNode, "query/other", EmptyNodeHandling.CreateNew)); ProcessQueries(); ConfigureDebugging(); LoginByCookie(); String mainEvent = QueryEvents["main"]; String mainEventValue = QueryEvents["mainValue"]; if (mainEvent == "login") { if (!Login(QueryData["login"], QueryData["password"])) { if (_settings != null && _settings["messages/loginerror"] != String.Empty) { httpPage.Response.Redirect(GetErrorUrl(httpPage.Server.UrlEncode(_settings["messages/loginerror"]))); } else { httpPage.Response.Redirect(GetRedirectUrl()); } } } else if (mainEvent == "logout") { Logout(); if (mainEventValue != String.Empty) { HttpPage.Response.Redirect(mainEventValue); } } else if (mainEvent == String.Empty) { if (mainEventValue != String.Empty) { HttpPage.Response.Redirect("/"); } } UpdateCookieTimeout(); LoadBaseData(); // loads new user... }