コード例 #1
0
ファイル: TopographForm.cs プロジェクト: lgatto/proteowizard
 public MruChosenHandler(TopographForm topographForm, string path)
 {
     _topographForm = topographForm;
     _path = path;
 }
コード例 #2
0
ファイル: NewOnlineWorkspaceForm.cs プロジェクト: zrolfs/pwiz
        private void BtnOkOnClick(object sender, EventArgs e)
        {
            if (!CheckRequiredField(tbxServer) ||
                !CheckRequiredField(tbxDatabase) ||
                !CheckRequiredField(tbxUsername) ||
                !CheckRequiredField(tbxPassword))
            {
                return;
            }
            Settings.Default.Reload();
            var tpgLnkDef = GetTpgLinkDef();

            try
            {
                using (tpgLnkDef.OpenConnectionNoDatabase())
                {
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(this,
                                string.Format(
                                    "The server, port, username, or password is invalid.  There was an error connecting to the database: {0}",
                                    exception), Program.AppName);
                return;
            }
            bool workspaceExists;

            try
            {
                var workspaceUpgrader = new WorkspaceUpgrader(tpgLnkDef);
                using (var connection = tpgLnkDef.OpenConnection())
                {
                    try
                    {
                        workspaceUpgrader.ReadSchemaVersion(connection);
                        if (MessageBox.Show(this,
                                            string.Format(
                                                "The database {0} already exists.  Instead of creating a new Online Workspace, would you like to save a .tpglnk file which allows you to connect to this existing Online Workspace.",
                                                tpgLnkDef.Database), Program.AppName, MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                        workspaceExists = true;
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(this, string.Format("The database {0} already exists but does not appear to be a Topograph workspace.", tpgLnkDef.Database),
                                        Program.AppName);
                        return;
                    }
                }
            }
            catch (Exception)
            {
                workspaceExists = false;
            }
            if (!workspaceExists)
            {
                try
                {
                    using (var sessionFactory = tpgLnkDef.CreateDatabase())
                    {
                        TopographForm.InitWorkspace(sessionFactory);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(this, string.Format("There was an error creating the database: {0}", exception), Program.AppName);
                    return;
                }
            }
            while (true)
            {
                using (var fileDialog = new SaveFileDialog
                {
                    Filter = TopographForm.OnlineWorkspaceFilter,
                    InitialDirectory = Settings.Default.WorkspaceDirectory,
                    FileName = tbxDatabase.Text + ".tpglnk",
                })
                {
                    if (fileDialog.ShowDialog(this) == DialogResult.Cancel)
                    {
                        DialogResult = DialogResult.Cancel;
                    }
                    try
                    {
                        tpgLnkDef.Save(fileDialog.FileName);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(this, string.Format("Error saving .tpglnk file: {0}", exception),
                                        Program.AppName);
                        continue;
                    }
                    Filename = fileDialog.FileName;
                    Settings.Default.WorkspaceDirectory = Path.GetDirectoryName(Filename);
                    break;
                }
            }
            Settings.Default.ConnectionSettings = new ConnectionSettings
            {
                Server   = tbxServer.Text,
                Port     = tbxPort.Text,
                Username = tbxUsername.Text,
            };
            Settings.Default.Save();
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #3
0
 public MruChosenHandler(TopographForm topographForm, string path)
 {
     _topographForm = topographForm;
     _path          = path;
 }
コード例 #4
0
ファイル: CreateFileAnalysesForm.cs プロジェクト: zrolfs/pwiz
        private void BtnOkOnClick(object sender, EventArgs e)
        {
            int unreadableFiles = 0;
            int checkedItems    = 0;

            TopographForm.Instance.EnsureDataDirectory(Workspace);
            var msDataFiles = new List <MsDataFile>();

            for (int i = 0; i < MsDataFiles.Count; i++)
            {
                if (!checkedListBox1.GetItemChecked(i))
                {
                    continue;
                }
                checkedItems++;
                var    msDataFile = MsDataFiles[i];
                string errorMessage;
                if (TopographForm.TryInitMsDataFile(this, msDataFile, out errorMessage))
                {
                    msDataFiles.Add(msDataFile);
                }
                else
                {
                    unreadableFiles++;
                }
            }
            if (checkedItems == 0)
            {
                return;
            }
            if (unreadableFiles > 0)
            {
                if (msDataFiles.Count == 0)
                {
                    var dlgResult = MessageBox.Show(this,
                                                    unreadableFiles +
                                                    " of the data files could not be read.  Do you want to process the remaining files?",
                                                    Program.AppName, MessageBoxButtons.YesNoCancel);
                    if (dlgResult == DialogResult.Cancel)
                    {
                        return;
                    }
                    if (dlgResult == DialogResult.No)
                    {
                        Close();
                        return;
                    }
                }
                else
                {
                    var dlgResult = MessageBox.Show("None of the selected files could be read.  Make sure the data directory setting is correct.", Program.AppName, MessageBoxButtons.OKCancel);
                    if (dlgResult == DialogResult.OK)
                    {
                        Close();
                    }
                    return;
                }
            }
            if (msDataFiles.Count > 0)
            {
                var job = new Task(PeptideAnalysis, msDataFiles);
                using (var longWaitDialog = new LongWaitDialog(TopLevelControl, "Creating file analyses"))
                {
                    new LongOperationBroker(job.Run, longWaitDialog).LaunchJob();
                }
                Workspace.DatabasePoller.Wake();
            }
            Close();
        }