示例#1
0
        /*
         *
         * The user needs to set a reference to HydraJsonClient project
         * He can open it as a project in the solution, and set a reference to it
         * or add a reference to HydraJsonClient.dll
         *
         * */
        static void Main(string[] args)
        {
            /**
             * The following parameters should be gotten from args or extracted from "hyra.ini", but for simplicity, they are hard coded in this example
             */
            int network_id = 2;          // network id

            int [] scenario_ids = { 2 }; // scenarios ids
            string user_name    = "root";
            string password     = "";    //user password
            string server_addrs = "http://127.0.0.1:8080/json/";
            string sessionid    = null;

            /*
             * if session id is provided, it will be used to connect to the server otherwsie, it will use user_name and password to connectto the server and get sessionid
             * */

            // intialize hydraNetworkExporter class with connection parameters

            NetworkExporter hydraNetworkExporter = new NetworkExporter(server_addrs, user_name, password, sessionid);

            // export the network with its id and scenarioa ids

            Network network = hydraNetworkExporter.exportNetworkWithData(network_id, scenario_ids);

            //it returned an object of Network class which contains all the network components and data  and the user has access to all of them

            MessagesWriter.writeMessage("\nNetwork: " + network.name + " is exported\nNo of nodes: " + network.nodes.Length + "\nNo of links: " + network.links.Length);
        }
示例#2
0
        void getUser()
        {
            string res = callServer(user.getLoginParameters());
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                MessagesWriter.writeMessage("res: " + res);
                hydra_user uses = js.Deserialize <hydra_user>(res);
                user.sessonid = uses.session_id;
            }
            catch (System.Exception ex) { }
        }