/// <summary> Показать форму ввода параметров </summary> /// <returns> true - DialogResult == DialogResult.OK, иначе - false </returns> public static bool GetLogin(ref string username, ref string password, ref string database, string dblabel, string sectionname, object[] dbList = null) { using (var lf = new LoginForm(dbList)) return(lf.Login(ref username, ref password, ref database, dblabel, sectionname)); }
/// <summary> Показать форму ввода параметров </summary> /// <returns> true - DialogResult == DialogResult.OK, иначе - false </returns> public static bool GetLogin(ref string username, ref string password, ref string database, string dblabel, ref string loginhistory) { using (var lf = new LoginForm()) return(lf.Login(ref username, ref password, ref database, dblabel, ref loginhistory)); }
/// <summary> Открытие соединения с учётом передаваемых параметров или уже существующих настроек </summary> /// <param name="connectionString">строка соединения</param> /// <param name="schema">схема БД</param> /// <returns>true - удалось установить соединение, false - иначе</returns> public bool OpenConnection(string connectionString = null, string schema = null) { lock (lockObj) { // ConnectionString = connectionString.IfEmpty(ConnectionString); Schema = schema.IfEmpty(Schema); // int requestPassCount = AppContext.Config.GetParameter(ConfigSection, "requestpasscount", 0); var dbLabel = AppContext.Config[ConfigSection, "label"]; var server = Server; var database = Database; var login = User; var password = Password; int startRequestPassCount = requestPassCount; do { try { CloseConnection(); if (AppContext.UserInteractive && (server.IsEmpty() || (login.IsEmpty() && !password.IsEmpty()) || (!login.IsEmpty() && password.IsEmpty()) || requestPassCount != startRequestPassCount)) { if (OnGetConnectionInfo != null?!OnGetConnectionInfo(ref login, ref password, ref server, ref database, ConfigSection):!LoginForm.GetLogin(ref login, ref password, ref server, dbLabel, ConfigSection, GetDBList())) { return(false); } } ConnectionString = GetConnectionString(server, database, login, password, schema); OpenConnection(); return(true); } catch (DbException oe) { if (OnException == null || !OnException(oe)) { _log.HandleException(oe); } CloseConnection(); server = Server; login = User; password = ""; if (!AppContext.UserInteractive || (--requestPassCount < 0)) { return(false); } } }while (true); } }