private static TryLoadSettingsFromSql LoadLocalSettingsFromSQL() { string exceptionMsg; if (!SqlWorks.CheckSQL_Connection(MainSettings.JsonSettings.ConnectionString, out exceptionMsg)) { return(new TryLoadSettingsFromSql(false, $"Ошибка подключения к SQL-базе заданий.\r\nПричина: {exceptionMsg}")); } if (MainSqlSettings.ComputerId == null || MainSqlSettings.ComputerId == 0) { return(new TryLoadSettingsFromSql(false, "Ошибка регистрации компьютера, не получен ComputerId. Проверьте настройки и перезапустите службу.")); } else { try { LocalSqlSettings = new SqlLocalSettings(); LocalSqlSettings.LoadSqlLocalSettings(); } catch (Exception ex) { return(new TryLoadSettingsFromSql(false, ex.Message)); } return(new TryLoadSettingsFromSql()); } }
private bool CheckSQLConnection(JsonLocalSettings jsonLocalSettings, bool isShowSuccessMessage = true) { if (SqlWorks.CheckSQL_Connection(jsonLocalSettings.ConnectionString)) { if (isShowSuccessMessage) { MessageBox.Show("Тест соединения успешно пройден.", "Тест подключения", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(true); } else { MessageBox.Show("Ошибка при попытке установить соединение", "Тест подключения", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private void SettingsForm_Shown(object sender, EventArgs e) { CheckService(); tabControlSettings.Appearance = TabAppearance.FlatButtons; tabControlSettings.ItemSize = new Size(0, 1); tabControlSettings.SizeMode = TabSizeMode.Fixed; if (SqlWorks.CheckSQL_Connection(MainSettings.JsonSettings.ConnectionString)) { ActivateSettingsPage(tabPageSettings); } else { ActivateSettingsPage(tabPageConnectionString); } _serviceCheckTimer = new System.Threading.Timer(ServiceCheckTimerTick, null, _serviceCheckTimeout, Timeout.Infinite); }
public static TryLoadCommonGlobalSettings LoadMonitorCommonGlobalSettings() { var loadFromJsonResult = LoadFromJson(); if (!loadFromJsonResult.IsComplete) { return(new TryLoadCommonGlobalSettings(false, loadFromJsonResult.Message)); } string exceptionMsg; if (!SqlWorks.CheckSQL_Connection(MainSettings.JsonSettings.ConnectionString, out exceptionMsg)) { return(new TryLoadCommonGlobalSettings(false, $"Ошибка подключения к SQL-базе заданий.\r\nПричина: {exceptionMsg}")); } _globalSettings = new CommonGlobalSettings(); return(_globalSettings.LoadCommonGlobalSettings()); }