mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Update Agent contracts to match SQL Ops definitons (#633)
* WIP 2 * Update contracts to match SQL Ops definitons
This commit is contained in:
@@ -23,37 +23,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
/// <summary>
|
||||
/// Summary description for JobStepAdvancedLogging.
|
||||
/// </summary>
|
||||
internal sealed class JobStepAdvancedLogging : IJobStepPropertiesControl
|
||||
internal sealed class JobStepAdvancedLogging
|
||||
{
|
||||
private CDataContainer dataContainer = null;
|
||||
// private IMessageBoxProvider messageProvider = null;
|
||||
// private System.Windows.Forms.Label fileLabel;
|
||||
// private System.Windows.Forms.TextBox outputFile;
|
||||
// private System.Windows.Forms.Button browse;
|
||||
// private System.Windows.Forms.CheckBox appendOutput;
|
||||
|
||||
private bool userIsSysAdmin = false;
|
||||
private bool canViewFileLog = false;
|
||||
private bool canSetFileLog = false;
|
||||
|
||||
|
||||
private JobStepData jobStepData;
|
||||
// private CheckBox logToTable;
|
||||
// private CheckBox appendToFile;
|
||||
// private CheckBox appendToTable;
|
||||
// private Button viewFileLog;
|
||||
// private Button viewTableLog;
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
|
||||
public JobStepAdvancedLogging()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
|
||||
// TODO: Add any initialization after the InitForm call
|
||||
|
||||
}
|
||||
|
||||
public JobStepAdvancedLogging(CDataContainer dataContainer, JobStepData jobStepData)
|
||||
@@ -62,305 +40,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
this.jobStepData = jobStepData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
// protected override void Dispose(bool disposing)
|
||||
// {
|
||||
// if (disposing)
|
||||
// {
|
||||
// if (components != null)
|
||||
// {
|
||||
// components.Dispose();
|
||||
// }
|
||||
// }
|
||||
// base.Dispose(disposing);
|
||||
// }
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
// System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(JobStepAdvancedLogging));
|
||||
// this.fileLabel = new System.Windows.Forms.Label();
|
||||
// this.outputFile = new System.Windows.Forms.TextBox();
|
||||
// this.browse = new System.Windows.Forms.Button();
|
||||
// this.appendOutput = new System.Windows.Forms.CheckBox();
|
||||
// this.logToTable = new System.Windows.Forms.CheckBox();
|
||||
// this.appendToFile = new System.Windows.Forms.CheckBox();
|
||||
// this.appendToTable = new System.Windows.Forms.CheckBox();
|
||||
// this.viewFileLog = new System.Windows.Forms.Button();
|
||||
// this.viewTableLog = new System.Windows.Forms.Button();
|
||||
// this.SuspendLayout();
|
||||
// this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
// this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
// //
|
||||
// // fileLabel
|
||||
// //
|
||||
// resources.ApplyResources(this.fileLabel, "fileLabel");
|
||||
// this.fileLabel.Name = "fileLabel";
|
||||
// //
|
||||
// // outputFile
|
||||
// //
|
||||
// resources.ApplyResources(this.outputFile, "outputFile");
|
||||
// this.outputFile.Name = "outputFile";
|
||||
// this.outputFile.TextChanged += new System.EventHandler(this.outputFile_TextChanged);
|
||||
// //
|
||||
// // browse
|
||||
// //
|
||||
// resources.ApplyResources(this.browse, "browse");
|
||||
// this.browse.Name = "browse";
|
||||
// this.browse.Click += new System.EventHandler(this.browse_Click);
|
||||
// //
|
||||
// // appendOutput
|
||||
// //
|
||||
// resources.ApplyResources(this.appendOutput, "appendOutput");
|
||||
// this.appendOutput.Name = "appendOutput";
|
||||
// //
|
||||
// // logToTable
|
||||
// //
|
||||
// resources.ApplyResources(this.logToTable, "logToTable");
|
||||
// this.logToTable.Name = "logToTable";
|
||||
// this.logToTable.CheckedChanged += new System.EventHandler(this.logToTable_CheckedChanged);
|
||||
// //
|
||||
// // appendToFile
|
||||
// //
|
||||
// resources.ApplyResources(this.appendToFile, "appendToFile");
|
||||
// this.appendToFile.Name = "appendToFile";
|
||||
// //
|
||||
// // appendToTable
|
||||
// //
|
||||
// resources.ApplyResources(this.appendToTable, "appendToTable");
|
||||
// this.appendToTable.Name = "appendToTable";
|
||||
// //
|
||||
// // viewFileLog
|
||||
// //
|
||||
// resources.ApplyResources(this.viewFileLog, "viewFileLog");
|
||||
// this.viewFileLog.Name = "viewFileLog";
|
||||
// this.viewFileLog.Click += new System.EventHandler(this.viewFileLog_Click);
|
||||
// //
|
||||
// // viewTableLog
|
||||
// //
|
||||
// resources.ApplyResources(this.viewTableLog, "viewTableLog");
|
||||
// this.viewTableLog.Name = "viewTableLog";
|
||||
// this.viewTableLog.Click += new System.EventHandler(this.viewTableLog_Click);
|
||||
// //
|
||||
// // JobStepAdvancedLogging
|
||||
// //
|
||||
// this.Controls.Add(this.viewTableLog);
|
||||
// this.Controls.Add(this.viewFileLog);
|
||||
// this.Controls.Add(this.appendToTable);
|
||||
// this.Controls.Add(this.appendToFile);
|
||||
// this.Controls.Add(this.logToTable);
|
||||
// this.Controls.Add(this.appendOutput);
|
||||
// this.Controls.Add(this.browse);
|
||||
// this.Controls.Add(this.outputFile);
|
||||
// this.Controls.Add(this.fileLabel);
|
||||
// this.Name = "JobStepAdvancedLogging";
|
||||
// resources.ApplyResources(this, "$this");
|
||||
// this.ResumeLayout(false);
|
||||
// this.PerformLayout();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IJobStepPropertiesControl implementation
|
||||
void IJobStepPropertiesControl.Load(JobStepData data)
|
||||
{
|
||||
// this.outputFile.Text = data.OutputFileName;
|
||||
// this.appendToFile.Checked = data.AppendToLogFile;
|
||||
// this.appendOutput.Checked = data.AppendToStepHistory;
|
||||
|
||||
// this.logToTable.Checked = data.WriteLogToTable;
|
||||
// this.logToTable.Enabled = data.CanLogToTable;
|
||||
|
||||
// this.appendToTable.Checked = data.AppendLogToTable;
|
||||
|
||||
this.userIsSysAdmin = (data.Parent.Parent.UserRole & UserRoles.SysAdmin) > 0;
|
||||
this.canViewFileLog = this.userIsSysAdmin && data.Version.Major <= 8;
|
||||
// must be sysadmin to set log in yukon
|
||||
this.canSetFileLog = (data.Version.Major <= 8 || this.userIsSysAdmin);
|
||||
|
||||
if (this.canSetFileLog)
|
||||
{
|
||||
// Managed Instance doesn't allow setting this path.
|
||||
//
|
||||
if (this.dataContainer != null &&
|
||||
this.dataContainer.Server != null &&
|
||||
this.dataContainer.Server.DatabaseEngineEdition == DatabaseEngineEdition.SqlManagedInstance)
|
||||
{
|
||||
this.canSetFileLog = false;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateControlStatus();
|
||||
|
||||
}
|
||||
void IJobStepPropertiesControl.Save(JobStepData data, bool isSwitching)
|
||||
{
|
||||
// if (this.appendToFile.Checked && this.outputFile.Text.Trim().Length == 0)
|
||||
// {
|
||||
// throw new ApplicationException(SRError.MissingOutputLogFileName);
|
||||
// }
|
||||
|
||||
// data.OutputFileName = this.outputFile.Text;
|
||||
// data.AppendToLogFile = this.appendToFile.Checked;
|
||||
// data.AppendToStepHistory = this.appendOutput.Checked;
|
||||
|
||||
// data.WriteLogToTable = this.logToTable.Checked;
|
||||
// if (this.logToTable.Checked)
|
||||
// {
|
||||
// data.AppendLogToTable = this.appendToTable.Checked;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// data.AppendLogToTable = false;
|
||||
// }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region event handlers
|
||||
/// <summary>
|
||||
/// Called when the user clicks on the browse for file button. Will allow the
|
||||
/// user to either enter a new file, or pick an existing one for logging on the server
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void browse_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
// using (BrowseFolder browse = new BrowseFolder(this.dataContainer.Server.ConnectionContext,
|
||||
// this.messageProvider))
|
||||
// {
|
||||
// browse.Font = this.Font;
|
||||
// browse.BrowseForFiles = true;
|
||||
|
||||
// if (browse.ShowDialog() == DialogResult.OK)
|
||||
// {
|
||||
// this.outputFile.Text = browse.SelectedFullFileName;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void outputFile_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateControlStatus();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// User wishes to view the file log
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void viewFileLog_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Cursor originalCursor = Cursor.Current;
|
||||
// try
|
||||
// {
|
||||
// Cursor.Current = Cursors.WaitCursor;
|
||||
// try
|
||||
// {
|
||||
// string tempFileName = String.Empty;
|
||||
// if (CheckFileExistsAndIsValid(this.outputFile.Text))
|
||||
// {
|
||||
// tempFileName = ReadLogToFile(this.outputFile.Text);
|
||||
// }
|
||||
|
||||
// ViewLog(tempFileName);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// messageProvider.ShowMessage(
|
||||
// ex
|
||||
// , SRError.SQLWorkbench
|
||||
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxButtons.OK
|
||||
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxSymbol.Error
|
||||
// , this);
|
||||
// }
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// Cursor.Current = originalCursor;
|
||||
// }
|
||||
}
|
||||
/// <summary>
|
||||
/// user wishes to view the table log
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void logToTable_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateControlStatus();
|
||||
}
|
||||
private void viewTableLog_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Cursor originalCursor = Cursor.Current;
|
||||
// try
|
||||
// {
|
||||
// Cursor.Current = Cursors.WaitCursor;
|
||||
// try
|
||||
// {
|
||||
// JobStep step = this.jobStepData.JobStep;
|
||||
// String tempFileName = String.Empty;
|
||||
|
||||
// if (step != null)
|
||||
// {
|
||||
// tempFileName = ReadStepLogToFile(step);
|
||||
// }
|
||||
// // Note that ViewLog deletes the temp file after showing it.
|
||||
// ViewLog(tempFileName);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// messageProvider.ShowMessage(
|
||||
// ex
|
||||
// , SRError.SQLWorkbench
|
||||
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxButtons.OK
|
||||
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxSymbol.Error
|
||||
// , this);
|
||||
// }
|
||||
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// Cursor.Current = originalCursor;
|
||||
// }
|
||||
}
|
||||
|
||||
private void ViewLog(string tempFileName)
|
||||
{
|
||||
// if (tempFileName == null || tempFileName.Length == 0)
|
||||
// {
|
||||
// messageProvider.ShowMessage(
|
||||
// SRError.LogNotYetCreated
|
||||
// , SRError.SQLWorkbench
|
||||
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxButtons.OK
|
||||
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxSymbol.Information
|
||||
// , this);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// String notepadProcess = String.Format(CultureInfo.InvariantCulture
|
||||
// , "{0}\\notepad.exe"
|
||||
// , System.Environment.SystemDirectory);
|
||||
|
||||
// System.Diagnostics.Process.Start(notepadProcess, tempFileName);
|
||||
// System.Threading.Thread.Sleep(1000);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// System.IO.File.Delete(tempFileName);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region internal helpers
|
||||
/// <summary>
|
||||
@@ -496,11 +175,3 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user