/// <summary> /// Processes the record. /// </summary> /// <exception cref="System.IO.FileNotFoundException">Installer does not exist</exception> protected override void ProcessRecord() { var activityId = ActivityIdProvider.GetNextActivityId(); if (!string.IsNullOrWhiteSpace(OfflineRabbitMqInstallerPath)) { if (PrepareForOfflineInstall) { WriteDebug($"Preparing offline installer path {OfflineRabbitMqInstallerPath}"); if (Force) { WriteVerbose("Forcing download"); } WriteVerbose("Downloading Erlang"); var downloader = new PrerequisiteDownloader(); var downloadUrl = UseThycoticMirror ? InstallationConstants.RabbitMq.ThycoticMirrorDownloadUrl : InstallationConstants.RabbitMq.DownloadUrl; downloader.Download(CancellationToken.None, new Uri(downloadUrl, UriKind.Absolute), OfflineRabbitMqInstallerPath, InstallationConstants.RabbitMq.InstallerChecksum, Force, 5, WriteDebug, WriteVerbose, (s, exception) => throw exception, progress => { WriteProgress(new ProgressRecord(activityId, "RabbitMq download in progress", "Downloading") { PercentComplete = progress.ProgressPercentage, RecordType = progress.ProgressPercentage == 100 ? ProgressRecordType.Completed : ProgressRecordType.Processing }); }); } else { WriteVerbose(string.Format("Using offline installer path {0}", OfflineRabbitMqInstallerPath)); if (!File.Exists(OfflineRabbitMqInstallerPath)) { throw new FileNotFoundException("Installer does not exist"); } if (PrerequisiteDownloader.CalculateSha512(OfflineRabbitMqInstallerPath) != InstallationConstants.RabbitMq.InstallerChecksum) { throw new FileNotFoundException("Installer checksum does not match"); } if (File.Exists(RabbitMqInstallerPath)) { File.Delete(RabbitMqInstallerPath); } File.Copy(OfflineRabbitMqInstallerPath, RabbitMqInstallerPath); } } else { if (Force) { WriteVerbose("Forcing download"); } WriteVerbose("Downloading RabbitMq"); var downloader = new PrerequisiteDownloader(); var downloadUrl = UseThycoticMirror ? InstallationConstants.RabbitMq.ThycoticMirrorDownloadUrl : InstallationConstants.RabbitMq.DownloadUrl; downloader.Download(CancellationToken.None, new Uri(downloadUrl, UriKind.Absolute), RabbitMqInstallerPath, InstallationConstants.RabbitMq.InstallerChecksum, Force, 5, WriteDebug, WriteVerbose, (s, exception) => throw exception, progress => { WriteProgress(new ProgressRecord(activityId, "RabbitMq download in progress", "Downloading") { PercentComplete = progress.ProgressPercentage, RecordType = progress.ProgressPercentage == 100 ? ProgressRecordType.Completed : ProgressRecordType.Processing }); }); } }
/// <summary> /// Processes the record. /// </summary> protected override void ProcessRecord() { var client = new RabbitMqRestClient(BaseUrl, AdminCredential.UserName, AdminCredential.GetNetworkCredential().Password); var queues = client.GetAllQueues().ToArray(); if (!queues.Any()) { WriteVerbose("There are no queues to remove"); return; } var activityid = ActivityIdProvider.GetNextActivityId(); const string activity = "Removing"; WriteProgress(new ProgressRecord(activityid, activity, "Removing all queues") { PercentComplete = 5 }); var orderedQueues = queues.OrderBy(q => q.vhost).ThenBy(q => q.name).ToList(); var c = 0; var total = orderedQueues.Count; var statuses = new List <KeyValuePair <string, string> >(); orderedQueues.ForEach(q => { if (q.auto_delete || q.exclusive) { WriteVerbose($"Skipping {q.name} on {q.vhost}"); c++; return; } WriteProgress(new ProgressRecord(activityid, activity, $"Removing {q.name} on {q.vhost}") { PercentComplete = Convert.ToInt32(Convert.ToDouble(c) / total * 100) }); WriteVerbose($"Removing {q.name} on {q.vhost}"); try { client.DeleteQueue(q.vhost, q.name); statuses.Add(new KeyValuePair <string, string>(q.name, HttpStatusCode.OK.ToString())); } catch (Exception ex) { statuses.Add(new KeyValuePair <string, string>(q.name, ex.Message)); } c++; }); WriteObject(statuses); WriteProgress(new ProgressRecord(activityid, activity, "Removed all queues") { PercentComplete = 100, RecordType = ProgressRecordType.Completed }); }