コード例 #1
0
        public static void Main(string[] args)
        {
            try {
                //  Pre-parse the command line before initializing the ADK
                Adk.Debug = AdkDebugFlags.Moderate;
                AdkExamples.parseCL(null, args);

                //  Initialize the ADK. Note even though this example uses raw XML,
                //  it is still required that the appropriate SDO libraries be loaded
                Adk.Initialize(AdkExamples.Version, SIFVariant.SIF_US, (int)SdoLibraryType.Student);

                //  Start agent...
                MappingsDemo agent;
                agent = new MappingsDemo();

                agent.startAgent(args);

                //  Wait for Ctrl-C to be pressed
                Console.WriteLine();
                Console.WriteLine("Agent is running (Press Ctrl-C to stop)");
                Console.WriteLine();

                //  Install a shutdown hook to cleanup when Ctrl+C is pressed
                new AdkConsoleWait().WaitForExit();
                agent.Shutdown
                    (AdkExamples.Unreg ? ProvisioningFlags.Unregister : ProvisioningFlags.None);
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }
コード例 #2
0
 public virtual void setUp()
 {
     Adk.Initialize();
     fCfg = new AgentConfig();
     fCfg.Read("..\\..\\Library\\Tools\\Mapping\\SIF1.5.agent.cfg",
               false);
 }
コード例 #3
0
        public void setUp()
        {
            Adk.Initialize();

            fAgent = new TestAgent();
            fAgent.Initialize();
        }
コード例 #4
0
        private static void Main(string[] args)
        {
            try
            {
                Adk.Debug = AdkDebugFlags.Moderate;
                Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_AU, (int)SdoLibraryType.All);

                Chameleon agent;
                agent = new Chameleon();

                //  Start agent...
                agent.StartAgent(args);

                Console.WriteLine("Agent is running (Press Ctrl-C to stop)");
                sWaitMutex = new AdkConsoleWait();
                sWaitMutex.WaitForExit();

                //  Always shutdown the agent on exit
                agent.Shutdown(ProvisioningFlags.None);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #5
0
ファイル: AdkTest.cs プロジェクト: rubitek/OpenADK-csharp
 public virtual void StartTests()
 {
     if (!Adk.Initialized)
     {
         Adk.Initialize(SifVersion.LATEST, SdoLibraryType.All);
     }
 }
コード例 #6
0
    public static int Main(string[] args)
    {
        SimpleProvider agent = null;

        try
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: SimpleProvider /zone zone /url url [/events] [options]");
                Console.WriteLine("    /zone zone     The name of the zone");
                Console.WriteLine("    /url url       The zone URL");
                Console.WriteLine("    /events        Periodically send change events");
                AdkExamples.printHelp();
                return(0);
            }

            Console.ForegroundColor = ConsoleColor.Green;

            //	Pre-parse the command-line before initializing the ADK
            Adk.Debug = AdkDebugFlags.None;
            AdkExamples.parseCL(null, args);

            //  Initialize the ADK with the specified version, loading only the Student SDO package
            Adk.Initialize(SifVersion.SIF23, SIFVariant.SIF_UK, (int)SdoLibraryType.All);

            //  Start the agent...
            agent = new SimpleProvider();

            // Call StartAgent. This method does not return until the agent shuts down
            agent.startAgent(args);

            //	Wait for Ctrl-C to be pressed
            Console.WriteLine("Agent is running (Press Ctrl-C to stop)");
            new AdkConsoleWait().WaitForExit();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
        finally
        {
            if (agent != null && agent.Initialized)
            {
                //  Always shutdown the agent on exit
                try
                {
                    agent.Shutdown
                        (AdkExamples.Unreg
                             ? ProvisioningFlags.Unregister
                             : ProvisioningFlags.None);
                }
                catch (AdkException adkEx)
                {
                    Console.WriteLine(adkEx);
                }
            }
        }
        return(0);
    }
コード例 #7
0
 public virtual void setUp()
 {
     if (!Adk.Initialized)
     {
         Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_US, (int)SdoLibraryType.All);
     }
     Adk.SifVersion = SifVersion.LATEST;
 }
コード例 #8
0
        public void TestStableSortInGetContent()
        {
            if (!Adk.Initialized)
            {
                Adk.Initialize();
            }

            SIF_Register sr = new SIF_Register();

            sr.SIF_Icon = "test.ico";

            // Create the original list of SIF_Version strings
            string[] list = new string[5];
            list[0] = "1.1";
            list[1] = "2.*";
            list[2] = "2.0r1";
            list[3] = "2.5";
            list[4] = "1.0r1";

            for (int a = 0; a < 5; a++)
            {
                sr.AddSIF_Version(new SIF_Version(list[a]));
            }

            sr.SIF_Name = "AgentName";
            sr.SIF_Mode = "Push";

            IList <Element> elements = Adk.Dtd.GetFormatter(SifVersion.SIF11).GetContent(sr, SifVersion.SIF11);

            // We should have gotten back a list of elements like this:
            // SIF_Name
            // 5 SIF_Version elements
            // SIF_Mode
            // SIF_Icon (only if the version is 2.0 or greater)

            Assert.AreEqual("AgentName", elements[0].TextValue);
            // Assert that the SIF_Version elements returned are still in the order they went in
            for (int a = 0; a < 5; a++)
            {
                Assert.AreEqual(list[a], elements[a + 1].TextValue);
            }
            Assert.AreEqual("Push", elements[6].TextValue);
            // NOTE: SIF_Icon is not present in SIF 1.1

            elements = Adk.Dtd.GetFormatter(SifVersion.SIF21).GetContent(sr, SifVersion.SIF21);


            Assert.AreEqual("AgentName", elements[0].TextValue);
            // Assert that the SIF_Version elements returned are still in the order they went in
            for (int a = 0; a < 5; a++)
            {
                Assert.AreEqual(list[a], elements[a + 1].TextValue);
            }
            Assert.AreEqual("Push", elements[6].TextValue);
            Assert.AreEqual("test.ico", elements[7].TextValue);
        }
コード例 #9
0
 public void setUp()
 {
     if (!Adk.Initialized)
     {
         Adk.Initialize( );
     }
     Adk.SifVersion = fVersion;
     fCfg           = new AgentConfig();
     fCfg.Read("..\\..\\Library\\Tools\\Mapping\\SASI2.0.cfg", false);
 }
コード例 #10
0
        public void SetUp()
        {
            Adk.Initialize();

            /*
             *          f64BitKey = new byte[8];
             *          RNGCryptoServiceProvider.Create().GetBytes( f64BitKey );
             */

            f64BitKey  = Convert.FromBase64String("dW7SKzwdn0Q=");
            f128BitKey = Convert.FromBase64String("TcdilmUZ6qvbmegl2it2pA==");
            f192BitKey = Convert.FromBase64String("mECbXMo+fOMWRwam7tyUEE59jbO9O0Z4");

            StringBuilder builder = new StringBuilder();

            builder.Append("Created Unique 64-bit Encryption Key: ");
            foreach (byte b in f64BitKey)
            {
                builder.AppendFormat("0x{0:X}", b);
                builder.Append(new char[] { ',', ' ' });
            }
            builder.Append("\r\nBase 64 Value: ");
            builder.Append(Convert.ToBase64String(f64BitKey));
            Console.WriteLine(builder.ToString());

            /*
             *          f128BitKey = new byte[16];
             *          RNGCryptoServiceProvider.Create().GetBytes( f128BitKey );
             */

            builder = new StringBuilder();
            builder.Append("Created Unique 128-bit Encryption Key: ");
            foreach (byte b in f128BitKey)
            {
                builder.AppendFormat("0x{0:X}", b);
                builder.Append(new char[] { ',', ' ' });
            }
            builder.Append("\r\nBase 64 Value: ");
            builder.Append(Convert.ToBase64String(f128BitKey));

            Console.WriteLine(builder.ToString());


            builder = new StringBuilder();
            builder.Append("Created Unique 192-bit Encryption Key: ");
            foreach (byte b in f192BitKey)
            {
                builder.AppendFormat("0x{0:X}", b);
                builder.Append(new char[] { ',', ' ' });
            }
            builder.Append("\r\nBase 64 Value: ");
            builder.Append(Convert.ToBase64String(f192BitKey));

            Console.WriteLine(builder.ToString());
        }
コード例 #11
0
        /// <summary>
        /// Run the agent as an application
        /// </summary>
        /// <example>
        /// Pull mode
        ///Debug Command line arguments: /zone test /url http://127.0.0.1:7080/test /pull /events true</example>
        /// <example> Push mode
        /// /zone test /url http://127.0.0.1:7080/test /push /port 10000 /events true</example>
        /// <param name="args"></param>
        public static void Main(String[] args)
        {
            SimpleProvider agent = null;

            try
            {
                if (args.Length < 2)
                {
                    Console.WriteLine
                        ("Usage: SimpleSubscriber /zone zone /url url [/full] [options]");
                    AdkExamples.printHelp();
                    return;
                }

                //	Pre-parse the command-line before initializing the Adk
                Adk.Debug = AdkDebugFlags.None;
                AdkExamples.parseCL(null, args);

                //  Initialize the Adk with the specified version, loading only the learner SDO package
                Adk.Initialize(AdkExamples.Version, SIFVariant.SIF_AU, (int)SdoLibraryType.Student);

                //  Start the agent...
                agent = new SimpleProvider();

                // Call StartAgent. This method does not return until the agent shuts down
                agent.StartAgent(args);

                //	Wait for Ctrl-C to be pressed
                Console.WriteLine("Agent is running (Press Ctrl-C to stop)");
                new AdkConsoleWait().WaitForExit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                if (agent != null && agent.Initialized)
                {
                    //  Always shutdown the agent on exit
                    try
                    {
                        agent.Shutdown
                            (AdkExamples.Unreg
                                  ? ProvisioningFlags.Unprovide
                                  : ProvisioningFlags.None);
                    }
                    catch (AdkException adkEx)
                    {
                        Console.WriteLine(adkEx);
                    }
                }
            }
        }
コード例 #12
0
        public void Setup()
        {
            Adk.Initialize();
            TransportPlugin tp = new InMemoryTransportPlugin();

            Adk.InstallTransport(tp);
            fAgent = new TestAgent();
            fAgent.Initialize();
            fAgent.Properties.TransportProtocol = tp.Protocol;
            fZone = (TestZoneImpl)fAgent.ZoneFactory.GetInstance("test", "http://test");
        } //end method Setup
コード例 #13
0
        public void TestParseComplexTypes()
        {
            Adk.Initialize();
            Adk.SifVersion = SifVersion.SIF15r1;
            SifParser p        = SifParser.NewInstance();
            Activity  activity = new Activity();

            activity = (Activity)p.Parse(
                "<Activity RefId='0E3915409C3611DABE9FE16E3CD135F2' xml:lang='en'><Title>Activity 0E3915409C3611DABE9FE16E3CD135F2</Title><ActivityTime><CreationDate>20041016</CreationDate></ActivityTime></Activity>"
                , null);
            Assert.IsNotNull(activity, "Activity is null");
            Assert.AreEqual(activity.Title, "Activity 0E3915409C3611DABE9FE16E3CD135F2", "activity.Title is incorrect");
            Assert.AreEqual(DateTime.Parse(activity.ActivityTime.CreationDate.ToString()).ToString("yyyyMMdd"), "20041016", "activity.ActivityTime.CreationDate is incorrect");
        }//end TestParseComplexTypes
コード例 #14
0
        public virtual void Setup()
        {
            Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_US, (int)SdoLibraryType.All );
            //uses transportplugin interface , and factory method Createthat
            //returns new instance of class we're looking for 
            TransportPlugin tp = new InMemoryTransportPlugin();
            Adk.Install( tp );
            fAgent = new TestAgent();
            fAgent.Initialize();
            fAgent.Properties.TransportProtocol = tp.Protocol;

            //createzone added To ZoneFactoryImpl
            fZone =  (TestZoneImpl)fAgent.ZoneFactory.GetInstance( "test", TEST_URL );
        } //end method Setup
コード例 #15
0
ファイル: SIFQuery.cs プロジェクト: rubitek/OpenADK-csharp
     public static void Main(string[] args) {
        
        try {
            if( args.Length < 2 ) {
	            Console.WriteLine("Usage: SIFQuery /zone zone /url url [/events] [options]");
	            Console.WriteLine("    /zone zone     The name of the zone");
	            Console.WriteLine("    /url url       The zone URL");
	            AdkExamples.printHelp();
	            return;
            }
        	
            //	Pre-parse the command-line before initializing the ADK
            Adk.Debug = AdkDebugFlags.Moderate;
            AdkExamples.parseCL( null, args);
        	
            //  Initialize the ADK with the specified version, loading only the Student SDO package
            int sdoLibs;
            sdoLibs = (int)OpenADK.Library.us.SdoLibraryType.All;
            Adk.Initialize(SifVersion.SIF23,SIFVariant.SIF_US,sdoLibs);
            // Call StartAgent. 
            _agent.StartAgent(args);
        	
            // Turn down debugging
            Adk.Debug = AdkDebugFlags.None;
        	
            // Call runConsole() This method does not return until the agent shuts down
            _agent.RunConsole();
        	
            //	Wait for Ctrl-C to be pressed
            Console.WriteLine( "Agent is running (Press Ctrl-C to stop)" );
            new AdkConsoleWait().WaitForExit();
        	
        } catch(Exception e) {
            Console.WriteLine(e);
        } finally {
            if( _agent != null && _agent.Initialized ){
	            //  Always shutdown the agent on exit
	            try {
		            _agent.Shutdown( AdkExamples.Unreg ?  ProvisioningFlags.Unprovide : ProvisioningFlags.None );
	            }
	            catch( AdkException adkEx ){
		            Console.WriteLine( adkEx );
	            }
            }
						// set breakpoint here to prevent console from closing on errors
            Console.WriteLine("");
        }

	}
コード例 #16
0
        public void SetUpTest()
        {
            Adk.Debug = AdkDebugFlags.All;
            Adk.Initialize();

            ServicePointManager.CertificatePolicy = new TestCertificatePolicy();
            ServicePointManager.CheckCertificateRevocationList = false;
            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

            fTransport = (HttpTransport)fAgent.TransportManager.GetTransport("https");

            fProps                 = (HttpsProperties)fTransport.Properties;
            fProps.Port            = 9000;
            fProps.CertStore       = CERT_STORE;
            fProps.ClientAuthLevel = 0;
            fProps.ClientCertName  = null;



            fZone = new TestZone();
            fZone.Properties.MessagingMode = AgentMessagingMode.Push;
        }
コード例 #17
0
ファイル: Chameleon.cs プロジェクト: rubitek/OpenADK-csharp
        private static void Main(string[] args)
        {
            try
            {
                Adk.Debug = AdkDebugFlags.Detailed;
                Adk.Initialize();
                Chameleon agent;
                agent = new Chameleon();

                //  Start agent...
                agent.StartAgent(args);

                Console.WriteLine("Agent is running (Press Ctrl-C to stop)");
                sWaitMutex = new AdkConsoleWait();
                sWaitMutex.WaitForExit();

                //  Always shutdown the agent on exit
                agent.Shutdown(ProvisioningFlags.None);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #18
0
 public void setUp()
 {
    // Load only the Common and Infra objects
    Adk.Initialize(SifVersion.LATEST, SdoLibraryType.None);
 }
コード例 #19
0
 public void TestFixtureSetUp()
 {
     Adk.Initialize(SIFVariant.SIF_AU);
 }
コード例 #20
0
 public AdvancedMappingsTests()
 {
     Adk.Debug = AdkDebugFlags.All;
     Adk.Initialize(SifVersion.SIF20, SIFVariant.SIF_US, (int)SdoLibraryType.All);
 }
コード例 #21
0
 public void Setup()
 {
     Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_US, (int)SdoLibraryType.None);
 }
コード例 #22
0
 public void setUp()
 {
     Adk.Initialize();
 }
コード例 #23
0
ファイル: UsAdkTest.cs プロジェクト: rubitek/OpenADK-csharp
 public virtual void setUp()
 {
     Adk.Initialize();
 }
コード例 #24
0
        /// <summary>
        /// Configure the Agent based on the Agent configuration file, then initialise.
        /// </summary>
        /// <exception cref="System.IO.IOException">File or resource exception occurred, possibly while reading Agent configuration file.</exception>
        /// <exception cref="System.Reflection.TargetException">Unable to create an instance of a Publisher or Subscriber for the Agent.</exception>
        public override void Initialize()
        {
            if (Initialized)
            {
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent " + this.Id + " has already been initialised and will not be initialised again.");
                }
            }
            else
            {
                agentConfig = new AgentConfig();

                try
                {
                    // Read the Agent configuration file.
                    agentConfig.Read(this.cfgFileName, false);
                }
                catch (IOException e)
                {
                    throw new IOException("Error reading Agent configuration file " + this.cfgFileName + " when initialising Agent " + this.Id + ".", e);
                }

                // Initialise the ADK to use the latest SIF version and all SIF Data Object modules?
                Adk.Initialize(Locale);

                // Override the SourceId passed to the constructor with the SourceID specified in the configuration
                // file.
                Id = agentConfig.SourceId;
                // Inform the ADK of the version of SIF specified in the sifVersion= attribute of the <agent> element.
                Adk.SifVersion = agentConfig.Version;

                // Call the superclass initialise once the configuration file has been read.
                try
                {
                    base.Initialize();
                }
                catch (Exception e)
                {
                    throw new IOException("Agent " + this.Id + " is unable to initialise due to a file or resource exception.", e);
                }

                // Ask the AgentConfig instance to "apply" all configuration settings to this Agent. This includes
                // parsing and registering all <zone> elements with the Agent's ZoneFactory.
                agentConfig.Apply(this, true);

                // Set the level of debugging applied to the ADK.
                if (Properties.GetProperty("agent.debugAll", false))
                {
                    Adk.Debug = AdkDebugFlags.All;
                }
                else
                {
                    Adk.Debug = AdkDebugFlags.Minimal;
                }

                // Override the Agent display name if provided.
                String displayName = Properties.GetProperty("agent.description", null);

                if (displayName != null)
                {
                    this.fName = displayName;
                }

                if (!Directory.Exists(this.WorkDir))
                {
                    Directory.CreateDirectory(this.WorkDir);
                }

                if (log.IsInfoEnabled)
                {
                    log.Info("Agent " + this.Id + " has been initialised using configuration file " + this.cfgFileName + "...");
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Display name: " + this.fName);
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Messaging mode: " + Properties.MessagingMode);
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Transport protocol: " + Properties.TransportProtocol);
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Pull frequency: " + Properties.PullFrequency);
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Maximum buffer size: " + Properties.MaxBufferSize);
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Override SIF versions: " + Properties.OverrideSifVersions);
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Home directory: " + this.HomeDir);
                }
                if (log.IsInfoEnabled)
                {
                    log.Info("Agent Property => Work directory: " + this.WorkDir);
                }

                StartAgent();
            }
        }
コード例 #25
0
 public void setUp()
 {
     Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_US, (int)SdoLibraryType.Infra);
 }
コード例 #26
0
 public void Setup()
 {
     Adk.Initialize();
 }
コード例 #27
0
 public void setUp()
 {
     Adk.Initialize(SifVersion.SIF15r1, SIFVariant.SIF_US, (int)SdoLibraryType.Student);
 }
コード例 #28
0
    /// <summary>  Initialize and start the agent
    /// </summary>
    /// <param name="args">Command-line arguments (run with no arguments to display help)
    ///
    /// </param>
    public virtual void startAgent(string[] args)
    {
        Console.WriteLine("Initializing agent...");
        Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_AU, (int)SdoLibraryType.Student);

        //  Read the configuration file
        fCfg = new AgentConfig();
        Console.WriteLine("Reading configuration file...");
        fCfg.Read("agent.cfg", false);

        //  Override the SourceId passed to the constructor with the SourceId
        //  specified in the configuration file
        Id = fCfg.SourceId;

        //  Inform the ADK of the version of SIF specified in the sifVersion=
        //  attribute of the <agent> element
        SifVersion version = fCfg.Version;

        Adk.SifVersion = version;

        //  Now call the superclass initialize once the configuration file has been read
        base.Initialize();

        //
        //  Ask the AgentConfig instance to "apply" all configuration settings
        //  to this Agent; for example, all <property> elements that are children
        //  of the root <agent> node are parsed and applied to this Agent's
        //  AgentProperties object; all <zone> elements are parsed and registered
        //  with the Agent's ZoneFactory, and so on.
        //
        fCfg.Apply(this, true);

        //  Establish the ODBC connection to the Students.mdb database file.
        //  The JDBC driver and URL are specified in the agent.cfg configuration
        //  file and were automatically added to the AgentProperties when the
        //  apply method was called above.
        //
        Console.WriteLine("Opening database...");

        AgentProperties props  = Properties;
        string          driver = props.GetProperty("Connection");
        string          url    = props.GetProperty("ConnectionString");

        Console.WriteLine("- Using driver: " + driver);
        Console.WriteLine("- Connecting to URL: " + url);

        //  Load the DataDriver driver

        //  Get a Connection

        fConn = new OleDbConnection();
        fConn.ConnectionString = url;

        //  Connect to each zone specified in the configuration file, registering
        //  this agent as the Provider of Learner objects. Once connected,
        //  send a request for LearnerPersonal.
        //
        Console.WriteLine("Connecting to zones and requesting LearnerPersonal objects...");
        IZone[] allZones = ZoneFactory.GetAllZones();
        for (int i = 0; i < allZones.Length; i++)
        {
            try
            {
                //  Connect to this zone
                Console.WriteLine
                    ("- Connecting to zone \"" + allZones[i].ZoneId + "\" at " +
                    allZones[i].ZoneUrl);
                allZones[i].SetPublisher
                    (this, StudentDTD.STUDENTPERSONAL, new PublishingOptions());
                allZones[i].SetQueryResults(this);
                allZones[i].Connect(ProvisioningFlags.Register);

                //  Request all students
                Query q = new Query(StudentDTD.STUDENTPERSONAL);
                q.UserData = "Mappings Demo";
                allZones[i].Query(q);
            }
            catch (AdkException ex)
            {
                Console.WriteLine("  " + ex.Message);
            }
        }
    }