Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Verifies the existence of the specified FW data source.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static void CheckExistenceOfFwDatabase(PaDataSource ds)
        {
            if (ds == null)
            {
                return;
            }

            if (!FwDBUtils.IsSQLServerStarted && !FwDBUtils.StartSQLServer(true))
            {
                return;
            }

            if (ds.FwDataSourceInfo != null)
            {
                var fwDBInfoList =
                    FwDBUtils.GetFwDataSourceInfoList(ds.FwDataSourceInfo.Server, false);

                if (fwDBInfoList.Any(fwinfo => ds.FwPrjName == fwinfo.Name))
                {
                    return;
                }

                ds.FwDataSourceInfo.IsMissing = true;
            }

            MissingFWDatabaseMsgBox.ShowDialog(ds.ToString(true));
            ds.SkipLoadingBecauseOfProblem = true;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Show the dialog to allow the user to specify a FieldWorks database as a data source.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandleAddFw6DataSourceClick(object sender, EventArgs e)
        {
            // Make sure SQL Server is started.
            if (!FwDBUtils.IsSQLServerStarted && !FwDBUtils.StartSQLServer(true))
            {
                return;
            }

            using (var dlg = new FwProjectsDlg())
            {
                if (dlg.ShowDialog(this) == DialogResult.OK && dlg.ChosenDatabase != null)
                {
                    if (ProjectContainsFwDataSource(dlg.ChosenDatabase) &&
                        Utils.MsgBox(string.Format(DupDataSourceMsg, dlg.ChosenDatabase.ProjectName),
                                     MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        return;
                    }

                    _dataSources.Add(new PaDataSource(Project.Fields, dlg.ChosenDatabase));
                    LoadGrid(m_grid.Rows.Count);
                    m_dirty = true;
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        public ProjectSettingsDlg(PaProject project)
            : this()
        {
            Application.DoEvents();

            _isProjectNew          = (project == null);
            _chkMakeFolder.Visible = (_isProjectNew && !Properties.Settings.Default.AutoCreateProjectFilesAndFolderOnProjectCreation);
            _chkMakeFolder.Checked = (Properties.Settings.Default.CreateProjectFolderForNewProject || !_chkMakeFolder.Visible);

            BuildGrid();
            pnlGridHdg.ControlReceivingFocusOnMnemonic = m_grid;
            pnlGridHdg.BorderStyle = BorderStyle.None;

            if (project == null)
            {
                Project = new PaProject(true);
            }
            else
            {
                Project = project;
                _originallyMappedFields = project.GetMappedFields().Select(f => f.Name).ToList();
                _dataSources            = project.DataSources.Select(ds => ds.Copy()).ToList();
                txtProjName.Text        = project.Name;
                txtLanguageName.Text    = project.LanguageName;
                txtLanguageCode.Text    = project.LanguageCode;
                txtResearcher.Text      = project.Researcher;
                txtTranscriber.Text     = project.Transcriber;
                txtSpeaker.Text         = project.SpeakerName;
                txtComments.Text        = project.Comments;
                LoadGrid(-1);
            }

            WaitCursor.Show();

            if (Project.DistinctiveFeatureSet == BFeatureCache.DefaultFeatureSetName)
            {
                _comboDistinctiveFeaturesSet.SelectedIndex = 0;
            }
            else
            {
                _comboDistinctiveFeaturesSet.SelectedItem = Project.DistinctiveFeatureSet;
            }

            if (_dataSources.Any(ds => ds.Type == DataSourceType.FW))
            {
                FwDBUtils.StartSQLServer(true);
            }

            mnuAddFw6DataSource.Enabled = FwDBUtils.IsSQLServerInstalled(false);
            mnuAddFw7DataSource.Enabled = FwDBUtils.IsFw7Installed;

            DialogResult   = DialogResult.Cancel;
            m_dirty        = _isProjectNew;
            m_grid.IsDirty = false;
            WaitCursor.Hide();

            UpdateButtonStates();
        }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Cycles through the data sources, checking if any are sources directly from a
        /// FW database. If so, then an attempt is made to start SQL server if it isn't
        /// already started.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static void CheckNeedForSQLServer(IEnumerable <PaDataSource> dataSourcesToLoad)
        {
            bool alreadyTriedToStartSQLServer = false;

            foreach (var ds in dataSourcesToLoad.Where(ds => ds.Type == DataSourceType.FW && ds.FwSourceDirectFromDB))
            {
                if (!alreadyTriedToStartSQLServer && FwDBUtils.StartSQLServer(true))
                {
                    return;
                }

                alreadyTriedToStartSQLServer   = true;
                ds.SkipLoadingBecauseOfProblem = true;
            }
        }