diff --git a/PSAsigraDSClient/GetDSClientBackupSet.cs b/PSAsigraDSClient/GetDSClientBackupSet.cs index eabed5e..f665e68 100644 --- a/PSAsigraDSClient/GetDSClientBackupSet.cs +++ b/PSAsigraDSClient/GetDSClientBackupSet.cs @@ -14,13 +14,29 @@ sealed public class GetDSClientBackupSet: BaseDSClientBackupSet protected override void DSClientProcessRecord() { - WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); - BackupSet backupSet = DSClientSession.backup_set(BackupSetId); + BackupSet backupSet = null; + try + { + WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); + backupSet = DSClientSession.backup_set(BackupSetId); + } + catch (APIException e) + { + ErrorRecord errorRecord = new ErrorRecord( + e, + "APIException", + ErrorCategory.ObjectNotFound, + null); + WriteError(errorRecord); + } - WriteDebug("Parsing Backup Set details."); - DSClientBackupSet dSClientBackupSet = new DSClientBackupSet(backupSet, DSClientSessionInfo.OperatingSystem); + if (backupSet != null) + { + WriteDebug("Parsing Backup Set details."); + DSClientBackupSet dSClientBackupSet = new DSClientBackupSet(backupSet, DSClientSessionInfo.OperatingSystem); - WriteObject(dSClientBackupSet); + WriteObject(dSClientBackupSet); + } } } } \ No newline at end of file diff --git a/PSAsigraDSClient/GetDSClientBackupSetItem.cs b/PSAsigraDSClient/GetDSClientBackupSetItem.cs index c2ba88a..d68924f 100644 --- a/PSAsigraDSClient/GetDSClientBackupSetItem.cs +++ b/PSAsigraDSClient/GetDSClientBackupSetItem.cs @@ -14,24 +14,41 @@ sealed public class GetDSClientBackupSetItem: BaseDSClientBackupSet protected override void DSClientProcessRecord() { - // Get the specified Backup Set - WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); - BackupSet backupSet = DSClientSession.backup_set(BackupSetId); - - // Get the Data Type this Backup Set contains - EBackupDataType backupDataType = backupSet.getDataType(); - - // Get the Backup Set Items specified in the Backup Set - BackupSetItem[] backupSetItems = backupSet.items(); - - List dSClientBackupSetItems = new List(); + BackupSet backupSet = null; - foreach (BackupSetItem item in backupSetItems) - dSClientBackupSetItems.Add(new DSClientBackupSetItem(item, backupDataType, DSClientSessionInfo.OperatingSystem)); - - dSClientBackupSetItems.ForEach(WriteObject); - - backupSet.Dispose(); + // Get the specified Backup Set + try + { + WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); + backupSet = DSClientSession.backup_set(BackupSetId); + } + catch (APIException e) + { + ErrorRecord errorRecord = new ErrorRecord( + e, + "APIException", + ErrorCategory.ObjectNotFound, + null); + WriteError(errorRecord); + } + + if (backupSet != null) + { + // Get the Data Type this Backup Set contains + EBackupDataType backupDataType = backupSet.getDataType(); + + // Get the Backup Set Items specified in the Backup Set + BackupSetItem[] backupSetItems = backupSet.items(); + + List dSClientBackupSetItems = new List(); + + foreach (BackupSetItem item in backupSetItems) + dSClientBackupSetItems.Add(new DSClientBackupSetItem(item, backupDataType, DSClientSessionInfo.OperatingSystem)); + + dSClientBackupSetItems.ForEach(WriteObject); + + backupSet.Dispose(); + } } } } \ No newline at end of file diff --git a/PSAsigraDSClient/GetDSClientBackupSetLockStatus.cs b/PSAsigraDSClient/GetDSClientBackupSetLockStatus.cs index 0a7b6b0..f52c555 100644 --- a/PSAsigraDSClient/GetDSClientBackupSetLockStatus.cs +++ b/PSAsigraDSClient/GetDSClientBackupSetLockStatus.cs @@ -18,17 +18,35 @@ sealed public class GetDSClientBackupSetLockStatus : DSClientCmdlet protected override void DSClientProcessRecord() { + BackupSet backupSet = null; + // Retrieve the Backup Set - BackupSet backupSet = DSClientSession.backup_set(BackupSetId); + try + { + WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); + backupSet = DSClientSession.backup_set(BackupSetId); + } + catch (APIException e) + { + ErrorRecord errorRecord = new ErrorRecord( + e, + "APIException", + ErrorCategory.ObjectNotFound, + null); + WriteError(errorRecord); + } - // Activity Type - EActivityType activityType = StringToEnum(ActivityType); + if (backupSet != null) + { + // Activity Type + EActivityType activityType = StringToEnum(ActivityType); - EBackupSetLockStatus setLockStatus = backupSet.check_lock_status(activityType); + EBackupSetLockStatus setLockStatus = backupSet.check_lock_status(activityType); - backupSet.Dispose(); + backupSet.Dispose(); - WriteObject(new BackupSetLockStatus(setLockStatus)); + WriteObject(new BackupSetLockStatus(setLockStatus)); + } } private class BackupSetLockStatus diff --git a/PSAsigraDSClient/GetDSClientBackupSetNotification.cs b/PSAsigraDSClient/GetDSClientBackupSetNotification.cs index 79cf593..fb67dc0 100644 --- a/PSAsigraDSClient/GetDSClientBackupSetNotification.cs +++ b/PSAsigraDSClient/GetDSClientBackupSetNotification.cs @@ -15,23 +15,41 @@ sealed public class GetDSClientBackupSetNotification : DSClientCmdlet protected override void DSClientProcessRecord() { - WriteVerbose("Performing Action: Retrieve Backup Set"); - BackupSet backupSet = DSClientSession.backup_set(BackupSetId); - - BackupSetNotification backupSetNotification = backupSet.getNotification(); - - WriteVerbose("Performing Action: Retrieve Backup Set Notification Configuration"); - notification_info[] notifications = backupSetNotification.listNotification(); - - backupSetNotification.Dispose(); - backupSet.Dispose(); - - List backupSetNotifications = new List(); - - foreach (notification_info notification in notifications) - backupSetNotifications.Add(new DSClientBackupSetNotification(notification)); - - backupSetNotifications.ForEach(WriteObject); + BackupSet backupSet = null; + + // Retrieve the Backup Set + try + { + WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); + backupSet = DSClientSession.backup_set(BackupSetId); + } + catch (APIException e) + { + ErrorRecord errorRecord = new ErrorRecord( + e, + "APIException", + ErrorCategory.ObjectNotFound, + null); + WriteError(errorRecord); + } + + if (backupSet != null) + { + BackupSetNotification backupSetNotification = backupSet.getNotification(); + + WriteVerbose("Performing Action: Retrieve Backup Set Notification Configuration"); + notification_info[] notifications = backupSetNotification.listNotification(); + + backupSetNotification.Dispose(); + backupSet.Dispose(); + + List backupSetNotifications = new List(); + + foreach (notification_info notification in notifications) + backupSetNotifications.Add(new DSClientBackupSetNotification(notification)); + + backupSetNotifications.ForEach(WriteObject); + } } } } \ No newline at end of file diff --git a/PSAsigraDSClient/GetDSClientBackupSetSessions.cs b/PSAsigraDSClient/GetDSClientBackupSetSessions.cs index ddde932..8eaddb9 100644 --- a/PSAsigraDSClient/GetDSClientBackupSetSessions.cs +++ b/PSAsigraDSClient/GetDSClientBackupSetSessions.cs @@ -16,23 +16,41 @@ sealed public class GetDSClientBackupSetSessions: DSClientCmdlet protected override void DSClientProcessRecord() { - List BackupSessions = new List(); + BackupSet backupSet = null; - WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); - BackupSet backupSet = DSClientSession.backup_set(BackupSetId); - - WriteVerbose("Performing Action: Retrieve Backup Set Sessions"); - backup_sessions[] backupSessions = backupSet.backup_times(); - - foreach (backup_sessions session in backupSessions) + // Retrieve the Backup Set + try { - DSClientBackupSessions backupSession = new DSClientBackupSessions(BackupSetId, session); - BackupSessions.Add(backupSession); + WriteVerbose($"Performing Action: Retrieve Backup Set with BackupSetId: {BackupSetId}"); + backupSet = DSClientSession.backup_set(BackupSetId); + } + catch (APIException e) + { + ErrorRecord errorRecord = new ErrorRecord( + e, + "APIException", + ErrorCategory.ObjectNotFound, + null); + WriteError(errorRecord); } - BackupSessions.ForEach(WriteObject); + if (backupSet != null) + { + List BackupSessions = new List(); - backupSet.Dispose(); + WriteVerbose("Performing Action: Retrieve Backup Set Sessions"); + backup_sessions[] backupSessions = backupSet.backup_times(); + + foreach (backup_sessions session in backupSessions) + { + DSClientBackupSessions backupSession = new DSClientBackupSessions(BackupSetId, session); + BackupSessions.Add(backupSession); + } + + BackupSessions.ForEach(WriteObject); + + backupSet.Dispose(); + } } private class DSClientBackupSessions diff --git a/PSAsigraDSClient/GetDSClientRetentionRule.cs b/PSAsigraDSClient/GetDSClientRetentionRule.cs index 18fa7ed..9f803be 100644 --- a/PSAsigraDSClient/GetDSClientRetentionRule.cs +++ b/PSAsigraDSClient/GetDSClientRetentionRule.cs @@ -27,9 +27,21 @@ protected override void ProcessRetentionRule(RetentionRule[] dSClientRetentionRu { if (RetentionRuleId > 0) { - RetentionRule retentionRule = dSClientRetentionRules.Single(rule => rule.getID() == RetentionRuleId); - DSClientRetentionRule dSClientRetentionRule = new DSClientRetentionRule(retentionRule); - DSClientRetentionRules.Add(dSClientRetentionRule); + try + { + RetentionRule retentionRule = dSClientRetentionRules.Single(rule => rule.getID() == RetentionRuleId); + DSClientRetentionRule dSClientRetentionRule = new DSClientRetentionRule(retentionRule); + DSClientRetentionRules.Add(dSClientRetentionRule); + } + catch + { + ErrorRecord errorRecord = new ErrorRecord( + new Exception("Retention Rule not found"), + "Exception", + ErrorCategory.ObjectNotFound, + null); + WriteError(errorRecord); + } } if (Name != null) diff --git a/PSAsigraDSClient/GetDSClientScheduleDetail.cs b/PSAsigraDSClient/GetDSClientScheduleDetail.cs index 74b56bb..280ef06 100644 --- a/PSAsigraDSClient/GetDSClientScheduleDetail.cs +++ b/PSAsigraDSClient/GetDSClientScheduleDetail.cs @@ -22,91 +22,106 @@ sealed public class GetDSClientScheduleDetail: BaseDSClientSchedule protected override void DSClientProcessRecord() { ScheduleManager DSClientScheduleMgr = DSClientSession.getScheduleManager(); + Schedule schedule = null; - WriteVerbose($"Performing Action: Retrieve Schedule with ScheduleId: {ScheduleId}"); - Schedule Schedule = DSClientScheduleMgr.definedSchedule(ScheduleId); - - WriteVerbose($"Performing Action: Retrieve Schedule Info for ScheduleId: {ScheduleId}"); - schedule_info scheduleInfo = DSClientScheduleMgr.definedScheduleInfo(ScheduleId); - - WriteVerbose($"Performing Action: Retrieve Schedule Details for ScheduleId: {ScheduleId}"); - ScheduleDetail[] ScheduleDetails = Schedule.getDetails(); - int detailCount = ScheduleDetails.Count(); - WriteVerbose($"Notice: Yielded {detailCount} Schedule Details"); + try + { + WriteVerbose($"Performing Action: Retrieve Schedule with ScheduleId: {ScheduleId}"); + schedule = DSClientScheduleMgr.definedSchedule(ScheduleId); + } + catch (APIException e) + { + ErrorRecord errorRecord = new ErrorRecord( + e, + "APIException", + ErrorCategory.ObjectNotFound, + null); + } - List DSClientScheduleDetail = new List(); + if (schedule != null) + { + WriteVerbose($"Performing Action: Retrieve Schedule Info for ScheduleId: {ScheduleId}"); + schedule_info scheduleInfo = DSClientScheduleMgr.definedScheduleInfo(ScheduleId); - // Get Hash Codes for Previously Identified Schedule Details - Dictionary detailHashes = DSClientSessionInfo.GetScheduleOrRetentionDictionary(true); - if (detailHashes == null) - detailHashes = new Dictionary(); + WriteVerbose($"Performing Action: Retrieve Schedule Details for ScheduleId: {ScheduleId}"); + ScheduleDetail[] ScheduleDetails = schedule.getDetails(); + int detailCount = ScheduleDetails.Count(); + WriteVerbose($"Notice: Yielded {detailCount} Schedule Details"); - int startingId = 1; - Dictionary unidentified = new Dictionary(); + List DSClientScheduleDetail = new List(); - int detailCounter = 0; - int hashCounter = 0; - WriteVerbose("Performing Action: Process Schedule Details"); - ProgressRecord progressRecord = new ProgressRecord(1, "Process Schedule Details", $"0 of {detailCount} processed, 0%") - { - RecordType = ProgressRecordType.Processing, - CurrentOperation = "Processing Schedule Detail" - }; - foreach (ScheduleDetail detail in ScheduleDetails) - { - progressRecord.PercentComplete = (int)Math.Round((double)(((double)detailCounter + (double)hashCounter) / ((double)detailCount * 2)) * 100); - progressRecord.StatusDescription = $"{detailCounter} of {detailCount} processed, {progressRecord.PercentComplete}%"; - WriteProgress(progressRecord); + // Get Hash Codes for Previously Identified Schedule Details + Dictionary detailHashes = DSClientSessionInfo.GetScheduleOrRetentionDictionary(true); + if (detailHashes == null) + detailHashes = new Dictionary(); - string detailHash = ScheduleDetailHash(Schedule, detail); - hashCounter++; - WriteDebug($"Computed Hash: {detailHash}"); - progressRecord.PercentComplete = (int)Math.Round((double)(((double)detailCounter + (double)hashCounter) / ((double)detailCount * 2)) * 100); - progressRecord.StatusDescription = $"{detailCounter} of {detailCount} processed, {progressRecord.PercentComplete}%"; - WriteProgress(progressRecord); + int startingId = 1; + Dictionary unidentified = new Dictionary(); - // Check if the Hash is already in the Dictionary and if so fetch the associated Id - detailHashes.TryGetValue(detailHash, out int id); - if (id > 0) + int detailCounter = 0; + int hashCounter = 0; + WriteVerbose("Performing Action: Process Schedule Details"); + ProgressRecord progressRecord = new ProgressRecord(1, "Process Schedule Details", $"0 of {detailCount} processed, 0%") { - WriteDebug("Hash found in SessionState"); - if (id >= startingId) - startingId = id + 1; - DSClientScheduleDetail.Add(new DSClientScheduleDetail(id, scheduleInfo, detail)); - detail.Dispose(); - detailCounter++; + RecordType = ProgressRecordType.Processing, + CurrentOperation = "Processing Schedule Detail" + }; + foreach (ScheduleDetail detail in ScheduleDetails) + { + progressRecord.PercentComplete = (int)Math.Round((double)(((double)detailCounter + (double)hashCounter) / ((double)detailCount * 2)) * 100); + progressRecord.StatusDescription = $"{detailCounter} of {detailCount} processed, {progressRecord.PercentComplete}%"; + WriteProgress(progressRecord); + + string detailHash = ScheduleDetailHash(schedule, detail); + hashCounter++; + WriteDebug($"Computed Hash: {detailHash}"); + progressRecord.PercentComplete = (int)Math.Round((double)(((double)detailCounter + (double)hashCounter) / ((double)detailCount * 2)) * 100); + progressRecord.StatusDescription = $"{detailCounter} of {detailCount} processed, {progressRecord.PercentComplete}%"; + WriteProgress(progressRecord); + + // Check if the Hash is already in the Dictionary and if so fetch the associated Id + detailHashes.TryGetValue(detailHash, out int id); + if (id > 0) + { + WriteDebug("Hash found in SessionState"); + if (id >= startingId) + startingId = id + 1; + DSClientScheduleDetail.Add(new DSClientScheduleDetail(id, scheduleInfo, detail)); + detail.Dispose(); + detailCounter++; + } + else + { + WriteDebug("Hash not found in SessionState"); + unidentified.Add(detailHash, detail); + } } - else + + // Process all the Schedule Details that were not already in the Dictionary, and add them + foreach (KeyValuePair hash in unidentified) { - WriteDebug("Hash not found in SessionState"); - unidentified.Add(detailHash, detail); + progressRecord.PercentComplete = (int)Math.Round((double)(((double)detailCounter + hashCounter) / ((double)detailCount * 2)) * 100); + progressRecord.StatusDescription = $"{detailCounter} of {detailCount} processed, {progressRecord.PercentComplete}%"; + WriteProgress(progressRecord); + + DSClientScheduleDetail.Add(new DSClientScheduleDetail(startingId, scheduleInfo, hash.Value)); + hash.Value.Dispose(); + detailHashes.Add(hash.Key, startingId); + startingId++; + detailCounter++; } - } - // Process all the Schedule Details that were not already in the Dictionary, and add them - foreach (KeyValuePair hash in unidentified) - { + progressRecord.RecordType = ProgressRecordType.Completed; progressRecord.PercentComplete = (int)Math.Round((double)(((double)detailCounter + hashCounter) / ((double)detailCount * 2)) * 100); - progressRecord.StatusDescription = $"{detailCounter} of {detailCount} processed, {progressRecord.PercentComplete}%"; WriteProgress(progressRecord); - DSClientScheduleDetail.Add(new DSClientScheduleDetail(startingId, scheduleInfo, hash.Value)); - hash.Value.Dispose(); - detailHashes.Add(hash.Key, startingId); - startingId++; - detailCounter++; - } - - progressRecord.RecordType = ProgressRecordType.Completed; - progressRecord.PercentComplete = (int)Math.Round((double)(((double)detailCounter + hashCounter) / ((double)detailCount * 2)) * 100); - WriteProgress(progressRecord); + DSClientSessionInfo.SetScheduleOrRetentionDictonary(detailHashes, true); - DSClientSessionInfo.SetScheduleOrRetentionDictonary(detailHashes, true); + DSClientScheduleDetail.ForEach(WriteObject); - DSClientScheduleDetail.ForEach(WriteObject); - - Schedule.Dispose(); - DSClientScheduleMgr.Dispose(); + schedule.Dispose(); + DSClientScheduleMgr.Dispose(); + } } } } \ No newline at end of file diff --git a/PSAsigraDSClient/GetDSClientTimeRetentionOption.cs b/PSAsigraDSClient/GetDSClientTimeRetentionOption.cs index e831d27..f28fe2e 100644 --- a/PSAsigraDSClient/GetDSClientTimeRetentionOption.cs +++ b/PSAsigraDSClient/GetDSClientTimeRetentionOption.cs @@ -17,86 +17,98 @@ sealed public class GetDSClientTimeRetentionOption : BaseDSClientRetentionRule protected override void ProcessRetentionRule(RetentionRule[] retentionRules) { // Select the required Retention Rule - RetentionRule retentionRule = retentionRules.Single(rule => rule.getID() == RetentionRuleId); + RetentionRule retentionRule = retentionRules.SingleOrDefault(rule => rule.getID() == RetentionRuleId); - // Get all the Time Retention Options - WriteVerbose("Performing Action: Retrieve Time Retention Options"); - TimeRetentionOption[] timeRetentionOptions = retentionRule.getTimeRetentions(); - int optionCount = timeRetentionOptions.Count(); - - List timeRetentions = new List(); - - // Get Hash Codes for Previously Identified Time Retention Options from SessionState, or start a new Dictionary if none exists - Dictionary retentionHashes = DSClientSessionInfo.GetScheduleOrRetentionDictionary(false); - if (retentionHashes == null) - retentionHashes = new Dictionary(); + if (retentionRule == null) + { + ErrorRecord errorRecord = new ErrorRecord( + new Exception("Specified Retention Rule not found"), + "Exception", + ErrorCategory.ObjectNotFound, + null); + WriteError(errorRecord); + } + else + { + // Get all the Time Retention Options + WriteVerbose("Performing Action: Retrieve Time Retention Options"); + TimeRetentionOption[] timeRetentionOptions = retentionRule.getTimeRetentions(); + int optionCount = timeRetentionOptions.Count(); - int startingId = 1; - Dictionary unidentified = new Dictionary(); + List timeRetentions = new List(); - int optionCounter = 0; - int hashCounter = 0; + // Get Hash Codes for Previously Identified Time Retention Options from SessionState, or start a new Dictionary if none exists + Dictionary retentionHashes = DSClientSessionInfo.GetScheduleOrRetentionDictionary(false); + if (retentionHashes == null) + retentionHashes = new Dictionary(); - WriteVerbose("Performing Action: Process Time Retention Options"); - ProgressRecord progressRecord = new ProgressRecord(1, "Process Time Retention Options", $"0 of {optionCount} processed, 0%") - { - RecordType = ProgressRecordType.Processing, - CurrentOperation = "Processing Time Retention Option" - }; - foreach (TimeRetentionOption timeRetention in timeRetentionOptions) - { - progressRecord.PercentComplete = (int)Math.Round((double)(((double)optionCounter + (double)hashCounter) / ((double)optionCount * 2)) * 100); - progressRecord.StatusDescription = $"{optionCounter} of {optionCount} processed, {progressRecord.PercentComplete}%"; - WriteProgress(progressRecord); + int startingId = 1; + Dictionary unidentified = new Dictionary(); - string optionHash = TimeRetentionHash(retentionRule, timeRetention); - WriteDebug($"Computed Hash: {optionHash}"); - hashCounter++; - progressRecord.PercentComplete = (int)Math.Round((double)(((double)optionCounter + (double)hashCounter) / ((double)optionCount * 2)) * 100); - progressRecord.StatusDescription = $"{optionCounter} of {optionCount} processed, {progressRecord.PercentComplete}%"; - WriteProgress(progressRecord); + int optionCounter = 0; + int hashCounter = 0; - // Check if the Hash is already in the Dictionary and if so fetch the associated Id - retentionHashes.TryGetValue(optionHash, out int id); - if (id > 0) + WriteVerbose("Performing Action: Process Time Retention Options"); + ProgressRecord progressRecord = new ProgressRecord(1, "Process Time Retention Options", $"0 of {optionCount} processed, 0%") { - WriteDebug("Hash found in SessionState"); - if (id >= startingId) - startingId = id + 1; - timeRetentions.Add(new TimeRetentionOverview(id, timeRetention)); - timeRetention.Dispose(); - optionCounter++; + RecordType = ProgressRecordType.Processing, + CurrentOperation = "Processing Time Retention Option" + }; + foreach (TimeRetentionOption timeRetention in timeRetentionOptions) + { + progressRecord.PercentComplete = (int)Math.Round((double)(((double)optionCounter + (double)hashCounter) / ((double)optionCount * 2)) * 100); + progressRecord.StatusDescription = $"{optionCounter} of {optionCount} processed, {progressRecord.PercentComplete}%"; + WriteProgress(progressRecord); + + string optionHash = TimeRetentionHash(retentionRule, timeRetention); + WriteDebug($"Computed Hash: {optionHash}"); + hashCounter++; + progressRecord.PercentComplete = (int)Math.Round((double)(((double)optionCounter + (double)hashCounter) / ((double)optionCount * 2)) * 100); + progressRecord.StatusDescription = $"{optionCounter} of {optionCount} processed, {progressRecord.PercentComplete}%"; + WriteProgress(progressRecord); + + // Check if the Hash is already in the Dictionary and if so fetch the associated Id + retentionHashes.TryGetValue(optionHash, out int id); + if (id > 0) + { + WriteDebug("Hash found in SessionState"); + if (id >= startingId) + startingId = id + 1; + timeRetentions.Add(new TimeRetentionOverview(id, timeRetention)); + timeRetention.Dispose(); + optionCounter++; + } + else + { + WriteDebug("Hash not found in SessionState"); + unidentified.Add(optionHash, timeRetention); + } } - else + + // Process all the Time Retention Options that were not already in the Dictionary, and add them + foreach (KeyValuePair hash in unidentified) { - WriteDebug("Hash not found in SessionState"); - unidentified.Add(optionHash, timeRetention); + progressRecord.PercentComplete = (int)Math.Round((double)(((double)optionCounter + (double)hashCounter) / ((double)optionCount * 2)) * 100); + progressRecord.StatusDescription = $"{optionCounter} of {optionCount} processed, {progressRecord.PercentComplete}%"; + WriteProgress(progressRecord); + + timeRetentions.Add(new TimeRetentionOverview(startingId, hash.Value)); + hash.Value.Dispose(); + retentionHashes.Add(hash.Key, startingId); + startingId++; + optionCounter++; } - } - // Process all the Time Retention Options that were not already in the Dictionary, and add them - foreach (KeyValuePair hash in unidentified) - { + progressRecord.RecordType = ProgressRecordType.Completed; progressRecord.PercentComplete = (int)Math.Round((double)(((double)optionCounter + (double)hashCounter) / ((double)optionCount * 2)) * 100); - progressRecord.StatusDescription = $"{optionCounter} of {optionCount} processed, {progressRecord.PercentComplete}%"; WriteProgress(progressRecord); - timeRetentions.Add(new TimeRetentionOverview(startingId, hash.Value)); - hash.Value.Dispose(); - retentionHashes.Add(hash.Key, startingId); - startingId++; - optionCounter++; - } + DSClientSessionInfo.SetScheduleOrRetentionDictonary(retentionHashes, false); - progressRecord.RecordType = ProgressRecordType.Completed; - progressRecord.PercentComplete = (int)Math.Round((double)(((double)optionCounter + (double)hashCounter) / ((double)optionCount * 2)) * 100); - WriteProgress(progressRecord); + retentionRule.Dispose(); - DSClientSessionInfo.SetScheduleOrRetentionDictonary(retentionHashes, false); - - retentionRule.Dispose(); - - timeRetentions.ForEach(WriteObject); + timeRetentions.ForEach(WriteObject); + } } } } \ No newline at end of file