Exemplo n.º 1
0
        /// <summary> Конструктор класса GraphDBTest
        /// Создается база данных graphDB и сервер GraphDSServer
        /// </summary>
        public GraphDBTest()
        {
            var graphDB = new SonesGraphDB();

            List<PluginDefinition> QueryLanguagePATH = new List<PluginDefinition>();
            Dictionary<string, object> GQL_Parameters = new Dictionary<string, object>();
            GQL_Parameters.Add("GraphDB", graphDB);

            QueryLanguagePATH.Add(new PluginDefinition("sones.gql", GQL_Parameters));
 
            //adding the QueryLanguage as a GraphDSPlugin
            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguagePATH);

            GraphDSServer = new GraphDS_Server(graphDB, PluginsAndParameters);
            
            SecToken = GraphDSServer.LogOn(new UserPasswordCredentials("User", "test"));
            TransactionID = GraphDSServer.BeginTransaction(SecToken);

            edge_list = new List<List< KeyValuePair<long, Int32> >>();

            Dictionary<string, object> RestParameter = new Dictionary<string, object>();
            RestParameter.Add("IPAddress", IPAddress.Any);
            RestParameter.Add("Port", 9975);
            RestParameter.Add("Username", "test");
            RestParameter.Add("Password", "test");
            GraphDSServer.StartService("sones.RESTService", RestParameter);
        }
Exemplo n.º 2
0
        public TagExample()
        {
            //Make a new GraphDB instance
            var graphDB = new SonesGraphDB();

            var credentials = new UserPasswordCredentials("User", "test");

            //GraphDSServer = new GraphDS_Server(GraphDB, (ushort)9975, "User", "test", IPAddress.Any, PluginsAndParameters);
            GraphDSServer = new GraphDS_Server(graphDB, null);
            GraphDSServer.LogOn(credentials);
            //GraphDSServer.StartRESTService("", Properties.Settings.Default.ListeningPort, IPAddress.Any);

            //get a SecurityToken and an TransactionID
            SecToken = GraphDSServer.LogOn(credentials);
            TransationID = GraphDSServer.BeginTransaction(SecToken);
        }
Exemplo n.º 3
0
        public TagExample()
        {
            //Make a new GraphDB instance
            var graphDB = new SonesGraphDB();

            var credentials = new UserPasswordCredentials("User", "test");

            //GraphDSServer = new GraphDS_Server(GraphDB, (ushort)9975, "User", "test", IPAddress.Any, PluginsAndParameters);
            GraphDSServer = new GraphDS_Server(graphDB, null);
            GraphDSServer.LogOn(credentials);
            //GraphDSServer.StartRESTService("", Properties.Settings.Default.ListeningPort, IPAddress.Any);

            //get a SecurityToken and an TransactionID
            SecToken     = GraphDSServer.LogOn(credentials);
            TransationID = GraphDSServer.BeginTransaction(SecToken);
        }
Exemplo n.º 4
0
        public TagExampleWithRest(String[] myArgs)
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-us");

            if (myArgs.Count() > 0)
            {
                foreach (String parameter in myArgs)
                {
                    if (parameter.ToUpper() == "--Q")
                        quiet = true;
                }
            }
            #region Start REST, WebDAV and WebAdmin services, send GraphDS notification

            IGraphDB GraphDB;

            GraphDB = new SonesGraphDB(null, true, new CultureInfo("en-us"));

            #region Configure PlugIns
            // Plugins are loaded by the GraphDS with their according PluginDefinition and only if they are listed
            // below - there is no auto-discovery for plugin types in GraphDS (!)

            #region Query Languages
            // the GQL Query Language Plugin needs the GraphDB instance as a parameter
            List<PluginDefinition> QueryLanguages = new List<PluginDefinition>();
            Dictionary<string, object> GQL_Parameters = new Dictionary<string, object>();
            GQL_Parameters.Add("GraphDB", GraphDB);

            QueryLanguages.Add(new PluginDefinition("sones.gql", GQL_Parameters));
            #endregion

            #region REST Service Plugins
            List<PluginDefinition> SonesRESTServices = new List<PluginDefinition>();
            // not yet used
            #endregion

            #region GraphDS Service Plugins
            List<PluginDefinition> GraphDSServices = new List<PluginDefinition>();
            #endregion

            List<PluginDefinition> UsageDataCollector = new List<PluginDefinition>();

            #endregion

            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguages);
            _dsServer = new GraphDS_Server(GraphDB, PluginsAndParameters);

            #region Start GraphDS Services

            #region pre-configure REST Service
            Dictionary<string, object> RestParameter = new Dictionary<string, object>();
            RestParameter.Add("IPAddress", IPAddress.Any);
            RestParameter.Add("Port", 9975);
            RestParameter.Add("Username", "test");
            RestParameter.Add("Password", "test");
            _dsServer.StartService("sones.RESTService", RestParameter);
            #endregion

            #endregion

            SecToken = _dsServer.LogOn(new UserPasswordCredentials("test", "test"));
            TransactionID = _dsServer.BeginTransaction(SecToken);

            #endregion

            Run();

            #region Some helping lines...
            if (!quiet)
            {
                Console.WriteLine("This GraphDB Instance offers the following options:");
                Console.WriteLine("   * If you want to suppress console output add --Q as a");
                Console.WriteLine("     parameter.");
                Console.WriteLine();
                Console.WriteLine("   * the following GraphDS Service Plugins are initialized and started: ");

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine("      * " + Service.PluginName);
                    Console.WriteLine(Service.Description);

                }
                Console.WriteLine();
                Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance.");
            }

            Console.CancelKeyPress += OnCancelKeyPress;

            while (!shutdown)
            {
                String command = Console.ReadLine();

                if (!_ctrlCPressed)
                {
                    if (command != null)
                    {
                        if (command.ToUpper() == "SHUTDOWN")
                            shutdown = true;
                    }
                }
            }

            Console.WriteLine("Shutting down GraphDS Server");
            _dsServer.Shutdown(null);
            Console.WriteLine("Shutdown complete");
            #endregion
        }
Exemplo n.º 5
0
        public TagExampleWithRest(String[] myArgs)
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-us");

            if (myArgs.Count() > 0)
            {
                foreach (String parameter in myArgs)
                {
                    if (parameter.ToUpper() == "--Q")
                    {
                        quiet = true;
                    }
                }
            }
            #region Start REST, WebDAV and WebAdmin services, send GraphDS notification

            IGraphDB GraphDB;

            GraphDB = new SonesGraphDB(null, true, new CultureInfo("en-us"));

            #region Configure PlugIns
            // Plugins are loaded by the GraphDS with their according PluginDefinition and only if they are listed
            // below - there is no auto-discovery for plugin types in GraphDS (!)

            #region Query Languages
            // the GQL Query Language Plugin needs the GraphDB instance as a parameter
            List <PluginDefinition>     QueryLanguages = new List <PluginDefinition>();
            Dictionary <string, object> GQL_Parameters = new Dictionary <string, object>();
            GQL_Parameters.Add("GraphDB", GraphDB);

            QueryLanguages.Add(new PluginDefinition("sones.gql", GQL_Parameters));
            #endregion

            #region REST Service Plugins
            List <PluginDefinition> SonesRESTServices = new List <PluginDefinition>();
            // not yet used
            #endregion

            #region GraphDS Service Plugins
            List <PluginDefinition> GraphDSServices = new List <PluginDefinition>();
            #endregion

            List <PluginDefinition> UsageDataCollector = new List <PluginDefinition>();

            #endregion

            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguages);
            _dsServer = new GraphDS_Server(GraphDB, PluginsAndParameters);

            #region Start GraphDS Services

            #region pre-configure REST Service
            Dictionary <string, object> RestParameter = new Dictionary <string, object>();
            RestParameter.Add("IPAddress", IPAddress.Any);
            RestParameter.Add("Port", 9975);
            RestParameter.Add("Username", "test");
            RestParameter.Add("Password", "test");
            _dsServer.StartService("sones.RESTService", RestParameter);
            #endregion

            #endregion

            SecToken      = _dsServer.LogOn(new UserPasswordCredentials("test", "test"));
            TransactionID = _dsServer.BeginTransaction(SecToken);

            #endregion

            Run();

            #region Some helping lines...
            if (!quiet)
            {
                Console.WriteLine("This GraphDB Instance offers the following options:");
                Console.WriteLine("   * If you want to suppress console output add --Q as a");
                Console.WriteLine("     parameter.");
                Console.WriteLine();
                Console.WriteLine("   * the following GraphDS Service Plugins are initialized and started: ");

                foreach (var Service in _dsServer.AvailableServices)
                {
                    Console.WriteLine("      * " + Service.PluginName);
                    Console.WriteLine(Service.ServiceDescription);
                }
                Console.WriteLine();
                Console.WriteLine("Enter 'shutdown' to initiate the shutdown of this instance.");
            }

            Console.CancelKeyPress += OnCancelKeyPress;

            while (!shutdown)
            {
                String command = Console.ReadLine();

                if (!_ctrlCPressed)
                {
                    if (command != null)
                    {
                        if (command.ToUpper() == "SHUTDOWN")
                        {
                            shutdown = true;
                        }
                    }
                }
            }

            Console.WriteLine("Shutting down GraphDS Server");
            _dsServer.Shutdown(null);
            Console.WriteLine("Shutdown complete");
            #endregion
        }