コード例 #1
0
ファイル: FindForm.cs プロジェクト: ewcasas/DVTK
        public FindForm(MainForm theMainForm)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            _MainForm = theMainForm;
        }
コード例 #2
0
        public SessionTreeViewManager(ProjectForm2 theParentForm, Project theProject, System.Windows.Forms.TreeView theSessionTreeView)
        {
            _ParentForm = theParentForm;
            _MainForm = (MainForm)_ParentForm._MainForm;
            _Project = theProject;
            _SessionTreeView = theSessionTreeView;

            _StorageSCUEmulatorFormAsyncCallback = new System.AsyncCallback(this.ResultsFromExecutingEmulatorStorageScuAsynchronously);
            _StorageSCUEmulatorForm = new StorageSCUEmulatorForm(_StorageSCUEmulatorFormAsyncCallback);
        }
コード例 #3
0
ファイル: ProjectForm2.cs プロジェクト: ewcasas/DVTK
        /// <summary>
        /// 
        /// </summary>
        /// <param name="theProject"></param>
        /// <param name="theMainForm"></param>
        public ProjectForm2(DvtkApplicationLayer.Project theProject, MainForm theMainForm)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.userControlSessionTree.projectApp = theProject;
            userControlSessionTree.ProjectForm = this;
            _ActivityReportEventHandler = new Dvtk.Events.ActivityReportEventHandler(TCM_OnActivityReportEvent);
            projectApp = theProject;
            _MainForm = theMainForm;
            ListBoxSecuritySettings.SelectedIndex = 0;
            _SopClassesManager = new SopClassesManager(this, DataGridSpecifySopClasses, ComboBoxSpecifySopClassesAeTitle, ListBoxSpecifySopClassesDefinitionFileDirectories, RichTextBoxSpecifySopClassesInfo, userControlSessionTree, ButtonSpecifySopClassesRemoveDirectory);
            _TCM_ValidationResultsBrowser = new ValidationResultsManager(webBrowserValResult);
            //_TCM_ValidationResultsManagerBrowser = new ValidationResultsManager(webBrowserResultMgr);

            // Because the webbrowser navigation is "cancelled" when browsing to an .xml file
            // first another html file has to be shown to make this work under Windows 2000.
            _TCM_ValidationResultsBrowser.ShowHtml("about:blank");
            _TCM_AppendTextToActivityLogging_ThreadSafe_Delegate = new TCM_AppendTextToActivityLogging_ThreadSafe_Delegate(this.TCM_AppendTextToActivityLogging_ThreadSafe);

            resultProjectXml  = projectApp.ProjectFileName + ".xml";
        }
コード例 #4
0
        public void ExecuteSelectedScript()
        {
            _MainForm = (MainForm)parentForm._MainForm;
            Script theScriptFileTag = GetSelectedTag() as Script;

            if (theScriptFileTag == null) {
                // Sanity check.
                Debug.Assert(false);
            }
            else {
                theScriptFileTag.ParentSession.IsExecute = true;
                bool isExecutionCancelled = false;

                // Remove the current results files for this script file.
                // If results files exists that will be removed, ask the user what to do with them.
                ArrayList theResultsFilesToRemove = Result.GetAllNamesForSession(theScriptFileTag.ParentSession);
                theResultsFilesToRemove = Result.GetNamesForScriptFile(theScriptFileTag.ScriptFileName, theResultsFilesToRemove);
                theResultsFilesToRemove = Result.GetNamesForCurrentSessionId(theScriptFileTag.ParentSession, theResultsFilesToRemove);

                if (theResultsFilesToRemove.Count != 0) {
                    string theWarningMessage = string.Format("Results files exist that will be removed before execution of script file {0}.\nCopy these results files to backup files?", theScriptFileTag.ScriptFileName);
                    DialogResult theDialogResult = DialogResult.No;

                    // Only ask to backup the results file if this is configured.
                    if (_MainForm._UserSettings.AskForBackupResultsFile) {
                        theDialogResult = MessageBox.Show(theWarningMessage, "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }

                    if (theDialogResult == DialogResult.Yes) {
                        Result.BackupFiles(theScriptFileTag.ParentSession, theResultsFilesToRemove);
                        Result.Remove(theScriptFileTag.ParentSession, theResultsFilesToRemove);
                    }
                    else if (theDialogResult == DialogResult.No) {
                        Result.Remove(theScriptFileTag.ParentSession, theResultsFilesToRemove);
                    }
                    else {
                        _TagThatIsBeingExecuted  = null;

                        // Update the UI.
                        EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                        Notify(theEndExecution);

                        isExecutionCancelled = true;
                    }
                }

                if (!isExecutionCancelled) {
                    if ( (System.IO.Path.GetExtension(theScriptFileTag.ScriptFileName).ToLower() == ".dss") ||
                        (System.IO.Path.GetExtension(theScriptFileTag.ScriptFileName).ToLower() == ".ds")
                        ) {
                        ExecuteDicomScriptInThread(theScriptFileTag);
                    }
                    else if (System.IO.Path.GetExtension(theScriptFileTag.ScriptFileName).ToLower() == ".vbs") {
                        ExecuteVisualBasicScriptInThread(theScriptFileTag);
                    }
                    else {
                        MessageBox.Show("Execution of this type of file not supported (yet)");

                        _TagThatIsBeingExecuted = null;

                        // Update the UI.
                        EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                        Notify(theEndExecution);
                    }
                }
            }
        }
コード例 #5
0
        public void UpdateSessionNodeTextMainNodeOnly(TreeNode theTreeNode, Session theSession)
        {
            _MainForm = (MainForm)parentForm._MainForm;
            bool isSessionExecuting = _MainForm.IsExecuting(theSession);
            //bool isSessionExecuting = theSession.IsExecute;
            bool isSessionExecutingInOtherSessionTreeView = (isSessionExecuting && (theSession != GetExecutingSession()));

            theTreeNode.Text = System.IO.Path.GetFileName(theSession.SessionFileName);

            if ( (theSession is ScriptSession) ||
                (theSession is EmulatorSession)
                ) {
                if (isSessionExecutingInOtherSessionTreeView) {
                    theTreeNode.Text+= " (disabled)";
                }
            }

            if (theSession is DvtkApplicationLayer.MediaSession) {
                // If this session is executing...
                if (isSessionExecuting) {
                    // If the executing session is executed by this session tree view...
                    if (theSession == GetExecutingSession()) {
                        theTreeNode.Text+= " (executing)";
                    }
                        // If the executing session is not executed by this session tree view...
                    else {
                        theTreeNode.Text+= "(disabled)";
                    }
                }
            }

            if (theSession.GetSessionChanged(theSession)) {
                theTreeNode.Text+= " *";
            }
        }
コード例 #6
0
        private void ExecuteSelectedEmulator()
        {
            _MainForm = (MainForm)parentForm._MainForm;
            EmulatorSession theEmulatorSession = GetSession() as EmulatorSession;
            /// To check added some code
            if (theEmulatorSession == null) {
                // Sanity check.
                Debug.Assert(false);
            } else {
                theEmulatorSession.IsExecute = true ;
                Emulator theEmulatorTag = (Emulator)GetSelectedTag();
                string theResultsFileName = null;
                bool isExecutionCancelled = false;

                // Remove the current results files for the emulator.
                // If results files exists that will be removed, ask the user what to do with them.
                ArrayList theResultsFilesToRemove = Result.GetAllNamesForSession(theEmulatorSession);
                string theEmulatorBaseName = Result.GetBaseNameForEmulator(theEmulatorTag.EmulatorType);
                theResultsFilesToRemove = Result.GetNamesForBaseName(theEmulatorBaseName, theResultsFilesToRemove);
                theResultsFilesToRemove = Result.GetNamesForCurrentSessionId(theEmulatorSession, theResultsFilesToRemove);

                if (theResultsFilesToRemove.Count != 0) {
                    string theWarningMessage = string.Format("Results files exist that will be removed before execution of the emulator.\nCopy these results files to backup files?");
                    DialogResult theDialogResult = DialogResult.No;

                    // Only ask to backup the results file if this is configured.
                    if (_MainForm._UserSettings.AskForBackupResultsFile) {
                        theDialogResult = MessageBox.Show(theWarningMessage, "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }

                    if (theDialogResult == DialogResult.Yes) {
                        Result.BackupFiles(theEmulatorSession, theResultsFilesToRemove);
                        Result.Remove(theEmulatorSession, theResultsFilesToRemove);
                    }
                    else if (theDialogResult == DialogResult.No) {
                        Result.Remove(theEmulatorSession, theResultsFilesToRemove);
                    }
                    else {
                        _TagThatIsBeingExecuted  = null;

                        // Update the UI.
                        EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                        Notify(theEndExecution);

                        isExecutionCancelled = true;
                    }
                }
                if (!isExecutionCancelled) {
                    // Determine the results file name.
                    theResultsFileName =  Result.GetExpandedNameForEmulator(theEmulatorSession, theEmulatorTag.EmulatorType);

                    // Start the results gathering.
                    theEmulatorSession.EmulatorSessionImplementation.StartResultsGathering(theResultsFileName);

                    // If this is the print SCP emulator or the storage SCP emulator...
                    if ( (theEmulatorTag.EmulatorType == Emulator.EmulatorTypes.PRINT_SCP) ||
                        (theEmulatorTag.EmulatorType == Emulator.EmulatorTypes.STORAGE_SCP) ) {
                        // Perform the actual execution of the script.
                        theEmulatorSession.EmulatorSessionImplementation.ScpEmulatorType = DvtkData.Results.ScpEmulatorType.Storage ;
                        AsyncCallback theAsyncCallback = new AsyncCallback(this.ResultsFromExecutingEmulatorScpAsynchronously);
                        theEmulatorSession.EmulatorSessionImplementation.BeginEmulateSCP(theAsyncCallback);
                    }

                    // If this is the storage SCU emulator...
                    if (theEmulatorTag.EmulatorType == Emulator.EmulatorTypes.STORAGE_SCU) {
                        theEmulatorSession.EmulatorSessionImplementation.ScuEmulatorType = DvtkData.Results.ScuEmulatorType.Storage;

                        DialogResult theDialogResult = _StorageSCUEmulatorForm.ShowDialog(parentForm, theEmulatorSession);

                        if (theDialogResult == DialogResult.Cancel) {
                            // No sending of Dicom files is happening now.

                            // Save the results.
                            GetSession().Implementation.EndResultsGathering();

                            _TagThatIsBeingExecuted  = null;

                            // Update the UI.
                            EndExecution theEndExecution= new EndExecution(GetSelectedTag());
                            Notify(theEndExecution);
                        }
                        else {
                            // Dicom files are being send in another thread.
                            // Do nothing, let the call back method handle the enabling of the session in the UI.
                        }
                    }
                }
            }
        }
コード例 #7
0
        private void ExecuteSelectedMediaSession()
        {
            _MainForm = (MainForm)parentForm._MainForm;
            ArrayList theMediaFilesToBeValidatedLocalList = new ArrayList();
            DvtkApplicationLayer.MediaSession theMediaSession = GetSelectedSessionNew() as DvtkApplicationLayer.MediaSession;

            if (theMediaSession == null) {
                // Sanity check.
                Debug.Assert(false);
            }
            else {
                theMediaSession.IsExecute = true;
                mediaFilesToBeValidated.Clear();

                OpenFileDialog theOpenFileDialog = new OpenFileDialog();

                theOpenFileDialog.Filter = "All files (*.*)|*.*";
                theOpenFileDialog.Multiselect = true;
                theOpenFileDialog.ReadOnlyChecked = true;
                theOpenFileDialog.Title = "Select media files to validate";

                // Show the file dialog.
                // If the user pressed the OK button...
                if (theOpenFileDialog.ShowDialog() == DialogResult.OK)
                {
                    // Validate all files selected.
                    foreach (string theFullFileName in theOpenFileDialog.FileNames)
                    {
                        mediaFilesToBeValidated.Enqueue(theFullFileName);
                        theMediaFilesToBeValidatedLocalList.Add(theFullFileName);
                    }
                }

                if (mediaFilesToBeValidated.Count == 0) {
                    // No files selected, so no media validation to perform.
                    // Update UI.
                    _TagThatIsBeingExecuted  = null;

                    EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                    Notify(theEndExecution);
                }
                else {
                    bool isExecutionCancelled = false;

                    // Remove the current results files for the selected media files.
                    // If results files exists that will be removed, ask the user what to do with them.
                    ArrayList theResultsFilesForSession = Result.GetAllNamesForSession(theMediaSession);
                    ArrayList theResultsFilesToRemove = new ArrayList();

                    foreach(string theMediaFullFileName in theMediaFilesToBeValidatedLocalList) {
                        string theMediaFileBaseName = DvtkApplicationLayer.Result.GetBaseNameForMediaFile(theMediaFullFileName);

                        ArrayList theResultsFilesToRemoveForMediaFile = Result.GetNamesForBaseName(theMediaFileBaseName, theResultsFilesForSession);
                        theResultsFilesToRemoveForMediaFile = Result.GetNamesForCurrentSessionId(theMediaSession, theResultsFilesToRemoveForMediaFile);

                        theResultsFilesToRemove.AddRange(theResultsFilesToRemoveForMediaFile);
                    }

                    if (theResultsFilesToRemove.Count != 0) {
                        string theWarningMessage = string.Format("Results files exist that will be removed before media validation.\nCopy these results files to backup files?");
                        DialogResult theDialogResult = DialogResult.No;

                        // Only ask to backup the results file if this is configured.
                        if (_MainForm._UserSettings.AskForBackupResultsFile) {
                            theDialogResult = MessageBox.Show(theWarningMessage, "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }

                        if (theDialogResult == DialogResult.Yes) {
                            Result.BackupFiles(theMediaSession, theResultsFilesToRemove);
                            Result.Remove(theMediaSession, theResultsFilesToRemove);
                        }
                        else if (theDialogResult == DialogResult.No) {
                            Result.Remove(theMediaSession, theResultsFilesToRemove);
                        }
                        else {
                            _TagThatIsBeingExecuted  = null;

                            // Update the UI.
                            EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                            Notify(theEndExecution);

                            isExecutionCancelled = true;
                        }
                    }

                    if (!isExecutionCancelled) {
                        _FirstMediaFileToValidate = (string)mediaFilesToBeValidated.Peek();
                        ValidateMediaFiles();
                    }
                }
            }
        }
コード例 #8
0
ファイル: ProjectForm2.cs プロジェクト: ewcasas/DVTK
        public ProjectForm2(Project theProject, MainForm theMainForm)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            _ActivityReportEventHandler = new Dvtk.Events.ActivityReportEventHandler(TCM_OnActivityReportEvent);

            _Project = theProject;
            _MainForm = theMainForm;
            ListBoxSecuritySettings.SelectedIndex = 0;
            _SessionTreeViewManager = new SessionTreeViewManager(this, theProject, SessionTreeView);
            _SopClassesManager = new SopClassesManager(this, DataGridSpecifySopClasses, ComboBoxSpecifySopClassesAeTitle, ListBoxSpecifySopClassesDefinitionFileDirectories, RichTextBoxSpecifySopClassesInfo, _SessionTreeViewManager, ButtonSpecifySopClassesRemoveDirectory);
            _TCM_ValidationResultsManager = new ValidationResultsManager(WebDescriptionView);

            _TCM_ValidationResultsManager1 = new ValidationResultsManager(axWebBrowserScript);

            // Because the webbrowser navigation is "cancelled" when browsing to an .xml file
            // first another html file has to be shown to make this work under Windows 2000.
            _TCM_ValidationResultsManager.ShowHtml("about:blank");

            _TCM_AppendTextToActivityLogging_ThreadSafe_Delegate = new TCM_AppendTextToActivityLogging_ThreadSafe_Delegate(this.TCM_AppendTextToActivityLogging_ThreadSafe);

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            // MK!!!
        }
コード例 #9
0
        public void GenerateDICOMDIRWithDirectory()
        {
            FolderBrowserDialog mediaDirectoryBrowserDialog = new FolderBrowserDialog();
            mediaDirectoryBrowserDialog.Description = "Select the directory contains media files:";
            if (mediaDirectoryBrowserDialog.ShowDialog (this) == DialogResult.OK)
            {
                DirectoryInfo theDirectoryInfo = new DirectoryInfo(mediaDirectoryBrowserDialog.SelectedPath);
                FileInfo[] dcmFiles = null;
                if (theDirectoryInfo != null)
                {
                    // Get all the subdirectories
                    FileSystemInfo[] infos = theDirectoryInfo.GetFileSystemInfos();
                    ArrayList allDCMFiles = new ArrayList();
                    foreach (FileSystemInfo f in infos)
                    {
                        if (f is DirectoryInfo)
                        {
                            // Get all the files in a specific directory
                            FileInfo[] dcmFilesInSubDir = ((DirectoryInfo)f).GetFiles();
                            if(dcmFilesInSubDir.Length != 0)
                            {
                                foreach (FileInfo fileNext in dcmFilesInSubDir)
                                {
                                    allDCMFiles.Add(fileNext);
                                }
                            }
                        }
                        else if (f is FileInfo)
                        {
                            allDCMFiles.Add((FileInfo)f);
                        }
                    }

                    dcmFiles = (FileInfo[])allDCMFiles.ToArray(typeof(FileInfo));
                    allDCMFiles.Clear();
                }

                if(dcmFiles.Length != 0)
                {
                    DvtkApplicationLayer.MediaSession theMediaSession = GetSelectedSessionNew() as DvtkApplicationLayer.MediaSession;
                    if (theMediaSession == null)
                    {
                        // Sanity check.
                        Debug.Assert(false);
                    }
                    theMediaSession.IsExecute = true;
                    _TagThatIsBeingExecuted  = GetSelectedTag();

                    // Move all selected DCM files to directory "DICOM" in result root directory.
                    int i = 0;
                    DirectoryInfo theDICOOMDirInfo = null;
                    string resultsDir = theMediaSession.ResultsRootDirectory;
                    if(!resultsDir.EndsWith("\\"))
                        resultsDir += "\\";
                    theDICOOMDirInfo = new DirectoryInfo(resultsDir + "DICOM\\");

                    // Create "DICOM" directory if it doesn't exist
                    if(!theDICOOMDirInfo.Exists)
                    {
                        theDICOOMDirInfo.Create();
                    }
                    else
                    {
                        // Remove existing DCM files from "DICOM" directory
                        FileInfo[] files = theDICOOMDirInfo.GetFiles();
                        foreach(FileInfo file in files)
                        {
                            file.Delete();
                        }
                    }

                    string[] filesToSend = new string[dcmFiles.Length];
                    foreach(FileInfo theFileInfo in dcmFiles)
                    {
                        string newFileName = string.Format("I{0:00000}",i);
                        string destFileName = theDICOOMDirInfo.FullName + "\\" + newFileName;
                        //string destFileName = theDICOOMDirInfo.FullName + theFileInfo.Name;
                        theFileInfo.CopyTo(destFileName,true);
                        filesToSend.SetValue(destFileName,i);
                        i++;
                    }

                    _MainForm = (MainForm)_ParentForm._MainForm;
                    if(_MainForm != null)
                    {
                        _MainForm.MainStatusBar.Text = "Please wait, DICOMDIR creation is in progress...";
                    }

                    string theExpandedResultsFileName = theMediaSession.SessionId.ToString("000") + "_" + "dicomdir_creation_logging" + "_res.xml";
                    theMediaSession.Implementation.StartResultsGathering(theExpandedResultsFileName);
                    AsyncCallback createDicomdirAsyncCallback = new AsyncCallback(this.ResultsFromCreationDicomdirAsynchronously);
                    theMediaSession.MediaSessionImplementation.BeginGenerationDICOMDIR(filesToSend,createDicomdirAsyncCallback);
                }
                else
                {
                    // No files selected, so no media validation to perform.
                    // Update UI.
                    _TagThatIsBeingExecuted  = null;

                    EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                    Notify(theEndExecution);
                }
            }
        }
コード例 #10
0
        public void GenerateDICOMDIR()
        {
            OpenFileDialog theOpenFileDialog = new OpenFileDialog();

            theOpenFileDialog.Filter = "DICOM media files (*.dcm)|*.dcm|All files (*.*)|*.*";
            theOpenFileDialog.Title = "Select DCM files to create DICOMDIR";
            theOpenFileDialog.Multiselect = true;
            theOpenFileDialog.ReadOnlyChecked = true;

            // Show the file dialog.
            // If the user pressed the OK button...
            if (theOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                // Add all DCM files selected.
                string [] dcmFiles = new string [theOpenFileDialog.FileNames.Length];
                DvtkApplicationLayer.MediaSession theMediaSession = GetSelectedSessionNew() as DvtkApplicationLayer.MediaSession;
                if (theMediaSession == null)
                {
                    // Sanity check.
                    Debug.Assert(false);
                }
                theMediaSession.IsExecute = true;
                _TagThatIsBeingExecuted  = GetSelectedTag();

                if (theOpenFileDialog.FileNames.Length == 0)
                {
                    // No files selected, so no media validation to perform.
                    // Update UI.
                    _TagThatIsBeingExecuted  = null;

                    EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                    Notify(theEndExecution);
                }

                // Move all selected DCM files to directory "DICOM" in result root directory.
                int i = 0;
                DirectoryInfo theDirectoryInfo = null;
                try
                {
                    string resultsDir = theMediaSession.ResultsRootDirectory;
                    if(!resultsDir.EndsWith("\\"))
                        resultsDir += "\\";
                    theDirectoryInfo = new DirectoryInfo(resultsDir + "DICOM\\");

                    // Create "DICOM" directory if it doesn't exist
                    if(!theDirectoryInfo.Exists)
                    {
                        theDirectoryInfo.Create();
                    }
                    else
                    { // Remove existing DCM files from "DICOM" directory
                        FileInfo[] files = theDirectoryInfo.GetFiles();
                        foreach(FileInfo file in files)
                        {
                            file.Delete();
                        }
                    }

                    foreach(string dcmFile in theOpenFileDialog.FileNames)
                    {
                        FileInfo theFileInfo =  new FileInfo(dcmFile);
                        string newFileName = string.Format("I{0:00000}",i);
                        string destFileName = theDirectoryInfo.FullName + "\\" + newFileName;
                        //string destFileName = theDirectoryInfo.FullName + theFileInfo.Name;
                        theFileInfo.CopyTo(destFileName,true);
                        dcmFiles.SetValue(destFileName,i);
                        i++;
                    }
                }
                catch(IOException exception)
                {
                    MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                _MainForm = (MainForm)_ParentForm._MainForm;
                if(_MainForm != null)
                {
                    _MainForm.MainStatusBar.Text = "Please wait, DICOMDIR creation is in progress...";
                }

                string theExpandedResultsFileName = theMediaSession.SessionId.ToString("000") + "_" + "dicomdir_creation_logging" + "_res.xml";
                theMediaSession.Implementation.StartResultsGathering(theExpandedResultsFileName);
                AsyncCallback createDicomdirAsyncCallback = new AsyncCallback(this.ResultsFromCreationDicomdirAsynchronously);
                theMediaSession.MediaSessionImplementation.BeginGenerationDICOMDIR(dcmFiles,createDicomdirAsyncCallback);
            }
        }
コード例 #11
0
        //This method performs the validation of a media directory.
        private void ExecuteMediaDirectoryValidation( DirectoryInfo MediaDirectoryInfo)
        {
            _MainForm = (MainForm)_ParentForm._MainForm;
            ArrayList theMediaFilesToBeValidatedLocalList = null;
            DvtkApplicationLayer.MediaSession theMediaSession = GetSelectedSessionNew() as DvtkApplicationLayer.MediaSession;

            if (theMediaSession == null)
            {
                // Sanity check.
                Debug.Assert(false);
            }
            else
            {
                theMediaSession.IsExecute = true;
                mediaFilesToBeValidated.Clear();

                //Recursively get all the media files from all the sub directories
                theMediaFilesToBeValidatedLocalList = GetFilesRecursively(MediaDirectoryInfo);

                foreach (string theMediaFileName in theMediaFilesToBeValidatedLocalList)
                {
                    listOfFileNames.Add(Path.GetFileName(theMediaFileName));
                    mediaFilesToBeValidated.Enqueue(theMediaFileName);
                }

                if (mediaFilesToBeValidated.Count == 0)
                {
                    // No directory selected, so no media validation to perform.
                    // Update UI.
                    _TagThatIsBeingExecuted = null;

                    MessageBox.Show("The Selected Directory has no media files", "No Media Files present!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                    Notify(theEndExecution);
                }
                else
                {
                    bool isExecutionCancelled = false;

                    if (!isExecutionCancelled)
                    {
                        _FirstMediaFileToValidate = (string)mediaFilesToBeValidated.Peek();
                        ValidateMediaDirectory();
                    }
                }
            }
        }
コード例 #12
0
        public void ResultsFromCreationDicomdirAsynchronously(IAsyncResult theIAsyncResult)
        {
            DvtkApplicationLayer.MediaSession theMediaSession = (DvtkApplicationLayer.MediaSession)GetExecutingSession();

            try
            {
                // Obligated to call the following method according to the asynchronous design pattern.
                theMediaSession.MediaSessionImplementation.EndGenerationDICOMDIR(theIAsyncResult);
            }
            catch (Exception ex)
            {
                //
                // Problem:
                // Errors thrown from a workerthread are eaten by the .NET 1.x CLR.
                // Workaround:
                // Directly call the global (untrapped) exception handler callback.
                // Do NOT rely on
                // either
                // - System.AppDomain.CurrentDomain.UnhandledException
                // or
                // - System.Windows.Forms.Application.ThreadException
                // These events will only be triggered for the main thread not for worker threads.
                //
            //				CustomExceptionHandler eh = new CustomExceptionHandler();
            //				System.Threading.ThreadExceptionEventArgs args = new ThreadExceptionEventArgs(ex);
            //				eh.OnThreadException(this, args);
                //
                // Rethrow. This rethrow may work in the future .NET 2.x CLR.
                // Currently eaten.
                //
                throw ex;
            }

            theMediaSession.MediaSessionImplementation.EndResultsGathering();

            DvtkApplicationLayer.MediaSession mediaSession = (DvtkApplicationLayer.MediaSession)_TagThatIsBeingExecuted;
            mediaSession.CreateMediaFiles();
            _FirstMediaFileToValidate = "dicomdir_creation_logging";

            // Update the UI. Do this with an invoke, because the thread that is calling this
            // method is NOT the thread that created all controls used!
            _EndExecution = new EndExecution(_TagThatIsBeingExecuted);
            theMediaSession.IsExecute = false;

            _TagThatIsBeingExecuted  = null;

            _MainForm = (MainForm)_ParentForm._MainForm;
            if(_MainForm != null)
            {
                _MainForm.MainStatusBar.Text = "DICOMDIR creation completed.";
            }

            _NotifyDelegate = new NotifyDelegate(_ParentForm.Notify);
            _ParentForm.Invoke(_NotifyDelegate, new object[]{_EndExecution});
        }