Example #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="scriptSession">The script Session the script belongs to.</param>
 /// <param name="scriptFileName">The script file name (not including path).</param>
 public VisualBasicScript(DvtkSession.ScriptSession session, String fileName)
 {
     this.scriptSession       = session;
     this.scriptFileName      = fileName;
     this.scriptRootDirectory = scriptSession.DicomScriptRootDirectory;
     this.scriptFullFileName  = Path.Combine(scriptSession.DicomScriptRootDirectory, fileName);
 }
Example #2
0
        /// <summary>
        /// Expand and compile the script to check if the syntax is OK.
        ///
        /// This is a "standalone" method. Use this when no Session object is available.
        /// </summary>
        /// <param name="scriptFullFileName">The full script file name.</param>
        /// <param name="includeAndCompileErrors">String containing include and compile errors if existing.</param>
        /// <returns>Boolean indicating if the script is correct.</returns>
        public static bool ExpandAndCompile(String scriptFullFileName, out String includeAndCompileErrors)
        {
            includeAndCompileErrors = "";
            String includeErrors;
            String compileErrors;

            // Construct the following objects because this is a "standalone" method.
            DvtkSession.ScriptSession scriptSession     = new Dvtk.Sessions.ScriptSession();
            VisualBasicScript         visualBasicScript = new VisualBasicScript(scriptSession, Path.GetDirectoryName(scriptFullFileName), Path.GetFileName(scriptFullFileName));

            // Get the script host.
            DvtkScriptSupport.DvtkScriptHost dvtkScriptHost = visualBasicScript.GetDvtkScriptHost();

            // Set the source code.
            dvtkScriptHost.SourceCode = visualBasicScript.GetExpandedContent(out includeErrors);

            // Add expand results.
            includeAndCompileErrors += includeErrors;

            // Compile.
            visualBasicScript.Compile(dvtkScriptHost, out compileErrors);

            // Add compile results.
            includeAndCompileErrors += compileErrors;

            return(includeAndCompileErrors.Length == 0);
        }
Example #3
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="resultsDirectory">Directory where the results files are to be written.</param>
 public ResultsReporter(System.String resultsDirectory)
 {
     _scriptSession = new ScriptSession();
     _scriptSession.ResultsRootDirectory      = resultsDirectory;
     _scriptSession.DetailedValidationResults = true;
     _scriptSession.SummaryValidationResults  = true;
 }
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="scriptSession">The script Session the script belongs to.</param>
 /// <param name="scriptFileName">The script file name (not including path).</param>
 public VisualBasicScript(DvtkSession.ScriptSession session, String fileName)
 {
     this.scriptSession = session ;
     this.scriptFileName = fileName ;
     this.scriptRootDirectory = scriptSession.DicomScriptRootDirectory ;
     this.scriptFullFileName = Path.Combine(scriptSession.DicomScriptRootDirectory , fileName) ;
 }
Example #5
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="resultsDirectory">Directory where the results files are to be written.</param>
 public ResultsReporter(System.String resultsDirectory)
 {
     _scriptSession = new ScriptSession();
     _scriptSession.ResultsRootDirectory = resultsDirectory;
     _scriptSession.DetailedValidationResults = true;
     _scriptSession.SummaryValidationResults = true;
 }
Example #6
0
 internal Confirmer(ScriptSession scriptSession)
 {
     if (scriptSession == null)
     {
         throw new System.ArgumentNullException();
     }
     this.m_parentSession = scriptSession;
 }
Example #7
0
 /// <summary>
 /// Constructor.
 /// 
 /// Use this constructor when the script file is located in a directory, other then the
 /// Session script directory.
 /// </summary>
 /// <param name="scriptSession">The script Session the script belongs to.</param>
 /// <param name="scriptDirectory">The directory of the script file.</param>
 /// <param name="scriptFileName">The script file name (not including path).</param>
 public VisualBasicScript(DvtkSession.ScriptSession  session, String directory, String scriptFileName)
 {
     this.scriptSession = session ;
     this.scriptFileName = scriptFileName ;
     if (directory == "") {
         this.scriptRootDirectory = scriptSession.DicomScriptRootDirectory ;
     }
     else {
         this.scriptRootDirectory = directory ;
     }
     this.scriptFullFileName = Path.Combine(this.scriptRootDirectory , scriptFileName) ;
 }
Example #8
0
        public void Init()
        {
            scriptSession = ScriptSession.LoadFromFile(appDirectory + @"\test_validation.ses");
            if (scriptSession != null)
            {
                DirectoryInfo resultDir = new DirectoryInfo(scriptSession.ResultsRootDirectory);
                if (!resultDir.Exists)
                    resultDir.Create();
            }

            theAsyncCallback = new AsyncCallback(this.ResultsFromExecutingScriptAsynchronously);
        }
Example #9
0
        public void Init()
        {
            scriptSession = ScriptSession.LoadFromFile(appDirectory + @"\test_validation.ses");
            if (scriptSession != null)
            {
                DirectoryInfo resultDir = new DirectoryInfo(scriptSession.ResultsRootDirectory);
                if (!resultDir.Exists)
                {
                    resultDir.Create();
                }
            }

            theAsyncCallback = new AsyncCallback(this.ResultsFromExecutingScriptAsynchronously);
        }
Example #10
0
 /// <summary>
 /// Constructor.
 ///
 /// Use this constructor when the script file is located in a directory, other then the
 /// Session script directory.
 /// </summary>
 /// <param name="scriptSession">The script Session the script belongs to.</param>
 /// <param name="scriptDirectory">The directory of the script file.</param>
 /// <param name="scriptFileName">The script file name (not including path).</param>
 public VisualBasicScript(DvtkSession.ScriptSession session, String directory, String scriptFileName)
 {
     this.scriptSession  = session;
     this.scriptFileName = scriptFileName;
     if (directory == "")
     {
         this.scriptRootDirectory = scriptSession.DicomScriptRootDirectory;
     }
     else
     {
         this.scriptRootDirectory = directory;
     }
     this.scriptFullFileName = Path.Combine(this.scriptRootDirectory, scriptFileName);
 }
Example #11
0
        /// <summary>
        /// Load a session from file.
        /// </summary>
        /// <param name="fileName">file with extension <c>.SES</c></param>
        /// <returns>
        /// Returns a session of type;
        /// <list type="bullet">
        /// <item>Dvtk.Sessions.ScriptSession</item>
        /// <item>Dvtk.Sessions.EmulatorSession</item>
        /// <item>Dvtk.Sessions.MediaSession</item>
        /// </list>
        /// </returns>
        /// <remarks>
        /// The type of session is dynamically determined.
        /// </remarks>
        public Session Load(FileName fileName)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException();
            }
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
            if (!fileInfo.Exists)
            {
                throw new ArgumentException();
            }
            //
            // Transform fileName to fully qualified file name.
            //
            fileName = fileInfo.FullName;
            Session session = null;

            Wrappers.MBaseSession adaptee =
                Wrappers.MSessionFactory.Load(fileName);
            switch (adaptee.SessionType)
            {
            case Wrappers.SessionType.SessionTypeEmulator:
                session = new EmulatorSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeMedia:
                session = new MediaSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeScript:
                session = new ScriptSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeSniffer:
                session = new SnifferSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeUnknown:
                // Unknown Wrappers.SessionType
                throw new System.NotImplementedException();
            }
            return(session);
        }
Example #12
0
 /// <summary>
 /// Method to create the instance of a session. 
 /// </summary>
 /// <param name="sessionFileName"> FileName of the ScriptSession.</param>
 protected override void CreateSessionInstance(string sessionFileName)
 {
     if (implementation == null) {
         implementation = new DvtkSession.ScriptSession();
         LoadSession();
     }
 }
Example #13
0
 /// <summary>
 /// Method to create the instance of a EmulatorSession.
 /// </summary>
 protected override void CreateSessionInstance()
 {
     if (implementation == null) {
         implementation = new DvtkSession.ScriptSession();
     }
 }
Example #14
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="resultsDirectory">Directory where the results files are to be written.</param>
 public ResultsReporter(System.String resultsDirectory)
 {
     _scriptSession = new ScriptSession();
     _scriptSession.ResultsRootDirectory = resultsDirectory;
 }
Example #15
0
 /// <summary>
 /// Load a session from file.
 /// </summary>
 /// <param name="fileName">file with extension <c>.SES</c></param>
 /// <returns>
 /// Returns a session of type;
 /// <list type="bullet">
 /// <item>Dvtk.Sessions.ScriptSession</item>
 /// <item>Dvtk.Sessions.EmulatorSession</item>
 /// <item>Dvtk.Sessions.MediaSession</item>
 /// </list>
 /// </returns>
 /// <remarks>
 /// The type of session is dynamically determined.
 /// </remarks>
 public Session Load(FileName fileName)
 {
     if (fileName == null) throw new ArgumentNullException();
     System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
     if (!fileInfo.Exists) throw new ArgumentException();
     //
     // Transform fileName to fully qualified file name.
     //
     fileName = fileInfo.FullName;
     Session session = null;
     Wrappers.MBaseSession adaptee =
         Wrappers.MSessionFactory.Load(fileName);
     switch (adaptee.SessionType)
     {
         case Wrappers.SessionType.SessionTypeEmulator:
             session = new EmulatorSession(adaptee);
             break;
         case Wrappers.SessionType.SessionTypeMedia:
             session = new MediaSession(adaptee);
             break;
         case Wrappers.SessionType.SessionTypeScript:
             session = new ScriptSession(adaptee);
             break;
         case Wrappers.SessionType.SessionTypeUnknown:
             // Unknown Wrappers.SessionType
             throw new System.NotImplementedException();
     }
     return session;
 }
Example #16
0
 internal Confirmer(ScriptSession scriptSession)
 {
     if (scriptSession == null) throw new System.ArgumentNullException();
     this.m_parentSession = scriptSession;
 }
Example #17
0
        /// <summary>
        /// Copy all settings from the supplied ScriptSession to this ScriptSession.
        /// </summary>
        /// <param name="scriptSession">The ScriptSession to copy the settings from.</param>
        public virtual void CopySettingsFrom(ScriptSession scriptSession)
        {
            base.CopySettingsFrom(scriptSession);

            AddGroupLength = scriptSession.AddGroupLength;
            AutoType2Attributes = scriptSession.AutoType2Attributes;
            // Is read-only. ConfirmInteractionOption = scriptSession.ConfirmInteractionOption;
            DefineSqLength = scriptSession.DefineSqLength;
            DescriptionDirectory = scriptSession.DescriptionDirectory;
            DicomScriptRootDirectory = scriptSession.DicomScriptRootDirectory;

            // DvtSystemSettings.
            DvtSystemSettings.AeTitle = scriptSession.DvtSystemSettings.AeTitle;
            DvtSystemSettings.ImplementationClassUid = scriptSession.DvtSystemSettings.ImplementationClassUid;
            DvtSystemSettings.ImplementationVersionName = scriptSession.DvtSystemSettings.ImplementationVersionName;
            DvtSystemSettings.MaximumLengthReceived = scriptSession.DvtSystemSettings.MaximumLengthReceived;
            DvtSystemSettings.Port = scriptSession.DvtSystemSettings.Port;
            DvtSystemSettings.SocketTimeout = scriptSession.DvtSystemSettings.SocketTimeout;

            if (scriptSession.SecuritySettings.SecureSocketsEnabled)
            {
                // SecuritySettings.
                SecuritySettings.SecureSocketsEnabled = scriptSession.SecuritySettings.SecureSocketsEnabled;
                SecuritySettings.CacheTlsSessions = scriptSession.SecuritySettings.CacheTlsSessions;
                SecuritySettings.CertificateFileName = scriptSession.SecuritySettings.CertificateFileName;
                SecuritySettings.CheckRemoteCertificate = scriptSession.SecuritySettings.CheckRemoteCertificate;
                SecuritySettings.CipherFlags = scriptSession.SecuritySettings.CipherFlags;
                SecuritySettings.CredentialsFileName = scriptSession.SecuritySettings.CredentialsFileName;
                SecuritySettings.TlsCacheTimeout = scriptSession.SecuritySettings.TlsCacheTimeout;
                SecuritySettings.TlsPassword = scriptSession.SecuritySettings.TlsPassword;
                SecuritySettings.TlsVersionFlags = scriptSession.SecuritySettings.TlsVersionFlags;
            }

            // SutSystemSettings.
            SutSystemSettings.AeTitle = scriptSession.SutSystemSettings.AeTitle;
            SutSystemSettings.CommunicationRole = scriptSession.SutSystemSettings.CommunicationRole;
            SutSystemSettings.HostName = scriptSession.SutSystemSettings.HostName;
            SutSystemSettings.ImplementationClassUid = scriptSession.SutSystemSettings.ImplementationClassUid;
            SutSystemSettings.ImplementationVersionName = scriptSession.SutSystemSettings.ImplementationVersionName;
            SutSystemSettings.MaximumLengthReceived = scriptSession.SutSystemSettings.MaximumLengthReceived;
            SutSystemSettings.Port = scriptSession.SutSystemSettings.Port;
        }
Example #18
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="resultsDirectory">Directory where the results files are to be written.</param>
 public ResultsReporter(System.String resultsDirectory)
 {
     _scriptSession = new ScriptSession();
     _scriptSession.ResultsRootDirectory = resultsDirectory;
 }
Example #19
0
        /// <summary>
        /// Expand and compile the script to check if the syntax is OK.
        /// 
        /// This is a "standalone" method. Use this when no Session object is available.
        /// </summary>
        /// <param name="scriptFullFileName">The full script file name.</param>
        /// <param name="includeAndCompileErrors">String containing include and compile errors if existing.</param>
        /// <returns>Boolean indicating if the script is correct.</returns>
        public static bool ExpandAndCompile(String scriptFullFileName, out String includeAndCompileErrors)
        {
            includeAndCompileErrors = "";
            String includeErrors;
            String compileErrors;

            // Construct the following objects because this is a "standalone" method.
            DvtkSession.ScriptSession scriptSession = new Dvtk.Sessions.ScriptSession();
            VisualBasicScript visualBasicScript = new VisualBasicScript(scriptSession , Path.GetDirectoryName(scriptFullFileName), Path.GetFileName(scriptFullFileName));

            // Get the script host.
            DvtkScriptSupport.DvtkScriptHost dvtkScriptHost = visualBasicScript.GetDvtkScriptHost();

            // Set the source code.
            dvtkScriptHost.SourceCode = visualBasicScript.GetExpandedContent(out includeErrors);

            // Add expand results.
            includeAndCompileErrors+= includeErrors;

            // Compile.
            visualBasicScript.Compile(dvtkScriptHost, out compileErrors);

            // Add compile results.
            includeAndCompileErrors+= compileErrors;

            return(includeAndCompileErrors.Length == 0);
        }