private void ViewScript(object sender, EventArgs e)
        {
            ListView callingListView = null;

            if (sender is ToolStripDropDownItem)
            {
                ToolStripDropDownItem x     = (ToolStripDropDownItem)sender;
                ContextMenuStrip      strip = (ContextMenuStrip)x.Owner;
                if (strip.SourceControl is ListView)
                {
                    callingListView = (ListView)strip.SourceControl;
                }
            }
            else if (sender is ListView)
            {
                callingListView = (ListView)sender;
            }

            if (callingListView == null || callingListView.SelectedItems.Count == 0)
            {
                return;
            }

            string fileName = callingListView.SelectedItems[0].Text;

            if (File.Exists(Path.Combine(this.extractedPath, fileName)))
            {
                string            scriptContents = File.ReadAllText(Path.Combine(this.extractedPath, fileName));
                ScriptDisplayForm frmDisp        = new ScriptDisplayForm(scriptContents, "", fileName, Highlighting.SyntaxHightlightType.Sql);
                frmDisp.ShowDialog();
            }
        }
Esempio n. 2
0
        private void previewObjectScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstAdds.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem item    = lstAdds.SelectedItems[0];
            ObjectData   objData = (ObjectData)item.Tag;
            string       message;
            string       script = GetScriptPreviewText(objData, out message);

            if (script.Length > 0 || message.Length > 0)
            {
                ScriptDisplayForm frmDisplay;
                if (script.Length > 0)
                {
                    frmDisplay = new ScriptDisplayForm(script, this.connData.SQLServerName, item.SubItems[0].Text);
                }
                else
                {
                    frmDisplay = new ScriptDisplayForm(message, this.connData.SQLServerName, item.SubItems[0].Text);
                }

                frmDisplay.ShowDialog();
            }
        }
Esempio n. 3
0
        void frmScript_LoggingLinkClicked(string databaseInfo, string remoteEndPoint)
        {
            //database info expected int the format:   TLODDNO2\TLO_Clt1.TLO_002011#[01/17/2011 09:40:31.199]
            try
            {
                //MessageBox.Show(databaseInfo + "      " + remoteEndPoint);
                string   database  = databaseInfo.Split(new char[] { '#' })[0];
                string   timeStamp = databaseInfo.Split(new char[] { '#' })[1].Replace("[", "").Replace("]", "");
                DateTime submittedDate;
                if (!DateTime.TryParse(timeStamp, out submittedDate))
                {
                    MessageBox.Show(String.Format("Unable to determine build date with supplied Date/Time: {0}", timeStamp), "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    log.Error(String.Format("Unable to get submittedDate with info: databaseInfo=\"{0}\"; remoteEndPoint=\"{1}\"", databaseInfo, remoteEndPoint));
                }

                string text = buildManager.GetSpecificDetailedDatabaseLog(remoteEndPoint, database, submittedDate);
                SqlSync.ScriptDisplayForm frmScript = new ScriptDisplayForm(text, "", "Detailed Log from " + database);
                frmScript.Show();
            }
            catch (Exception exe)
            {
                log.Error(String.Format("Unable to get detailed log with info: databaseInfo=\"{0}\"; remoteEndPoint=\"{1}\"", databaseInfo, remoteEndPoint), exe);
                MessageBox.Show("Something went wrong! Please check the application log for detail", "Whoops", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void mnuViewObjectScript_Click(object sender, System.EventArgs e)
        {
            if (lstResults.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem item = lstResults.SelectedItems[0];

            SqlSync.ObjectScript.ObjectScriptHelper helper = new ObjectScriptHelper(this.connData);
            string script = string.Empty;
            string desc   = string.Empty;
            string message;
            string fullObjName = item.SubItems[0].Text;
            string name        = fullObjName;
            string schema;

            InfoHelper.ExtractNameAndSchema(name, out name, out schema);

            switch (item.SubItems[1].Text.Trim())
            {
            case "V":
                helper.ScriptDatabaseObject(SqlSync.Constants.DbObjectType.View, name, schema, ref script, ref desc, out message);
                break;

            case "P":
                helper.ScriptDatabaseObject(SqlSync.Constants.DbObjectType.StoredProcedure, name, schema, ref script, ref desc, out message);
                break;

            case "FN":
                helper.ScriptDatabaseObject(SqlSync.Constants.DbObjectType.UserDefinedFunction, name, schema, ref script, ref desc, out message);
                break;

            default:
                message = string.Empty;
                break;
            }

            if (script.Length > 0 || message.Length > 0)
            {
                ScriptDisplayForm frmDisplay;
                if (script.Length > 0)
                {
                    frmDisplay = new ScriptDisplayForm(script, this.connData.SQLServerName, item.SubItems[0].Text);
                }
                else
                {
                    frmDisplay = new ScriptDisplayForm(message, this.connData.SQLServerName, item.SubItems[0].Text);
                }

                frmDisplay.ShowDialog();
            }
        }
 void bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Result is string)
     {
         SqlSync.ScriptDisplayForm frmScript = new ScriptDisplayForm(e.Result.ToString(), "", "Sql Build Manager Application Log", SqlSync.Highlighting.SyntaxHightlightType.LogFile);
         frmScript.WordWrap          = false;
         frmScript.ScrollToEndOnLoad = true;
         frmScript.Show();
     }
     else if (e.Result is Exception)
     {
         MessageBox.Show("Sorry, there was an error trying to load the application log file", "Something went wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 6
0
        private void viewScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.dgDetail.SelectedCells.Count == 0)
            {
                return;
            }


            SqlSyncBuildData.ScriptRunRow row     = (SqlSyncBuildData.ScriptRunRow)((System.Data.DataRowView) this.dgDetail.SelectedCells[0].OwningRow.DataBoundItem).Row;
            ScriptDisplayForm             frmDisp = new ScriptDisplayForm(row.Results, row.Database, row.FileName);

            frmDisp.ShowDialog();
            frmDisp.Dispose();
        }
        private void viewScriptAsRunOnServerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <DataGridViewRow> selectedRows = GetSelectedRows(this.dataGridView1);

            if (selectedRows.Count != 1)
            {
                return;
            }

            SqlSync.SqlBuild.ScriptRunLogRow row = (SqlSync.SqlBuild.ScriptRunLogRow)((DataRowView)selectedRows[0].DataBoundItem).Row;
            ScriptDisplayForm frmDisp            = new ScriptDisplayForm(row.ScriptText, this.connData.SQLServerName, row.ScriptFileName);

            frmDisp.ShowDialog();
            frmDisp.Dispose();
        }
        private void viewStoredProcedureScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string script = "";
            string desc   = "";
            string message;

            if (this.treeView1.SelectedNode == null)
            {
                return;
            }

            StoredProcedure sp = null;

            if (this.treeView1.SelectedNode.Tag is StoredProcedure)
            {
                sp = (StoredProcedure)this.treeView1.SelectedNode.Tag;
            }
            else if (this.treeView1.SelectedNode.Parent.Tag is StoredProcedure)
            {
                sp = (StoredProcedure)this.treeView1.SelectedNode.Parent.Tag;
            }

            if (sp == null)
            {
                return;
            }

            SqlSync.ObjectScript.ObjectScriptHelper helper = new SqlSync.ObjectScript.ObjectScriptHelper(this.connData);
            string name = sp.Name;
            string schemaOwner;

            InfoHelper.ExtractNameAndSchema(name, out name, out schemaOwner);

            helper.ScriptDatabaseObject(SqlSync.Constants.DbObjectType.StoredProcedure, name, schemaOwner, ref script, ref desc, out message);

            ScriptDisplayForm frmDisplay;

            if (script.Length > 0)
            {
                frmDisplay = new ScriptDisplayForm(script, this.connData.SQLServerName, sp.Name);
            }
            else
            {
                frmDisplay = new ScriptDisplayForm(message, this.connData.SQLServerName, sp.Name);
            }

            frmDisplay.Show();
        }
Esempio n. 9
0
        private void viewRemoteServiceExecutableLogFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.SourceControl is DataGridView)
            {
                DataGridView dgvServerStatus = (DataGridView)this.SourceControl;
                if (dgvServerStatus.SelectedCells.Count == 0)
                {
                    return;
                }

                this.Cursor = Cursors.WaitCursor;
                //this.statGeneral.Text = "Retrieving Remote Service Executable log file...";
                //this.statProgBar.Style = ProgressBarStyle.Marquee;
                try
                {
                    string serverName     = string.Empty;
                    string remoteEndpoint = string.Empty;
                    string text           = string.Empty;
                    if (dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem is ServerConfigData)
                    {
                        ServerConfigData server = (ServerConfigData)dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem;
                        remoteEndpoint = server.ActiveServiceEndpoint;
                        serverName     = server.ServerName;
                    }
                    else if (dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem is BuildRecord)
                    {
                        BuildRecord buildRec = (BuildRecord)dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem;
                        remoteEndpoint = buildRec.RemoteEndPoint;
                        serverName     = buildRec.RemoteServerName;
                    }

                    text = buildManager.GetServiceLog(remoteEndpoint);
                    SqlSync.ScriptDisplayForm frmScript = new ScriptDisplayForm(text, serverName, "Service Executable Log from " + serverName, SqlSync.Highlighting.SyntaxHightlightType.LogFile);
                    frmScript.Show();
                }
                catch (Exception exe)
                {
                    MessageBox.Show("Sorry... There was an error attempting to retrieve the log file.\r\n " + exe.Message, "Problem!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                    //this.statGeneral.Text = "Ready.";
                    //this.statProgBar.Style = ProgressBarStyle.Blocks;
                }
            }
        }
Esempio n. 10
0
        private void viewExecutionCommitsLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.SourceControl is DataGridView)
            {
                DataGridView dgvServerStatus = (DataGridView)this.SourceControl;
                if (dgvServerStatus.SelectedCells.Count == 0)
                {
                    return;
                }

                try
                {
                    string serverName     = string.Empty;
                    string text           = string.Empty;
                    string remoteEndpoint = string.Empty;
                    if (dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem is ServerConfigData)
                    {
                        ServerConfigData server = (ServerConfigData)dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem;
                        remoteEndpoint = server.ActiveServiceEndpoint;
                        text           = buildManager.GetCommitsLog(server.ActiveServiceEndpoint);
                        serverName     = server.ServerName;
                    }
                    else if (dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem is BuildRecord)
                    {
                        BuildRecord buildRec = (BuildRecord)dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem;
                        remoteEndpoint = buildRec.RemoteEndPoint;
                        text           = buildManager.GetSpecificSummaryLogFile(buildRec.RemoteEndPoint, SummaryLogType.Commits, buildRec.submissionDate);
                        serverName     = buildRec.RemoteServerName;
                    }

                    SqlSync.ScriptDisplayForm frmScript = new ScriptDisplayForm(text, serverName, "Commits Log from " + serverName, SqlSync.Highlighting.SyntaxHightlightType.RemoteServiceLog, remoteEndpoint);
                    frmScript.LoggingLinkClicked += new LoggingLinkClickedEventHandler(frmScript_LoggingLinkClicked);
                    frmScript.Show();
                }
                catch (System.ServiceModel.CommunicationObjectFaultedException comExe)
                {
                    MessageBox.Show("There was a communication issue retrieving the log file.\r\nTo try to clear the communication error, try closing this page and reopening. If that does not work, you may need to restart the service on the target remote execution server.\r\n\r\nError Message:\r\n" + comExe.Message, "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception exe)
                {
                    MessageBox.Show("There was an issue retrieving the log file.\r\n" + exe.Message, "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 11
0
        private void txtDetailedLogTarget_KeyDown(object sender, KeyEventArgs e)
        {
            if (this.SourceControl is DataGridView)
            {
                DataGridView dgvServerStatus = (DataGridView)this.SourceControl;

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter)
                {
                    if (dgvServerStatus.SelectedCells.Count == 0 || txtDetailedLogTarget.Text.Length == 0)
                    {
                        return;
                    }
                    try
                    {
                        string serverName = string.Empty;
                        string text       = string.Empty;
                        if (dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem is ServerConfigData)
                        {
                            ServerConfigData server = (ServerConfigData)dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem;
                            text       = buildManager.GetDetailedDatabaseLog(server.ActiveServiceEndpoint, txtDetailedLogTarget.Text);
                            serverName = server.ServerName;
                        }
                        else if (dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem is BuildRecord)
                        {
                            BuildRecord buildRec = (BuildRecord)dgvServerStatus.Rows[dgvServerStatus.SelectedCells[0].RowIndex].DataBoundItem;
                            text       = buildManager.GetSpecificDetailedDatabaseLog(buildRec.RemoteEndPoint, txtDetailedLogTarget.Text, buildRec.submissionDate);
                            serverName = buildRec.RemoteServerName;
                        }

                        SqlSync.ScriptDisplayForm frmScript = new ScriptDisplayForm(text, serverName, "Detailed Log from " + txtDetailedLogTarget.Text);
                        frmScript.Show();

                        txtDetailedLogTarget.Text = string.Empty;
                    }
                    catch (Exception exe)
                    {
                        MessageBox.Show("There was an issue retrieving the log file.\r\n" + exe.Message, "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }