Esempio n. 1
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);
    }
Esempio n. 2
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;
    }