private void DeleteItems() { // Only execute method if there are selected items if (explorerListView.SelectedItems.Count > 0) { DialogResult answer = MessageBox.Show(string.Format(CultureInfo.InvariantCulture, Properties.Resources.DeleteItem), string.Format(CultureInfo.InvariantCulture, Properties.Resources.ConfirmDelete), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (answer == DialogResult.Yes) { ArrayList selectedItems = new ArrayList(); Cursor.Current = Cursors.WaitCursor; // Create ArrayList to pass to DeleteItems foreach (ListViewItem item in explorerListView.SelectedItems) { selectedItems.Add(item.Text); } // Call DeleteItems try { string itemPath; // Create batch header rs2005.BatchHeader singleBatchHeader = new rs2005.BatchHeader(); // Set EditItem batch id and top BatchHeaderValue singleBatchHeader.BatchID = rs.CreateBatch(); rs.BatchHeaderValue = singleBatchHeader; // Call DeleteItem methods foreach (string item in selectedItems) { itemPath = GetCleanPath(this.Path, item); rs.DeleteItem(itemPath); } // Execute DeleteItem methods in a batch rs.ExecuteBatch(); rs.BatchHeaderValue = null; } catch (Exception e) { HandleGeneralException(e); } finally { Cursor.Current = Cursors.Default; } // Restore UI DisplayItems(Path); } } }
public NLinkedReport UpdatedLinkedReport(string oldLinkedReportPath, string linkedReportName, string folderPath, string reportPath) { #region Validate Parameters if (string.IsNullOrEmpty(linkedReportName)) { throw new ArgumentNullException("linkedReportName"); } else if (string.IsNullOrEmpty(folderPath)) { throw new ArgumentNullException("folderPath"); } else if (string.IsNullOrEmpty(reportPath)) { throw new ArgumentNullException("reportPath"); } #endregion ValidateParameters if (!_authenticatedUserManager.CheckUserPermission(PermissionConstants.PermissionName.CreateLinkedReports)) { throw new AccessDeniedException("Unable to create linked report."); } // Create a BatchId to allow this multi-step process to succeed/fail as one step. BatchHeader updateBatchHeader = new BatchHeader(); updateBatchHeader.BatchID = ReportingServiceClient.CreateBatch(); ReportingServiceClient.BatchHeaderValue = updateBatchHeader; // Delete the old item ReportingServiceClient.DeleteItem(oldLinkedReportPath); // Create a new one Property[] properties = null; ReportingServiceClient.CreateLinkedReport(linkedReportName, folderPath, reportPath, properties); // Execute it as batch ReportingServiceClient.ExecuteBatch(); ReportingServiceClient.BatchHeaderValue = null; string linkedReportPath = string.Format("{0}/{1}", folderPath, linkedReportName); return new NLinkedReport(linkedReportName, linkedReportPath); }
public void EditItem(string name) { string item, target; try { // Get a clean path to pass to EditItem item = GetCleanPath(this.Path, m_lastShortName); target = GetCleanPath(this.Path, name); // Rename Item and Create new Properties based on old properties // Create batch header rs2005.BatchHeader singleBatchHeader = new rs2005.BatchHeader(); // Set EditItem batch id and top BatchHeaderValue singleBatchHeader.BatchID = this.rs.CreateBatch(); rs.BatchHeaderValue = singleBatchHeader; // Call methods to batch rs.MoveItem(item, target); // Test code. // this.SetProperties( newPath, null ); causes a failed method call which results in // a rollback of the MoveItem changes // Rollback transaction if either method fails rs.ExecuteBatch(); rs.BatchHeaderValue = null; } catch (Exception ex) { HandleGeneralException(ex); } finally { // Restore UI DisplayItems(Path); } }