Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public static bool AppInit()
        {
            CurrentConfig = new SqlBackUpperLibConfig(ASSEMBLY_NAME, SQLBACKUPPER_CONFIG_FILE_NAME);
            if (CurrentConfig.IsSetConfig)
            {
                Connection.AttachServerTypeObjects(CurrentConfig.Connections, CurrentConfig.ServerTypes);
            }
            else
            {
                return(MessageBoxes.CreateConfigFile() && CurrentConfig.WriteConfig());

                //if (MessageBoxes.CreateConfigFile())
                //{
                //    if (!CurrentConfig.WriteConfig())
                //        return false;
                //}
                //else
                //    //Log.Add("Config file is not set. Exit..");
                //    return false;
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        void Test()
        {
            ServerType st = ContentControls.cbServerType.SelectedItem as ServerType;

            if (st == null)
            {
                return;
            }

            string connString = string.Format(st.ConnectionStringMask,
                                              ContentControls.tbServer.Value, ContentControls.tbDatabase.Value, ContentControls.tbUser.Value, ContentControls.tbPassword.Value,
                                              "False", "False", "True");

            ContentControls.gMain.IsEnabled = false;

            try
            {
                SqlConnection conn = new SqlConnection(connString);
                conn.Open();
                var state = conn.State;
                conn.Close();

                bool res = (state == System.Data.ConnectionState.Open);
                MessageBoxes.ServerTest(this, ContentControls.tbServer.Value, res);
            }
            catch (SqlException sqlex)
            {
                MessageBoxes.Error(this, "Невозможно соединиться с сервером:\n" + sqlex.Message);
            }
            catch (Exception ex)
            {
                MessageBoxes.Error(this, "Ошибка в строке соединения:\n" + ex.Message);
            }

            ContentControls.gMain.IsEnabled = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        void Apply()
        {
            if (this.connections.Any() && !this.serverTypes.Any())
            {
                MessageBoxes.Warning(this, "Необходимо добавить хотя бы один тип сервера");
                return;
            }

            if (!this.connections.ToList().All(x => x.ServerType != null))
            {
                MessageBoxes.Warning(this, "У некоторых соединений не установлен тип сервера");
                return;
            }

            SqlBackUpperLibConfig config = App.CurrentConfig;

            config.Connections = this.connections.ToList();
            config.ServerTypes = this.serverTypes.ToList();

            //
            config.WriteConfig();

            Close();
        }