static public string GetTableSelect(string provider, IDbConnection cn) { if (SqlEntries == null) { RdlEngineConfigInit(); } SqlConfigEntry sce = SqlEntries[provider] as SqlConfigEntry; if (sce == null) { //if (cn != null) //{ //OdbcConnection oc = cn as OdbcConnection; //if (oc != null && oc.Driver.ToLower().IndexOf("my") >= 0) // not a good way but ... // return "show tables"; // mysql syntax is non-standard //} return("SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES ORDER BY 2, 1"); } //if (cn != null) //{ // OdbcConnection oc = cn as OdbcConnection; // if (oc != null && oc.Driver.ToLower().IndexOf("my") >= 0) // not a good way but ... // return "show tables"; // mysql syntax is non-standard //} return(sce.TableSelect); }
static public string GetTableSelect(string provider, IDbConnection cn) { SqlConfigEntry sce = SqlEntries[provider] as SqlConfigEntry; if (sce == null) { if (cn != null) { OdbcConnection oc = cn as OdbcConnection; if (oc != null && oc.Driver.ToLower().IndexOf("my") >= 0) // not a good way but ... { return("SHOW TABLES"); // mysql syntax is non-standard } } return("SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES ORDER BY 2, 1"); } if (cn != null) { OdbcConnection oc = cn as OdbcConnection; if (oc != null && oc.Driver.ToLower().IndexOf("my") >= 0) // not a good way but ... { return("SHOW TABLES"); // mysql syntax is non-standard } } return(sce.TableSelect); }
static public bool DoParameterReplacement(string provider, IDbConnection cn) { if (SqlEntries == null) { RdlEngineConfigInit(); } SqlConfigEntry sce = SqlEntries[provider] as SqlConfigEntry; return(sce == null ? false : sce.ReplaceParameters); }
public static IDbConnection GetConnection(string provider, string cstring) { IDbConnection cn = null; switch (provider.ToLower()) { case "sql": // can't connect unless information provided; // when user wants to set the connection programmatically this they should do this if (cstring.Length > 0) { cn = new SqlConnection(cstring); } break; case "odbc": cn = new OdbcConnection(cstring); break; case "oledb": cn = new OleDbConnection(cstring); break; default: if (SqlEntries == null) // if never initialized; we should init { RdlEngineConfigInit(); } SqlConfigEntry sce = SqlEntries[provider] as SqlConfigEntry; if (sce == null || sce.CodeModule == null) { if (sce != null && sce.ErrorMsg != null) // error during initialization?? { throw new Exception(sce.ErrorMsg); } break; } object[] args = new object[] { cstring }; Assembly asm = sce.CodeModule; object o = asm.CreateInstance(sce.ClassName, false, BindingFlags.CreateInstance, null, args, null, null); if (o == null) { throw new Exception(string.Format("Unable to create instance of '{0}' for provider '{1}'", sce.ClassName, provider)); } cn = o as IDbConnection; break; } return(cn); }
static public string GetTableSelect(string provider, IDbConnection cn) { SqlConfigEntry sce = SqlEntries[provider] as SqlConfigEntry; if (sce == null) { if (cn != null) { OdbcConnection oc = cn as OdbcConnection; if (oc != null && oc.Driver.ToLower().IndexOf("my") >= 0) // not a good way but ... { return("show tables"); // mysql syntax is non-standard } OleDbConnection orac = cn as OleDbConnection; if (string.Compare(provider, "Oracle", true) == 0) { return("SELECT TABLE_NAME,'TABLE',OWNER FROM ALL_TABLES WHERE OWNER IN (SELECT USERNAME FROM ALL_USERS WHERE CREATED > TO_DATE('2004-03-11 00:00:00','yyyy-mm-dd HH24:Mi:ss')) ORDER BY 3, 1"); } } //return "SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES ORDER BY 2, 1"; return("SELECT TABLE_NAME,TABLE_TYPE, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES ORDER BY 3, 1"); } if (cn != null) { OdbcConnection oc = cn as OdbcConnection; if (oc != null && oc.Driver.ToLower().IndexOf("my") >= 0) // not a good way but ... { return("show tables"); // mysql syntax is non-standard } } return(sce.TableSelect); }
static void GetDataSource(XmlNode xNode) { string provider=null; string codemodule=null; string cname=null; string inter="SQL"; string tselect=null; bool replaceparameters=false; foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "DataProvider": provider = xNodeLoop.InnerText; break; case "CodeModule": codemodule = xNodeLoop.InnerText; break; case "Interface": inter = xNodeLoop.InnerText; break; case "ClassName": cname = xNodeLoop.InnerText; break; case "TableSelect": tselect = xNodeLoop.InnerText; break; case "ReplaceParameters": if (xNodeLoop.InnerText.ToLower() == "true") replaceparameters = true; break; default: break; } } if (provider == null) return; // nothing to do if no provider specified SqlConfigEntry sce; try { // load the module early; saves problems with concurrency later string msg=null; Assembly la=null; if (codemodule != null && cname != null) { la = XmlUtil.AssemblyLoadFrom(codemodule); if (la == null) msg = string.Format("{0} could not be loaded", codemodule); } sce = new SqlConfigEntry(provider, cname, la, tselect, msg); SqlEntries.Add(provider, sce); } catch (Exception e) { // keep exception; if this DataProvided is ever useed we will see the message sce = new SqlConfigEntry(provider, cname, null, tselect, e.Message); SqlEntries.Add(provider, sce); } sce.ReplaceParameters = replaceparameters; }
static void GetDataSource(IDictionary dsDir, XmlNode xNode) { string provider = null; string codemodule = null; string cname = null; string inter = "SQL"; string tselect = null; bool replaceparameters = false; foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "DataProvider": provider = xNodeLoop.InnerText; break; case "CodeModule": codemodule = xNodeLoop.InnerText; break; case "Interface": inter = xNodeLoop.InnerText; break; case "ClassName": cname = xNodeLoop.InnerText; break; case "TableSelect": tselect = xNodeLoop.InnerText; break; case "ReplaceParameters": if (xNodeLoop.InnerText.ToLower() == "true") replaceparameters = true; break; default: break; } } if (provider == null) return; // nothing to do if no provider specified SqlConfigEntry sce; try { // load the module early; saves problems with concurrency later string msg = null; Assembly la = null; if (codemodule != null && cname != null) { // When running report server and RdlEngineConfig is configured for local directy // The file cannot be found without adding the current directoyr if (System.IO.File.Exists(codemodule) == false && System.IO.Path.GetFileName(codemodule) == codemodule) { if (AppDomain.CurrentDomain.RelativeSearchPath != null) { codemodule = System.IO.Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath, codemodule); } else if (AppDomain.CurrentDomain.BaseDirectory != null) { codemodule = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, codemodule); } } if (System.IO.File.Exists(codemodule) == false) { sce = new SqlConfigEntry(provider, codemodule , cname, null, tselect, string.Format(Strings.RdlEngineConfig_Error_CashModuleNotFound, codemodule)); dsDir.Add(provider, sce); return; } // check to see if the DLL has been previously loaded // many of the DataProvider done by fyiReporting are in a single code module foreach (SqlConfigEntry sc in dsDir.Values) { if (sc.FileName == codemodule && sc.CodeModule != null) { la = sc.CodeModule; break; } } if (la == null) { la = XmlUtil.AssemblyLoadFrom(codemodule); } if (la == null) { msg = string.Format(Strings.RdlEngineConfig_Error_CashModuleNotFound, codemodule); } } sce = new SqlConfigEntry(provider, codemodule, cname, la, tselect, msg); dsDir.Add(provider, sce); } catch (Exception e) { // keep exception; if this DataProvided is ever useed we will see the message sce = new SqlConfigEntry(provider, codemodule, cname, null, tselect, e.Message); dsDir.Add(provider, sce); } sce.ReplaceParameters = replaceparameters; }
static void GetDataSource(XmlNode xNode) { string provider = null; string codemodule = null; string cname = null; string inter = "SQL"; string tselect = null; bool replaceparameters = false; foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "DataProvider": provider = xNodeLoop.InnerText; break; case "CodeModule": codemodule = xNodeLoop.InnerText; break; case "Interface": inter = xNodeLoop.InnerText; break; case "ClassName": cname = xNodeLoop.InnerText; break; case "TableSelect": tselect = xNodeLoop.InnerText; break; case "ReplaceParameters": if (xNodeLoop.InnerText.ToLower() == "true") { replaceparameters = true; } break; default: break; } } if (provider == null) { return; // nothing to do if no provider specified } SqlConfigEntry sce; try { // load the module early; saves problems with concurrency later string msg = null; Assembly la = null; if (codemodule != null && cname != null) { la = XmlUtil.AssemblyLoadFrom(codemodule); if (la == null) { msg = string.Format("{0} could not be loaded", codemodule); } } sce = new SqlConfigEntry(provider, cname, la, tselect, msg); SqlEntries.Add(provider, sce); } catch (Exception e) { // keep exception; if this DataProvided is ever useed we will see the message sce = new SqlConfigEntry(provider, cname, null, tselect, e.Message); SqlEntries.Add(provider, sce); } sce.ReplaceParameters = replaceparameters; }
public static IDbConnection GetConnection(string provider, string cstring) { IDbConnection cn = null; switch (provider.ToLower()) { case "sql": // can't connect unless information provided; // when user wants to set the connection programmatically this they should do this if (cstring.Length > 0) { cn = new SqlConnection(cstring); } break; case "odbc": cn = new OdbcConnection(cstring); break; case "oledb": cn = new OleDbConnection(cstring); break; case "filedirectory": cn = new fyiReporting.Data.FileDirConnection(cstring); break; case "xml": cn = new fyiReporting.Data.XmlConnection(cstring); break; case "webservice": cn = new fyiReporting.Data.WebServiceConnection(cstring); break; case "weblog": cn = new fyiReporting.Data.LogConnection(cstring); break; case "text": cn = new fyiReporting.Data.TxtConnection(cstring); break; case "itunes": cn = new fyiReporting.Data.iTunesConnection(cstring); break; default: if (SqlEntries == null) // if never initialized; we should init { RdlEngineConfigInit(); } System.Console.WriteLine("Attempt to find provider"); SqlConfigEntry sce = SqlEntries[provider] as SqlConfigEntry; if (sce == null || sce.CodeModule == null) { if (sce != null && sce.ErrorMsg != null) // error during initialization?? { throw new Exception(sce.ErrorMsg); } break; } System.Console.WriteLine("Provider Create Instance"); object[] args = new object[] { cstring }; Assembly asm = sce.CodeModule; object o = asm.CreateInstance(sce.ClassName, false, BindingFlags.CreateInstance, null, args, null, null); if (o == null) { throw new Exception(string.Format("Unable to create instance of '{0}' for provider '{1}'", sce.ClassName, provider)); } cn = o as IDbConnection; break; } return(cn); }
static void GetDataSource(IDictionary dsDir, XmlNode xNode) { string provider = null; string codemodule = null; string cname = null; string inter = "SQL"; string tselect = null; bool replaceparameters = false; foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "DataProvider": provider = xNodeLoop.InnerText; break; case "CodeModule": codemodule = xNodeLoop.InnerText; break; case "Interface": inter = xNodeLoop.InnerText; break; case "ClassName": cname = xNodeLoop.InnerText; break; case "TableSelect": tselect = xNodeLoop.InnerText; break; case "ReplaceParameters": if (xNodeLoop.InnerText.ToLower() == "true") { replaceparameters = true; } break; default: break; } } if (provider == null) { return; // nothing to do if no provider specified } SqlConfigEntry sce; try { // load the module early; saves problems with concurrency later string msg = null; Assembly la = null; if (codemodule != null && cname != null) { // When running report server and RdlEngineConfig is configured for local directy // The file cannot be found without adding the current directoyr if (System.IO.File.Exists(codemodule) == false && System.IO.Path.GetFileName(codemodule) == codemodule) { if (AppDomain.CurrentDomain.RelativeSearchPath != null) { codemodule = System.IO.Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath, codemodule); } else if (AppDomain.CurrentDomain.BaseDirectory != null) { codemodule = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, codemodule); } } if (System.IO.File.Exists(codemodule) == false) { sce = new SqlConfigEntry(provider, codemodule, cname, null, tselect, codemodule + " could not be found"); dsDir.Add(provider, sce); return; } // check to see if the DLL has been previously loaded // many of the DataProvider done by fyiReporting are in a single code module foreach (SqlConfigEntry sc in dsDir.Values) { if (sc.FileName == codemodule && sc.CodeModule != null) { la = sc.CodeModule; break; } } if (la == null) { la = XmlUtil.AssemblyLoadFrom(codemodule); } if (la == null) { msg = string.Format("{0} could not be loaded", codemodule); } } sce = new SqlConfigEntry(provider, codemodule, cname, la, tselect, msg); dsDir.Add(provider, sce); } catch (Exception e) { // keep exception; if this DataProvided is ever useed we will see the message sce = new SqlConfigEntry(provider, codemodule, cname, null, tselect, e.Message); dsDir.Add(provider, sce); } sce.ReplaceParameters = replaceparameters; }
public static IDbConnection GetConnection(string provider, string cstring) { IDbConnection cn = null; switch (provider.ToLower()) { case "sqlite": if (cstring.Length > 0) { cn = new SqliteConnection(cstring); } break; case "oracle": if (cstring.Length > 0) { cn = new System.Data.OracleClient.OracleConnection(cstring); } break; case "postgresql": if (cstring.Length > 0) { cn = new Npgsql.NpgsqlConnection(cstring); } break; case "firebird.net": if (cstring.Length > 0) { cn = new FirebirdSql.Data.FirebirdClient.FbConnection(cstring); } break; case "mysql.net": // can't connect unless information provided; // when user wants to set the connection programmatically this they should do this if (cstring.Length > 0) { cn = new MySql.Data.MySqlClient.MySqlConnection(cstring); } break; case "sql": // can't connect unless information provided; // when user wants to set the connection programmatically this they should do this if (cstring.Length > 0) { cn = new SqlConnection(cstring); } break; case "odbc": cn = new OdbcConnection(cstring); break; //case "oledb": // cn = new OleDbConnection(cstring); // break; case "filedirectory": cn = new fyiReporting.Data.FileDirConnection(cstring); break; case "xml": cn = new fyiReporting.Data.XmlConnection(cstring); break; //case "webservice": // cn = new fyiReporting.Data.WebServiceConnection(cstring); // break; case "weblog": cn = new fyiReporting.Data.LogConnection(cstring); break; case "text": cn = new fyiReporting.Data.TxtConnection(cstring); break; case "itunes": cn = new fyiReporting.Data.iTunesConnection(cstring); break; #if EnableBundleLinux // See properties -> Build -> Conditional compilation symbols case "sqlite": cn = new Mono.Data.Sqlite.SqliteConnection(cstring); break; case "postgresql": cn = new Npgsql.NpgsqlConnection(cstring); break; #endif default: if (SqlEntries == null) { // if never initialized; we should init RdlEngineConfigInit(); } System.Console.WriteLine("Attempt to find provider"); SqlConfigEntry sce = SqlEntries[provider] as SqlConfigEntry; if (sce == null || sce.CodeModule == null) { if (sce != null && sce.ErrorMsg != null) { // error during initialization?? throw new Exception(sce.ErrorMsg); } break; } System.Console.WriteLine("Provider Create Instance"); object[] args = new object[] { cstring }; Assembly asm = sce.CodeModule; object o = asm.CreateInstance(sce.ClassName, false, BindingFlags.CreateInstance, null, args, null, null); if (o == null) { throw new Exception(string.Format(Strings.RdlEngineConfig_Error_UnableCreateInstance, sce.ClassName, provider)); } cn = o as IDbConnection; break; } return(cn); }