Example #1
0
        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 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;
        }
Example #3
0
        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");
        }
 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 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;
 }
        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;
        }