public void Start(IDictionary<String, Object> my_Parameters = null) { try { if(_HttpServer != null && _HttpServer.IsRunning) _HttpServer.Stop(); // iterate through input dictionary and upper case it Dictionary<string, object> myParameters = new Dictionary<string, object>(); foreach (String Key in my_Parameters.Keys) { myParameters.Add(Key.ToUpper(), my_Parameters[Key]); } String Username = "******"; if (myParameters != null && myParameters.ContainsKey("USERNAME")) Username = (String)Convert.ChangeType(myParameters["USERNAME"], typeof(String)); String Password = "******"; if (myParameters != null && myParameters.ContainsKey("PASSWORD")) Password = (String)Convert.ChangeType(myParameters["PASSWORD"], typeof(String)); IPAddress Address = IPAddress.Any; if (myParameters != null && myParameters.ContainsKey("IPADDRESS")) Address = (IPAddress)Convert.ChangeType(myParameters["IPADDRESS"], typeof(IPAddress)); ushort Port = 9975; if (myParameters != null && myParameters.ContainsKey("PORT")) Port = (ushort)Convert.ChangeType(myParameters["PORT"], typeof(ushort)); _Security = new BasicServerSecurity(new PasswordValidator(null, Username, Password)); _RESTService = new GraphDSREST_Service(); _RESTService.Initialize(_GraphDS, Port, Address); _HttpServer = new HttpServer( Address, Port, _RESTService, mySecurity: _Security, myAutoStart: false); _LifeTime.Start(); _HttpServer.Start(); String MyIPAdressString = Address.ToString(); if (MyIPAdressString == "0.0.0.0") MyIPAdressString = "localhost"; _description = " * REST Service is started at http://" + MyIPAdressString + ":" + Port + Environment.NewLine + " * access it directly by passing the GraphQL query using the" + Environment.NewLine + " REST interface or a client library. (see documentation)" + Environment.NewLine + " * if you want JSON Output add ACCEPT: application/json " + Environment.NewLine + " to the client request header (or application/xml or" + Environment.NewLine + " application/text)" + Environment.NewLine + " * for first steps we recommend to use the AJAX WebShell. " + Environment.NewLine + " Browse to http://" + MyIPAdressString + ":" + Port + "/WebShell" + Environment.NewLine + " (default username and passwort: test / test)"; } catch (Exception Ex) { throw new RESTServiceCouldNotStartException("The REST Service could not be started. See inner exception for details.", Ex); } }
public void Start(IDictionary <String, Object> my_Parameters = null) { try { if (_HttpServer != null && _HttpServer.IsRunning) { _HttpServer.Stop(); } // iterate through input dictionary and upper case it Dictionary <string, object> myParameters = new Dictionary <string, object>(); foreach (String Key in my_Parameters.Keys) { myParameters.Add(Key.ToUpper(), my_Parameters[Key]); } String Username = "******"; if (myParameters != null && myParameters.ContainsKey("USERNAME")) { Username = (String)Convert.ChangeType(myParameters["USERNAME"], typeof(String)); } String Password = "******"; if (myParameters != null && myParameters.ContainsKey("PASSWORD")) { Password = (String)Convert.ChangeType(myParameters["PASSWORD"], typeof(String)); } IPAddress Address = IPAddress.Any; if (myParameters != null && myParameters.ContainsKey("IPADDRESS")) { Address = (IPAddress)Convert.ChangeType(myParameters["IPADDRESS"], typeof(IPAddress)); } ushort Port = 9975; if (myParameters != null && myParameters.ContainsKey("PORT")) { Port = (ushort)Convert.ChangeType(myParameters["PORT"], typeof(ushort)); } _Security = new BasicServerSecurity(new PasswordValidator(null, Username, Password)); _RESTService = new GraphDSREST_Service(); _RESTService.Initialize(_GraphDS, Port, Address); _HttpServer = new HttpServer( Address, Port, _RESTService, mySecurity: _Security, myAutoStart: false); _LifeTime.Start(); _HttpServer.Start(); String MyIPAdressString = Address.ToString(); if (MyIPAdressString == "0.0.0.0") { MyIPAdressString = "localhost"; } _description = " * REST Service is started at http://" + MyIPAdressString + ":" + Port + Environment.NewLine + " * access it directly by passing the GraphQL query using the" + Environment.NewLine + " REST interface or a client library. (see documentation)" + Environment.NewLine + " * if you want JSON Output add ACCEPT: application/json " + Environment.NewLine + " to the client request header (or application/xml or" + Environment.NewLine + " application/text)" + Environment.NewLine + " * for first steps we recommend to use the AJAX WebShell. " + Environment.NewLine + " Browse to http://" + MyIPAdressString + ":" + Port + "/WebShell" + Environment.NewLine + " (default username and passwort: test / test)"; } catch (Exception Ex) { throw new RESTServiceCouldNotStartException("The REST Service could not be started. See inner exception for details.", Ex); } }