/// <summary> /// 'userID, connectionName\userName' /// </summary> /// <returns></returns> public NameValueCollection GetAllConnections() { NameValueCollection result = new NameValueCollection(); TDSettings.ConnectionDataTable lstConn = this.GetActiveConnections(); foreach (TDSettings.ConnectionRow conn in lstConn) { result.Add(conn.ConnectionId.ToString(), conn.ConnectionName + "\\" + conn.UserName); } return(result); }
public void LoadDefaultData(string applicationPath) { _appPath = applicationPath; string fileName = applicationPath + Path.DirectorySeparatorChar + _fileName; string defaultFileName = Application.StartupPath + Path.DirectorySeparatorChar + _defaultFileName; try { if (File.Exists(fileName)) { _instance.ReadXml(fileName); } //if QueriesTree does not exist in the windows user application data folder //load the default values from the application folder else if (File.Exists(defaultFileName)) { TDSQueriesTree t = new TDSQueriesTree(); t.ReadXml(defaultFileName); _instance.QueryTypes.Merge(t.QueryTypes); _instance.QueryParameters.Merge(t.QueryParameters); MyZillaSettingsDataSet settings = MyZillaSettingsDataSet.GetInstance(); TDSettings.ConnectionDataTable connections = settings.GetActiveConnections(); foreach (TDSettings.ConnectionRow connection in connections) { CatalogueManager catalogues = CatalogueManager.Instance(); if (catalogues.GetCataloguesForConnection(connection.ConnectionId) != null) { BuildTreeStructureForUserId(t, connection); } } } else { throw (new IOException("Default queries configuration [" + fileName + "] is missing!")); } } catch (IOException) { throw (new IOException("File " + fileName + " not exist.")); } }
/// <summary> /// Load catalogues for all users that are active and the credentials are known. /// </summary> public void LoadCataloguesForActiveConnections() { #if DEBUG System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew(); #endif // get all active users TDSettings.ConnectionDataTable activeConnections = _appSettings.GetActiveConnections(); if (activeConnections.Rows.Count > 0) { for (int iThread = 0; iThread < activeConnections.Count; iThread++) { Interlocked.Increment(ref activeThreads); TDSettings.ConnectionRow currentConnection = activeConnections.Rows[iThread] as TDSettings.ConnectionRow; ParameterizedThreadStart operation = new ParameterizedThreadStart(StartAsyncOperation); Thread ts = new Thread(operation); ts.Start(currentConnection); } // Wait for all threads to complete their task... do { }while (activeThreads != 0); #if DEBUG watch.Stop(); MyLogger.Write(watch.ElapsedMilliseconds.ToString(), "LoadCataloguesForActiveConnections", LoggingCategory.Debug); #endif } }