public static bool CanExport(DatabaseManager.DatabaseType type) { bool result; try { switch (type) { case DatabaseManager.DatabaseType.ODBC: result = ODBCDriver.CanExport; break; //case DatabaseManager.DatabaseType.MSAccess: // result = MSAccessDriver2003.CanExport; // break; //case DatabaseManager.DatabaseType.MSAccess2007: // result = MSAccessDriver2007.CanExport; // break; default: result = false; break; } } catch (System.Exception ex) { Log.WriteLine("DatabaseType {0} is not supported because creating database driver failed", new object[] { type }); Log.WriteLine(ex.ToString()); result = false; } return(result); }
private void SaveSettings() { string connectionHistoryFile = this.GetConnectionHistoryFile(); Log.WriteLine("SaveSettings"); Log.Indent(); DatabaseManager.DatabaseType databaseType = (DatabaseManager.CurrentDatabaseType == DatabaseManager.DatabaseType.Invalid) ? DatabaseManager.lastDatabaseType : DatabaseManager.CurrentDatabaseType; Log.WriteLine("#Last Database type: " + databaseType); foreach (System.Collections.Generic.KeyValuePair <DatabaseManager.DatabaseType, System.Collections.Generic.List <string> > current in DatabaseManager.m_LastConnection) { foreach (string current2 in current.Value) { Log.WriteLine("{0},{1}", new object[] { current.Key, current2 }); } } Log.Unindent(); System.IO.StreamWriter streamWriter = null; try { if (Command.ConfigFile.Debug) { streamWriter = new System.IO.StreamWriter(connectionHistoryFile, false); } else { System.IO.IsolatedStorage.IsolatedStorageFile store = System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(System.IO.IsolatedStorage.IsolatedStorageScope.User | System.IO.IsolatedStorage.IsolatedStorageScope.Assembly, null, null); streamWriter = new System.IO.StreamWriter(new System.IO.IsolatedStorage.IsolatedStorageFileStream(System.IO.Path.GetFileName(connectionHistoryFile), System.IO.FileMode.Create, store)); } streamWriter.WriteLine("#Last Database type: " + databaseType); foreach (System.Collections.Generic.KeyValuePair <DatabaseManager.DatabaseType, System.Collections.Generic.List <string> > current3 in DatabaseManager.m_LastConnection) { foreach (string current4 in current3.Value) { streamWriter.WriteLine("{0},{1}", current3.Key, current4); } } } catch { } finally { if (streamWriter != null) { streamWriter.Close(); } } }
private static IDatabaseDriver CreateDatabaseDriver(DatabaseManager.DatabaseType type) { switch (type) { case DatabaseManager.DatabaseType.ODBC: return(new ODBCDriver()); //case DatabaseManager.DatabaseType.MSAccess: // return new MSAccessDriver2003(); //case DatabaseManager.DatabaseType.MSAccess2007: // return new MSAccessDriver2007(); default: return(null); } }
public static System.Collections.Generic.List <string> GetPreviousConnectionsFor(DatabaseManager.DatabaseType type) { System.Collections.Generic.List <string> list; if (!DatabaseManager.m_LastConnection.TryGetValue(type, out list)) { list = new System.Collections.Generic.List <string>(); DatabaseManager.m_LastConnection.Add(type, list); } return(list); }
private void LoadSettings() { DatabaseManager.m_LastConnection.Clear(); string connectionHistoryFile = this.GetConnectionHistoryFile(); System.IO.StreamReader streamReader = null; try { if (Command.ConfigFile.Debug) { if (!System.IO.File.Exists(connectionHistoryFile)) { return; } streamReader = new System.IO.StreamReader(connectionHistoryFile); } else { System.IO.IsolatedStorage.IsolatedStorageFile store = System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(System.IO.IsolatedStorage.IsolatedStorageScope.User | System.IO.IsolatedStorage.IsolatedStorageScope.Assembly, null, null); streamReader = new System.IO.StreamReader(new System.IO.IsolatedStorage.IsolatedStorageFileStream(System.IO.Path.GetFileName(connectionHistoryFile), System.IO.FileMode.Open, store)); } if (streamReader != null) { while (!streamReader.EndOfStream) { string text = streamReader.ReadLine(); if (string.IsNullOrEmpty(text)) { break; } if (text.StartsWith("#")) { if (!text.StartsWith("#Last Database type: ")) { continue; } string value = text.Replace("#Last Database type: ", "").Trim(); try { DatabaseManager.lastDatabaseType = (DatabaseManager.DatabaseType)System.Enum.Parse(typeof(DatabaseManager.DatabaseType), value, true); Log.WriteLine("Get last DatabaseType: " + DatabaseManager.lastDatabaseType); continue; } catch (System.Exception) { continue; } } int num = text.IndexOf(','); string value2 = text.Substring(0, num); string item = text.Substring(num + 1); DatabaseManager.DatabaseType key = (DatabaseManager.DatabaseType)System.Enum.Parse(typeof(DatabaseManager.DatabaseType), value2); System.Collections.Generic.List <string> list; if (!DatabaseManager.m_LastConnection.TryGetValue(key, out list)) { list = new System.Collections.Generic.List <string>(); DatabaseManager.m_LastConnection.Add(key, list); } list.Add(item); } } } catch (System.IO.FileNotFoundException) { } catch (System.Exception ex) { Log.WriteLine(ex.ToString()); } finally { if (streamReader != null) { streamReader.Close(); } } }