Esempio n. 1
0
        public int test_connect_IN()
        {
            InfoNode      infoNode     = InfoNode.GetInstance();
            List <String> list         = new List <string>();
            String        listToIN     = "";
            String        listIN       = "Port";
            String        listINMax    = "Port";
            String        listDistance = "Distance";

            for (int i = 0; i < ListNodeIN.Count; i++)
            {
                for (int j = 0; j < ListNodeMN.Count; j++)
                {
                    if (ListNodeIN[i].InRange(ListNodeMN[j]))
                    {
                        //list_node_to_IN.Add(ListNodeMN[j]);
                        Console.WriteLine("Node connect to IN is: " + ListNodeMN[j].Text + "  " + ListNodeMN[j].index + " " + Simulation.ListNodeMN[ListNodeMN[j].index].Node_Port);
                        list.Add(Simulation.ListNodeMN[ListNodeMN[j].index].Node_Port);
                        listToIN     = listToIN + Simulation.ListNodeMN[ListNodeMN[j].index].Node_Port;
                        listIN       = listIN + "-" + Simulation.ListNodeMN[ListNodeMN[j].index].Node_Port;
                        listDistance = listDistance + "-" + ListNodeIN[i].InDistance(ListNodeMN[j]);
                    }
                    if (ListNodeIN[i].InDistance(ListNodeMN[j]))
                    {
                        listINMax = listINMax + "-" + Simulation.ListNodeMN[ListNodeMN[j].index].Node_Port;
                    }
                }
            }
            String a = listToIN;

            Console.WriteLine(listToIN + " aaa " + id + listDistance);
            SQLiteConnection sqlite_conn;

            sqlite_conn = GetDataProxy.CreateConnection();
            GetDataProxy.InsertData(sqlite_conn, a, id);
            GetDataProxy.ReadData(sqlite_conn, id);
            sqlite_conn.Dispose();
            //String sourceFile = "C:/Users/eduyduy/Documents/SIMULATOR/IN-MN-Standard/DataProxy/MyDatabase.sqlite";
            //String destFile = "C:/Users/eduyduy/Documents/SIMULATOR/IN-MN-Standard/DataProxy/MyDatabase2.sqlite";

            String filePathMin = "C:/Users/eduyduy/Documents/SIMULATOR/IN-MN-Standard/DataProxy/dataMin.txt";
            String filePathMax = "C:/Users/eduyduy/Documents/SIMULATOR/IN-MN-Standard/DataProxy/dataMax.txt";

            File.WriteAllText(filePathMin, listIN);
            File.WriteAllText(filePathMax, listINMax);

            //System.IO.File.Copy(sourceFile, destFile, true);

            list_node_In = new List <Node>();

            id++;
            t = list.Count();
            //Console.WriteLine("Simulator---" + list[0]);
            flag = true;
            return(t);
        }
Esempio n. 2
0
        private void button_run_Click(object sender, EventArgs e)
        {
            RemoveAll();
            ////Đưa dữ liệu thiết lập trong infoNode vào node
            //InfoNode infoNode = InfoNode.GetInstance();
            //for(int i = 0; i < ListNodeIN.Count; i++)
            //{infoNode.SetData(ListNodeIN[i]);}
            //for(int i = 0; i < ListNodeMN.Count; i++)
            //{infoNode.SetData(ListNodeMN[i]);}
            String fileDirectoryPath = "C:/Users/eduyduy/Documents/SIMULATOR/IN-MN-Standard/IN-MN-Standard";

            if (Directory.Exists(fileDirectoryPath))
            {
                Directory.CreateDirectory(fileDirectoryPath);
            }
            //Kết nối và RUN các node
            NodeConect conect = new NodeConect();

            conect.conectNode();

            doConfig doCofig = new doConfig();

            doCofig.doCofig();

            String FilePath = "C:/Users/eduyduy/Documents/SIMULATOR/IN-MN-Standard/run-new-all.bat";

            System.Diagnostics.Process prc = new System.Diagnostics.Process();
            prc.StartInfo.FileName    = FilePath; // vd: "D:"
            prc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            prc.Start();

            Thread.Sleep(3000);
            //connectData.Open();
            createTable();
            getData();

            SQLiteConnection sqlite_conn;

            sqlite_conn = GetDataProxy.CreateConnection();
            GetDataProxy.DeleteTable(sqlite_conn);
            GetDataProxy.CreateTable(sqlite_conn);
            sqlite_conn.Close();
            //GetDataProxy.CloseConnection();
        }