Exemple #1
0
        /// <summary>
        /// Загружаемся, проверяем текущее состояние
        /// </summary>
        protected void LoadApp()
        {
            try
            {
                if (_app != null)
                {
                    if (_app.CurrentProject != null)
                    {
                        Project current = _app.CurrentProject;
                        load_res = loadResults.ProjectLoaded;

                        if (_app.Manager.IsConnectValid)
                        {
                            toolStripStatusLabelDBStatus.Text = "Соединение с SQL сервером установлено";

                            // ---- есть связь с сервером БД
                            if (CheckBD(current.DB_Name))
                            {
                                // ---- найдена БД для проекта ----

                                load_res = loadResults.ProjectLoadedDBFind;
                                if (LoadDB(current.DB_Name))
                                {
                                    load_res = loadResults.ProjectLoadedAndDBLoaded;

                                    InsertKoefs(_app.CurrentProject);
                                    InsertToListStages(_app.CurrentProject);
                                }
                                else
                                {
                                    load_res = loadResults.ProjectLoadedDBNotLoad;

                                    InsertKoefs(_app.CurrentProject);
                                    InsertToListStages(_app.CurrentProject);

                                    toolStripStatusLabelDBStatus.Text = "Связь с БД отсутсвует";
                                }
                            }
                            else
                            {
                                // ---- не найдена БД на сервере ----

                                load_res = loadResults.ProjectLoadedNotFindDB;

                                InsertKoefs(_app.CurrentProject);
                                InsertToListStages(_app.CurrentProject);

                                toolStripStatusLabelDBStatus.Text = "Связь с БД отсутсвует";
                            }
                        }
                        else
                        {
                            // ----- нету связи с сервером быз данных -----

                            load_res = loadResults.ProjectLoadNotBDPing;

                            InsertKoefs(_app.CurrentProject);
                            InsertToListStages(_app.CurrentProject);

                            toolStripStatusLabelDBStatus.Text = "Связь с БД отсутсвует";

                        }
                    }
                    else
                    {
                        // ---- нету активного проекта ----

                        load_res = loadResults.ProjectNotLoaded;
                        toolStripStatusLabelDBStatus.Text = "Задание не выбрано";
                    }
                }
            }
            catch { }
        }
Exemple #2
0
        /// <summary>
        /// обрабатываем БД для нового проекта
        /// </summary>
        /// <param name="project">Обрабатываемый проект</param>
        protected void CheckAndLoadBD(Project project)
        {
            try
            {
                if (project != null)
                {
                    string db_name = project.DB_Name;
                    if (db_name != string.Empty)
                    {
                        if (_app.Manager.IsConnectValid)
                        {
                            string[] bases = _app.Manager.DataBases;
                            if (bases != null)
                            {
                                bool find = false;
                                foreach (string db in bases)
                                {
                                    if (db_name == db)
                                    {
                                        find = true;
                                        break;
                                    }
                                }

                                if (find == false)
                                {
                                    _app.Manager.CreateBD(db_name);
                                    _app.Manager.LoadDB(db_name);

                                    if (_app.Manager.State == DataBaseState.Loaded)
                                    {
                                        foreach (Parameter parameter in _app.Commutator.Parameters)
                                        {
                                            _app.Manager.InsertParameter(parameter.Identifier);
                                        }
                                    }

                                    load_res = loadResults.ProjectLoadedAndDBLoaded;
                                    toolStripStatusLabelDBStatus.Text = "Связь с SQL сервером установлена";
                                }
                                else
                                {
                                    // ---- нашли БД нужно ее загрузить ----

                                    _app.Manager.LoadDB(db_name);
                                    load_res = loadResults.ProjectLoadedAndDBLoaded;

                                    toolStripStatusLabelDBStatus.Text = "Связь с SQL сервером установлена";
                                }
                            }
                            else
                            {
                                // ---- нету баз данных ----
                                load_res = loadResults.ProjectLoadedNotFindDB;
                                toolStripStatusLabelDBStatus.Text = "Связь с БД отсутствует";
                            }
                        }
                        else
                        {
                            // ---- нету связи с сервером БД ----
                            load_res = loadResults.ProjectLoadNotBDPing;
                            toolStripStatusLabelDBStatus.Text = "Связь с SQL сервером не установлена";
                        }
                    }
                    else
                    {
                        // ---- не определено имя БД для проекта ----
                        load_res = loadResults.NotLoadBD;
                        toolStripStatusLabelDBStatus.Text = "Связь с БД отсутсвует";
                    }
                }
                else
                {
                    // ---- проект не загружен ----

                    load_res = loadResults.ProjectNotLoaded;
                    toolStripStatusLabelDBStatus.Text = "Задание не удалось загрузить";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                load_res = loadResults.Default;

                toolStripStatusLabelDBStatus.Text = "Задание не загружено";
            }
        }