/// <summary> /// Creates snapshots for known Reports /// </summary> public void CreateReportSnapshotsForKnownReports() { int retrycount = 3; bool retry = false; RSWarning[] warns = null; string historyId = string.Empty; foreach (string report in ExistingReports) { retry = false; retrycount = 0; // Either first time comming through or retry effort while ((retrycount == 0) || (retry == true)) { try { warns = null; historyId = string.Empty; historyId = SoapAccessor.Management.CreateItemHistorySnapshot(report, out warns); // Add or update the history id to the report key ReportSnapshots.AddOrUpdate(report, historyId, (key, oldValue) => historyId); retry = false; } catch (Exception ex) { Logging.Log("Retrying CreateReportSnapshotsForKnownReports : " + ex.Message); retry = true; // cause to loop back - should use retry with function } retrycount++; if (retrycount > 10) { retry = false; // breaks the loop } } } }
/// <summary> /// Get SnaphshotID (aka HistoryID) for a given report. If it does not exist, create one, then add to list /// NOTE: sometime this may have expiration time so will need management of that. /// </summary> /// <param name="report">Existing Report Path</param> /// <returns>Snapshot ID (History ID)</returns> public string GetSnapshotIDFromCache(string report) { string historyIdForReport = null; historyIdForReport = ReportSnapshots.GetOrAdd( report, (historyID) => { if (HasReportSnapshot(report)) { return(GetReportSnapshotId(report)); } else { return(CreateReportSnapshot(report)); } }); return(historyIdForReport); }