コード例 #1
0
        public static List <NetwokImport> ImportNetworkNames()
        {
            List <NetwokImport> networks = new List <NetwokImport>();
            List <string>       tables   = DatabaseManager.LoadTables(DbSetting.DATABASENAME, DbSetting.DATABASEPASSWORD);
            // all tables.
            int i = 1;

            foreach (string table in tables)
            {
                NetwokImport net = new NetwokImport();
                net.lbl_id.Content           = i++;
                net.lbl_network_name.Content = table;
                networks.Add(net);
            }
            return(networks);
        }
コード例 #2
0
        public static void ImportNetwok(NetwokImport Netwok)
        {
            string          tabelName = Netwok.lbl_network_name.Content.ToString();
            OleDbConnection oldb_connectionProvidor = null;
            OleDbCommand    command = null;
            OleDbDataReader Dr      = null;

            try
            {
                oldb_connectionProvidor = new OleDbConnection();
                oldb_connectionProvidor.ConnectionString = DbSetting.ConnectionString;
                oldb_connectionProvidor.Open();
                string txt = SqlOperations.Select.AllWithNoCondition(tabelName);

                command = new OleDbCommand(txt, oldb_connectionProvidor);
                Dr      = command.ExecuteReader();
                while (Dr.Read())
                {
                    ImportedSensor sensor = new ImportedSensor();
                    sensor.NodeID = Convert.ToInt16(Dr["NodeID"]);
                    sensor.Pox    = Convert.ToDouble(Dr["Pox"]);
                    sensor.Poy    = Convert.ToDouble(Dr["Poy"]);
                    sensor.R      = Convert.ToDouble(Dr["R"]);
                    Netwok.ImportedSensorSensors.Add(sensor);
                }
            }
            catch { }
            finally
            {
                if (oldb_connectionProvidor != null)
                {
                    oldb_connectionProvidor.Close(); oldb_connectionProvidor.Dispose();
                }
                if (command != null)
                {
                    command.Dispose();
                }
                if (Dr != null)
                {
                    Dr.Close(); Dr.Dispose();
                }
            }
        }