/// <summary>
        ///  Init the tree and the connection
        /// </summary>
        /// <param name="pGVSTreeName"></param>
        public GVSTreeWithRoot(string pGVSTreeName)
        {
            var t    = DateTime.Now.Subtract(new DateTime(1970, 01, 01, 01, 0, 0, 0));
            var time = (long)(t.TotalMilliseconds);

            this.gvsTreeId    = time;
            this.gvsTreeNodes = new HashSet <GVSTreeNode>();
            this.gvsTreeName  = pGVSTreeName ?? "";

            var gvsPortFile = AppSettings[GVSPORTFILE];
            var gvsHost     = AppSettings[GVSHOST];
            var gvsPort     = AppSettings[GVSPORT];

            if (gvsPortFile != null)
            {
                try{
                    Console.WriteLine("Load socketinformation from " + gvsPortFile);
                    var reader = new XmlTextReader(gvsPortFile);
                    while (reader.Read())
                    {
                        if (reader.IsStartElement("Port"))
                        {
                            reader.Read();
                            port = int.Parse(reader.Value);
                        }
                        if (reader.IsStartElement("Host"))
                        {
                            reader.Read();
                            host = reader.Value.ToString();
                        }
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine("Fehler Portfile");
                    Console.WriteLine(ex.Message);
                }
            }
            else if (gvsHost != null && gvsPort != null)
            {
                try{
                    Console.WriteLine("Load Socketinformation from AppConfig (Host,Port)");
                    this.host = gvsHost;
                    this.port = int.Parse(gvsPort);
                }
                catch (Exception ex) {
                    Console.WriteLine("port or host failed");
                    Console.WriteLine(ex.Message);
                }
            }

            else
            {
                Console.WriteLine("Keine Connection angaben. Lokaler Server. Port auf 3000");
                this.host = "127.0.0.1";
                this.port = 3000;
            }
            xmlConnection = new XMLConnection(host, port);
            xmlConnection.connectToServer();
        }
Пример #2
0
        /// <summary>
        ///	 Creates the Graph-Object. Id will be set to System.currentTimeMillis()
        ///  If no properties are set, the default port 3000 and localhost will be applied.
        /// </summary>
        /// <param name="pGVSGraphName"></param>
        /// <param name="pGvsStyle"></param>
        public GVSGraph(string pGVSGraphName)
        {
            //Create the System.currentTimeMillis()(JAVA)
            var t    = DateTime.Now.Subtract(new DateTime(1970, 01, 01, 01, 0, 0, 0));
            var time = (long)(t.TotalMilliseconds);

            this.gvsGraphId = time;

            this.gvsGraphName = pGVSGraphName ?? "";

            gvsGraphVertizes = new HashSet <GVSDefaultVertex>();
            gvsGraphEdges    = new HashSet <GVSGraphEdge>();

            var gvsPortFile = ConfigurationSettings.AppSettings[GVSPORTFILE];
            var gvsHost     = ConfigurationSettings.AppSettings[GVSHOST];
            var gvsPort     = ConfigurationSettings.AppSettings[GVSPORT];

            if (gvsPortFile != null)
            {
                try{
                    Console.WriteLine("Load socketinformation from " + gvsPortFile);
                    var reader = new XmlTextReader(gvsPortFile);
                    while (reader.Read())
                    {
                        if (reader.IsStartElement("Port"))
                        {
                            reader.Read();
                            port = int.Parse(reader.Value);
                        }
                        if (reader.IsStartElement("Host"))
                        {
                            reader.Read();
                            host = reader.Value.ToString();
                        }
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine("Error Portfile");
                    Console.WriteLine(ex.Message);
                }
            }
            else if (gvsHost != null && gvsPort != null)
            {
                try{
                    Console.WriteLine("Load Socketinformation from AppConfig (Host,Port)");
                    this.host = gvsHost;
                    this.port = int.Parse(gvsPort);
                }
                catch (Exception ex) {
                    Console.WriteLine("port or host failed");
                    Console.WriteLine(ex.Message);
                }
            }

            else
            {
                this.host = "127.0.0.1";
                this.port = 3000;
            }
            xmlConnection = new XMLConnection(host, port);
            xmlConnection.connectToServer();
        }