protected void DeleteButton_Clicked(object sender, ImageClickEventArgs e)
        {

            if (Page.IsValid)
            {
                try
                {
                    string reason = ReasonListBox.SelectedItem.Text;
                    if (!String.IsNullOrEmpty(SaveReasonAsName.Text))
                    {
                        SaveCustomReason();
                        reason = SaveReasonAsName.Text;
                    }

                    OnDeletingStudies();
                    StudyController controller = new StudyController();
                    foreach (DeleteStudyInfo study in DeletingStudies)
                    {
                        try
                        {
                            controller.DeleteStudy(study.StudyKey, reason + "::" + Comment.Text);

							// Audit log
                        	DicomStudyDeletedAuditHelper helper = new DicomStudyDeletedAuditHelper(
                        										ServerPlatform.AuditSource, 
																EventIdentificationContentsEventOutcomeIndicator.Success);
							helper.AddUserParticipant(new AuditPersonActiveParticipant(
																SessionManager.Current.Credentials.UserName, 
																null, 
																SessionManager.Current.Credentials.DisplayName));
                        	helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
																	study.StudyInstanceUid, 
																	study.AccessionNumber ?? string.Empty));
                        	ServerPlatform.LogAuditMessage(helper);
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex, "DeleteClicked failed: Unable to delete studies");
                            throw;
                        }
                    }

                    OnStudiesDeleted();
                }
                finally
                {
                    Close();
                }
            }
            else
            {
                EnsureDialogVisible();
            }
        }
 private void AuditLog(Study affectedStudy)
 {
     // Audit log
     DicomStudyDeletedAuditHelper helper =
         new DicomStudyDeletedAuditHelper(
             ServerPlatform.AuditSource,
             EventIdentificationContentsEventOutcomeIndicator.Success);
     helper.AddUserParticipant(new AuditPersonActiveParticipant(
                                   SessionManager.Current.Credentials.
                                       UserName,
                                   null,
                                   SessionManager.Current.Credentials.
                                       DisplayName));
     helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
                                          affectedStudy.StudyInstanceUid,
                                          affectedStudy.AccessionNumber ??
                                          string.Empty));
     ServerAuditHelper.LogAuditMessage(helper);
 }
        protected virtual void OnStudyDeleted()
        {

            // Audit log
            DicomStudyDeletedAuditHelper helper = new DicomStudyDeletedAuditHelper(
                                                ServerPlatform.AuditSource,
                                                EventIdentificationContentsEventOutcomeIndicator.Success);
            helper.AddUserParticipant(new AuditProcessActiveParticipant(ServerPartition.AeTitle));
            helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
                                                    StorageLocation.StudyInstanceUid,
                                                    Study == null ? string.Empty : Study.AccessionNumber));
            ServerPlatform.LogAuditMessage(helper);


            IList<IDeleteStudyProcessorExtension> extensions = LoadExtensions();
            foreach (IDeleteStudyProcessorExtension ext in extensions)
            {
                if (ext.Enabled)
                    ext.OnStudyDeleted();
            }
        }