public static string GetParentPath(ReportServerItem item) { if (item == null) throw new ArgumentNullException("item"); if (string.IsNullOrEmpty(item.Path)) throw new ArgumentException("item.Path"); if (string.IsNullOrEmpty(item.Name)) throw new ArgumentException("item.Name"); string path = item.Path; string name = item.Name; string parentPath = null; if (path == "/") parentPath = path; else { parentPath = path.Replace(name, ""); if (parentPath.EndsWith("/")) { parentPath = parentPath.Substring(0, parentPath.Length - 1); if (parentPath.EndsWith("/")) parentPath = parentPath.Substring(0, parentPath.Length - 1); } } if (!parentPath.StartsWith("/")) parentPath = "/" + parentPath; return parentPath; }
// Reporters private void ReportsReader_Reporter(ReportServerItem item) { if (item == null) { this.mLogger.Warn("ReportsReader_Reporter - item contains a NULL value."); return; } ListViewItem oItem = new ListViewItem(item.Name); oItem.Checked = true; oItem.Tag = item.Path; oItem.SubItems.Add(item.Path); // Assign to proper ListViewGroup if (item.GetType() == typeof(FolderItem)) oItem.Group = this.lstSrcReports.Groups["foldersGroup"]; else if (item.GetType() == typeof(DataSourceItem)) oItem.Group = this.lstSrcReports.Groups["dataSourcesGroup"]; else if (item.GetType() == typeof(ReportItem)) oItem.Group = this.lstSrcReports.Groups["reportsGroup"]; this.lstSrcReports.Invoke(new Action(() => this.lstSrcReports.Items.Add(oItem))); this.lstSrcReports.Invoke(new Action(() => oItem.EnsureVisible())); this.lblStatus.Text = string.Format("Refreshing item '{0}'...", item.Path); this.mLogger.Debug("Refreshing item '{0}' on server '{1}'...", item.Path, this.mSourceServerUrl); this.mDebugForm.LogMessage(string.Format("Refreshing item '{0}' on server '{1}'...", item.Path, this.mSourceServerUrl)); }
/// <summary> /// Adds an item to the ListView for a successfully 'imported' entry. /// </summary> /// <param name="e">The ItemReadEvent object for the entry imported.</param> /// <param name="status">The ImportStatus object for the entry imported.</param> /// <param name="item">The ReportServerItem object that was imported.</param> /// <returns></returns> private ListViewItem AddListViewItem_Success(ItemReadEvent e, ImportStatus status, ReportServerItem item) { ListViewItem oItem = new ListViewItem(item.Name); oItem.Tag = item; oItem.SubItems.Add(item.Path); oItem.SubItems.Add(""); oItem.Checked = true; return oItem; }
public void GetParentPath_PathMissingFirstSlash() { ReportServerItem item = new ReportServerItem() { Name = "Sub Folder", Path = "SSRSMigrate/Reports/Sub Folder" }; string expected = "/SSRSMigrate/Reports"; string actual = SSRSUtil.GetParentPath(item); Assert.AreEqual(expected, actual); }
public void GetParentPath_PathIsSlash() { ReportServerItem item = new ReportServerItem() { Name = "Sub Folder", Path = "/" }; string expected = "/"; string actual = SSRSUtil.GetParentPath(item); Assert.AreEqual(expected, actual); }
public void GetParentPath_ParentContainsName() { ReportServerItem item = new ReportServerItem() { Name = "Reports", Path = "/SSRSMigrate/Reports/Reports" }; string expected = "/SSRSMigrate/Reports"; string actual = SSRSUtil.GetParentPath(item); Assert.AreEqual(expected, actual); }
public void GetParentPath_NullPath() { ReportServerItem item = new ReportServerItem() { Name = "Sub Folder", Path = null }; ArgumentException ex = Assert.Throws<ArgumentException>( delegate { SSRSUtil.GetParentPath(item); }); Assert.That(ex.Message, Is.EqualTo("item.Path")); }
public void GetParentPath_NullName() { ReportServerItem item = new ReportServerItem() { Name = null, Path = "/SSRSMigrate/Reports/Sub Folder" }; ArgumentException ex = Assert.Throws<ArgumentException>( delegate { SSRSUtil.GetParentPath(item); }); Assert.That(ex.Message, Is.EqualTo("item.Name")); }
public string DeleteItem(ReportServerItem item) { throw new NotImplementedException(); }