public static async Task <AgentNotebookInfo> CreateNotebook( AgentService agentServiceInstance, string ownerUri, AgentNotebookInfo notebook, string templatePath, RunType runType) { if (!File.Exists(templatePath)) { throw new FileNotFoundException(); } AgentNotebookInfo result; ConnectionInfo connInfo; agentServiceInstance.ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo); // creating notebook job step notebook.JobSteps = CreateNotebookPowerShellStep(notebook.Name, notebook.TargetDatabase); // creating sql agent job var jobCreationResult = await agentServiceInstance.ConfigureAgentJob( ownerUri, notebook.Name, notebook, ConfigAction.Create, runType); if (jobCreationResult.Item1 == false) { throw new Exception(jobCreationResult.Item2); } // creating notebook metadata for the job string jobId = await SetUpNotebookAndGetJobId( connInfo, notebook.Name, notebook.TargetDatabase, templatePath, notebook.ExecuteDatabase); notebook.JobId = jobId; result = notebook; return(result); }
internal static async Task UpdateNotebook( AgentService agentServiceInstance, string ownerUri, string originalNotebookName, AgentNotebookInfo notebook, string templatePath, RunType runType) { ConnectionInfo connInfo; agentServiceInstance.ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo); if (!string.IsNullOrEmpty(templatePath) && !File.Exists(templatePath)) { throw new FileNotFoundException(); } // updating notebook agent job var updateJobResult = await agentServiceInstance.ConfigureAgentJob( ownerUri, originalNotebookName, notebook, ConfigAction.Update, runType); if (!updateJobResult.Item1) { throw new Exception(updateJobResult.Item2); } // update notebook metadata UpdateNotebookInfo( connInfo, notebook.JobId, templatePath, notebook.ExecuteDatabase, notebook.TargetDatabase); }