TaskResult IExecutable.Execute() { var results = new TaskResult(); Warning[] warnings; var name = ReportRdl.FileNameWithoutExtension; var rs = GetWsClient (); try { rs.CreateCatalogItem ("Report", name, DestinationPathOnServer.Path, true, _rdl, null, out warnings); results.Success ("Report '{0}' was created successfully in server temp directory.", name); } catch (SoapException e) { results.Error ("Report '{0}' not created successfully. Error:\n{1}\n", name, e.Detail.InnerXml); return results; } if (warnings != null) { foreach (var warning in warnings) results.Warning (warning.Message); } return results; }
public void WhenAnErrorIsAdded_ContainsError_ShouldBeTrue() { var result = new TaskResult (); result.Error ("my error"); result.ContainsError ().ShouldBe (true); }
TaskResult IPreparable.Prepare() { var result = new TaskResult (); if (File.Exists (Source) == false) { result.Error ("Source file does not exist!"); return result; } var dest = new FileInfo (Destination); if (dest.Exists) { var sourceMd5 = GetMd5 (Source); var destMd5 = GetMd5 (Destination); _exactFileExists = sourceMd5.SequenceEqual (destMd5); } else { _exactFileExists = false; } if (_exactFileExists) return result; DetectAndAppendCopyErrorsToResult (result, dest); return result; }
TaskResult IExecutable.Execute() { var result = new TaskResult(); if (_exactFileExists) { result.Success (Destination + " already exists with matching file contents."); return result; } var destInfo = new FileInfo (Destination); DetectAndAppendCopyErrorsToResult (result, destInfo); if (result.ContainsError()) return result; if (destInfo.Exists && destInfo.IsReadOnly) { destInfo.IsReadOnly = false; File.Copy (Source, Destination, true); destInfo.IsReadOnly = true; } else { File.Copy (Source, Destination, true); } result.Success ("{0} successfully copied to {1}.", Source, Destination); return result; }
TaskResult IPreparable.Prepare() { var result = new TaskResult (); if (File.Exists (SourceZip) == false) result.Error ("Zip file not found: " + SourceZip); return result; }
public void GivenAnErrorResult_ReportError() { var result = new TaskResult (); result.Error ("my error"); var receiver = new TestTaskResultReceiver (); result.SendSubResultsTo (receiver); receiver.AssertResultCount (1); receiver.AssertMessageAndTypeEquals (1, "Error", "my error"); }
public void GivenAnErrorAndSuccess_ReportBoth() { var result = new TaskResult (); result.Success ("my success"); result.Error ("my error"); var receiver = new TestTaskResultReceiver (); result.SendSubResultsTo (receiver); receiver.AssertResultCount (2); receiver.AssertMessageAndTypeEquals (1, "Success", "my success"); receiver.AssertMessageAndTypeEquals (2, "Error", "my error"); }
public void GivenMultipleErrorResults_ReportAllErrors() { var result = new TaskResult (); result.Error ("my error"); result.Error ("my error2"); var receiver = new TestTaskResultReceiver (); result.SendSubResultsTo (receiver); receiver.AssertResultCount (2); receiver.AssertMessageAndTypeEquals (1, "Error", "my error"); receiver.AssertMessageAndTypeEquals (2, "Error", "my error2"); }
private TaskResult CheckConnectivity() { var results = new TaskResult (); try { var rs = GetWsClient(); rs.GetSystemPermissions(); results.Success ("Verified connection to report server at {0}.", ReportServerUrl); } catch (SoapException e) { results.Error ("Unable to connect to report server ({0}).\n" + "Error details:\n{1}", ReportServerUrl, e.Message); } return results; }
TaskResult IExecutable.Execute() { using (var zip = ZipFile.Read(SourceZip)) { switch (OnDestinationExistsAction) { case DestinationExistsAction.Fail: zip.ExtractAll(DestinationDir); break; case DestinationExistsAction.Overwrite: case DestinationExistsAction.OverwriteEvenReadOnly: zip.ExtractAll(DestinationDir, ExtractExistingFileAction.OverwriteSilently); break; default: throw new ArgumentOutOfRangeException(OnDestinationExistsAction.ToString()); } } var result = new TaskResult (); result.Success ("{0} extracted to {1}.", SourceZip, DestinationDir); return result; }
TaskResult IPreparable.Prepare() { var results = new TaskResult(); var rdlPath = ReportRdl.MakeAbsolute(); if (rdlPath.FileInfo.Exists) { try { _rdl = File.ReadAllBytes (rdlPath); } catch (IOException e) { results.Error("Error while loading report file '{0}':\n{1}", ReportRdl, e.Message); } } else { results.Error("Report definition (.rdl) file not found: " + ReportRdl); } return results; }
public void WhenNoErrorsAdded_ContainsError_ShouldBeFalse() { var result = new TaskResult (); result.ContainsError().ShouldBe (false); }
private SqlConnection OpenConnection(TaskResult results) { var builder = new SqlConnectionStringBuilder { DataSource = Server, InitialCatalog = Database, UserID = Username, Password = Password }; var conn = new SqlConnection (builder.ToString ()); try { conn.Open (); results.Success("Successfully opened connection with SQL Server."); } catch (Exception e) { results.Error (e, "Unable to open connection to SQL Server '{0}'" + " database '{1}'", Server, Database); } return conn; }
TaskResult IExecutable.Execute() { var result = new TaskResult(); result.Success("Executing scripts on server '{0}' database '{1}'.", Server, Database); foreach (var scriptFile in _scripts) { try { ExecuteSql(scriptFile.Script); result.Success("\tExecuted script: {0}", scriptFile.Filename); } catch(Exception e) { var exception = e.InnerException ?? e; result.Error("Error executing script: {0}:\n{1}", scriptFile.Filename, exception.Message); } } return result; }
public void CanAddError() { var result = new TaskResult(); result.Error ("my error"); }
private void DetectAndAppendCopyErrorsToResult(TaskResult result, FileInfo destInfo) { switch (OnDestinationExistsWithDiffContent) { case DestinationExistsAction.Fail: if (destInfo.Exists) result.Error (Destination + " already exists!"); break; case DestinationExistsAction.Overwrite: if (destInfo.Exists && destInfo.IsReadOnly) result.Error("{0} exists and is readonly.", Destination); break; case DestinationExistsAction.OverwriteEvenReadOnly: break; default: result.Error ("Unexpected destination action: " + OnDestinationExistsWithDiffContent); break; } }
TaskResult IPreparable.Prepare() { var results = new TaskResult (); if (_foundSmoAssembly == false) { results.Error ("!!!! IF SQL SERVER NOT INSTALLED, INSTALL SQL SERVER SMO REDISTRIBUTABLE !!!!"); } foreach (var path in ScriptFiles) { try { // obviously not the most memory efficient - consider deferring var script = File.ReadAllText (path, Encoding.Default); _scripts.Enqueue(new ScriptFile { Filename = path, Script = script }); } catch(Exception e) { results.Error(e, "Error reading file: {0}", path); } } _conn = OpenConnection (results); return results; }